blob: dd4d312766c5139f8572db8dd0f9298b61114dcc [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
paula2c62832003-04-23 17:01:31 +0000295DEFUN (ospf_passive_interface,
296 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000297 "passive-interface IFNAME A.B.C.D",
298 "Suppress routing updates on an interface\n"
299 "Interface's name\n")
300{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000301 struct interface *ifp;
302 struct in_addr addr;
303 int ret;
304 struct ospf_if_params *params;
305 struct route_node *rn;
306 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000307
Andrew J. Schorr43540882006-11-28 16:36:39 +0000308 if (argc == 0)
309 {
310 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
311 return CMD_SUCCESS;
312 }
313
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000314 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000315
316 params = IF_DEF_PARAMS (ifp);
317
Andrew J. Schorr43540882006-11-28 16:36:39 +0000318 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000319 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000320 ret = inet_aton(argv[1], &addr);
321 if (!ret)
322 {
323 vty_out (vty, "Please specify interface address by A.B.C.D%s",
324 VTY_NEWLINE);
325 return CMD_WARNING;
326 }
paul718e3742002-12-13 20:15:29 +0000327
Andrew J. Schorr43540882006-11-28 16:36:39 +0000328 params = ospf_get_if_params (ifp, addr);
329 ospf_if_update_params (ifp, addr);
Paul Jakmae1bcd472014-09-19 16:41:10 +0100330 ospf_passive_interface_update_addr (ospf, ifp, params,
331 OSPF_IF_PASSIVE, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000332 }
Paul Jakmae1bcd472014-09-19 16:41:10 +0100333
334 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000335
ajsba6454e2005-02-08 15:37:30 +0000336 /* XXX We should call ospf_if_set_multicast on exactly those
337 * interfaces for which the passive property changed. It is too much
338 * work to determine this set, so we do this for every interface.
339 * This is safe and reasonable because ospf_if_set_multicast uses a
340 * record of joined groups to avoid systems calls if the desired
341 * memberships match the current memership.
342 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000343
ajsba6454e2005-02-08 15:37:30 +0000344 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
345 {
346 struct ospf_interface *oi = rn->info;
347
348 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000349 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000350 }
351 /*
352 * XXX It is not clear what state transitions the interface needs to
353 * undergo when going from active to passive. Fixing this will
354 * require precise identification of interfaces having such a
355 * transition.
356 */
357
paul718e3742002-12-13 20:15:29 +0000358 return CMD_SUCCESS;
359}
360
paula2c62832003-04-23 17:01:31 +0000361ALIAS (ospf_passive_interface,
362 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000363 "passive-interface IFNAME",
364 "Suppress routing updates on an interface\n"
365 "Interface's name\n")
366
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000367ALIAS (ospf_passive_interface,
368 ospf_passive_interface_default_cmd,
369 "passive-interface default",
370 "Suppress routing updates on an interface\n"
371 "Suppress routing updates on interfaces by default\n")
372
paula2c62832003-04-23 17:01:31 +0000373DEFUN (no_ospf_passive_interface,
374 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000375 "no passive-interface IFNAME A.B.C.D",
376 NO_STR
377 "Allow routing updates on an interface\n"
378 "Interface's name\n")
379{
380 struct interface *ifp;
381 struct in_addr addr;
382 struct ospf_if_params *params;
383 int ret;
ajsba6454e2005-02-08 15:37:30 +0000384 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000385 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000386
387 if (argc == 0)
388 {
389 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
390 return CMD_SUCCESS;
391 }
paul718e3742002-12-13 20:15:29 +0000392
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000393 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000394
395 params = IF_DEF_PARAMS (ifp);
396
Andrew J. Schorr43540882006-11-28 16:36:39 +0000397 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000398 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000399 ret = inet_aton(argv[1], &addr);
400 if (!ret)
401 {
402 vty_out (vty, "Please specify interface address by A.B.C.D%s",
403 VTY_NEWLINE);
404 return CMD_WARNING;
405 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000406
Andrew J. Schorr43540882006-11-28 16:36:39 +0000407 params = ospf_lookup_if_params (ifp, addr);
408 if (params == NULL)
409 return CMD_SUCCESS;
Paul Jakmae1bcd472014-09-19 16:41:10 +0100410 ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE,
411 addr);
paul718e3742002-12-13 20:15:29 +0000412 }
Paul Jakmae1bcd472014-09-19 16:41:10 +0100413 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE);
414
ajsba6454e2005-02-08 15:37:30 +0000415 /* XXX We should call ospf_if_set_multicast on exactly those
416 * interfaces for which the passive property changed. It is too much
417 * work to determine this set, so we do this for every interface.
418 * This is safe and reasonable because ospf_if_set_multicast uses a
419 * record of joined groups to avoid systems calls if the desired
420 * memberships match the current memership.
421 */
422 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
423 {
424 struct ospf_interface *oi = rn->info;
425
426 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
427 ospf_if_set_multicast(oi);
428 }
429
paul718e3742002-12-13 20:15:29 +0000430 return CMD_SUCCESS;
431}
432
paula2c62832003-04-23 17:01:31 +0000433ALIAS (no_ospf_passive_interface,
434 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000435 "no passive-interface IFNAME",
436 NO_STR
437 "Allow routing updates on an interface\n"
438 "Interface's name\n")
439
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000440ALIAS (no_ospf_passive_interface,
441 no_ospf_passive_interface_default_cmd,
442 "no passive-interface default",
443 NO_STR
444 "Allow routing updates on an interface\n"
445 "Allow routing updates on interfaces by default\n")
446
paula2c62832003-04-23 17:01:31 +0000447DEFUN (ospf_network_area,
448 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000449 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
450 "Enable routing on an IP network\n"
451 "OSPF network prefix\n"
452 "Set the OSPF area ID\n"
453 "OSPF area ID in IP address format\n"
454 "OSPF area ID as a decimal value\n")
455{
456 struct ospf *ospf= vty->index;
457 struct prefix_ipv4 p;
458 struct in_addr area_id;
459 int ret, format;
460
461 /* Get network prefix and Area ID. */
462 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
463 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
464
465 ret = ospf_network_set (ospf, &p, area_id);
466 if (ret == 0)
467 {
468 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
469 return CMD_WARNING;
470 }
471
472 return CMD_SUCCESS;
473}
474
paula2c62832003-04-23 17:01:31 +0000475DEFUN (no_ospf_network_area,
476 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000477 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
478 NO_STR
479 "Enable routing on an IP network\n"
480 "OSPF network prefix\n"
481 "Set the OSPF area ID\n"
482 "OSPF area ID in IP address format\n"
483 "OSPF area ID as a decimal value\n")
484{
485 struct ospf *ospf = (struct ospf *) vty->index;
486 struct prefix_ipv4 p;
487 struct in_addr area_id;
488 int ret, format;
489
490 /* Get network prefix and Area ID. */
491 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
492 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
493
494 ret = ospf_network_unset (ospf, &p, area_id);
495 if (ret == 0)
496 {
497 vty_out (vty, "Can't find specified network area configuration.%s",
498 VTY_NEWLINE);
499 return CMD_WARNING;
500 }
501
502 return CMD_SUCCESS;
503}
504
David Lamparter6b0655a2014-06-04 06:53:35 +0200505
paula2c62832003-04-23 17:01:31 +0000506DEFUN (ospf_area_range,
507 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000508 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
509 "OSPF area parameters\n"
510 "OSPF area ID in IP address format\n"
511 "OSPF area ID as a decimal value\n"
512 "Summarize routes matching address/mask (border routers only)\n"
513 "Area range prefix\n")
514{
515 struct ospf *ospf = vty->index;
516 struct prefix_ipv4 p;
517 struct in_addr area_id;
518 int format;
519 u_int32_t cost;
520
521 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
522 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
523
524 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
525 if (argc > 2)
526 {
paul4dadc292005-05-06 21:37:42 +0000527 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000528 ospf_area_range_cost_set (ospf, area_id, &p, cost);
529 }
530
531 return CMD_SUCCESS;
532}
533
paula2c62832003-04-23 17:01:31 +0000534ALIAS (ospf_area_range,
535 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000536 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
537 "OSPF area parameters\n"
538 "OSPF area ID in IP address format\n"
539 "OSPF area ID as a decimal value\n"
540 "OSPF area range for route advertise (default)\n"
541 "Area range prefix\n"
542 "Advertise this range (default)\n")
543
paula2c62832003-04-23 17:01:31 +0000544ALIAS (ospf_area_range,
545 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000546 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
547 "OSPF area parameters\n"
548 "OSPF area ID in IP address format\n"
549 "OSPF area ID as a decimal value\n"
550 "Summarize routes matching address/mask (border routers only)\n"
551 "Area range prefix\n"
552 "User specified metric for this range\n"
553 "Advertised metric for this range\n")
554
paula2c62832003-04-23 17:01:31 +0000555ALIAS (ospf_area_range,
556 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000557 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
558 "OSPF area parameters\n"
559 "OSPF area ID in IP address format\n"
560 "OSPF area ID as a decimal value\n"
561 "Summarize routes matching address/mask (border routers only)\n"
562 "Area range prefix\n"
563 "Advertise this range (default)\n"
564 "User specified metric for this range\n"
565 "Advertised metric for this range\n")
566
paula2c62832003-04-23 17:01:31 +0000567DEFUN (ospf_area_range_not_advertise,
568 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000569 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
570 "OSPF area parameters\n"
571 "OSPF area ID in IP address format\n"
572 "OSPF area ID as a decimal value\n"
573 "Summarize routes matching address/mask (border routers only)\n"
574 "Area range prefix\n"
575 "DoNotAdvertise this range\n")
576{
577 struct ospf *ospf = vty->index;
578 struct prefix_ipv4 p;
579 struct in_addr area_id;
580 int format;
581
582 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
583 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
584
585 ospf_area_range_set (ospf, area_id, &p, 0);
586
587 return CMD_SUCCESS;
588}
589
paula2c62832003-04-23 17:01:31 +0000590DEFUN (no_ospf_area_range,
591 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000592 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
593 NO_STR
594 "OSPF area parameters\n"
595 "OSPF area ID in IP address format\n"
596 "OSPF area ID as a decimal value\n"
597 "Summarize routes matching address/mask (border routers only)\n"
598 "Area range prefix\n")
599{
600 struct ospf *ospf = vty->index;
601 struct prefix_ipv4 p;
602 struct in_addr area_id;
603 int format;
604
605 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
606 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
607
608 ospf_area_range_unset (ospf, area_id, &p);
609
610 return CMD_SUCCESS;
611}
612
paula2c62832003-04-23 17:01:31 +0000613ALIAS (no_ospf_area_range,
614 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000615 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
616 NO_STR
617 "OSPF area parameters\n"
618 "OSPF area ID in IP address format\n"
619 "OSPF area ID as a decimal value\n"
620 "Summarize routes matching address/mask (border routers only)\n"
621 "Area range prefix\n"
622 "Advertise this range (default)\n"
623 "DoNotAdvertise this range\n")
624
paula2c62832003-04-23 17:01:31 +0000625ALIAS (no_ospf_area_range,
626 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000627 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
628 NO_STR
629 "OSPF area parameters\n"
630 "OSPF area ID in IP address format\n"
631 "OSPF area ID as a decimal value\n"
632 "Summarize routes matching address/mask (border routers only)\n"
633 "Area range prefix\n"
634 "User specified metric for this range\n"
635 "Advertised metric for this range\n")
636
paula2c62832003-04-23 17:01:31 +0000637ALIAS (no_ospf_area_range,
638 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000639 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
640 NO_STR
641 "OSPF area parameters\n"
642 "OSPF area ID in IP address format\n"
643 "OSPF area ID as a decimal value\n"
644 "Summarize routes matching address/mask (border routers only)\n"
645 "Area range prefix\n"
646 "Advertise this range (default)\n"
647 "User specified metric for this range\n"
648 "Advertised metric for this range\n")
David Lamparter6b0655a2014-06-04 06:53:35 +0200649
paula2c62832003-04-23 17:01:31 +0000650DEFUN (ospf_area_range_substitute,
651 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000652 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
653 "OSPF area parameters\n"
654 "OSPF area ID in IP address format\n"
655 "OSPF area ID as a decimal value\n"
656 "Summarize routes matching address/mask (border routers only)\n"
657 "Area range prefix\n"
658 "Announce area range as another prefix\n"
659 "Network prefix to be announced instead of range\n")
660{
661 struct ospf *ospf = vty->index;
662 struct prefix_ipv4 p, s;
663 struct in_addr area_id;
664 int format;
665
666 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
667 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
668 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
669
670 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
671
672 return CMD_SUCCESS;
673}
674
paula2c62832003-04-23 17:01:31 +0000675DEFUN (no_ospf_area_range_substitute,
676 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000677 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
678 NO_STR
679 "OSPF area parameters\n"
680 "OSPF area ID in IP address format\n"
681 "OSPF area ID as a decimal value\n"
682 "Summarize routes matching address/mask (border routers only)\n"
683 "Area range prefix\n"
684 "Announce area range as another prefix\n"
685 "Network prefix to be announced instead of range\n")
686{
687 struct ospf *ospf = vty->index;
688 struct prefix_ipv4 p, s;
689 struct in_addr area_id;
690 int format;
691
692 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
693 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
694 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
695
696 ospf_area_range_substitute_unset (ospf, area_id, &p);
697
698 return CMD_SUCCESS;
699}
700
David Lamparter6b0655a2014-06-04 06:53:35 +0200701
paul718e3742002-12-13 20:15:29 +0000702/* Command Handler Logic in VLink stuff is delicate!!
703
704 ALTER AT YOUR OWN RISK!!!!
705
706 Various dummy values are used to represent 'NoChange' state for
707 VLink configuration NOT being changed by a VLink command, and
708 special syntax is used within the command strings so that the
709 typed in command verbs can be seen in the configuration command
710 bacckend handler. This is to drastically reduce the verbeage
711 required to coe up with a reasonably compatible Cisco VLink command
712
713 - Matthew Grant <grantma@anathoth.gen.nz>
714 Wed, 21 Feb 2001 15:13:52 +1300
715 */
716
717
718/* Configuration data for virtual links
719 */
720struct ospf_vl_config_data {
721 struct vty *vty; /* vty stuff */
722 struct in_addr area_id; /* area ID from command line */
723 int format; /* command line area ID format */
724 struct in_addr vl_peer; /* command line vl_peer */
725 int auth_type; /* Authehntication type, if given */
726 char *auth_key; /* simple password if present */
727 int crypto_key_id; /* Cryptographic key ID */
728 char *md5_key; /* MD5 authentication key */
729 int hello_interval; /* Obvious what these are... */
730 int retransmit_interval;
731 int transmit_delay;
732 int dead_interval;
733};
734
paul4dadc292005-05-06 21:37:42 +0000735static void
paul718e3742002-12-13 20:15:29 +0000736ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
737 struct vty *vty)
738{
739 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
740 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
741 vl_config->vty = vty;
742}
743
paul4dadc292005-05-06 21:37:42 +0000744static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000745ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000746{
747 struct ospf_area *area;
748 struct ospf_vl_data *vl_data;
749 struct vty *vty;
750 struct in_addr area_id;
751
752 vty = vl_config->vty;
753 area_id = vl_config->area_id;
754
755 if (area_id.s_addr == OSPF_AREA_BACKBONE)
756 {
757 vty_out (vty,
758 "Configuring VLs over the backbone is not allowed%s",
759 VTY_NEWLINE);
760 return NULL;
761 }
paul68980082003-03-25 05:07:42 +0000762 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000763
764 if (area->external_routing != OSPF_AREA_DEFAULT)
765 {
766 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
767 vty_out (vty, "Area %s is %s%s",
768 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000769 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000770 VTY_NEWLINE);
771 else
772 vty_out (vty, "Area %ld is %s%s",
773 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000774 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000775 VTY_NEWLINE);
776 return NULL;
777 }
778
Paul Jakma9c27ef92006-05-04 07:32:57 +0000779 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000780 {
781 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
782 if (vl_data->vl_oi == NULL)
783 {
paul68980082003-03-25 05:07:42 +0000784 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
785 ospf_vl_add (ospf, vl_data);
Paul Jakmab6eef002014-10-09 14:19:51 +0100786 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
paul718e3742002-12-13 20:15:29 +0000787 }
788 }
789 return vl_data;
790}
791
792
paul4dadc292005-05-06 21:37:42 +0000793static int
paul718e3742002-12-13 20:15:29 +0000794ospf_vl_set_security (struct ospf_vl_data *vl_data,
795 struct ospf_vl_config_data *vl_config)
796{
797 struct crypt_key *ck;
798 struct vty *vty;
799 struct interface *ifp = vl_data->vl_oi->ifp;
800
801 vty = vl_config->vty;
802
803 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
804 {
805 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
806 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
807 }
808
809 if (vl_config->auth_key)
810 {
811 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000812 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000813 OSPF_AUTH_SIMPLE_SIZE);
814 }
815 else if (vl_config->md5_key)
816 {
817 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
818 != NULL)
819 {
820 vty_out (vty, "OSPF: Key %d already exists%s",
821 vl_config->crypto_key_id, VTY_NEWLINE);
822 return CMD_WARNING;
823 }
824 ck = ospf_crypt_key_new ();
825 ck->key_id = vl_config->crypto_key_id;
826 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000827 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000828
829 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
830 }
831 else if (vl_config->crypto_key_id != 0)
832 {
833 /* Delete a key */
834
835 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
836 vl_config->crypto_key_id) == NULL)
837 {
838 vty_out (vty, "OSPF: Key %d does not exist%s",
839 vl_config->crypto_key_id, VTY_NEWLINE);
840 return CMD_WARNING;
841 }
842
843 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
844
845 }
846
847 return CMD_SUCCESS;
848}
849
paul4dadc292005-05-06 21:37:42 +0000850static int
paul718e3742002-12-13 20:15:29 +0000851ospf_vl_set_timers (struct ospf_vl_data *vl_data,
852 struct ospf_vl_config_data *vl_config)
853{
854 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
855 /* Virtual Link data initialised to defaults, so only set
856 if a value given */
857 if (vl_config->hello_interval)
858 {
859 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
860 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
861 }
862
863 if (vl_config->dead_interval)
864 {
865 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
866 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
867 }
868
869 if (vl_config->retransmit_interval)
870 {
871 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
872 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
873 }
874
875 if (vl_config->transmit_delay)
876 {
877 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
878 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
879 }
880
881 return CMD_SUCCESS;
882}
883
884
885
886/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000887static int
paul68980082003-03-25 05:07:42 +0000888ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000889{
890 struct ospf_vl_data *vl_data;
891 int ret;
892
paul68980082003-03-25 05:07:42 +0000893 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000894 if (!vl_data)
895 return CMD_WARNING;
896
897 /* Process this one first as it can have a fatal result, which can
898 only logically occur if the virtual link exists already
899 Thus a command error does not result in a change to the
900 running configuration such as unexpectedly altered timer
901 values etc.*/
902 ret = ospf_vl_set_security (vl_data, vl_config);
903 if (ret != CMD_SUCCESS)
904 return ret;
905
906 /* Set any time based parameters, these area already range checked */
907
908 ret = ospf_vl_set_timers (vl_data, vl_config);
909 if (ret != CMD_SUCCESS)
910 return ret;
911
912 return CMD_SUCCESS;
913
914}
915
916/* This stuff exists to make specifying all the alias commands A LOT simpler
917 */
918#define VLINK_HELPSTR_IPADDR \
919 "OSPF area parameters\n" \
920 "OSPF area ID in IP address format\n" \
921 "OSPF area ID as a decimal value\n" \
922 "Configure a virtual link\n" \
923 "Router ID of the remote ABR\n"
924
925#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
926 "Enable authentication on this virtual link\n" \
927 "dummy string \n"
928
929#define VLINK_HELPSTR_AUTHTYPE_ALL \
930 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
931 "Use null authentication\n" \
932 "Use message-digest authentication\n"
933
934#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
935 "Time between HELLO packets\n" \
936 "Time between retransmitting lost link state advertisements\n" \
937 "Link state transmit delay\n" \
938 "Interval after which a neighbor is declared dead\n"
939
940#define VLINK_HELPSTR_TIME_PARAM \
941 VLINK_HELPSTR_TIME_PARAM_NOSECS \
942 "Seconds\n"
943
944#define VLINK_HELPSTR_AUTH_SIMPLE \
945 "Authentication password (key)\n" \
946 "The OSPF password (key)"
947
948#define VLINK_HELPSTR_AUTH_MD5 \
949 "Message digest authentication password (key)\n" \
950 "dummy string \n" \
951 "Key ID\n" \
952 "Use MD5 algorithm\n" \
953 "The OSPF password (key)"
954
paula2c62832003-04-23 17:01:31 +0000955DEFUN (ospf_area_vlink,
956 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000957 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
958 VLINK_HELPSTR_IPADDR)
959{
paul68980082003-03-25 05:07:42 +0000960 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000961 struct ospf_vl_config_data vl_config;
962 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
963 char md5_key[OSPF_AUTH_MD5_SIZE+1];
964 int i;
965 int ret;
966
967 ospf_vl_config_data_init(&vl_config, vty);
968
969 /* Read off first 2 parameters and check them */
970 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
971 if (ret < 0)
972 {
973 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
974 return CMD_WARNING;
975 }
976
977 ret = inet_aton (argv[1], &vl_config.vl_peer);
978 if (! ret)
979 {
980 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
981 VTY_NEWLINE);
982 return CMD_WARNING;
983 }
984
985 if (argc <=2)
986 {
987 /* Thats all folks! - BUGS B. strikes again!!!*/
988
paul68980082003-03-25 05:07:42 +0000989 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000990 }
991
992 /* Deal with other parameters */
993 for (i=2; i < argc; i++)
994 {
995
996 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
997
998 switch (argv[i][0])
999 {
1000
1001 case 'a':
1002 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1003 {
1004 /* authentication-key - this option can occur anywhere on
1005 command line. At start of command line
1006 must check for authentication option. */
1007 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1008 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
1009 vl_config.auth_key = auth_key;
1010 i++;
1011 }
1012 else if (strncmp (argv[i], "authentication", 14) == 0)
1013 {
1014 /* authentication - this option can only occur at start
1015 of command line */
1016 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1017 if ((i+1) < argc)
1018 {
1019 if (strncmp (argv[i+1], "n", 1) == 0)
1020 {
1021 /* "authentication null" */
1022 vl_config.auth_type = OSPF_AUTH_NULL;
1023 i++;
1024 }
1025 else if (strncmp (argv[i+1], "m", 1) == 0
1026 && strcmp (argv[i+1], "message-digest-") != 0)
1027 {
1028 /* "authentication message-digest" */
1029 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1030 i++;
1031 }
1032 }
1033 }
1034 break;
1035
1036 case 'm':
1037 /* message-digest-key */
1038 i++;
1039 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1040 if (vl_config.crypto_key_id < 0)
1041 return CMD_WARNING;
1042 i++;
1043 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1044 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1045 vl_config.md5_key = md5_key;
1046 break;
1047
1048 case 'h':
1049 /* Hello interval */
1050 i++;
1051 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1052 if (vl_config.hello_interval < 0)
1053 return CMD_WARNING;
1054 break;
1055
1056 case 'r':
1057 /* Retransmit Interval */
1058 i++;
1059 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1060 if (vl_config.retransmit_interval < 0)
1061 return CMD_WARNING;
1062 break;
1063
1064 case 't':
1065 /* Transmit Delay */
1066 i++;
1067 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1068 if (vl_config.transmit_delay < 0)
1069 return CMD_WARNING;
1070 break;
1071
1072 case 'd':
1073 /* Dead Interval */
1074 i++;
1075 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1076 if (vl_config.dead_interval < 0)
1077 return CMD_WARNING;
1078 break;
1079 }
1080 }
1081
1082
1083 /* Action configuration */
1084
paul68980082003-03-25 05:07:42 +00001085 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001086
1087}
1088
paula2c62832003-04-23 17:01:31 +00001089DEFUN (no_ospf_area_vlink,
1090 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001091 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1092 NO_STR
1093 VLINK_HELPSTR_IPADDR)
1094{
paul68980082003-03-25 05:07:42 +00001095 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001096 struct ospf_area *area;
1097 struct ospf_vl_config_data vl_config;
1098 struct ospf_vl_data *vl_data = NULL;
1099 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1100 int i;
1101 int ret, format;
1102
1103 ospf_vl_config_data_init(&vl_config, vty);
1104
1105 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1106 if (ret < 0)
1107 {
1108 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1109 return CMD_WARNING;
1110 }
1111
paul68980082003-03-25 05:07:42 +00001112 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001113 if (!area)
1114 {
1115 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1116 return CMD_WARNING;
1117 }
1118
1119 ret = inet_aton (argv[1], &vl_config.vl_peer);
1120 if (! ret)
1121 {
1122 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1123 VTY_NEWLINE);
1124 return CMD_WARNING;
1125 }
1126
1127 if (argc <=2)
1128 {
1129 /* Basic VLink no command */
1130 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001131 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001132 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001133
paul68980082003-03-25 05:07:42 +00001134 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001135
1136 return CMD_SUCCESS;
1137 }
1138
1139 /* If we are down here, we are reseting parameters */
1140
1141 /* Deal with other parameters */
1142 for (i=2; i < argc; i++)
1143 {
paul718e3742002-12-13 20:15:29 +00001144 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1145
1146 switch (argv[i][0])
1147 {
1148
1149 case 'a':
1150 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1151 {
1152 /* authentication-key - this option can occur anywhere on
1153 command line. At start of command line
1154 must check for authentication option. */
1155 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1156 vl_config.auth_key = auth_key;
1157 }
1158 else if (strncmp (argv[i], "authentication", 14) == 0)
1159 {
1160 /* authentication - this option can only occur at start
1161 of command line */
1162 vl_config.auth_type = OSPF_AUTH_NOTSET;
1163 }
1164 break;
1165
1166 case 'm':
1167 /* message-digest-key */
1168 /* Delete one key */
1169 i++;
1170 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1171 if (vl_config.crypto_key_id < 0)
1172 return CMD_WARNING;
1173 vl_config.md5_key = NULL;
1174 break;
1175
1176 case 'h':
1177 /* Hello interval */
1178 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1179 break;
1180
1181 case 'r':
1182 /* Retransmit Interval */
1183 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1184 break;
1185
1186 case 't':
1187 /* Transmit Delay */
1188 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1189 break;
1190
1191 case 'd':
1192 /* Dead Interval */
1193 i++;
1194 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1195 break;
1196 }
1197 }
1198
1199
1200 /* Action configuration */
1201
paul68980082003-03-25 05:07:42 +00001202 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001203}
1204
paula2c62832003-04-23 17:01:31 +00001205ALIAS (ospf_area_vlink,
1206 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001207 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1208 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1209 VLINK_HELPSTR_IPADDR
1210 VLINK_HELPSTR_TIME_PARAM)
1211
paula2c62832003-04-23 17:01:31 +00001212ALIAS (no_ospf_area_vlink,
1213 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001214 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1216 NO_STR
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM)
1219
paula2c62832003-04-23 17:01:31 +00001220ALIAS (ospf_area_vlink,
1221 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001222 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1223 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1224 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1225 VLINK_HELPSTR_IPADDR
1226 VLINK_HELPSTR_TIME_PARAM
1227 VLINK_HELPSTR_TIME_PARAM)
1228
paula2c62832003-04-23 17:01:31 +00001229ALIAS (no_ospf_area_vlink,
1230 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001231 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1232 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1233 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1234 NO_STR
1235 VLINK_HELPSTR_IPADDR
1236 VLINK_HELPSTR_TIME_PARAM
1237 VLINK_HELPSTR_TIME_PARAM)
1238
paula2c62832003-04-23 17:01:31 +00001239ALIAS (ospf_area_vlink,
1240 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001241 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1242 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1243 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1244 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1245 VLINK_HELPSTR_IPADDR
1246 VLINK_HELPSTR_TIME_PARAM
1247 VLINK_HELPSTR_TIME_PARAM
1248 VLINK_HELPSTR_TIME_PARAM)
1249
paula2c62832003-04-23 17:01:31 +00001250ALIAS (no_ospf_area_vlink,
1251 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001252 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1254 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1255 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_TIME_PARAM
1259 VLINK_HELPSTR_TIME_PARAM
1260 VLINK_HELPSTR_TIME_PARAM)
1261
paula2c62832003-04-23 17:01:31 +00001262ALIAS (ospf_area_vlink,
1263 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001264 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1265 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1267 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1268 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1269 VLINK_HELPSTR_IPADDR
1270 VLINK_HELPSTR_TIME_PARAM
1271 VLINK_HELPSTR_TIME_PARAM
1272 VLINK_HELPSTR_TIME_PARAM
1273 VLINK_HELPSTR_TIME_PARAM)
1274
paula2c62832003-04-23 17:01:31 +00001275ALIAS (no_ospf_area_vlink,
1276 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001277 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1278 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1279 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1280 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1281 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1282 NO_STR
1283 VLINK_HELPSTR_IPADDR
1284 VLINK_HELPSTR_TIME_PARAM
1285 VLINK_HELPSTR_TIME_PARAM
1286 VLINK_HELPSTR_TIME_PARAM
1287 VLINK_HELPSTR_TIME_PARAM)
1288
paula2c62832003-04-23 17:01:31 +00001289ALIAS (ospf_area_vlink,
1290 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001291 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1292 "(authentication|) (message-digest|null)",
1293 VLINK_HELPSTR_IPADDR
1294 VLINK_HELPSTR_AUTHTYPE_ALL)
1295
paula2c62832003-04-23 17:01:31 +00001296ALIAS (ospf_area_vlink,
1297 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001298 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1299 "(authentication|)",
1300 VLINK_HELPSTR_IPADDR
1301 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1302
paula2c62832003-04-23 17:01:31 +00001303ALIAS (no_ospf_area_vlink,
1304 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001305 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1306 "(authentication|)",
1307 NO_STR
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1310
paula2c62832003-04-23 17:01:31 +00001311ALIAS (ospf_area_vlink,
1312 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001313 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1314 "(message-digest-key|) <1-255> md5 KEY",
1315 VLINK_HELPSTR_IPADDR
1316 VLINK_HELPSTR_AUTH_MD5)
1317
paula2c62832003-04-23 17:01:31 +00001318ALIAS (no_ospf_area_vlink,
1319 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001320 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1321 "(message-digest-key|) <1-255>",
1322 NO_STR
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTH_MD5)
1325
paula2c62832003-04-23 17:01:31 +00001326ALIAS (ospf_area_vlink,
1327 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001328 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(authentication-key|) AUTH_KEY",
1330 VLINK_HELPSTR_IPADDR
1331 VLINK_HELPSTR_AUTH_SIMPLE)
1332
paula2c62832003-04-23 17:01:31 +00001333ALIAS (no_ospf_area_vlink,
1334 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001335 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1336 "(authentication-key|)",
1337 NO_STR
1338 VLINK_HELPSTR_IPADDR
1339 VLINK_HELPSTR_AUTH_SIMPLE)
1340
paula2c62832003-04-23 17:01:31 +00001341ALIAS (ospf_area_vlink,
1342 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001343 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1344 "(authentication|) (message-digest|null) "
1345 "(authentication-key|) AUTH_KEY",
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_AUTHTYPE_ALL
1348 VLINK_HELPSTR_AUTH_SIMPLE)
1349
paula2c62832003-04-23 17:01:31 +00001350ALIAS (ospf_area_vlink,
1351 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001352 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1353 "(authentication|) "
1354 "(authentication-key|) AUTH_KEY",
1355 VLINK_HELPSTR_IPADDR
1356 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1357 VLINK_HELPSTR_AUTH_SIMPLE)
1358
paula2c62832003-04-23 17:01:31 +00001359ALIAS (no_ospf_area_vlink,
1360 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001361 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1362 "(authentication|) "
1363 "(authentication-key|)",
1364 NO_STR
1365 VLINK_HELPSTR_IPADDR
1366 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1367 VLINK_HELPSTR_AUTH_SIMPLE)
1368
paula2c62832003-04-23 17:01:31 +00001369ALIAS (ospf_area_vlink,
1370 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001371 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1372 "(authentication|) (message-digest|null) "
1373 "(message-digest-key|) <1-255> md5 KEY",
1374 VLINK_HELPSTR_IPADDR
1375 VLINK_HELPSTR_AUTHTYPE_ALL
1376 VLINK_HELPSTR_AUTH_MD5)
1377
paula2c62832003-04-23 17:01:31 +00001378ALIAS (ospf_area_vlink,
1379 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001380 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1381 "(authentication|) "
1382 "(message-digest-key|) <1-255> md5 KEY",
1383 VLINK_HELPSTR_IPADDR
1384 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1385 VLINK_HELPSTR_AUTH_MD5)
1386
paula2c62832003-04-23 17:01:31 +00001387ALIAS (no_ospf_area_vlink,
1388 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001389 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1390 "(authentication|) "
1391 "(message-digest-key|)",
1392 NO_STR
1393 VLINK_HELPSTR_IPADDR
1394 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1395 VLINK_HELPSTR_AUTH_MD5)
1396
David Lamparter6b0655a2014-06-04 06:53:35 +02001397
paula2c62832003-04-23 17:01:31 +00001398DEFUN (ospf_area_shortcut,
1399 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001400 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1401 "OSPF area parameters\n"
1402 "OSPF area ID in IP address format\n"
1403 "OSPF area ID as a decimal value\n"
1404 "Configure the area's shortcutting mode\n"
1405 "Set default shortcutting behavior\n"
1406 "Enable shortcutting through the area\n"
1407 "Disable shortcutting through the area\n")
1408{
paul68980082003-03-25 05:07:42 +00001409 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001410 struct ospf_area *area;
1411 struct in_addr area_id;
1412 int mode;
1413 int format;
1414
1415 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1416
paul68980082003-03-25 05:07:42 +00001417 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001418
1419 if (strncmp (argv[1], "de", 2) == 0)
1420 mode = OSPF_SHORTCUT_DEFAULT;
1421 else if (strncmp (argv[1], "di", 2) == 0)
1422 mode = OSPF_SHORTCUT_DISABLE;
1423 else if (strncmp (argv[1], "e", 1) == 0)
1424 mode = OSPF_SHORTCUT_ENABLE;
1425 else
1426 return CMD_WARNING;
1427
paul68980082003-03-25 05:07:42 +00001428 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001429
paul68980082003-03-25 05:07:42 +00001430 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001431 vty_out (vty, "Shortcut area setting will take effect "
1432 "only when the router is configured as Shortcut ABR%s",
1433 VTY_NEWLINE);
1434
1435 return CMD_SUCCESS;
1436}
1437
paula2c62832003-04-23 17:01:31 +00001438DEFUN (no_ospf_area_shortcut,
1439 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001440 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1441 NO_STR
1442 "OSPF area parameters\n"
1443 "OSPF area ID in IP address format\n"
1444 "OSPF area ID as a decimal value\n"
1445 "Deconfigure the area's shortcutting mode\n"
1446 "Deconfigure enabled shortcutting through the area\n"
1447 "Deconfigure disabled shortcutting through the area\n")
1448{
paul68980082003-03-25 05:07:42 +00001449 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001450 struct ospf_area *area;
1451 struct in_addr area_id;
1452 int format;
1453
1454 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1455
paul68980082003-03-25 05:07:42 +00001456 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001457 if (!area)
1458 return CMD_SUCCESS;
1459
paul68980082003-03-25 05:07:42 +00001460 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001461
1462 return CMD_SUCCESS;
1463}
1464
David Lamparter6b0655a2014-06-04 06:53:35 +02001465
paula2c62832003-04-23 17:01:31 +00001466DEFUN (ospf_area_stub,
1467 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001468 "area (A.B.C.D|<0-4294967295>) stub",
1469 "OSPF area parameters\n"
1470 "OSPF area ID in IP address format\n"
1471 "OSPF area ID as a decimal value\n"
1472 "Configure OSPF area as stub\n")
1473{
1474 struct ospf *ospf = vty->index;
1475 struct in_addr area_id;
1476 int ret, format;
1477
1478 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1479
1480 ret = ospf_area_stub_set (ospf, area_id);
1481 if (ret == 0)
1482 {
1483 vty_out (vty, "First deconfigure all virtual link through this area%s",
1484 VTY_NEWLINE);
1485 return CMD_WARNING;
1486 }
1487
1488 ospf_area_no_summary_unset (ospf, area_id);
1489
1490 return CMD_SUCCESS;
1491}
1492
paula2c62832003-04-23 17:01:31 +00001493DEFUN (ospf_area_stub_no_summary,
1494 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001495 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1496 "OSPF stub parameters\n"
1497 "OSPF area ID in IP address format\n"
1498 "OSPF area ID as a decimal value\n"
1499 "Configure OSPF area as stub\n"
1500 "Do not inject inter-area routes into stub\n")
1501{
1502 struct ospf *ospf = vty->index;
1503 struct in_addr area_id;
1504 int ret, format;
1505
1506 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1507
1508 ret = ospf_area_stub_set (ospf, area_id);
1509 if (ret == 0)
1510 {
paulb0a053b2003-06-22 09:04:47 +00001511 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001512 VTY_NEWLINE);
1513 return CMD_WARNING;
1514 }
1515
1516 ospf_area_no_summary_set (ospf, area_id);
1517
1518 return CMD_SUCCESS;
1519}
1520
paula2c62832003-04-23 17:01:31 +00001521DEFUN (no_ospf_area_stub,
1522 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001523 "no area (A.B.C.D|<0-4294967295>) stub",
1524 NO_STR
1525 "OSPF area parameters\n"
1526 "OSPF area ID in IP address format\n"
1527 "OSPF area ID as a decimal value\n"
1528 "Configure OSPF area as stub\n")
1529{
1530 struct ospf *ospf = vty->index;
1531 struct in_addr area_id;
1532 int format;
1533
1534 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1535
1536 ospf_area_stub_unset (ospf, area_id);
1537 ospf_area_no_summary_unset (ospf, area_id);
1538
1539 return CMD_SUCCESS;
1540}
1541
paula2c62832003-04-23 17:01:31 +00001542DEFUN (no_ospf_area_stub_no_summary,
1543 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001544 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1545 NO_STR
1546 "OSPF area parameters\n"
1547 "OSPF area ID in IP address format\n"
1548 "OSPF area ID as a decimal value\n"
1549 "Configure OSPF area as stub\n"
1550 "Do not inject inter-area routes into area\n")
1551{
1552 struct ospf *ospf = vty->index;
1553 struct in_addr area_id;
1554 int format;
1555
1556 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1557 ospf_area_no_summary_unset (ospf, area_id);
1558
1559 return CMD_SUCCESS;
1560}
1561
paul4dadc292005-05-06 21:37:42 +00001562static int
paul6c835672004-10-11 11:00:30 +00001563ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1564 int nosum)
paul718e3742002-12-13 20:15:29 +00001565{
1566 struct ospf *ospf = vty->index;
1567 struct in_addr area_id;
1568 int ret, format;
1569
1570 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1571
1572 ret = ospf_area_nssa_set (ospf, area_id);
1573 if (ret == 0)
1574 {
1575 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1576 VTY_NEWLINE);
1577 return CMD_WARNING;
1578 }
1579
1580 if (argc > 1)
1581 {
1582 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001583 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001584 OSPF_NSSA_ROLE_CANDIDATE);
1585 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001586 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001587 OSPF_NSSA_ROLE_NEVER);
1588 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001589 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001590 OSPF_NSSA_ROLE_ALWAYS);
1591 }
paulb0a053b2003-06-22 09:04:47 +00001592 else
1593 {
1594 ospf_area_nssa_translator_role_set (ospf, area_id,
1595 OSPF_NSSA_ROLE_CANDIDATE);
1596 }
paul718e3742002-12-13 20:15:29 +00001597
paulb0a053b2003-06-22 09:04:47 +00001598 if (nosum)
paul718e3742002-12-13 20:15:29 +00001599 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001600 else
1601 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001602
paulb0a053b2003-06-22 09:04:47 +00001603 ospf_schedule_abr_task (ospf);
1604
paul718e3742002-12-13 20:15:29 +00001605 return CMD_SUCCESS;
1606}
1607
paulb0a053b2003-06-22 09:04:47 +00001608DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001609 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001610 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001611 "OSPF area parameters\n"
1612 "OSPF area ID in IP address format\n"
1613 "OSPF area ID as a decimal value\n"
1614 "Configure OSPF area as nssa\n"
1615 "Configure NSSA-ABR for translate election (default)\n"
1616 "Configure NSSA-ABR to never translate\n"
1617 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001618 "Do not inject inter-area routes into nssa\n")
1619{
1620 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1621}
paul718e3742002-12-13 20:15:29 +00001622
paulb0a053b2003-06-22 09:04:47 +00001623DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001624 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001625 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1626 "OSPF area parameters\n"
1627 "OSPF area ID in IP address format\n"
1628 "OSPF area ID as a decimal value\n"
1629 "Configure OSPF area as nssa\n"
1630 "Configure NSSA-ABR for translate election (default)\n"
1631 "Configure NSSA-ABR to never translate\n"
1632 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001633{
1634 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1635}
1636
1637DEFUN (ospf_area_nssa,
1638 ospf_area_nssa_cmd,
1639 "area (A.B.C.D|<0-4294967295>) nssa",
1640 "OSPF area parameters\n"
1641 "OSPF area ID in IP address format\n"
1642 "OSPF area ID as a decimal value\n"
1643 "Configure OSPF area as nssa\n")
1644{
1645 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1646}
paul718e3742002-12-13 20:15:29 +00001647
paula2c62832003-04-23 17:01:31 +00001648DEFUN (ospf_area_nssa_no_summary,
1649 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001650 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1651 "OSPF area parameters\n"
1652 "OSPF area ID in IP address format\n"
1653 "OSPF area ID as a decimal value\n"
1654 "Configure OSPF area as nssa\n"
1655 "Do not inject inter-area routes into nssa\n")
1656{
paulb0a053b2003-06-22 09:04:47 +00001657 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001658}
1659
paula2c62832003-04-23 17:01:31 +00001660DEFUN (no_ospf_area_nssa,
1661 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001662 "no area (A.B.C.D|<0-4294967295>) nssa",
1663 NO_STR
1664 "OSPF area parameters\n"
1665 "OSPF area ID in IP address format\n"
1666 "OSPF area ID as a decimal value\n"
1667 "Configure OSPF area as nssa\n")
1668{
1669 struct ospf *ospf = vty->index;
1670 struct in_addr area_id;
1671 int format;
1672
1673 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1674
1675 ospf_area_nssa_unset (ospf, area_id);
1676 ospf_area_no_summary_unset (ospf, area_id);
1677
paulb0a053b2003-06-22 09:04:47 +00001678 ospf_schedule_abr_task (ospf);
1679
paul718e3742002-12-13 20:15:29 +00001680 return CMD_SUCCESS;
1681}
1682
paula2c62832003-04-23 17:01:31 +00001683DEFUN (no_ospf_area_nssa_no_summary,
1684 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001685 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1686 NO_STR
1687 "OSPF area parameters\n"
1688 "OSPF area ID in IP address format\n"
1689 "OSPF area ID as a decimal value\n"
1690 "Configure OSPF area as nssa\n"
1691 "Do not inject inter-area routes into nssa\n")
1692{
1693 struct ospf *ospf = vty->index;
1694 struct in_addr area_id;
1695 int format;
1696
1697 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1698 ospf_area_no_summary_unset (ospf, area_id);
1699
1700 return CMD_SUCCESS;
1701}
1702
paula2c62832003-04-23 17:01:31 +00001703DEFUN (ospf_area_default_cost,
1704 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001705 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1706 "OSPF area parameters\n"
1707 "OSPF area ID in IP address format\n"
1708 "OSPF area ID as a decimal value\n"
1709 "Set the summary-default cost of a NSSA or stub area\n"
1710 "Stub's advertised default summary cost\n")
1711{
paul68980082003-03-25 05:07:42 +00001712 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001713 struct ospf_area *area;
1714 struct in_addr area_id;
1715 u_int32_t cost;
1716 int format;
vincentba682532005-09-29 13:52:57 +00001717 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001718
1719 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1720 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1721
paul68980082003-03-25 05:07:42 +00001722 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001723
1724 if (area->external_routing == OSPF_AREA_DEFAULT)
1725 {
1726 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1727 return CMD_WARNING;
1728 }
1729
1730 area->default_cost = cost;
1731
vincentba682532005-09-29 13:52:57 +00001732 p.family = AF_INET;
1733 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1734 p.prefixlen = 0;
1735 if (IS_DEBUG_OSPF_EVENT)
1736 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1737 "announcing 0.0.0.0/0 to area %s",
1738 inet_ntoa (area->area_id));
1739 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1740
paul718e3742002-12-13 20:15:29 +00001741 return CMD_SUCCESS;
1742}
1743
paula2c62832003-04-23 17:01:31 +00001744DEFUN (no_ospf_area_default_cost,
1745 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001746 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1747 NO_STR
1748 "OSPF area parameters\n"
1749 "OSPF area ID in IP address format\n"
1750 "OSPF area ID as a decimal value\n"
1751 "Set the summary-default cost of a NSSA or stub area\n"
1752 "Stub's advertised default summary cost\n")
1753{
paul68980082003-03-25 05:07:42 +00001754 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001755 struct ospf_area *area;
1756 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001757 int format;
vincentba682532005-09-29 13:52:57 +00001758 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001759
1760 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
Andrew Certain0798cee2012-12-04 13:43:42 -08001761 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
paul718e3742002-12-13 20:15:29 +00001762
paul68980082003-03-25 05:07:42 +00001763 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001764 if (area == NULL)
1765 return CMD_SUCCESS;
1766
1767 if (area->external_routing == OSPF_AREA_DEFAULT)
1768 {
1769 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1770 return CMD_WARNING;
1771 }
1772
1773 area->default_cost = 1;
1774
vincentba682532005-09-29 13:52:57 +00001775 p.family = AF_INET;
1776 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1777 p.prefixlen = 0;
1778 if (IS_DEBUG_OSPF_EVENT)
1779 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1780 "announcing 0.0.0.0/0 to area %s",
1781 inet_ntoa (area->area_id));
1782 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1783
1784
paul68980082003-03-25 05:07:42 +00001785 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001786
1787 return CMD_SUCCESS;
1788}
1789
paula2c62832003-04-23 17:01:31 +00001790DEFUN (ospf_area_export_list,
1791 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001792 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1793 "OSPF area parameters\n"
1794 "OSPF area ID in IP address format\n"
1795 "OSPF area ID as a decimal value\n"
1796 "Set the filter for networks announced to other areas\n"
1797 "Name of the access-list\n")
1798{
paul68980082003-03-25 05:07:42 +00001799 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001800 struct ospf_area *area;
1801 struct in_addr area_id;
1802 int format;
1803
hasso52930762004-04-19 18:26:53 +00001804 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1805
paul68980082003-03-25 05:07:42 +00001806 area = ospf_area_get (ospf, area_id, format);
1807 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001808
1809 return CMD_SUCCESS;
1810}
1811
paula2c62832003-04-23 17:01:31 +00001812DEFUN (no_ospf_area_export_list,
1813 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001814 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1815 NO_STR
1816 "OSPF area parameters\n"
1817 "OSPF area ID in IP address format\n"
1818 "OSPF area ID as a decimal value\n"
1819 "Unset the filter for networks announced to other areas\n"
1820 "Name of the access-list\n")
1821{
paul68980082003-03-25 05:07:42 +00001822 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001823 struct ospf_area *area;
1824 struct in_addr area_id;
1825 int format;
1826
hasso52930762004-04-19 18:26:53 +00001827 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1828
paul68980082003-03-25 05:07:42 +00001829 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001830 if (area == NULL)
1831 return CMD_SUCCESS;
1832
paul68980082003-03-25 05:07:42 +00001833 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001834
1835 return CMD_SUCCESS;
1836}
1837
1838
paula2c62832003-04-23 17:01:31 +00001839DEFUN (ospf_area_import_list,
1840 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001841 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1842 "OSPF area parameters\n"
1843 "OSPF area ID in IP address format\n"
1844 "OSPF area ID as a decimal value\n"
1845 "Set the filter for networks from other areas announced to the specified one\n"
1846 "Name of the access-list\n")
1847{
paul68980082003-03-25 05:07:42 +00001848 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001849 struct ospf_area *area;
1850 struct in_addr area_id;
1851 int format;
1852
hasso52930762004-04-19 18:26:53 +00001853 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1854
paul68980082003-03-25 05:07:42 +00001855 area = ospf_area_get (ospf, area_id, format);
1856 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001857
1858 return CMD_SUCCESS;
1859}
1860
paula2c62832003-04-23 17:01:31 +00001861DEFUN (no_ospf_area_import_list,
1862 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001863 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1864 NO_STR
1865 "OSPF area parameters\n"
1866 "OSPF area ID in IP address format\n"
1867 "OSPF area ID as a decimal value\n"
1868 "Unset the filter for networks announced to other areas\n"
1869 "Name of the access-list\n")
1870{
paul68980082003-03-25 05:07:42 +00001871 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001872 struct ospf_area *area;
1873 struct in_addr area_id;
1874 int format;
1875
hasso52930762004-04-19 18:26:53 +00001876 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1877
paul68980082003-03-25 05:07:42 +00001878 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001879 if (area == NULL)
1880 return CMD_SUCCESS;
1881
paul68980082003-03-25 05:07:42 +00001882 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001883
1884 return CMD_SUCCESS;
1885}
1886
paula2c62832003-04-23 17:01:31 +00001887DEFUN (ospf_area_filter_list,
1888 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001889 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1890 "OSPF area parameters\n"
1891 "OSPF area ID in IP address format\n"
1892 "OSPF area ID as a decimal value\n"
1893 "Filter networks between OSPF areas\n"
1894 "Filter prefixes between OSPF areas\n"
1895 "Name of an IP prefix-list\n"
1896 "Filter networks sent to this area\n"
1897 "Filter networks sent from this area\n")
1898{
paul68980082003-03-25 05:07:42 +00001899 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001900 struct ospf_area *area;
1901 struct in_addr area_id;
1902 struct prefix_list *plist;
1903 int format;
1904
1905 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1906
paul68980082003-03-25 05:07:42 +00001907 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001908 plist = prefix_list_lookup (AFI_IP, argv[1]);
1909 if (strncmp (argv[2], "in", 2) == 0)
1910 {
1911 PREFIX_LIST_IN (area) = plist;
1912 if (PREFIX_NAME_IN (area))
1913 free (PREFIX_NAME_IN (area));
1914
1915 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001916 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001917 }
1918 else
1919 {
1920 PREFIX_LIST_OUT (area) = plist;
1921 if (PREFIX_NAME_OUT (area))
1922 free (PREFIX_NAME_OUT (area));
1923
1924 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001925 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001926 }
1927
1928 return CMD_SUCCESS;
1929}
1930
paula2c62832003-04-23 17:01:31 +00001931DEFUN (no_ospf_area_filter_list,
1932 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001933 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1934 NO_STR
1935 "OSPF area parameters\n"
1936 "OSPF area ID in IP address format\n"
1937 "OSPF area ID as a decimal value\n"
1938 "Filter networks between OSPF areas\n"
1939 "Filter prefixes between OSPF areas\n"
1940 "Name of an IP prefix-list\n"
1941 "Filter networks sent to this area\n"
1942 "Filter networks sent from this area\n")
1943{
paul68980082003-03-25 05:07:42 +00001944 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001945 struct ospf_area *area;
1946 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001947 int format;
1948
1949 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1950
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001951 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1952 return CMD_SUCCESS;
1953
paul718e3742002-12-13 20:15:29 +00001954 if (strncmp (argv[2], "in", 2) == 0)
1955 {
1956 if (PREFIX_NAME_IN (area))
1957 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1958 return CMD_SUCCESS;
1959
1960 PREFIX_LIST_IN (area) = NULL;
1961 if (PREFIX_NAME_IN (area))
1962 free (PREFIX_NAME_IN (area));
1963
1964 PREFIX_NAME_IN (area) = NULL;
1965
paul68980082003-03-25 05:07:42 +00001966 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001967 }
1968 else
1969 {
1970 if (PREFIX_NAME_OUT (area))
1971 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1972 return CMD_SUCCESS;
1973
1974 PREFIX_LIST_OUT (area) = NULL;
1975 if (PREFIX_NAME_OUT (area))
1976 free (PREFIX_NAME_OUT (area));
1977
1978 PREFIX_NAME_OUT (area) = NULL;
1979
paul68980082003-03-25 05:07:42 +00001980 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001981 }
1982
1983 return CMD_SUCCESS;
1984}
1985
David Lamparter6b0655a2014-06-04 06:53:35 +02001986
paula2c62832003-04-23 17:01:31 +00001987DEFUN (ospf_area_authentication_message_digest,
1988 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001989 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1990 "OSPF area parameters\n"
Christian Franke2b005152013-09-30 12:27:49 +00001991 "OSPF area ID in IP address format\n"
1992 "OSPF area ID as a decimal value\n"
paul718e3742002-12-13 20:15:29 +00001993 "Enable authentication\n"
1994 "Use message-digest authentication\n")
1995{
paul68980082003-03-25 05:07:42 +00001996 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001997 struct ospf_area *area;
1998 struct in_addr area_id;
1999 int format;
2000
2001 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2002
paul68980082003-03-25 05:07:42 +00002003 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002004 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
2005
2006 return CMD_SUCCESS;
2007}
2008
paula2c62832003-04-23 17:01:31 +00002009DEFUN (ospf_area_authentication,
2010 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002011 "area (A.B.C.D|<0-4294967295>) authentication",
2012 "OSPF area parameters\n"
2013 "OSPF area ID in IP address format\n"
2014 "OSPF area ID as a decimal value\n"
2015 "Enable authentication\n")
2016{
paul68980082003-03-25 05:07:42 +00002017 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002018 struct ospf_area *area;
2019 struct in_addr area_id;
2020 int format;
2021
2022 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2023
paul68980082003-03-25 05:07:42 +00002024 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002025 area->auth_type = OSPF_AUTH_SIMPLE;
2026
2027 return CMD_SUCCESS;
2028}
2029
paula2c62832003-04-23 17:01:31 +00002030DEFUN (no_ospf_area_authentication,
2031 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002032 "no area (A.B.C.D|<0-4294967295>) authentication",
2033 NO_STR
2034 "OSPF area parameters\n"
2035 "OSPF area ID in IP address format\n"
2036 "OSPF area ID as a decimal value\n"
2037 "Enable authentication\n")
2038{
paul68980082003-03-25 05:07:42 +00002039 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002040 struct ospf_area *area;
2041 struct in_addr area_id;
2042 int format;
2043
2044 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2045
paul68980082003-03-25 05:07:42 +00002046 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002047 if (area == NULL)
2048 return CMD_SUCCESS;
2049
2050 area->auth_type = OSPF_AUTH_NULL;
2051
paul68980082003-03-25 05:07:42 +00002052 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002053
2054 return CMD_SUCCESS;
2055}
2056
David Lamparter6b0655a2014-06-04 06:53:35 +02002057
paul718e3742002-12-13 20:15:29 +00002058DEFUN (ospf_abr_type,
2059 ospf_abr_type_cmd,
2060 "ospf abr-type (cisco|ibm|shortcut|standard)",
2061 "OSPF specific commands\n"
2062 "Set OSPF ABR type\n"
2063 "Alternative ABR, cisco implementation\n"
2064 "Alternative ABR, IBM implementation\n"
2065 "Shortcut ABR\n"
2066 "Standard behavior (RFC2328)\n")
2067{
paul68980082003-03-25 05:07:42 +00002068 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002069 u_char abr_type = OSPF_ABR_UNKNOWN;
2070
2071 if (strncmp (argv[0], "c", 1) == 0)
2072 abr_type = OSPF_ABR_CISCO;
2073 else if (strncmp (argv[0], "i", 1) == 0)
2074 abr_type = OSPF_ABR_IBM;
2075 else if (strncmp (argv[0], "sh", 2) == 0)
2076 abr_type = OSPF_ABR_SHORTCUT;
2077 else if (strncmp (argv[0], "st", 2) == 0)
2078 abr_type = OSPF_ABR_STAND;
2079 else
2080 return CMD_WARNING;
2081
2082 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002083 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002084 {
paul68980082003-03-25 05:07:42 +00002085 ospf->abr_type = abr_type;
2086 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002087 }
2088
2089 return CMD_SUCCESS;
2090}
2091
2092DEFUN (no_ospf_abr_type,
2093 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002094 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002095 NO_STR
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{
paul68980082003-03-25 05:07:42 +00002102 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002103 u_char abr_type = OSPF_ABR_UNKNOWN;
2104
2105 if (strncmp (argv[0], "c", 1) == 0)
2106 abr_type = OSPF_ABR_CISCO;
2107 else if (strncmp (argv[0], "i", 1) == 0)
2108 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002109 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002110 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002111 else if (strncmp (argv[0], "st", 2) == 0)
2112 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002113 else
2114 return CMD_WARNING;
2115
2116 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002117 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002118 {
pauld57834f2005-07-12 20:04:22 +00002119 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002120 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002121 }
2122
2123 return CMD_SUCCESS;
2124}
2125
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002126DEFUN (ospf_log_adjacency_changes,
2127 ospf_log_adjacency_changes_cmd,
2128 "log-adjacency-changes",
2129 "Log changes in adjacency state\n")
2130{
2131 struct ospf *ospf = vty->index;
2132
2133 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2134 return CMD_SUCCESS;
2135}
2136
2137DEFUN (ospf_log_adjacency_changes_detail,
2138 ospf_log_adjacency_changes_detail_cmd,
2139 "log-adjacency-changes detail",
2140 "Log changes in adjacency state\n"
2141 "Log all state changes\n")
2142{
2143 struct ospf *ospf = vty->index;
2144
2145 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2146 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2147 return CMD_SUCCESS;
2148}
2149
2150DEFUN (no_ospf_log_adjacency_changes,
2151 no_ospf_log_adjacency_changes_cmd,
2152 "no log-adjacency-changes",
2153 NO_STR
2154 "Log changes in adjacency state\n")
2155{
2156 struct ospf *ospf = vty->index;
2157
2158 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2159 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2160 return CMD_SUCCESS;
2161}
2162
2163DEFUN (no_ospf_log_adjacency_changes_detail,
2164 no_ospf_log_adjacency_changes_detail_cmd,
2165 "no log-adjacency-changes detail",
2166 NO_STR
2167 "Log changes in adjacency state\n"
2168 "Log all state changes\n")
2169{
2170 struct ospf *ospf = vty->index;
2171
2172 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2173 return CMD_SUCCESS;
2174}
2175
paul718e3742002-12-13 20:15:29 +00002176DEFUN (ospf_compatible_rfc1583,
2177 ospf_compatible_rfc1583_cmd,
2178 "compatible rfc1583",
2179 "OSPF compatibility list\n"
2180 "compatible with RFC 1583\n")
2181{
2182 struct ospf *ospf = vty->index;
2183
2184 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2185 {
2186 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
Paul Jakmab6eef002014-10-09 14:19:51 +01002187 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
paul718e3742002-12-13 20:15:29 +00002188 }
2189 return CMD_SUCCESS;
2190}
2191
2192DEFUN (no_ospf_compatible_rfc1583,
2193 no_ospf_compatible_rfc1583_cmd,
2194 "no compatible rfc1583",
2195 NO_STR
2196 "OSPF compatibility list\n"
2197 "compatible with RFC 1583\n")
2198{
2199 struct ospf *ospf = vty->index;
2200
2201 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2202 {
2203 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
Paul Jakmab6eef002014-10-09 14:19:51 +01002204 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
paul718e3742002-12-13 20:15:29 +00002205 }
2206 return CMD_SUCCESS;
2207}
2208
2209ALIAS (ospf_compatible_rfc1583,
2210 ospf_rfc1583_flag_cmd,
2211 "ospf rfc1583compatibility",
2212 "OSPF specific commands\n"
2213 "Enable the RFC1583Compatibility flag\n")
2214
2215ALIAS (no_ospf_compatible_rfc1583,
2216 no_ospf_rfc1583_flag_cmd,
2217 "no ospf rfc1583compatibility",
2218 NO_STR
2219 "OSPF specific commands\n"
2220 "Disable the RFC1583Compatibility flag\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002221
pauld24f6e22005-10-21 09:23:12 +00002222static int
2223ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2224 unsigned int hold,
2225 unsigned int max)
2226{
2227 struct ospf *ospf = vty->index;
2228
2229 ospf->spf_delay = delay;
2230 ospf->spf_holdtime = hold;
2231 ospf->spf_max_holdtime = max;
2232
2233 return CMD_SUCCESS;
2234}
paul718e3742002-12-13 20:15:29 +00002235
Michael Rossberg2ef762e2015-07-27 07:56:25 +02002236DEFUN (ospf_timers_min_ls_interval,
2237 ospf_timers_min_ls_interval_cmd,
2238 "timers throttle lsa all <0-5000>",
2239 "Adjust routing timers\n"
2240 "Throttling adaptive timer\n"
2241 "LSA delay between transmissions\n"
2242 NO_STR
2243 "Delay (msec) between sending LSAs\n")
2244{
2245 struct ospf *ospf = vty->index;
2246 unsigned int interval;
2247
2248 if (argc != 1)
2249 {
2250 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2251 return CMD_WARNING;
2252 }
2253
2254 VTY_GET_INTEGER ("LSA interval", interval, argv[0]);
2255
2256 ospf->min_ls_interval = interval;
2257
2258 return CMD_SUCCESS;
2259}
2260
2261DEFUN (no_ospf_timers_min_ls_interval,
2262 no_ospf_timers_min_ls_interval_cmd,
2263 "no timers throttle lsa all",
2264 NO_STR
2265 "Adjust routing timers\n"
2266 "Throttling adaptive timer\n"
2267 "LSA delay between transmissions\n")
2268{
2269 struct ospf *ospf = vty->index;
2270 ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
2271
2272 return CMD_SUCCESS;
2273}
2274
2275DEFUN (ospf_timers_min_ls_arrival,
2276 ospf_timers_min_ls_arrival_cmd,
2277 "timers lsa arrival <0-1000>",
2278 "Adjust routing timers\n"
2279 "Throttling link state advertisement delays\n"
2280 "OSPF minimum arrival interval delay\n"
2281 "Delay (msec) between accepted LSAs\n")
2282{
2283 struct ospf *ospf = vty->index;
2284 unsigned int arrival;
2285
2286 if (argc != 1)
2287 {
2288 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2289 return CMD_WARNING;
2290 }
2291
2292 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000);
2293
2294 ospf->min_ls_arrival = arrival;
2295
2296 return CMD_SUCCESS;
2297}
2298
2299DEFUN (no_ospf_timers_min_ls_arrival,
2300 no_ospf_timers_min_ls_arrival_cmd,
2301 "no timers lsa arrival",
2302 NO_STR
2303 "Adjust routing timers\n"
2304 "Throttling link state advertisement delays\n"
2305 "OSPF minimum arrival interval delay\n")
2306{
2307 struct ospf *ospf = vty->index;
2308 ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
2309
2310 return CMD_SUCCESS;
2311}
2312
pauld24f6e22005-10-21 09:23:12 +00002313DEFUN (ospf_timers_throttle_spf,
2314 ospf_timers_throttle_spf_cmd,
2315 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2316 "Adjust routing timers\n"
2317 "Throttling adaptive timer\n"
2318 "OSPF SPF timers\n"
2319 "Delay (msec) from first change received till SPF calculation\n"
2320 "Initial hold time (msec) between consecutive SPF calculations\n"
2321 "Maximum hold time (msec)\n")
2322{
2323 unsigned int delay, hold, max;
2324
2325 if (argc != 3)
2326 {
2327 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2328 return CMD_WARNING;
2329 }
2330
2331 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2332 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2333 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2334
2335 return ospf_timers_spf_set (vty, delay, hold, max);
2336}
2337
2338DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002339 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002340 "timers spf <0-4294967295> <0-4294967295>",
2341 "Adjust routing timers\n"
2342 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002343 "Delay (s) between receiving a change to SPF calculation\n"
2344 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002345{
pauld24f6e22005-10-21 09:23:12 +00002346 unsigned int delay, hold;
2347
2348 if (argc != 2)
2349 {
2350 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2351 return CMD_WARNING;
2352 }
2353
paul4dadc292005-05-06 21:37:42 +00002354 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2355 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002356
2357 /* truncate down the second values if they're greater than 600000ms */
2358 if (delay > (600000 / 1000))
2359 delay = 600000;
2360 else if (delay == 0)
2361 /* 0s delay was probably specified because of lack of ms resolution */
2362 delay = OSPF_SPF_DELAY_DEFAULT;
2363 if (hold > (600000 / 1000))
2364 hold = 600000;
2365
2366 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002367}
2368
pauld24f6e22005-10-21 09:23:12 +00002369DEFUN (no_ospf_timers_throttle_spf,
2370 no_ospf_timers_throttle_spf_cmd,
2371 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002372 NO_STR
2373 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002374 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002375 "OSPF SPF timers\n")
2376{
pauld24f6e22005-10-21 09:23:12 +00002377 return ospf_timers_spf_set (vty,
2378 OSPF_SPF_DELAY_DEFAULT,
2379 OSPF_SPF_HOLDTIME_DEFAULT,
2380 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002381}
2382
pauld24f6e22005-10-21 09:23:12 +00002383ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2384 no_ospf_timers_spf_cmd,
2385 "no timers spf",
2386 NO_STR
2387 "Adjust routing timers\n"
2388 "OSPF SPF timers\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002389
paula2c62832003-04-23 17:01:31 +00002390DEFUN (ospf_neighbor,
2391 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002392 "neighbor A.B.C.D",
2393 NEIGHBOR_STR
2394 "Neighbor IP address\n")
2395{
2396 struct ospf *ospf = vty->index;
2397 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002398 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2399 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002400
2401 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2402
2403 if (argc > 1)
2404 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2405
2406 if (argc > 2)
2407 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2408
2409 ospf_nbr_nbma_set (ospf, nbr_addr);
2410 if (argc > 1)
2411 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2412 if (argc > 2)
Andrew Certain1a61ad12012-12-04 12:50:23 -08002413 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
paul718e3742002-12-13 20:15:29 +00002414
2415 return CMD_SUCCESS;
2416}
2417
paula2c62832003-04-23 17:01:31 +00002418ALIAS (ospf_neighbor,
2419 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002420 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2421 NEIGHBOR_STR
2422 "Neighbor IP address\n"
2423 "Neighbor Priority\n"
2424 "Priority\n"
2425 "Dead Neighbor Polling interval\n"
2426 "Seconds\n")
2427
paula2c62832003-04-23 17:01:31 +00002428ALIAS (ospf_neighbor,
2429 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002430 "neighbor A.B.C.D priority <0-255>",
2431 NEIGHBOR_STR
2432 "Neighbor IP address\n"
2433 "Neighbor Priority\n"
2434 "Seconds\n")
2435
paula2c62832003-04-23 17:01:31 +00002436DEFUN (ospf_neighbor_poll_interval,
2437 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002438 "neighbor A.B.C.D poll-interval <1-65535>",
2439 NEIGHBOR_STR
2440 "Neighbor IP address\n"
2441 "Dead Neighbor Polling interval\n"
2442 "Seconds\n")
2443{
2444 struct ospf *ospf = vty->index;
2445 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002446 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2447 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002448
2449 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2450
2451 if (argc > 1)
2452 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2453
2454 if (argc > 2)
2455 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2456
2457 ospf_nbr_nbma_set (ospf, nbr_addr);
2458 if (argc > 1)
2459 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2460 if (argc > 2)
2461 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2462
2463 return CMD_SUCCESS;
2464}
2465
paula2c62832003-04-23 17:01:31 +00002466ALIAS (ospf_neighbor_poll_interval,
2467 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002468 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2469 NEIGHBOR_STR
2470 "Neighbor address\n"
2471 "OSPF dead-router polling interval\n"
2472 "Seconds\n"
2473 "OSPF priority of non-broadcast neighbor\n"
2474 "Priority\n")
2475
paula2c62832003-04-23 17:01:31 +00002476DEFUN (no_ospf_neighbor,
2477 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002478 "no neighbor A.B.C.D",
2479 NO_STR
2480 NEIGHBOR_STR
2481 "Neighbor IP address\n")
2482{
2483 struct ospf *ospf = vty->index;
2484 struct in_addr nbr_addr;
paul718e3742002-12-13 20:15:29 +00002485
2486 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2487
Andrew Certain0798cee2012-12-04 13:43:42 -08002488 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
paul718e3742002-12-13 20:15:29 +00002489
2490 return CMD_SUCCESS;
2491}
2492
paula2c62832003-04-23 17:01:31 +00002493ALIAS (no_ospf_neighbor,
2494 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002495 "no neighbor A.B.C.D priority <0-255>",
2496 NO_STR
2497 NEIGHBOR_STR
2498 "Neighbor IP address\n"
2499 "Neighbor Priority\n"
2500 "Priority\n")
2501
paula2c62832003-04-23 17:01:31 +00002502ALIAS (no_ospf_neighbor,
2503 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002504 "no neighbor A.B.C.D poll-interval <1-65535>",
2505 NO_STR
2506 NEIGHBOR_STR
2507 "Neighbor IP address\n"
2508 "Dead Neighbor Polling interval\n"
2509 "Seconds\n")
2510
paula2c62832003-04-23 17:01:31 +00002511ALIAS (no_ospf_neighbor,
2512 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002513 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2514 NO_STR
2515 NEIGHBOR_STR
2516 "Neighbor IP address\n"
2517 "Neighbor Priority\n"
2518 "Priority\n"
2519 "Dead Neighbor Polling interval\n"
2520 "Seconds\n")
2521
David Lamparter6b0655a2014-06-04 06:53:35 +02002522
paula2c62832003-04-23 17:01:31 +00002523DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002524 "refresh timer <10-1800>",
2525 "Adjust refresh parameters\n"
2526 "Set refresh timer\n"
2527 "Timer value in seconds\n")
2528{
2529 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002530 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002531
2532 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2533 interval = (interval / 10) * 10;
2534
2535 ospf_timers_refresh_set (ospf, interval);
2536
2537 return CMD_SUCCESS;
2538}
2539
paula2c62832003-04-23 17:01:31 +00002540DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002541 "no refresh timer <10-1800>",
2542 "Adjust refresh parameters\n"
2543 "Unset refresh timer\n"
2544 "Timer value in seconds\n")
2545{
2546 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002547 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002548
2549 if (argc == 1)
2550 {
2551 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2552
2553 if (ospf->lsa_refresh_interval != interval ||
2554 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2555 return CMD_SUCCESS;
2556 }
2557
2558 ospf_timers_refresh_unset (ospf);
2559
2560 return CMD_SUCCESS;
2561}
2562
paula2c62832003-04-23 17:01:31 +00002563ALIAS (no_ospf_refresh_timer,
2564 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002565 "no refresh timer",
2566 "Adjust refresh parameters\n"
2567 "Unset refresh timer\n")
2568
paula2c62832003-04-23 17:01:31 +00002569DEFUN (ospf_auto_cost_reference_bandwidth,
2570 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002571 "auto-cost reference-bandwidth <1-4294967>",
2572 "Calculate OSPF interface cost according to bandwidth\n"
2573 "Use reference bandwidth method to assign OSPF cost\n"
2574 "The reference bandwidth in terms of Mbits per second\n")
2575{
paul68980082003-03-25 05:07:42 +00002576 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002577 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002578 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002579 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002580
2581 refbw = strtol (argv[0], NULL, 10);
2582 if (refbw < 1 || refbw > 4294967)
2583 {
2584 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2585 return CMD_WARNING;
2586 }
2587
2588 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002589 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002590 return CMD_SUCCESS;
2591
paul68980082003-03-25 05:07:42 +00002592 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002593 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2594 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002595
2596 return CMD_SUCCESS;
2597}
2598
paula2c62832003-04-23 17:01:31 +00002599DEFUN (no_ospf_auto_cost_reference_bandwidth,
2600 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002601 "no auto-cost reference-bandwidth",
2602 NO_STR
2603 "Calculate OSPF interface cost according to bandwidth\n"
2604 "Use reference bandwidth method to assign OSPF cost\n")
2605{
paul68980082003-03-25 05:07:42 +00002606 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002607 struct listnode *node, *nnode;
2608 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002609
paul68980082003-03-25 05:07:42 +00002610 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002611 return CMD_SUCCESS;
2612
paul68980082003-03-25 05:07:42 +00002613 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002614 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2615 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2616
paul1eb8ef22005-04-07 07:30:20 +00002617 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2618 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002619
2620 return CMD_SUCCESS;
2621}
2622
hassoeb1ce602004-10-08 08:17:22 +00002623const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002624{
2625 "Unknown",
2626 "Standard (RFC2328)",
2627 "Alternative IBM",
2628 "Alternative Cisco",
2629 "Alternative Shortcut"
2630};
2631
hassoeb1ce602004-10-08 08:17:22 +00002632const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002633{
2634 "Default",
2635 "Enabled",
2636 "Disabled"
2637};
2638
2639
David Lamparter6b0655a2014-06-04 06:53:35 +02002640
paul4dadc292005-05-06 21:37:42 +00002641static void
paul718e3742002-12-13 20:15:29 +00002642show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2643{
2644 /* Show Area ID. */
2645 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2646
2647 /* Show Area type/mode. */
2648 if (OSPF_IS_AREA_BACKBONE (area))
2649 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2650 else
2651 {
2652 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002653 vty_out (vty, " (Stub%s%s)",
2654 area->no_summary ? ", no summary" : "",
2655 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002656
paulb0a053b2003-06-22 09:04:47 +00002657 else if (area->external_routing == OSPF_AREA_NSSA)
2658 vty_out (vty, " (NSSA%s%s)",
2659 area->no_summary ? ", no summary" : "",
2660 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002661
2662 vty_out (vty, "%s", VTY_NEWLINE);
2663 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002664 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002665 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002666 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002667 }
2668
2669 /* Show number of interfaces. */
2670 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2671 "Active: %d%s", listcount (area->oiflist),
2672 area->act_ints, VTY_NEWLINE);
2673
paul718e3742002-12-13 20:15:29 +00002674 if (area->external_routing == OSPF_AREA_NSSA)
2675 {
2676 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 +00002677 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002678 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2679 VTY_NEWLINE);
2680 else if (area->NSSATranslatorState)
2681 {
2682 vty_out (vty, " We are an ABR and ");
2683 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2684 vty_out (vty, "the NSSA Elected Translator. %s",
2685 VTY_NEWLINE);
2686 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2687 vty_out (vty, "always an NSSA Translator. %s",
2688 VTY_NEWLINE);
2689 }
paul718e3742002-12-13 20:15:29 +00002690 else
paulb0a053b2003-06-22 09:04:47 +00002691 {
2692 vty_out (vty, " We are an ABR, but ");
2693 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2694 vty_out (vty, "not the NSSA Elected Translator. %s",
2695 VTY_NEWLINE);
2696 else
hassoc6b87812004-12-22 13:09:59 +00002697 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002698 VTY_NEWLINE);
2699 }
paul718e3742002-12-13 20:15:29 +00002700 }
paul88d6cf32005-10-29 12:50:09 +00002701 /* Stub-router state for this area */
2702 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2703 {
ajs649654a2005-11-16 20:17:52 +00002704 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002705 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2706 VTY_NEWLINE);
2707 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2708 vty_out (vty, " Administratively activated (indefinitely)%s",
2709 VTY_NEWLINE);
2710 if (area->t_stub_router)
2711 vty_out (vty, " Active from startup, %s remaining%s",
2712 ospf_timer_dump (area->t_stub_router, timebuf,
2713 sizeof(timebuf)), VTY_NEWLINE);
2714 }
2715
paul718e3742002-12-13 20:15:29 +00002716 /* Show number of fully adjacent neighbors. */
2717 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002718 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002719
2720 /* Show authentication type. */
2721 vty_out (vty, " Area has ");
2722 if (area->auth_type == OSPF_AUTH_NULL)
2723 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2724 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2725 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2726 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2727 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2728
2729 if (!OSPF_IS_AREA_BACKBONE (area))
2730 vty_out (vty, " Number of full virtual adjacencies going through"
2731 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2732
2733 /* Show SPF calculation times. */
2734 vty_out (vty, " SPF algorithm executed %d times%s",
2735 area->spf_calculation, VTY_NEWLINE);
2736
2737 /* Show number of LSA. */
2738 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002739 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2740 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2741 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2742 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2743 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2744 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2745 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2746 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2747 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2748 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2749 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2750 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2751 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2752 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2753 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2754#ifdef HAVE_OPAQUE_LSA
2755 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2756 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2757 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2758 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2759 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2760 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2761#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002762 vty_out (vty, "%s", VTY_NEWLINE);
2763}
2764
2765DEFUN (show_ip_ospf,
2766 show_ip_ospf_cmd,
2767 "show ip ospf",
2768 SHOW_STR
2769 IP_STR
2770 "OSPF information\n")
2771{
paul1eb8ef22005-04-07 07:30:20 +00002772 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002773 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002774 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002775 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002776 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002777
2778 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002779 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002780 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002781 {
2782 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2783 return CMD_SUCCESS;
2784 }
2785
2786 /* Show Router ID. */
2787 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002788 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002789 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002790
2791 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002792 if (ospf->t_deferred_shutdown)
2793 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2794 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002795 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002796 /* Show capability. */
2797 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2798 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2799 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002800 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002801 "enabled" : "disabled", VTY_NEWLINE);
2802#ifdef HAVE_OPAQUE_LSA
Paul Jakmae30677a2015-01-20 15:45:36 +00002803 vty_out (vty, " OpaqueCapability flag is %s%s",
paul68980082003-03-25 05:07:42 +00002804 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002805 "enabled" : "disabled",
paul718e3742002-12-13 20:15:29 +00002806 VTY_NEWLINE);
2807#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002808
2809 /* Show stub-router configuration */
2810 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2811 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2812 {
2813 vty_out (vty, " Stub router advertisement is configured%s",
2814 VTY_NEWLINE);
2815 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2816 vty_out (vty, " Enabled for %us after start-up%s",
2817 ospf->stub_router_startup_time, VTY_NEWLINE);
2818 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2819 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2820 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2821 }
2822
paul718e3742002-12-13 20:15:29 +00002823 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002824 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2825 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2826 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2827 " Hold time multiplier is currently %d%s",
2828 ospf->spf_delay, VTY_NEWLINE,
2829 ospf->spf_holdtime, VTY_NEWLINE,
2830 ospf->spf_max_holdtime, VTY_NEWLINE,
2831 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002832 vty_out (vty, " SPF algorithm ");
2833 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2834 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002835 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002836 vty_out (vty, "last executed %s ago%s",
2837 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2838 VTY_NEWLINE);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -07002839 vty_out (vty, " Last SPF duration %s%s",
2840 ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)),
2841 VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002842 }
2843 else
2844 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002845 vty_out (vty, " SPF timer %s%s%s",
2846 (ospf->t_spf_calc ? "due in " : "is "),
2847 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2848 VTY_NEWLINE);
2849
paul718e3742002-12-13 20:15:29 +00002850 /* Show refresh parameters. */
2851 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002852 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002853
2854 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002855 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002856 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002857 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002858
paul68980082003-03-25 05:07:42 +00002859 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002860 vty_out (vty, " This router is an ASBR "
2861 "(injecting external routing information)%s", VTY_NEWLINE);
2862
2863 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002864 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2865 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2866 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2867#ifdef HAVE_OPAQUE_LSA
2868 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2869 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2870 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2871#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002872 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002873 vty_out (vty, " Number of areas attached to this router: %d%s",
2874 listcount (ospf->areas), VTY_NEWLINE);
2875
2876 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2877 {
2878 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2879 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2880 else
2881 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2882 }
2883
2884 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002885
2886 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002887 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2888 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002889
2890 return CMD_SUCCESS;
2891}
2892
David Lamparter6b0655a2014-06-04 06:53:35 +02002893
ajsfd651fa2005-03-29 16:08:16 +00002894static void
paul68980082003-03-25 05:07:42 +00002895show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2896 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002897{
ajsfd651fa2005-03-29 16:08:16 +00002898 int is_up;
paul718e3742002-12-13 20:15:29 +00002899 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002900 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002901
paul718e3742002-12-13 20:15:29 +00002902 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002903 vty_out (vty, "%s is %s%s", ifp->name,
2904 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002905 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2906 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2907 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002908
2909 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002910 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002911 {
2912 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2913 return;
2914 }
ajsfd651fa2005-03-29 16:08:16 +00002915 else if (!is_up)
2916 {
2917 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2918 VTY_NEWLINE);
2919 return;
2920 }
2921
paul718e3742002-12-13 20:15:29 +00002922 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2923 {
2924 struct ospf_interface *oi = rn->info;
2925
2926 if (oi == NULL)
2927 continue;
2928
2929 /* Show OSPF interface information. */
2930 vty_out (vty, " Internet Address %s/%d,",
2931 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2932
Paul Jakma9c27ef92006-05-04 07:32:57 +00002933 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2934 {
2935 struct in_addr *dest;
2936 const char *dstr;
2937
Andrew J. Schorre4529632006-12-12 19:18:21 +00002938 if (CONNECTED_PEER(oi->connected)
2939 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002940 dstr = "Peer";
2941 else
2942 dstr = "Broadcast";
2943
2944 /* For Vlinks, showing the peer address is probably more
2945 * informative than the local interface that is being used
2946 */
2947 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2948 dest = &oi->vl_data->peer_addr;
2949 else
2950 dest = &oi->connected->destination->u.prefix4;
2951
2952 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2953 }
hasso3fb9cd62004-10-19 19:44:43 +00002954
paul718e3742002-12-13 20:15:29 +00002955 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2956 VTY_NEWLINE);
2957
vincentba682532005-09-29 13:52:57 +00002958 vty_out (vty, " MTU mismatch detection:%s%s",
2959 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2960
paul718e3742002-12-13 20:15:29 +00002961 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002962 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002963 oi->output_cost, VTY_NEWLINE);
2964
2965 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2966 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2967 PRIORITY (oi), VTY_NEWLINE);
2968
2969 /* Show DR information. */
2970 if (DR (oi).s_addr == 0)
2971 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2972 else
2973 {
2974 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2975 if (nbr == NULL)
2976 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2977 else
2978 {
2979 vty_out (vty, " Designated Router (ID) %s,",
2980 inet_ntoa (nbr->router_id));
2981 vty_out (vty, " Interface Address %s%s",
2982 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2983 }
2984 }
2985
2986 /* Show BDR information. */
2987 if (BDR (oi).s_addr == 0)
2988 vty_out (vty, " No backup designated router on this network%s",
2989 VTY_NEWLINE);
2990 else
2991 {
2992 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2993 if (nbr == NULL)
2994 vty_out (vty, " No backup designated router on this network%s",
2995 VTY_NEWLINE);
2996 else
2997 {
2998 vty_out (vty, " Backup Designated Router (ID) %s,",
2999 inet_ntoa (nbr->router_id));
3000 vty_out (vty, " Interface Address %s%s",
3001 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3002 }
3003 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01003004
3005 /* Next network-LSA sequence number we'll use, if we're elected DR */
3006 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
3007 != OSPF_INITIAL_SEQUENCE_NUMBER)
3008 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
3009 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
3010
ajsba6454e2005-02-08 15:37:30 +00003011 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00003012 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
3013 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3014 {
3015 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
3016 vty_out (vty, " OSPFAllRouters");
3017 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3018 vty_out (vty, " OSPFDesignatedRouters");
3019 }
3020 else
ajsba6454e2005-02-08 15:37:30 +00003021 vty_out (vty, " <None>");
3022 vty_out (vty, "%s", VTY_NEWLINE);
3023
paul718e3742002-12-13 20:15:29 +00003024 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00003025 vty_out (vty, " Hello ");
3026 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
3027 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
3028 else
3029 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
3030 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
3031 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00003032 OSPF_IF_PARAM (oi, v_wait),
3033 OSPF_IF_PARAM (oi, retransmit_interval),
3034 VTY_NEWLINE);
3035
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00003036 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00003037 {
ajs649654a2005-11-16 20:17:52 +00003038 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00003039 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00003040 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00003041 VTY_NEWLINE);
3042 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00003043 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00003044 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
3045
3046 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00003047 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00003048 VTY_NEWLINE);
3049 }
3050}
3051
3052DEFUN (show_ip_ospf_interface,
3053 show_ip_ospf_interface_cmd,
3054 "show ip ospf interface [INTERFACE]",
3055 SHOW_STR
3056 IP_STR
3057 "OSPF information\n"
3058 "Interface information\n"
3059 "Interface name\n")
3060{
3061 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00003062 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003063 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003064
paul020709f2003-04-04 02:44:16 +00003065 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00003066 if (ospf == NULL)
3067 {
3068 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
3069 return CMD_SUCCESS;
3070 }
paul020709f2003-04-04 02:44:16 +00003071
paul718e3742002-12-13 20:15:29 +00003072 /* Show All Interfaces. */
3073 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00003074 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3075 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003076 /* Interface name is specified. */
3077 else
3078 {
3079 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3080 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3081 else
paul68980082003-03-25 05:07:42 +00003082 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003083 }
3084
3085 return CMD_SUCCESS;
3086}
3087
paul4dadc292005-05-06 21:37:42 +00003088static void
pauld24f6e22005-10-21 09:23:12 +00003089show_ip_ospf_neighbour_header (struct vty *vty)
3090{
3091 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3092 VTY_NEWLINE,
3093 "Neighbor ID", "Pri", "State", "Dead Time",
3094 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3095 VTY_NEWLINE);
3096}
3097
3098static void
paul718e3742002-12-13 20:15:29 +00003099show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3100{
3101 struct route_node *rn;
3102 struct ospf_neighbor *nbr;
3103 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003104 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003105
3106 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3107 if ((nbr = rn->info))
3108 /* Do not show myself. */
3109 if (nbr != oi->nbr_self)
3110 /* Down state is not shown. */
3111 if (nbr->state != NSM_Down)
3112 {
3113 ospf_nbr_state_message (nbr, msgbuf, 16);
3114
3115 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003116 vty_out (vty, "%-15s %3d %-15s ",
3117 "-", nbr->priority,
3118 msgbuf);
3119 else
3120 vty_out (vty, "%-15s %3d %-15s ",
3121 inet_ntoa (nbr->router_id), nbr->priority,
3122 msgbuf);
3123
3124 vty_out (vty, "%9s ",
3125 ospf_timer_dump (nbr->t_inactivity, timebuf,
3126 sizeof(timebuf)));
3127
paul718e3742002-12-13 20:15:29 +00003128 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003129 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003130 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3131 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3132 VTY_NEWLINE);
3133 }
3134}
3135
3136DEFUN (show_ip_ospf_neighbor,
3137 show_ip_ospf_neighbor_cmd,
3138 "show ip ospf neighbor",
3139 SHOW_STR
3140 IP_STR
3141 "OSPF information\n"
3142 "Neighbor list\n")
3143{
paul020709f2003-04-04 02:44:16 +00003144 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003145 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003146 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003147
paul020709f2003-04-04 02:44:16 +00003148 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003149 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003150 {
3151 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3152 return CMD_SUCCESS;
3153 }
3154
pauld24f6e22005-10-21 09:23:12 +00003155 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003156
paul1eb8ef22005-04-07 07:30:20 +00003157 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3158 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003159
3160 return CMD_SUCCESS;
3161}
3162
3163DEFUN (show_ip_ospf_neighbor_all,
3164 show_ip_ospf_neighbor_all_cmd,
3165 "show ip ospf neighbor all",
3166 SHOW_STR
3167 IP_STR
3168 "OSPF information\n"
3169 "Neighbor list\n"
3170 "include down status neighbor\n")
3171{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003172 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003173 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003174 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003175
paul68980082003-03-25 05:07:42 +00003176 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003177 {
3178 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3179 return CMD_SUCCESS;
3180 }
pauld24f6e22005-10-21 09:23:12 +00003181
3182 show_ip_ospf_neighbour_header (vty);
3183
paul1eb8ef22005-04-07 07:30:20 +00003184 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003185 {
hasso52dc7ee2004-09-23 19:18:23 +00003186 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003187 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003188
3189 show_ip_ospf_neighbor_sub (vty, oi);
3190
3191 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003192 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003193 {
paul718e3742002-12-13 20:15:29 +00003194 if (nbr_nbma->nbr == NULL
3195 || nbr_nbma->nbr->state == NSM_Down)
3196 {
pauld24f6e22005-10-21 09:23:12 +00003197 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003198 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003199 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003200 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3201 0, 0, 0, VTY_NEWLINE);
3202 }
3203 }
3204 }
3205
3206 return CMD_SUCCESS;
3207}
3208
3209DEFUN (show_ip_ospf_neighbor_int,
3210 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003211 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003212 SHOW_STR
3213 IP_STR
3214 "OSPF information\n"
3215 "Neighbor list\n"
3216 "Interface name\n")
3217{
paul020709f2003-04-04 02:44:16 +00003218 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003219 struct interface *ifp;
3220 struct route_node *rn;
3221
3222 ifp = if_lookup_by_name (argv[0]);
3223 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003224 {
hassobb5b7552005-08-21 20:01:15 +00003225 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003226 return CMD_WARNING;
3227 }
3228
paul020709f2003-04-04 02:44:16 +00003229 ospf = ospf_lookup ();
3230 if (ospf == NULL)
3231 {
3232 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3233 return CMD_SUCCESS;
3234 }
pauld24f6e22005-10-21 09:23:12 +00003235
3236 show_ip_ospf_neighbour_header (vty);
3237
hassobb5b7552005-08-21 20:01:15 +00003238 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003239 {
hassobb5b7552005-08-21 20:01:15 +00003240 struct ospf_interface *oi = rn->info;
3241
3242 if (oi == NULL)
3243 continue;
3244
paul718e3742002-12-13 20:15:29 +00003245 show_ip_ospf_neighbor_sub (vty, oi);
3246 }
3247
3248 return CMD_SUCCESS;
3249}
3250
paul4dadc292005-05-06 21:37:42 +00003251static void
paul718e3742002-12-13 20:15:29 +00003252show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3253 struct ospf_nbr_nbma *nbr_nbma)
3254{
ajs649654a2005-11-16 20:17:52 +00003255 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003256
3257 /* Show neighbor ID. */
3258 vty_out (vty, " Neighbor %s,", "-");
3259
3260 /* Show interface address. */
3261 vty_out (vty, " interface address %s%s",
3262 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3263 /* Show Area ID. */
3264 vty_out (vty, " In the area %s via interface %s%s",
3265 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3266 /* Show neighbor priority and state. */
3267 vty_out (vty, " Neighbor priority is %d, State is %s,",
3268 nbr_nbma->priority, "Down");
3269 /* Show state changes. */
3270 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3271
3272 /* Show PollInterval */
3273 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3274
3275 /* Show poll-interval timer. */
3276 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003277 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3278 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003279
3280 /* Show poll-interval timer thread. */
3281 vty_out (vty, " Thread Poll Timer %s%s",
3282 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3283}
3284
paul4dadc292005-05-06 21:37:42 +00003285static void
paul718e3742002-12-13 20:15:29 +00003286show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3287 struct ospf_neighbor *nbr)
3288{
ajs649654a2005-11-16 20:17:52 +00003289 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003290
3291 /* Show neighbor ID. */
3292 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3293 vty_out (vty, " Neighbor %s,", "-");
3294 else
3295 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3296
3297 /* Show interface address. */
3298 vty_out (vty, " interface address %s%s",
3299 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3300 /* Show Area ID. */
3301 vty_out (vty, " In the area %s via interface %s%s",
3302 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3303 /* Show neighbor priority and state. */
3304 vty_out (vty, " Neighbor priority is %d, State is %s,",
3305 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3306 /* Show state changes. */
3307 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003308 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003309 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003310 struct timeval res
3311 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003312 vty_out (vty, " Most recent state change statistics:%s",
3313 VTY_NEWLINE);
3314 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003315 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003316 VTY_NEWLINE);
3317 }
3318 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3319 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003320 struct timeval res
3321 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003322 vty_out (vty, " Regressive change %s ago, due to %s%s",
3323 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3324 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003325 VTY_NEWLINE);
3326 }
paul718e3742002-12-13 20:15:29 +00003327 /* Show Designated Rotuer ID. */
3328 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3329 /* Show Backup Designated Rotuer ID. */
3330 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3331 /* Show options. */
3332 vty_out (vty, " Options %d %s%s", nbr->options,
3333 ospf_options_dump (nbr->options), VTY_NEWLINE);
3334 /* Show Router Dead interval timer. */
3335 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003336 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3337 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003338 /* Show Database Summary list. */
3339 vty_out (vty, " Database Summary List %d%s",
3340 ospf_db_summary_count (nbr), VTY_NEWLINE);
3341 /* Show Link State Request list. */
3342 vty_out (vty, " Link State Request List %ld%s",
3343 ospf_ls_request_count (nbr), VTY_NEWLINE);
3344 /* Show Link State Retransmission list. */
3345 vty_out (vty, " Link State Retransmission List %ld%s",
3346 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3347 /* Show inactivity timer thread. */
3348 vty_out (vty, " Thread Inactivity Timer %s%s",
3349 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3350 /* Show Database Description retransmission thread. */
3351 vty_out (vty, " Thread Database Description Retransmision %s%s",
3352 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3353 /* Show Link State Request Retransmission thread. */
3354 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3355 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3356 /* Show Link State Update Retransmission thread. */
3357 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3358 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3359}
3360
3361DEFUN (show_ip_ospf_neighbor_id,
3362 show_ip_ospf_neighbor_id_cmd,
3363 "show ip ospf neighbor A.B.C.D",
3364 SHOW_STR
3365 IP_STR
3366 "OSPF information\n"
3367 "Neighbor list\n"
3368 "Neighbor ID\n")
3369{
paul020709f2003-04-04 02:44:16 +00003370 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003371 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003372 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003373 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003374 struct in_addr router_id;
3375 int ret;
3376
3377 ret = inet_aton (argv[0], &router_id);
3378 if (!ret)
3379 {
3380 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3381 return CMD_WARNING;
3382 }
3383
paul020709f2003-04-04 02:44:16 +00003384 ospf = ospf_lookup ();
3385 if (ospf == NULL)
3386 {
3387 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3388 return CMD_SUCCESS;
3389 }
3390
paul1eb8ef22005-04-07 07:30:20 +00003391 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3392 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003393 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003394
paul718e3742002-12-13 20:15:29 +00003395 return CMD_SUCCESS;
3396}
3397
3398DEFUN (show_ip_ospf_neighbor_detail,
3399 show_ip_ospf_neighbor_detail_cmd,
3400 "show ip ospf neighbor detail",
3401 SHOW_STR
3402 IP_STR
3403 "OSPF information\n"
3404 "Neighbor list\n"
3405 "detail of all neighbors\n")
3406{
paul020709f2003-04-04 02:44:16 +00003407 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003408 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003409 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003410
paul020709f2003-04-04 02:44:16 +00003411 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003412 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003413 {
3414 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3415 return CMD_SUCCESS;
3416 }
paul718e3742002-12-13 20:15:29 +00003417
paul1eb8ef22005-04-07 07:30:20 +00003418 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003419 {
paul718e3742002-12-13 20:15:29 +00003420 struct route_node *rn;
3421 struct ospf_neighbor *nbr;
3422
3423 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3424 if ((nbr = rn->info))
3425 if (nbr != oi->nbr_self)
3426 if (nbr->state != NSM_Down)
3427 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3428 }
3429
3430 return CMD_SUCCESS;
3431}
3432
3433DEFUN (show_ip_ospf_neighbor_detail_all,
3434 show_ip_ospf_neighbor_detail_all_cmd,
3435 "show ip ospf neighbor detail all",
3436 SHOW_STR
3437 IP_STR
3438 "OSPF information\n"
3439 "Neighbor list\n"
3440 "detail of all neighbors\n"
3441 "include down status neighbor\n")
3442{
paul020709f2003-04-04 02:44:16 +00003443 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003444 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003445 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003446
paul020709f2003-04-04 02:44:16 +00003447 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003448 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003449 {
3450 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3451 return CMD_SUCCESS;
3452 }
paul718e3742002-12-13 20:15:29 +00003453
paul1eb8ef22005-04-07 07:30:20 +00003454 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003455 {
paul718e3742002-12-13 20:15:29 +00003456 struct route_node *rn;
3457 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003458 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003459
3460 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3461 if ((nbr = rn->info))
3462 if (nbr != oi->nbr_self)
3463 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3464 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3465
3466 if (oi->type == OSPF_IFTYPE_NBMA)
3467 {
hasso52dc7ee2004-09-23 19:18:23 +00003468 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003469
paul1eb8ef22005-04-07 07:30:20 +00003470 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3471 if (nbr_nbma->nbr == NULL
3472 || nbr_nbma->nbr->state == NSM_Down)
3473 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003474 }
3475 }
3476
3477 return CMD_SUCCESS;
3478}
3479
3480DEFUN (show_ip_ospf_neighbor_int_detail,
3481 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003482 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003483 SHOW_STR
3484 IP_STR
3485 "OSPF information\n"
3486 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003487 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003488 "detail of all neighbors")
3489{
paul020709f2003-04-04 02:44:16 +00003490 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003491 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003492 struct interface *ifp;
3493 struct route_node *rn, *nrn;
3494 struct ospf_neighbor *nbr;
3495
3496 ifp = if_lookup_by_name (argv[0]);
3497 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003498 {
hassobb5b7552005-08-21 20:01:15 +00003499 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003500 return CMD_WARNING;
3501 }
3502
paul020709f2003-04-04 02:44:16 +00003503 ospf = ospf_lookup ();
3504 if (ospf == NULL)
3505 {
3506 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3507 return CMD_SUCCESS;
3508 }
paul68980082003-03-25 05:07:42 +00003509
paul718e3742002-12-13 20:15:29 +00003510
hassobb5b7552005-08-21 20:01:15 +00003511 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3512 if ((oi = rn->info))
3513 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3514 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003515 if (nbr != oi->nbr_self)
3516 if (nbr->state != NSM_Down)
3517 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003518
3519 return CMD_SUCCESS;
3520}
3521
David Lamparter6b0655a2014-06-04 06:53:35 +02003522
paul718e3742002-12-13 20:15:29 +00003523/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003524static int
paul020709f2003-04-04 02:44:16 +00003525show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003526{
paul718e3742002-12-13 20:15:29 +00003527 struct router_lsa *rl;
3528 struct summary_lsa *sl;
3529 struct as_external_lsa *asel;
3530 struct prefix_ipv4 p;
3531
3532 if (lsa != NULL)
3533 /* If self option is set, check LSA self flag. */
3534 if (self == 0 || IS_LSA_SELF (lsa))
3535 {
3536 /* LSA common part show. */
3537 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3538 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3539 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3540 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3541 /* LSA specific part show. */
3542 switch (lsa->data->type)
3543 {
3544 case OSPF_ROUTER_LSA:
3545 rl = (struct router_lsa *) lsa->data;
3546 vty_out (vty, " %-d", ntohs (rl->links));
3547 break;
3548 case OSPF_SUMMARY_LSA:
3549 sl = (struct summary_lsa *) lsa->data;
3550
3551 p.family = AF_INET;
3552 p.prefix = sl->header.id;
3553 p.prefixlen = ip_masklen (sl->mask);
3554 apply_mask_ipv4 (&p);
3555
3556 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3557 break;
3558 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003559 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003560 asel = (struct as_external_lsa *) lsa->data;
3561
3562 p.family = AF_INET;
3563 p.prefix = asel->header.id;
3564 p.prefixlen = ip_masklen (asel->mask);
3565 apply_mask_ipv4 (&p);
3566
3567 vty_out (vty, " %s %s/%d [0x%lx]",
3568 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3569 inet_ntoa (p.prefix), p.prefixlen,
3570 (u_long)ntohl (asel->e[0].route_tag));
3571 break;
3572 case OSPF_NETWORK_LSA:
3573 case OSPF_ASBR_SUMMARY_LSA:
3574#ifdef HAVE_OPAQUE_LSA
3575 case OSPF_OPAQUE_LINK_LSA:
3576 case OSPF_OPAQUE_AREA_LSA:
3577 case OSPF_OPAQUE_AS_LSA:
3578#endif /* HAVE_OPAQUE_LSA */
3579 default:
3580 break;
3581 }
3582 vty_out (vty, VTY_NEWLINE);
3583 }
3584
3585 return 0;
3586}
3587
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003588static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003589{
3590 "unknown",
3591 "Router Link States",
3592 "Net Link States",
3593 "Summary Link States",
3594 "ASBR-Summary Link States",
3595 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003596 "Group Membership LSA",
3597 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003598#ifdef HAVE_OPAQUE_LSA
3599 "Type-8 LSA",
3600 "Link-Local Opaque-LSA",
3601 "Area-Local Opaque-LSA",
3602 "AS-external Opaque-LSA",
3603#endif /* HAVE_OPAQUE_LSA */
3604};
3605
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003606static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003607{
3608 "",
3609 "Link ID ADV Router Age Seq# CkSum Link count",
3610 "Link ID ADV Router Age Seq# CkSum",
3611 "Link ID ADV Router Age Seq# CkSum Route",
3612 "Link ID ADV Router Age Seq# CkSum",
3613 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003614 " --- header for Group Member ----",
3615 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003616#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003617 " --- type-8 ---",
3618 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3619 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3620 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3621#endif /* HAVE_OPAQUE_LSA */
3622};
3623
paul4dadc292005-05-06 21:37:42 +00003624static void
paul718e3742002-12-13 20:15:29 +00003625show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3626{
3627 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003628
paul718e3742002-12-13 20:15:29 +00003629 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003630 vty_out (vty, " Options: 0x%-2x : %s%s",
3631 lsa->data->options,
3632 ospf_options_dump(lsa->data->options),
3633 VTY_NEWLINE);
3634 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003635 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003636 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3637 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003638
3639 if (lsa->data->type == OSPF_ROUTER_LSA)
3640 {
3641 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3642
3643 if (rlsa->flags)
3644 vty_out (vty, " :%s%s%s%s",
3645 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3646 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3647 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3648 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3649
3650 vty_out (vty, "%s", VTY_NEWLINE);
3651 }
3652 vty_out (vty, " LS Type: %s%s",
3653 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3654 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3655 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3656 vty_out (vty, " Advertising Router: %s%s",
3657 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3658 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3659 VTY_NEWLINE);
3660 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3661 VTY_NEWLINE);
3662 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3663}
3664
hassoeb1ce602004-10-08 08:17:22 +00003665const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003666{
3667 "(null)",
3668 "another Router (point-to-point)",
3669 "a Transit Network",
3670 "Stub Network",
3671 "a Virtual Link",
3672};
3673
hassoeb1ce602004-10-08 08:17:22 +00003674const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003675{
3676 "(null)",
3677 "Neighboring Router ID",
3678 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003679 "Net",
paul718e3742002-12-13 20:15:29 +00003680 "Neighboring Router ID",
3681};
3682
hassoeb1ce602004-10-08 08:17:22 +00003683const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003684{
3685 "(null)",
3686 "Router Interface address",
3687 "Router Interface address",
3688 "Network Mask",
3689 "Router Interface address",
3690};
3691
3692/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003693static void
paul718e3742002-12-13 20:15:29 +00003694show_ip_ospf_database_router_links (struct vty *vty,
3695 struct router_lsa *rl)
3696{
Donald Sharp0bc874b2015-07-29 19:16:13 -04003697 int len, type;
3698 unsigned int i;
paul718e3742002-12-13 20:15:29 +00003699
3700 len = ntohs (rl->header.length) - 4;
3701 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3702 {
3703 type = rl->link[i].type;
3704
3705 vty_out (vty, " Link connected to: %s%s",
3706 link_type_desc[type], VTY_NEWLINE);
3707 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3708 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3709 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3710 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3711 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3712 vty_out (vty, " TOS 0 Metric: %d%s",
3713 ntohs (rl->link[i].metric), VTY_NEWLINE);
3714 vty_out (vty, "%s", VTY_NEWLINE);
3715 }
3716}
3717
3718/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003719static int
paul718e3742002-12-13 20:15:29 +00003720show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3721{
3722 if (lsa != NULL)
3723 {
3724 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3725
3726 show_ip_ospf_database_header (vty, lsa);
3727
3728 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3729 VTY_NEWLINE, VTY_NEWLINE);
3730
3731 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003732 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003733 }
3734
3735 return 0;
3736}
3737
3738/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003739static int
paul718e3742002-12-13 20:15:29 +00003740show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3741{
3742 int length, i;
3743
3744 if (lsa != NULL)
3745 {
3746 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3747
3748 show_ip_ospf_database_header (vty, lsa);
3749
3750 vty_out (vty, " Network Mask: /%d%s",
3751 ip_masklen (nl->mask), VTY_NEWLINE);
3752
3753 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3754
3755 for (i = 0; length > 0; i++, length -= 4)
3756 vty_out (vty, " Attached Router: %s%s",
3757 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3758
3759 vty_out (vty, "%s", VTY_NEWLINE);
3760 }
3761
3762 return 0;
3763}
3764
3765/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003766static int
paul718e3742002-12-13 20:15:29 +00003767show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3768{
3769 if (lsa != NULL)
3770 {
3771 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3772
3773 show_ip_ospf_database_header (vty, lsa);
3774
3775 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3776 VTY_NEWLINE);
3777 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3778 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003779 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003780 }
3781
3782 return 0;
3783}
3784
3785/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003786static int
paul718e3742002-12-13 20:15:29 +00003787show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3788{
3789 if (lsa != NULL)
3790 {
3791 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3792
3793 show_ip_ospf_database_header (vty, lsa);
3794
3795 vty_out (vty, " Network Mask: /%d%s",
3796 ip_masklen (sl->mask), VTY_NEWLINE);
3797 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3798 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003799 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003800 }
3801
3802 return 0;
3803}
3804
3805/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003806static int
paul718e3742002-12-13 20:15:29 +00003807show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3808{
3809 if (lsa != NULL)
3810 {
3811 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3812
3813 show_ip_ospf_database_header (vty, lsa);
3814
3815 vty_out (vty, " Network Mask: /%d%s",
3816 ip_masklen (al->mask), VTY_NEWLINE);
3817 vty_out (vty, " Metric Type: %s%s",
3818 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3819 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3820 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3821 vty_out (vty, " Metric: %d%s",
3822 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3823 vty_out (vty, " Forward Address: %s%s",
3824 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3825
3826 vty_out (vty, " External Route Tag: %lu%s%s",
3827 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3828 }
3829
3830 return 0;
3831}
3832
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003833#if 0
paul4dadc292005-05-06 21:37:42 +00003834static int
paul718e3742002-12-13 20:15:29 +00003835show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3836{
3837 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3838
3839 /* show_ip_ospf_database_header (vty, lsa); */
3840
ajs2a42e282004-12-08 18:43:03 +00003841 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003842 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003843 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003844 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3845 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003846 zlog_debug( " TOS: 0%s", "\n");
3847 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003848 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003849 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003850 inet_ntoa (al->e[0].fwd_addr), "\n");
3851
ajs2a42e282004-12-08 18:43:03 +00003852 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003853 ntohl (al->e[0].route_tag), "\n", "\n");
3854
3855 return 0;
3856}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003857#endif
paul718e3742002-12-13 20:15:29 +00003858
3859/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003860static int
paul718e3742002-12-13 20:15:29 +00003861show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3862{
3863 if (lsa != NULL)
3864 {
3865 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3866
3867 show_ip_ospf_database_header (vty, lsa);
3868
3869 vty_out (vty, " Network Mask: /%d%s",
3870 ip_masklen (al->mask), VTY_NEWLINE);
3871 vty_out (vty, " Metric Type: %s%s",
3872 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3873 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3874 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3875 vty_out (vty, " Metric: %d%s",
3876 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3877 vty_out (vty, " NSSA: Forward Address: %s%s",
3878 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3879
3880 vty_out (vty, " External Route Tag: %u%s%s",
3881 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3882 }
3883
3884 return 0;
3885}
3886
paul4dadc292005-05-06 21:37:42 +00003887static int
paul718e3742002-12-13 20:15:29 +00003888show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3889{
3890 return 0;
3891}
3892
3893#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003894static int
paul718e3742002-12-13 20:15:29 +00003895show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3896{
3897 if (lsa != NULL)
3898 {
3899 show_ip_ospf_database_header (vty, lsa);
3900 show_opaque_info_detail (vty, lsa);
3901
3902 vty_out (vty, "%s", VTY_NEWLINE);
3903 }
3904 return 0;
3905}
3906#endif /* HAVE_OPAQUE_LSA */
3907
3908int (*show_function[])(struct vty *, struct ospf_lsa *) =
3909{
3910 NULL,
3911 show_router_lsa_detail,
3912 show_network_lsa_detail,
3913 show_summary_lsa_detail,
3914 show_summary_asbr_lsa_detail,
3915 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003916 show_func_dummy,
3917 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003918#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003919 NULL, /* type-8 */
3920 show_opaque_lsa_detail,
3921 show_opaque_lsa_detail,
3922 show_opaque_lsa_detail,
3923#endif /* HAVE_OPAQUE_LSA */
3924};
3925
paul4dadc292005-05-06 21:37:42 +00003926static void
paul718e3742002-12-13 20:15:29 +00003927show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3928 struct in_addr *adv_router)
3929{
3930 memset (lp, 0, sizeof (struct prefix_ls));
3931 lp->family = 0;
3932 if (id == NULL)
3933 lp->prefixlen = 0;
3934 else if (adv_router == NULL)
3935 {
3936 lp->prefixlen = 32;
3937 lp->id = *id;
3938 }
3939 else
3940 {
3941 lp->prefixlen = 64;
3942 lp->id = *id;
3943 lp->adv_router = *adv_router;
3944 }
3945}
3946
paul4dadc292005-05-06 21:37:42 +00003947static void
paul718e3742002-12-13 20:15:29 +00003948show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3949 struct in_addr *id, struct in_addr *adv_router)
3950{
3951 struct prefix_ls lp;
3952 struct route_node *rn, *start;
3953 struct ospf_lsa *lsa;
3954
3955 show_lsa_prefix_set (vty, &lp, id, adv_router);
3956 start = route_node_get (rt, (struct prefix *) &lp);
3957 if (start)
3958 {
3959 route_lock_node (start);
3960 for (rn = start; rn; rn = route_next_until (rn, start))
3961 if ((lsa = rn->info))
3962 {
paul718e3742002-12-13 20:15:29 +00003963 if (show_function[lsa->data->type] != NULL)
3964 show_function[lsa->data->type] (vty, lsa);
3965 }
3966 route_unlock_node (start);
3967 }
3968}
3969
3970/* Show detail LSA information
3971 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003972static void
paul020709f2003-04-04 02:44:16 +00003973show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003974 struct in_addr *id, struct in_addr *adv_router)
3975{
hasso52dc7ee2004-09-23 19:18:23 +00003976 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003977 struct ospf_area *area;
3978
paul718e3742002-12-13 20:15:29 +00003979 switch (type)
3980 {
3981 case OSPF_AS_EXTERNAL_LSA:
3982#ifdef HAVE_OPAQUE_LSA
3983 case OSPF_OPAQUE_AS_LSA:
3984#endif /* HAVE_OPAQUE_LSA */
3985 vty_out (vty, " %s %s%s",
3986 show_database_desc[type],
3987 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003988 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003989 break;
3990 default:
paul1eb8ef22005-04-07 07:30:20 +00003991 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003992 {
paul718e3742002-12-13 20:15:29 +00003993 vty_out (vty, "%s %s (Area %s)%s%s",
3994 VTY_NEWLINE, show_database_desc[type],
3995 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3996 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3997 }
3998 break;
3999 }
4000}
4001
paul4dadc292005-05-06 21:37:42 +00004002static void
paul718e3742002-12-13 20:15:29 +00004003show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
4004 struct in_addr *adv_router)
4005{
4006 struct route_node *rn;
4007 struct ospf_lsa *lsa;
4008
4009 for (rn = route_top (rt); rn; rn = route_next (rn))
4010 if ((lsa = rn->info))
4011 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
4012 {
paul718e3742002-12-13 20:15:29 +00004013 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
4014 continue;
paul718e3742002-12-13 20:15:29 +00004015 if (show_function[lsa->data->type] != NULL)
4016 show_function[lsa->data->type] (vty, lsa);
4017 }
4018}
4019
4020/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00004021static void
paul020709f2003-04-04 02:44:16 +00004022show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00004023 struct in_addr *adv_router)
4024{
hasso52dc7ee2004-09-23 19:18:23 +00004025 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00004026 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00004027
4028 switch (type)
4029 {
4030 case OSPF_AS_EXTERNAL_LSA:
4031#ifdef HAVE_OPAQUE_LSA
4032 case OSPF_OPAQUE_AS_LSA:
4033#endif /* HAVE_OPAQUE_LSA */
4034 vty_out (vty, " %s %s%s",
4035 show_database_desc[type],
4036 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00004037 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00004038 adv_router);
4039 break;
4040 default:
paul1eb8ef22005-04-07 07:30:20 +00004041 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00004042 {
paul718e3742002-12-13 20:15:29 +00004043 vty_out (vty, "%s %s (Area %s)%s%s",
4044 VTY_NEWLINE, show_database_desc[type],
4045 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
4046 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
4047 adv_router);
4048 }
4049 break;
4050 }
4051}
4052
paul4dadc292005-05-06 21:37:42 +00004053static void
paul020709f2003-04-04 02:44:16 +00004054show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00004055{
paul020709f2003-04-04 02:44:16 +00004056 struct ospf_lsa *lsa;
4057 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00004058 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00004059 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004060 int type;
4061
paul1eb8ef22005-04-07 07:30:20 +00004062 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00004063 {
paul718e3742002-12-13 20:15:29 +00004064 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4065 {
4066 switch (type)
4067 {
4068 case OSPF_AS_EXTERNAL_LSA:
4069#ifdef HAVE_OPAQUE_LSA
4070 case OSPF_OPAQUE_AS_LSA:
4071#endif /* HAVE_OPAQUE_LSA */
4072 continue;
4073 default:
4074 break;
4075 }
4076 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4077 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4078 {
4079 vty_out (vty, " %s (Area %s)%s%s",
4080 show_database_desc[type],
4081 ospf_area_desc_string (area),
4082 VTY_NEWLINE, VTY_NEWLINE);
4083 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4084
paul020709f2003-04-04 02:44:16 +00004085 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4086 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00004087
4088 vty_out (vty, "%s", VTY_NEWLINE);
4089 }
4090 }
4091 }
4092
4093 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4094 {
4095 switch (type)
4096 {
4097 case OSPF_AS_EXTERNAL_LSA:
4098#ifdef HAVE_OPAQUE_LSA
4099 case OSPF_OPAQUE_AS_LSA:
4100#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004101 break;
paul718e3742002-12-13 20:15:29 +00004102 default:
4103 continue;
4104 }
paul68980082003-03-25 05:07:42 +00004105 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4106 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004107 {
4108 vty_out (vty, " %s%s%s",
4109 show_database_desc[type],
4110 VTY_NEWLINE, VTY_NEWLINE);
4111 vty_out (vty, "%s%s", show_database_header[type],
4112 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004113
4114 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4115 show_lsa_summary (vty, lsa, self);
4116
paul718e3742002-12-13 20:15:29 +00004117 vty_out (vty, "%s", VTY_NEWLINE);
4118 }
4119 }
4120
4121 vty_out (vty, "%s", VTY_NEWLINE);
4122}
4123
paul4dadc292005-05-06 21:37:42 +00004124static void
paul020709f2003-04-04 02:44:16 +00004125show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004126{
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004127 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00004128
4129 vty_out (vty, "%s MaxAge Link States:%s%s",
4130 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4131
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004132 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
paul1eb8ef22005-04-07 07:30:20 +00004133 {
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004134 struct ospf_lsa *lsa;
4135
4136 if ((lsa = rn->info) != NULL)
4137 {
4138 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4139 vty_out (vty, "Link State ID: %s%s",
4140 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4141 vty_out (vty, "Advertising Router: %s%s",
4142 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4143 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4144 vty_out (vty, "%s", VTY_NEWLINE);
4145 }
paul1eb8ef22005-04-07 07:30:20 +00004146 }
paul718e3742002-12-13 20:15:29 +00004147}
4148
paul718e3742002-12-13 20:15:29 +00004149#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4150#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004151
4152#ifdef HAVE_OPAQUE_LSA
4153#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4154#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4155#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4156#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4157#else /* HAVE_OPAQUE_LSA */
4158#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4159#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4160#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4161#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4162#endif /* HAVE_OPAQUE_LSA */
4163
4164#define OSPF_LSA_TYPES_CMD_STR \
4165 "asbr-summary|external|network|router|summary" \
4166 OSPF_LSA_TYPE_NSSA_CMD_STR \
4167 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4168
4169#define OSPF_LSA_TYPES_DESC \
4170 "ASBR summary link states\n" \
4171 "External link states\n" \
4172 "Network link states\n" \
4173 "Router link states\n" \
4174 "Network summary link states\n" \
4175 OSPF_LSA_TYPE_NSSA_DESC \
4176 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4177 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4178 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4179
4180DEFUN (show_ip_ospf_database,
4181 show_ip_ospf_database_cmd,
4182 "show ip ospf database",
4183 SHOW_STR
4184 IP_STR
4185 "OSPF information\n"
4186 "Database summary\n")
4187{
paul020709f2003-04-04 02:44:16 +00004188 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004189 int type, ret;
4190 struct in_addr id, adv_router;
4191
paul020709f2003-04-04 02:44:16 +00004192 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004193 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004194 {
4195 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4196 return CMD_SUCCESS;
4197 }
paul718e3742002-12-13 20:15:29 +00004198
4199 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004200 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004201
4202 /* Show all LSA. */
4203 if (argc == 0)
4204 {
paul020709f2003-04-04 02:44:16 +00004205 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004206 return CMD_SUCCESS;
4207 }
4208
4209 /* Set database type to show. */
4210 if (strncmp (argv[0], "r", 1) == 0)
4211 type = OSPF_ROUTER_LSA;
4212 else if (strncmp (argv[0], "ne", 2) == 0)
4213 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004214 else if (strncmp (argv[0], "ns", 2) == 0)
4215 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004216 else if (strncmp (argv[0], "su", 2) == 0)
4217 type = OSPF_SUMMARY_LSA;
4218 else if (strncmp (argv[0], "a", 1) == 0)
4219 type = OSPF_ASBR_SUMMARY_LSA;
4220 else if (strncmp (argv[0], "e", 1) == 0)
4221 type = OSPF_AS_EXTERNAL_LSA;
4222 else if (strncmp (argv[0], "se", 2) == 0)
4223 {
paul020709f2003-04-04 02:44:16 +00004224 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004225 return CMD_SUCCESS;
4226 }
4227 else if (strncmp (argv[0], "m", 1) == 0)
4228 {
paul020709f2003-04-04 02:44:16 +00004229 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004230 return CMD_SUCCESS;
4231 }
4232#ifdef HAVE_OPAQUE_LSA
4233 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4234 type = OSPF_OPAQUE_LINK_LSA;
4235 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4236 type = OSPF_OPAQUE_AREA_LSA;
4237 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4238 type = OSPF_OPAQUE_AS_LSA;
4239#endif /* HAVE_OPAQUE_LSA */
4240 else
4241 return CMD_WARNING;
4242
4243 /* `show ip ospf database LSA'. */
4244 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004245 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004246 else if (argc >= 2)
4247 {
4248 ret = inet_aton (argv[1], &id);
4249 if (!ret)
4250 return CMD_WARNING;
4251
4252 /* `show ip ospf database LSA ID'. */
4253 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004254 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004255 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4256 else if (argc == 3)
4257 {
4258 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004259 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004260 else
4261 {
4262 ret = inet_aton (argv[2], &adv_router);
4263 if (!ret)
4264 return CMD_WARNING;
4265 }
paul020709f2003-04-04 02:44:16 +00004266 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004267 }
4268 }
4269
4270 return CMD_SUCCESS;
4271}
4272
4273ALIAS (show_ip_ospf_database,
4274 show_ip_ospf_database_type_cmd,
4275 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4276 SHOW_STR
4277 IP_STR
4278 "OSPF information\n"
4279 "Database summary\n"
4280 OSPF_LSA_TYPES_DESC
4281 "LSAs in MaxAge list\n"
4282 "Self-originated link states\n")
4283
4284ALIAS (show_ip_ospf_database,
4285 show_ip_ospf_database_type_id_cmd,
4286 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4287 SHOW_STR
4288 IP_STR
4289 "OSPF information\n"
4290 "Database summary\n"
4291 OSPF_LSA_TYPES_DESC
4292 "Link State ID (as an IP address)\n")
4293
4294ALIAS (show_ip_ospf_database,
4295 show_ip_ospf_database_type_id_adv_router_cmd,
4296 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4297 SHOW_STR
4298 IP_STR
4299 "OSPF information\n"
4300 "Database summary\n"
4301 OSPF_LSA_TYPES_DESC
4302 "Link State ID (as an IP address)\n"
4303 "Advertising Router link states\n"
4304 "Advertising Router (as an IP address)\n")
4305
4306ALIAS (show_ip_ospf_database,
4307 show_ip_ospf_database_type_id_self_cmd,
4308 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4309 SHOW_STR
4310 IP_STR
4311 "OSPF information\n"
4312 "Database summary\n"
4313 OSPF_LSA_TYPES_DESC
4314 "Link State ID (as an IP address)\n"
4315 "Self-originated link states\n"
4316 "\n")
4317
4318DEFUN (show_ip_ospf_database_type_adv_router,
4319 show_ip_ospf_database_type_adv_router_cmd,
4320 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4321 SHOW_STR
4322 IP_STR
4323 "OSPF information\n"
4324 "Database summary\n"
4325 OSPF_LSA_TYPES_DESC
4326 "Advertising Router link states\n"
4327 "Advertising Router (as an IP address)\n")
4328{
paul020709f2003-04-04 02:44:16 +00004329 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004330 int type, ret;
4331 struct in_addr adv_router;
4332
paul020709f2003-04-04 02:44:16 +00004333 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004334 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004335 {
4336 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4337 return CMD_SUCCESS;
4338 }
paul718e3742002-12-13 20:15:29 +00004339
4340 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004341 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004342
4343 if (argc != 2)
4344 return CMD_WARNING;
4345
4346 /* Set database type to show. */
4347 if (strncmp (argv[0], "r", 1) == 0)
4348 type = OSPF_ROUTER_LSA;
4349 else if (strncmp (argv[0], "ne", 2) == 0)
4350 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004351 else if (strncmp (argv[0], "ns", 2) == 0)
4352 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004353 else if (strncmp (argv[0], "s", 1) == 0)
4354 type = OSPF_SUMMARY_LSA;
4355 else if (strncmp (argv[0], "a", 1) == 0)
4356 type = OSPF_ASBR_SUMMARY_LSA;
4357 else if (strncmp (argv[0], "e", 1) == 0)
4358 type = OSPF_AS_EXTERNAL_LSA;
4359#ifdef HAVE_OPAQUE_LSA
4360 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4361 type = OSPF_OPAQUE_LINK_LSA;
4362 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4363 type = OSPF_OPAQUE_AREA_LSA;
4364 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4365 type = OSPF_OPAQUE_AS_LSA;
4366#endif /* HAVE_OPAQUE_LSA */
4367 else
4368 return CMD_WARNING;
4369
4370 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4371 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004372 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004373 else
4374 {
4375 ret = inet_aton (argv[1], &adv_router);
4376 if (!ret)
4377 return CMD_WARNING;
4378 }
4379
paul020709f2003-04-04 02:44:16 +00004380 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004381
4382 return CMD_SUCCESS;
4383}
4384
4385ALIAS (show_ip_ospf_database_type_adv_router,
4386 show_ip_ospf_database_type_self_cmd,
4387 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4388 SHOW_STR
4389 IP_STR
4390 "OSPF information\n"
4391 "Database summary\n"
4392 OSPF_LSA_TYPES_DESC
4393 "Self-originated link states\n")
4394
David Lamparter6b0655a2014-06-04 06:53:35 +02004395
paul718e3742002-12-13 20:15:29 +00004396DEFUN (ip_ospf_authentication_args,
4397 ip_ospf_authentication_args_addr_cmd,
4398 "ip ospf authentication (null|message-digest) A.B.C.D",
4399 "IP Information\n"
4400 "OSPF interface commands\n"
4401 "Enable authentication on this interface\n"
4402 "Use null authentication\n"
4403 "Use message-digest authentication\n"
4404 "Address of interface")
4405{
4406 struct interface *ifp;
4407 struct in_addr addr;
4408 int ret;
4409 struct ospf_if_params *params;
4410
4411 ifp = vty->index;
4412 params = IF_DEF_PARAMS (ifp);
4413
4414 if (argc == 2)
4415 {
4416 ret = inet_aton(argv[1], &addr);
4417 if (!ret)
4418 {
4419 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4420 VTY_NEWLINE);
4421 return CMD_WARNING;
4422 }
4423
4424 params = ospf_get_if_params (ifp, addr);
4425 ospf_if_update_params (ifp, addr);
4426 }
4427
4428 /* Handle null authentication */
4429 if ( argv[0][0] == 'n' )
4430 {
4431 SET_IF_PARAM (params, auth_type);
4432 params->auth_type = OSPF_AUTH_NULL;
4433 return CMD_SUCCESS;
4434 }
4435
4436 /* Handle message-digest authentication */
4437 if ( argv[0][0] == 'm' )
4438 {
4439 SET_IF_PARAM (params, auth_type);
4440 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4441 return CMD_SUCCESS;
4442 }
4443
4444 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4445 return CMD_WARNING;
4446}
4447
4448ALIAS (ip_ospf_authentication_args,
4449 ip_ospf_authentication_args_cmd,
4450 "ip ospf authentication (null|message-digest)",
4451 "IP Information\n"
4452 "OSPF interface commands\n"
4453 "Enable authentication on this interface\n"
4454 "Use null authentication\n"
4455 "Use message-digest authentication\n")
4456
4457DEFUN (ip_ospf_authentication,
4458 ip_ospf_authentication_addr_cmd,
4459 "ip ospf authentication A.B.C.D",
4460 "IP Information\n"
4461 "OSPF interface commands\n"
4462 "Enable authentication on this interface\n"
4463 "Address of interface")
4464{
4465 struct interface *ifp;
4466 struct in_addr addr;
4467 int ret;
4468 struct ospf_if_params *params;
4469
4470 ifp = vty->index;
4471 params = IF_DEF_PARAMS (ifp);
4472
4473 if (argc == 1)
4474 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004475 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004476 if (!ret)
4477 {
4478 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4479 VTY_NEWLINE);
4480 return CMD_WARNING;
4481 }
4482
4483 params = ospf_get_if_params (ifp, addr);
4484 ospf_if_update_params (ifp, addr);
4485 }
4486
4487 SET_IF_PARAM (params, auth_type);
4488 params->auth_type = OSPF_AUTH_SIMPLE;
4489
4490 return CMD_SUCCESS;
4491}
4492
4493ALIAS (ip_ospf_authentication,
4494 ip_ospf_authentication_cmd,
4495 "ip ospf authentication",
4496 "IP Information\n"
4497 "OSPF interface commands\n"
4498 "Enable authentication on this interface\n")
4499
4500DEFUN (no_ip_ospf_authentication,
4501 no_ip_ospf_authentication_addr_cmd,
4502 "no ip ospf authentication A.B.C.D",
4503 NO_STR
4504 "IP Information\n"
4505 "OSPF interface commands\n"
4506 "Enable authentication on this interface\n"
4507 "Address of interface")
4508{
4509 struct interface *ifp;
4510 struct in_addr addr;
4511 int ret;
4512 struct ospf_if_params *params;
4513
4514 ifp = vty->index;
4515 params = IF_DEF_PARAMS (ifp);
4516
4517 if (argc == 1)
4518 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004519 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004520 if (!ret)
4521 {
4522 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4523 VTY_NEWLINE);
4524 return CMD_WARNING;
4525 }
4526
4527 params = ospf_lookup_if_params (ifp, addr);
4528 if (params == NULL)
4529 return CMD_SUCCESS;
4530 }
4531
4532 params->auth_type = OSPF_AUTH_NOTSET;
4533 UNSET_IF_PARAM (params, auth_type);
4534
4535 if (params != IF_DEF_PARAMS (ifp))
4536 {
4537 ospf_free_if_params (ifp, addr);
4538 ospf_if_update_params (ifp, addr);
4539 }
4540
4541 return CMD_SUCCESS;
4542}
4543
4544ALIAS (no_ip_ospf_authentication,
4545 no_ip_ospf_authentication_cmd,
4546 "no ip ospf authentication",
4547 NO_STR
4548 "IP Information\n"
4549 "OSPF interface commands\n"
4550 "Enable authentication on this interface\n")
4551
4552DEFUN (ip_ospf_authentication_key,
4553 ip_ospf_authentication_key_addr_cmd,
4554 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4555 "IP Information\n"
4556 "OSPF interface commands\n"
4557 "Authentication password (key)\n"
4558 "The OSPF password (key)\n"
4559 "Address of interface")
4560{
4561 struct interface *ifp;
4562 struct in_addr addr;
4563 int ret;
4564 struct ospf_if_params *params;
4565
4566 ifp = vty->index;
4567 params = IF_DEF_PARAMS (ifp);
4568
4569 if (argc == 2)
4570 {
4571 ret = inet_aton(argv[1], &addr);
4572 if (!ret)
4573 {
4574 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4575 VTY_NEWLINE);
4576 return CMD_WARNING;
4577 }
4578
4579 params = ospf_get_if_params (ifp, addr);
4580 ospf_if_update_params (ifp, addr);
4581 }
4582
4583
4584 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004585 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004586 SET_IF_PARAM (params, auth_simple);
4587
4588 return CMD_SUCCESS;
4589}
4590
4591ALIAS (ip_ospf_authentication_key,
4592 ip_ospf_authentication_key_cmd,
4593 "ip ospf authentication-key AUTH_KEY",
4594 "IP Information\n"
4595 "OSPF interface commands\n"
4596 "Authentication password (key)\n"
4597 "The OSPF password (key)")
4598
4599ALIAS (ip_ospf_authentication_key,
4600 ospf_authentication_key_cmd,
4601 "ospf authentication-key AUTH_KEY",
4602 "OSPF interface commands\n"
4603 "Authentication password (key)\n"
4604 "The OSPF password (key)")
4605
4606DEFUN (no_ip_ospf_authentication_key,
4607 no_ip_ospf_authentication_key_addr_cmd,
4608 "no ip ospf authentication-key A.B.C.D",
4609 NO_STR
4610 "IP Information\n"
4611 "OSPF interface commands\n"
4612 "Authentication password (key)\n"
4613 "Address of interface")
4614{
4615 struct interface *ifp;
4616 struct in_addr addr;
4617 int ret;
4618 struct ospf_if_params *params;
4619
4620 ifp = vty->index;
4621 params = IF_DEF_PARAMS (ifp);
4622
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004623 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004624 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004625 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004626 if (!ret)
4627 {
4628 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4629 VTY_NEWLINE);
4630 return CMD_WARNING;
4631 }
4632
4633 params = ospf_lookup_if_params (ifp, addr);
4634 if (params == NULL)
4635 return CMD_SUCCESS;
4636 }
4637
4638 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4639 UNSET_IF_PARAM (params, auth_simple);
4640
4641 if (params != IF_DEF_PARAMS (ifp))
4642 {
4643 ospf_free_if_params (ifp, addr);
4644 ospf_if_update_params (ifp, addr);
4645 }
4646
4647 return CMD_SUCCESS;
4648}
4649
4650ALIAS (no_ip_ospf_authentication_key,
4651 no_ip_ospf_authentication_key_cmd,
4652 "no ip ospf authentication-key",
4653 NO_STR
4654 "IP Information\n"
4655 "OSPF interface commands\n"
4656 "Authentication password (key)\n")
4657
4658ALIAS (no_ip_ospf_authentication_key,
4659 no_ospf_authentication_key_cmd,
4660 "no ospf authentication-key",
4661 NO_STR
4662 "OSPF interface commands\n"
4663 "Authentication password (key)\n")
4664
4665DEFUN (ip_ospf_message_digest_key,
4666 ip_ospf_message_digest_key_addr_cmd,
4667 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4668 "IP Information\n"
4669 "OSPF interface commands\n"
4670 "Message digest authentication password (key)\n"
4671 "Key ID\n"
4672 "Use MD5 algorithm\n"
4673 "The OSPF password (key)"
4674 "Address of interface")
4675{
4676 struct interface *ifp;
4677 struct crypt_key *ck;
4678 u_char key_id;
4679 struct in_addr addr;
4680 int ret;
4681 struct ospf_if_params *params;
4682
4683 ifp = vty->index;
4684 params = IF_DEF_PARAMS (ifp);
4685
4686 if (argc == 3)
4687 {
4688 ret = inet_aton(argv[2], &addr);
4689 if (!ret)
4690 {
4691 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4692 VTY_NEWLINE);
4693 return CMD_WARNING;
4694 }
4695
4696 params = ospf_get_if_params (ifp, addr);
4697 ospf_if_update_params (ifp, addr);
4698 }
4699
4700 key_id = strtol (argv[0], NULL, 10);
4701 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4702 {
4703 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4704 return CMD_WARNING;
4705 }
4706
4707 ck = ospf_crypt_key_new ();
4708 ck->key_id = (u_char) key_id;
4709 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004710 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004711
4712 ospf_crypt_key_add (params->auth_crypt, ck);
4713 SET_IF_PARAM (params, auth_crypt);
4714
4715 return CMD_SUCCESS;
4716}
4717
4718ALIAS (ip_ospf_message_digest_key,
4719 ip_ospf_message_digest_key_cmd,
4720 "ip ospf message-digest-key <1-255> md5 KEY",
4721 "IP Information\n"
4722 "OSPF interface commands\n"
4723 "Message digest authentication password (key)\n"
4724 "Key ID\n"
4725 "Use MD5 algorithm\n"
4726 "The OSPF password (key)")
4727
4728ALIAS (ip_ospf_message_digest_key,
4729 ospf_message_digest_key_cmd,
4730 "ospf message-digest-key <1-255> md5 KEY",
4731 "OSPF interface commands\n"
4732 "Message digest authentication password (key)\n"
4733 "Key ID\n"
4734 "Use MD5 algorithm\n"
4735 "The OSPF password (key)")
4736
4737DEFUN (no_ip_ospf_message_digest_key,
4738 no_ip_ospf_message_digest_key_addr_cmd,
4739 "no ip ospf message-digest-key <1-255> A.B.C.D",
4740 NO_STR
4741 "IP Information\n"
4742 "OSPF interface commands\n"
4743 "Message digest authentication password (key)\n"
4744 "Key ID\n"
4745 "Address of interface")
4746{
4747 struct interface *ifp;
4748 struct crypt_key *ck;
4749 int key_id;
4750 struct in_addr addr;
4751 int ret;
4752 struct ospf_if_params *params;
4753
4754 ifp = vty->index;
4755 params = IF_DEF_PARAMS (ifp);
4756
4757 if (argc == 2)
4758 {
4759 ret = inet_aton(argv[1], &addr);
4760 if (!ret)
4761 {
4762 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4763 VTY_NEWLINE);
4764 return CMD_WARNING;
4765 }
4766
4767 params = ospf_lookup_if_params (ifp, addr);
4768 if (params == NULL)
4769 return CMD_SUCCESS;
4770 }
4771
4772 key_id = strtol (argv[0], NULL, 10);
4773 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4774 if (ck == NULL)
4775 {
4776 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4777 return CMD_WARNING;
4778 }
4779
4780 ospf_crypt_key_delete (params->auth_crypt, key_id);
4781
4782 if (params != IF_DEF_PARAMS (ifp))
4783 {
4784 ospf_free_if_params (ifp, addr);
4785 ospf_if_update_params (ifp, addr);
4786 }
4787
4788 return CMD_SUCCESS;
4789}
4790
4791ALIAS (no_ip_ospf_message_digest_key,
4792 no_ip_ospf_message_digest_key_cmd,
4793 "no ip ospf message-digest-key <1-255>",
4794 NO_STR
4795 "IP Information\n"
4796 "OSPF interface commands\n"
4797 "Message digest authentication password (key)\n"
4798 "Key ID\n")
4799
4800ALIAS (no_ip_ospf_message_digest_key,
4801 no_ospf_message_digest_key_cmd,
4802 "no ospf message-digest-key <1-255>",
4803 NO_STR
4804 "OSPF interface commands\n"
4805 "Message digest authentication password (key)\n"
4806 "Key ID\n")
4807
4808DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004809 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004810 "ip ospf cost <1-65535> A.B.C.D",
4811 "IP Information\n"
4812 "OSPF interface commands\n"
4813 "Interface cost\n"
4814 "Cost\n"
4815 "Address of interface")
4816{
4817 struct interface *ifp = vty->index;
4818 u_int32_t cost;
4819 struct in_addr addr;
4820 int ret;
4821 struct ospf_if_params *params;
4822
4823 params = IF_DEF_PARAMS (ifp);
4824
4825 cost = strtol (argv[0], NULL, 10);
4826
4827 /* cost range is <1-65535>. */
4828 if (cost < 1 || cost > 65535)
4829 {
4830 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4831 return CMD_WARNING;
4832 }
4833
4834 if (argc == 2)
4835 {
4836 ret = inet_aton(argv[1], &addr);
4837 if (!ret)
4838 {
4839 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4840 VTY_NEWLINE);
4841 return CMD_WARNING;
4842 }
4843
4844 params = ospf_get_if_params (ifp, addr);
4845 ospf_if_update_params (ifp, addr);
4846 }
4847
4848 SET_IF_PARAM (params, output_cost_cmd);
4849 params->output_cost_cmd = cost;
4850
4851 ospf_if_recalculate_output_cost (ifp);
4852
4853 return CMD_SUCCESS;
4854}
4855
4856ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004857 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004858 "ip ospf cost <1-65535>",
4859 "IP Information\n"
4860 "OSPF interface commands\n"
4861 "Interface cost\n"
4862 "Cost")
4863
4864ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004865 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004866 "ospf cost <1-65535>",
4867 "OSPF interface commands\n"
4868 "Interface cost\n"
4869 "Cost")
4870
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004871ALIAS (ip_ospf_cost,
4872 ospf_cost_u32_inet4_cmd,
4873 "ospf cost <1-65535> A.B.C.D",
4874 "OSPF interface commands\n"
4875 "Interface cost\n"
4876 "Cost\n"
4877 "Address of interface")
4878
paul718e3742002-12-13 20:15:29 +00004879DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004880 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004881 "no ip ospf cost A.B.C.D",
4882 NO_STR
4883 "IP Information\n"
4884 "OSPF interface commands\n"
4885 "Interface cost\n"
4886 "Address of interface")
4887{
4888 struct interface *ifp = vty->index;
4889 struct in_addr addr;
4890 int ret;
4891 struct ospf_if_params *params;
4892
4893 ifp = vty->index;
4894 params = IF_DEF_PARAMS (ifp);
4895
4896 if (argc == 1)
4897 {
4898 ret = inet_aton(argv[0], &addr);
4899 if (!ret)
4900 {
4901 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4902 VTY_NEWLINE);
4903 return CMD_WARNING;
4904 }
4905
4906 params = ospf_lookup_if_params (ifp, addr);
4907 if (params == NULL)
4908 return CMD_SUCCESS;
4909 }
4910
4911 UNSET_IF_PARAM (params, output_cost_cmd);
4912
4913 if (params != IF_DEF_PARAMS (ifp))
4914 {
4915 ospf_free_if_params (ifp, addr);
4916 ospf_if_update_params (ifp, addr);
4917 }
4918
4919 ospf_if_recalculate_output_cost (ifp);
4920
4921 return CMD_SUCCESS;
4922}
4923
4924ALIAS (no_ip_ospf_cost,
4925 no_ip_ospf_cost_cmd,
4926 "no ip ospf cost",
4927 NO_STR
4928 "IP Information\n"
4929 "OSPF interface commands\n"
4930 "Interface cost\n")
4931
4932ALIAS (no_ip_ospf_cost,
4933 no_ospf_cost_cmd,
4934 "no ospf cost",
4935 NO_STR
4936 "OSPF interface commands\n"
4937 "Interface cost\n")
4938
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004939ALIAS (no_ip_ospf_cost,
4940 no_ospf_cost_inet4_cmd,
4941 "no ospf cost A.B.C.D",
4942 NO_STR
4943 "OSPF interface commands\n"
4944 "Interface cost\n"
4945 "Address of interface")
4946
Denis Ovsienko827341b2009-09-28 19:34:59 +04004947DEFUN (no_ip_ospf_cost2,
4948 no_ip_ospf_cost_u32_cmd,
4949 "no ip ospf cost <1-65535>",
4950 NO_STR
4951 "IP Information\n"
4952 "OSPF interface commands\n"
4953 "Interface cost\n"
4954 "Cost")
4955{
4956 struct interface *ifp = vty->index;
4957 struct in_addr addr;
4958 u_int32_t cost;
4959 int ret;
4960 struct ospf_if_params *params;
4961
4962 ifp = vty->index;
4963 params = IF_DEF_PARAMS (ifp);
4964
4965 /* According to the semantics we are mimicking "no ip ospf cost N" is
4966 * always treated as "no ip ospf cost" regardless of the actual value
4967 * of N already configured for the interface. Thus the first argument
4968 * is always checked to be a number, but is ignored after that.
4969 */
4970 cost = strtol (argv[0], NULL, 10);
4971 if (cost < 1 || cost > 65535)
4972 {
4973 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4974 return CMD_WARNING;
4975 }
4976
4977 if (argc == 2)
4978 {
4979 ret = inet_aton(argv[1], &addr);
4980 if (!ret)
4981 {
4982 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4983 VTY_NEWLINE);
4984 return CMD_WARNING;
4985 }
4986
4987 params = ospf_lookup_if_params (ifp, addr);
4988 if (params == NULL)
4989 return CMD_SUCCESS;
4990 }
4991
4992 UNSET_IF_PARAM (params, output_cost_cmd);
4993
4994 if (params != IF_DEF_PARAMS (ifp))
4995 {
4996 ospf_free_if_params (ifp, addr);
4997 ospf_if_update_params (ifp, addr);
4998 }
4999
5000 ospf_if_recalculate_output_cost (ifp);
5001
5002 return CMD_SUCCESS;
5003}
5004
5005ALIAS (no_ip_ospf_cost2,
5006 no_ospf_cost_u32_cmd,
5007 "no ospf cost <1-65535>",
5008 NO_STR
5009 "OSPF interface commands\n"
5010 "Interface cost\n"
5011 "Cost")
5012
5013ALIAS (no_ip_ospf_cost2,
5014 no_ip_ospf_cost_u32_inet4_cmd,
5015 "no ip ospf cost <1-65535> A.B.C.D",
5016 NO_STR
5017 "IP Information\n"
5018 "OSPF interface commands\n"
5019 "Interface cost\n"
5020 "Cost\n"
5021 "Address of interface")
5022
5023ALIAS (no_ip_ospf_cost2,
5024 no_ospf_cost_u32_inet4_cmd,
5025 "no ospf cost <1-65535> A.B.C.D",
5026 NO_STR
5027 "OSPF interface commands\n"
5028 "Interface cost\n"
5029 "Cost\n"
5030 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04005031
paul4dadc292005-05-06 21:37:42 +00005032static void
paul718e3742002-12-13 20:15:29 +00005033ospf_nbr_timer_update (struct ospf_interface *oi)
5034{
5035 struct route_node *rn;
5036 struct ospf_neighbor *nbr;
5037
5038 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
5039 if ((nbr = rn->info))
5040 {
5041 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
5042 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
5043 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
5044 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
5045 }
5046}
5047
paulf9ad9372005-10-21 00:45:17 +00005048static int
5049ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
5050 const char *nbr_str,
5051 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00005052{
5053 struct interface *ifp = vty->index;
5054 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00005055 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00005056 struct in_addr addr;
5057 int ret;
5058 struct ospf_if_params *params;
5059 struct ospf_interface *oi;
5060 struct route_node *rn;
5061
5062 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00005063
5064 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005065 {
paulf9ad9372005-10-21 00:45:17 +00005066 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00005067 if (!ret)
5068 {
5069 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5070 VTY_NEWLINE);
5071 return CMD_WARNING;
5072 }
5073
5074 params = ospf_get_if_params (ifp, addr);
5075 ospf_if_update_params (ifp, addr);
5076 }
5077
paulf9ad9372005-10-21 00:45:17 +00005078 if (interval_str)
5079 {
5080 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
5081 1, 65535);
5082
5083 /* reset fast_hello too, just to be sure */
5084 UNSET_IF_PARAM (params, fast_hello);
5085 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5086 }
5087 else if (fast_hello_str)
5088 {
5089 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5090 1, 10);
5091 /* 1s dead-interval with sub-second hellos desired */
5092 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5093 SET_IF_PARAM (params, fast_hello);
5094 params->fast_hello = hellomult;
5095 }
5096 else
5097 {
5098 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5099 VTY_NEWLINE);
5100 return CMD_WARNING;
5101 }
5102
paul718e3742002-12-13 20:15:29 +00005103 SET_IF_PARAM (params, v_wait);
5104 params->v_wait = seconds;
5105
5106 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005107 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005108 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005109 struct ospf *ospf;
5110 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005111 {
5112 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5113 if (oi)
5114 ospf_nbr_timer_update (oi);
5115 }
paul718e3742002-12-13 20:15:29 +00005116 }
5117 else
5118 {
5119 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5120 if ((oi = rn->info))
5121 ospf_nbr_timer_update (oi);
5122 }
5123
5124 return CMD_SUCCESS;
5125}
5126
paulf9ad9372005-10-21 00:45:17 +00005127
5128DEFUN (ip_ospf_dead_interval,
5129 ip_ospf_dead_interval_addr_cmd,
5130 "ip ospf dead-interval <1-65535> A.B.C.D",
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Interval after which a neighbor is declared dead\n"
5134 "Seconds\n"
5135 "Address of interface\n")
5136{
5137 if (argc == 2)
5138 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5139 else
5140 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5141}
5142
paul718e3742002-12-13 20:15:29 +00005143ALIAS (ip_ospf_dead_interval,
5144 ip_ospf_dead_interval_cmd,
5145 "ip ospf dead-interval <1-65535>",
5146 "IP Information\n"
5147 "OSPF interface commands\n"
5148 "Interval after which a neighbor is declared dead\n"
5149 "Seconds\n")
5150
5151ALIAS (ip_ospf_dead_interval,
5152 ospf_dead_interval_cmd,
5153 "ospf dead-interval <1-65535>",
5154 "OSPF interface commands\n"
5155 "Interval after which a neighbor is declared dead\n"
5156 "Seconds\n")
5157
paulf9ad9372005-10-21 00:45:17 +00005158DEFUN (ip_ospf_dead_interval_minimal,
5159 ip_ospf_dead_interval_minimal_addr_cmd,
5160 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5161 "IP Information\n"
5162 "OSPF interface commands\n"
5163 "Interval after which a neighbor is declared dead\n"
5164 "Minimal 1s dead-interval with fast sub-second hellos\n"
5165 "Hello multiplier factor\n"
5166 "Number of Hellos to send each second\n"
5167 "Address of interface\n")
5168{
5169 if (argc == 2)
5170 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5171 else
5172 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5173}
5174
5175ALIAS (ip_ospf_dead_interval_minimal,
5176 ip_ospf_dead_interval_minimal_cmd,
5177 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5178 "IP Information\n"
5179 "OSPF interface commands\n"
5180 "Interval after which a neighbor is declared dead\n"
5181 "Minimal 1s dead-interval with fast sub-second hellos\n"
5182 "Hello multiplier factor\n"
5183 "Number of Hellos to send each second\n")
5184
paul718e3742002-12-13 20:15:29 +00005185DEFUN (no_ip_ospf_dead_interval,
5186 no_ip_ospf_dead_interval_addr_cmd,
5187 "no ip ospf dead-interval A.B.C.D",
5188 NO_STR
5189 "IP Information\n"
5190 "OSPF interface commands\n"
5191 "Interval after which a neighbor is declared dead\n"
5192 "Address of interface")
5193{
5194 struct interface *ifp = vty->index;
5195 struct in_addr addr;
5196 int ret;
5197 struct ospf_if_params *params;
5198 struct ospf_interface *oi;
5199 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005200
paul718e3742002-12-13 20:15:29 +00005201 ifp = vty->index;
5202 params = IF_DEF_PARAMS (ifp);
5203
5204 if (argc == 1)
5205 {
5206 ret = inet_aton(argv[0], &addr);
5207 if (!ret)
5208 {
5209 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5210 VTY_NEWLINE);
5211 return CMD_WARNING;
5212 }
5213
5214 params = ospf_lookup_if_params (ifp, addr);
5215 if (params == NULL)
5216 return CMD_SUCCESS;
5217 }
5218
5219 UNSET_IF_PARAM (params, v_wait);
5220 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005221
5222 UNSET_IF_PARAM (params, fast_hello);
5223 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5224
paul718e3742002-12-13 20:15:29 +00005225 if (params != IF_DEF_PARAMS (ifp))
5226 {
5227 ospf_free_if_params (ifp, addr);
5228 ospf_if_update_params (ifp, addr);
5229 }
5230
5231 /* Update timer values in neighbor structure. */
5232 if (argc == 1)
5233 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005234 struct ospf *ospf;
5235
5236 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005237 {
5238 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5239 if (oi)
5240 ospf_nbr_timer_update (oi);
5241 }
paul718e3742002-12-13 20:15:29 +00005242 }
5243 else
5244 {
5245 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5246 if ((oi = rn->info))
5247 ospf_nbr_timer_update (oi);
5248 }
5249
5250 return CMD_SUCCESS;
5251}
5252
5253ALIAS (no_ip_ospf_dead_interval,
5254 no_ip_ospf_dead_interval_cmd,
5255 "no ip ospf dead-interval",
5256 NO_STR
5257 "IP Information\n"
5258 "OSPF interface commands\n"
5259 "Interval after which a neighbor is declared dead\n")
5260
5261ALIAS (no_ip_ospf_dead_interval,
5262 no_ospf_dead_interval_cmd,
5263 "no ospf dead-interval",
5264 NO_STR
5265 "OSPF interface commands\n"
5266 "Interval after which a neighbor is declared dead\n")
5267
5268DEFUN (ip_ospf_hello_interval,
5269 ip_ospf_hello_interval_addr_cmd,
5270 "ip ospf hello-interval <1-65535> A.B.C.D",
5271 "IP Information\n"
5272 "OSPF interface commands\n"
5273 "Time between HELLO packets\n"
5274 "Seconds\n"
5275 "Address of interface")
5276{
5277 struct interface *ifp = vty->index;
5278 u_int32_t seconds;
5279 struct in_addr addr;
5280 int ret;
5281 struct ospf_if_params *params;
5282
5283 params = IF_DEF_PARAMS (ifp);
5284
5285 seconds = strtol (argv[0], NULL, 10);
5286
5287 /* HelloInterval range is <1-65535>. */
5288 if (seconds < 1 || seconds > 65535)
5289 {
5290 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5291 return CMD_WARNING;
5292 }
5293
5294 if (argc == 2)
5295 {
5296 ret = inet_aton(argv[1], &addr);
5297 if (!ret)
5298 {
5299 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5300 VTY_NEWLINE);
5301 return CMD_WARNING;
5302 }
5303
5304 params = ospf_get_if_params (ifp, addr);
5305 ospf_if_update_params (ifp, addr);
5306 }
5307
paulf9ad9372005-10-21 00:45:17 +00005308 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005309 params->v_hello = seconds;
5310
5311 return CMD_SUCCESS;
5312}
5313
5314ALIAS (ip_ospf_hello_interval,
5315 ip_ospf_hello_interval_cmd,
5316 "ip ospf hello-interval <1-65535>",
5317 "IP Information\n"
5318 "OSPF interface commands\n"
5319 "Time between HELLO packets\n"
5320 "Seconds\n")
5321
5322ALIAS (ip_ospf_hello_interval,
5323 ospf_hello_interval_cmd,
5324 "ospf hello-interval <1-65535>",
5325 "OSPF interface commands\n"
5326 "Time between HELLO packets\n"
5327 "Seconds\n")
5328
5329DEFUN (no_ip_ospf_hello_interval,
5330 no_ip_ospf_hello_interval_addr_cmd,
5331 "no ip ospf hello-interval A.B.C.D",
5332 NO_STR
5333 "IP Information\n"
5334 "OSPF interface commands\n"
5335 "Time between HELLO packets\n"
5336 "Address of interface")
5337{
5338 struct interface *ifp = vty->index;
5339 struct in_addr addr;
5340 int ret;
5341 struct ospf_if_params *params;
5342
5343 ifp = vty->index;
5344 params = IF_DEF_PARAMS (ifp);
5345
5346 if (argc == 1)
5347 {
5348 ret = inet_aton(argv[0], &addr);
5349 if (!ret)
5350 {
5351 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5352 VTY_NEWLINE);
5353 return CMD_WARNING;
5354 }
5355
5356 params = ospf_lookup_if_params (ifp, addr);
5357 if (params == NULL)
5358 return CMD_SUCCESS;
5359 }
5360
5361 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005362 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005363
5364 if (params != IF_DEF_PARAMS (ifp))
5365 {
5366 ospf_free_if_params (ifp, addr);
5367 ospf_if_update_params (ifp, addr);
5368 }
5369
5370 return CMD_SUCCESS;
5371}
5372
5373ALIAS (no_ip_ospf_hello_interval,
5374 no_ip_ospf_hello_interval_cmd,
5375 "no ip ospf hello-interval",
5376 NO_STR
5377 "IP Information\n"
5378 "OSPF interface commands\n"
5379 "Time between HELLO packets\n")
5380
5381ALIAS (no_ip_ospf_hello_interval,
5382 no_ospf_hello_interval_cmd,
5383 "no ospf hello-interval",
5384 NO_STR
5385 "OSPF interface commands\n"
5386 "Time between HELLO packets\n")
5387
5388DEFUN (ip_ospf_network,
5389 ip_ospf_network_cmd,
5390 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5391 "IP Information\n"
5392 "OSPF interface commands\n"
5393 "Network type\n"
5394 "Specify OSPF broadcast multi-access network\n"
5395 "Specify OSPF NBMA network\n"
5396 "Specify OSPF point-to-multipoint network\n"
5397 "Specify OSPF point-to-point network\n")
5398{
5399 struct interface *ifp = vty->index;
5400 int old_type = IF_DEF_PARAMS (ifp)->type;
5401 struct route_node *rn;
Christian Franke4b4bda92013-07-11 07:56:29 +00005402
5403 if (old_type == OSPF_IFTYPE_LOOPBACK)
5404 {
5405 vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
5406 return CMD_WARNING;
5407 }
5408
paul718e3742002-12-13 20:15:29 +00005409 if (strncmp (argv[0], "b", 1) == 0)
5410 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5411 else if (strncmp (argv[0], "n", 1) == 0)
5412 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5413 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5414 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5415 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5416 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5417
5418 if (IF_DEF_PARAMS (ifp)->type == old_type)
5419 return CMD_SUCCESS;
5420
5421 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5422
5423 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5424 {
5425 struct ospf_interface *oi = rn->info;
5426
5427 if (!oi)
5428 continue;
5429
5430 oi->type = IF_DEF_PARAMS (ifp)->type;
5431
5432 if (oi->state > ISM_Down)
5433 {
5434 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5435 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5436 }
5437 }
5438
5439 return CMD_SUCCESS;
5440}
5441
5442ALIAS (ip_ospf_network,
5443 ospf_network_cmd,
5444 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5445 "OSPF interface commands\n"
5446 "Network type\n"
5447 "Specify OSPF broadcast multi-access network\n"
5448 "Specify OSPF NBMA network\n"
5449 "Specify OSPF point-to-multipoint network\n"
5450 "Specify OSPF point-to-point network\n")
5451
5452DEFUN (no_ip_ospf_network,
5453 no_ip_ospf_network_cmd,
5454 "no ip ospf network",
5455 NO_STR
5456 "IP Information\n"
5457 "OSPF interface commands\n"
5458 "Network type\n")
5459{
5460 struct interface *ifp = vty->index;
5461 int old_type = IF_DEF_PARAMS (ifp)->type;
5462 struct route_node *rn;
5463
ajsbc18d612004-12-15 15:07:19 +00005464 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005465
5466 if (IF_DEF_PARAMS (ifp)->type == old_type)
5467 return CMD_SUCCESS;
5468
5469 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5470 {
5471 struct ospf_interface *oi = rn->info;
5472
5473 if (!oi)
5474 continue;
5475
5476 oi->type = IF_DEF_PARAMS (ifp)->type;
5477
5478 if (oi->state > ISM_Down)
5479 {
5480 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5481 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5482 }
5483 }
5484
5485 return CMD_SUCCESS;
5486}
5487
5488ALIAS (no_ip_ospf_network,
5489 no_ospf_network_cmd,
5490 "no ospf network",
5491 NO_STR
5492 "OSPF interface commands\n"
5493 "Network type\n")
5494
5495DEFUN (ip_ospf_priority,
5496 ip_ospf_priority_addr_cmd,
5497 "ip ospf priority <0-255> A.B.C.D",
5498 "IP Information\n"
5499 "OSPF interface commands\n"
5500 "Router priority\n"
5501 "Priority\n"
5502 "Address of interface")
5503{
5504 struct interface *ifp = vty->index;
Andrew Certain0798cee2012-12-04 13:43:42 -08005505 long priority;
paul718e3742002-12-13 20:15:29 +00005506 struct route_node *rn;
5507 struct in_addr addr;
5508 int ret;
5509 struct ospf_if_params *params;
5510
5511 params = IF_DEF_PARAMS (ifp);
5512
5513 priority = strtol (argv[0], NULL, 10);
5514
5515 /* Router Priority range is <0-255>. */
5516 if (priority < 0 || priority > 255)
5517 {
5518 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5519 return CMD_WARNING;
5520 }
5521
5522 if (argc == 2)
5523 {
5524 ret = inet_aton(argv[1], &addr);
5525 if (!ret)
5526 {
5527 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5528 VTY_NEWLINE);
5529 return CMD_WARNING;
5530 }
5531
5532 params = ospf_get_if_params (ifp, addr);
5533 ospf_if_update_params (ifp, addr);
5534 }
5535
5536 SET_IF_PARAM (params, priority);
5537 params->priority = priority;
5538
5539 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5540 {
5541 struct ospf_interface *oi = rn->info;
5542
5543 if (!oi)
5544 continue;
5545
5546
5547 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5548 {
5549 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5550 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5551 }
5552 }
5553
5554 return CMD_SUCCESS;
5555}
5556
5557ALIAS (ip_ospf_priority,
5558 ip_ospf_priority_cmd,
5559 "ip ospf priority <0-255>",
5560 "IP Information\n"
5561 "OSPF interface commands\n"
5562 "Router priority\n"
5563 "Priority\n")
5564
5565ALIAS (ip_ospf_priority,
5566 ospf_priority_cmd,
5567 "ospf priority <0-255>",
5568 "OSPF interface commands\n"
5569 "Router priority\n"
5570 "Priority\n")
5571
5572DEFUN (no_ip_ospf_priority,
5573 no_ip_ospf_priority_addr_cmd,
5574 "no ip ospf priority A.B.C.D",
5575 NO_STR
5576 "IP Information\n"
5577 "OSPF interface commands\n"
5578 "Router priority\n"
5579 "Address of interface")
5580{
5581 struct interface *ifp = vty->index;
5582 struct route_node *rn;
5583 struct in_addr addr;
5584 int ret;
5585 struct ospf_if_params *params;
5586
5587 ifp = vty->index;
5588 params = IF_DEF_PARAMS (ifp);
5589
5590 if (argc == 1)
5591 {
5592 ret = inet_aton(argv[0], &addr);
5593 if (!ret)
5594 {
5595 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5596 VTY_NEWLINE);
5597 return CMD_WARNING;
5598 }
5599
5600 params = ospf_lookup_if_params (ifp, addr);
5601 if (params == NULL)
5602 return CMD_SUCCESS;
5603 }
5604
5605 UNSET_IF_PARAM (params, priority);
5606 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5607
5608 if (params != IF_DEF_PARAMS (ifp))
5609 {
5610 ospf_free_if_params (ifp, addr);
5611 ospf_if_update_params (ifp, addr);
5612 }
5613
5614 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5615 {
5616 struct ospf_interface *oi = rn->info;
5617
5618 if (!oi)
5619 continue;
5620
5621
5622 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5623 {
5624 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5625 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5626 }
5627 }
5628
5629 return CMD_SUCCESS;
5630}
5631
5632ALIAS (no_ip_ospf_priority,
5633 no_ip_ospf_priority_cmd,
5634 "no ip ospf priority",
5635 NO_STR
5636 "IP Information\n"
5637 "OSPF interface commands\n"
5638 "Router priority\n")
5639
5640ALIAS (no_ip_ospf_priority,
5641 no_ospf_priority_cmd,
5642 "no ospf priority",
5643 NO_STR
5644 "OSPF interface commands\n"
5645 "Router priority\n")
5646
5647DEFUN (ip_ospf_retransmit_interval,
5648 ip_ospf_retransmit_interval_addr_cmd,
5649 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5650 "IP Information\n"
5651 "OSPF interface commands\n"
5652 "Time between retransmitting lost link state advertisements\n"
5653 "Seconds\n"
5654 "Address of interface")
5655{
5656 struct interface *ifp = vty->index;
5657 u_int32_t seconds;
5658 struct in_addr addr;
5659 int ret;
5660 struct ospf_if_params *params;
5661
5662 params = IF_DEF_PARAMS (ifp);
5663 seconds = strtol (argv[0], NULL, 10);
5664
5665 /* Retransmit Interval range is <3-65535>. */
5666 if (seconds < 3 || seconds > 65535)
5667 {
5668 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5669 return CMD_WARNING;
5670 }
5671
5672
5673 if (argc == 2)
5674 {
5675 ret = inet_aton(argv[1], &addr);
5676 if (!ret)
5677 {
5678 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5679 VTY_NEWLINE);
5680 return CMD_WARNING;
5681 }
5682
5683 params = ospf_get_if_params (ifp, addr);
5684 ospf_if_update_params (ifp, addr);
5685 }
5686
5687 SET_IF_PARAM (params, retransmit_interval);
5688 params->retransmit_interval = seconds;
5689
5690 return CMD_SUCCESS;
5691}
5692
5693ALIAS (ip_ospf_retransmit_interval,
5694 ip_ospf_retransmit_interval_cmd,
5695 "ip ospf retransmit-interval <3-65535>",
5696 "IP Information\n"
5697 "OSPF interface commands\n"
5698 "Time between retransmitting lost link state advertisements\n"
5699 "Seconds\n")
5700
5701ALIAS (ip_ospf_retransmit_interval,
5702 ospf_retransmit_interval_cmd,
5703 "ospf retransmit-interval <3-65535>",
5704 "OSPF interface commands\n"
5705 "Time between retransmitting lost link state advertisements\n"
5706 "Seconds\n")
5707
5708DEFUN (no_ip_ospf_retransmit_interval,
5709 no_ip_ospf_retransmit_interval_addr_cmd,
5710 "no ip ospf retransmit-interval A.B.C.D",
5711 NO_STR
5712 "IP Information\n"
5713 "OSPF interface commands\n"
5714 "Time between retransmitting lost link state advertisements\n"
5715 "Address of interface")
5716{
5717 struct interface *ifp = vty->index;
5718 struct in_addr addr;
5719 int ret;
5720 struct ospf_if_params *params;
5721
5722 ifp = vty->index;
5723 params = IF_DEF_PARAMS (ifp);
5724
5725 if (argc == 1)
5726 {
5727 ret = inet_aton(argv[0], &addr);
5728 if (!ret)
5729 {
5730 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5731 VTY_NEWLINE);
5732 return CMD_WARNING;
5733 }
5734
5735 params = ospf_lookup_if_params (ifp, addr);
5736 if (params == NULL)
5737 return CMD_SUCCESS;
5738 }
5739
5740 UNSET_IF_PARAM (params, retransmit_interval);
5741 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5742
5743 if (params != IF_DEF_PARAMS (ifp))
5744 {
5745 ospf_free_if_params (ifp, addr);
5746 ospf_if_update_params (ifp, addr);
5747 }
5748
5749 return CMD_SUCCESS;
5750}
5751
5752ALIAS (no_ip_ospf_retransmit_interval,
5753 no_ip_ospf_retransmit_interval_cmd,
5754 "no ip ospf retransmit-interval",
5755 NO_STR
5756 "IP Information\n"
5757 "OSPF interface commands\n"
5758 "Time between retransmitting lost link state advertisements\n")
5759
5760ALIAS (no_ip_ospf_retransmit_interval,
5761 no_ospf_retransmit_interval_cmd,
5762 "no ospf retransmit-interval",
5763 NO_STR
5764 "OSPF interface commands\n"
5765 "Time between retransmitting lost link state advertisements\n")
5766
5767DEFUN (ip_ospf_transmit_delay,
5768 ip_ospf_transmit_delay_addr_cmd,
5769 "ip ospf transmit-delay <1-65535> A.B.C.D",
5770 "IP Information\n"
5771 "OSPF interface commands\n"
5772 "Link state transmit delay\n"
5773 "Seconds\n"
5774 "Address of interface")
5775{
5776 struct interface *ifp = vty->index;
5777 u_int32_t seconds;
5778 struct in_addr addr;
5779 int ret;
5780 struct ospf_if_params *params;
5781
5782 params = IF_DEF_PARAMS (ifp);
5783 seconds = strtol (argv[0], NULL, 10);
5784
5785 /* Transmit Delay range is <1-65535>. */
5786 if (seconds < 1 || seconds > 65535)
5787 {
5788 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5789 return CMD_WARNING;
5790 }
5791
5792 if (argc == 2)
5793 {
5794 ret = inet_aton(argv[1], &addr);
5795 if (!ret)
5796 {
5797 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5798 VTY_NEWLINE);
5799 return CMD_WARNING;
5800 }
5801
5802 params = ospf_get_if_params (ifp, addr);
5803 ospf_if_update_params (ifp, addr);
5804 }
5805
5806 SET_IF_PARAM (params, transmit_delay);
5807 params->transmit_delay = seconds;
5808
5809 return CMD_SUCCESS;
5810}
5811
5812ALIAS (ip_ospf_transmit_delay,
5813 ip_ospf_transmit_delay_cmd,
5814 "ip ospf transmit-delay <1-65535>",
5815 "IP Information\n"
5816 "OSPF interface commands\n"
5817 "Link state transmit delay\n"
5818 "Seconds\n")
5819
5820ALIAS (ip_ospf_transmit_delay,
5821 ospf_transmit_delay_cmd,
5822 "ospf transmit-delay <1-65535>",
5823 "OSPF interface commands\n"
5824 "Link state transmit delay\n"
5825 "Seconds\n")
5826
5827DEFUN (no_ip_ospf_transmit_delay,
5828 no_ip_ospf_transmit_delay_addr_cmd,
5829 "no ip ospf transmit-delay A.B.C.D",
5830 NO_STR
5831 "IP Information\n"
5832 "OSPF interface commands\n"
5833 "Link state transmit delay\n"
5834 "Address of interface")
5835{
5836 struct interface *ifp = vty->index;
5837 struct in_addr addr;
5838 int ret;
5839 struct ospf_if_params *params;
5840
5841 ifp = vty->index;
5842 params = IF_DEF_PARAMS (ifp);
5843
5844 if (argc == 1)
5845 {
5846 ret = inet_aton(argv[0], &addr);
5847 if (!ret)
5848 {
5849 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5850 VTY_NEWLINE);
5851 return CMD_WARNING;
5852 }
5853
5854 params = ospf_lookup_if_params (ifp, addr);
5855 if (params == NULL)
5856 return CMD_SUCCESS;
5857 }
5858
5859 UNSET_IF_PARAM (params, transmit_delay);
5860 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5861
5862 if (params != IF_DEF_PARAMS (ifp))
5863 {
5864 ospf_free_if_params (ifp, addr);
5865 ospf_if_update_params (ifp, addr);
5866 }
5867
5868 return CMD_SUCCESS;
5869}
5870
5871ALIAS (no_ip_ospf_transmit_delay,
5872 no_ip_ospf_transmit_delay_cmd,
5873 "no ip ospf transmit-delay",
5874 NO_STR
5875 "IP Information\n"
5876 "OSPF interface commands\n"
5877 "Link state transmit delay\n")
5878
5879ALIAS (no_ip_ospf_transmit_delay,
5880 no_ospf_transmit_delay_cmd,
5881 "no ospf transmit-delay",
5882 NO_STR
5883 "OSPF interface commands\n"
5884 "Link state transmit delay\n")
5885
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005886DEFUN (ip_ospf_area,
5887 ip_ospf_area_cmd,
5888 "ip ospf area (A.B.C.D|<0-4294967295>)",
5889 "IP Information\n"
5890 "OSPF interface commands\n"
5891 "Enable OSPF on this interface\n"
5892 "OSPF area ID in IP address format\n"
5893 "OSPF area ID as a decimal value\n")
5894{
5895 struct interface *ifp = vty->index;
5896 int format, ret;
5897 struct in_addr area_id;
5898 struct ospf *ospf;
5899 struct ospf_if_params *params;
5900
5901 ret = ospf_str2area_id (argv[0], &area_id, &format);
5902
5903 if (ret < 0)
5904 {
5905 vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s",
5906 VTY_NEWLINE);
5907 return CMD_WARNING;
5908 }
5909 params = IF_DEF_PARAMS (ifp);
5910 if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
5911 {
5912 vty_out (vty, "There is already a interface statement.%s", VTY_NEWLINE);
5913 return CMD_WARNING;
5914 }
5915 if (memcmp (ifp->name, "VLINK", 5) == 0)
5916 {
5917 vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE);
5918 return CMD_WARNING;
5919 }
5920
5921 SET_IF_PARAM (params, if_area);
5922 params->if_area = area_id;
5923 ospf_interface_set (ifp);
5924
5925 return CMD_SUCCESS;
5926}
5927
5928DEFUN (no_ip_ospf_area,
5929 no_ip_ospf_area_cmd,
5930 "no ip ospf area",
5931 NO_STR
5932 "IP Information\n"
5933 "OSPF interface commands\n"
5934 "Disable OSPF on this interface\n")
5935{
5936 struct interface *ifp = vty->index;
5937 struct ospf *ospf;
5938 struct ospf_if_params *params;
5939
5940 params = IF_DEF_PARAMS (ifp);
5941 if (!OSPF_IF_PARAM_CONFIGURED(params, if_area))
5942 return CMD_SUCCESS;
5943
5944 UNSET_IF_PARAM (params, if_area);
5945
5946 ospf_interface_unset (ifp);
5947 return CMD_SUCCESS;
5948}
5949
Christian Franke6f2a6702013-09-30 12:27:52 +00005950DEFUN (ospf_redistribute_source,
5951 ospf_redistribute_source_cmd,
5952 "redistribute " QUAGGA_REDIST_STR_OSPFD
5953 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
Paul Jakmad1c65c22006-06-27 08:01:43 +00005954 REDIST_STR
5955 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005956 "Metric for redistributed routes\n"
5957 "OSPF default metric\n"
5958 "OSPF exterior metric type for redistributed routes\n"
5959 "Set OSPF External Type 1 metrics\n"
5960 "Set OSPF External Type 2 metrics\n"
5961 "Route map reference\n"
5962 "Pointer to route-map entries\n")
5963{
paul020709f2003-04-04 02:44:16 +00005964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005965 int source;
5966 int type = -1;
5967 int metric = -1;
5968
Christian Franke6f2a6702013-09-30 12:27:52 +00005969 if (argc < 4)
5970 return CMD_WARNING; /* should not happen */
5971
paul718e3742002-12-13 20:15:29 +00005972 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005973 source = proto_redistnum(AFI_IP, argv[0]);
5974 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005975 return CMD_WARNING;
5976
5977 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005978 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00005979 if (!str2metric (argv[1], &metric))
5980 return CMD_WARNING;
5981
5982 /* Get metric type. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005983 if (argv[2] != NULL)
paul718e3742002-12-13 20:15:29 +00005984 if (!str2metric_type (argv[2], &type))
5985 return CMD_WARNING;
5986
Christian Franke6f2a6702013-09-30 12:27:52 +00005987 if (argv[3] != NULL)
paul020709f2003-04-04 02:44:16 +00005988 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005989 else
paul020709f2003-04-04 02:44:16 +00005990 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005991
paul020709f2003-04-04 02:44:16 +00005992 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005993}
5994
paul718e3742002-12-13 20:15:29 +00005995DEFUN (no_ospf_redistribute_source,
5996 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005997 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005998 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005999 REDIST_STR
6000 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006001{
paul020709f2003-04-04 02:44:16 +00006002 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006003 int source;
6004
David Lampartere0ca5fd2009-09-16 01:52:42 +02006005 source = proto_redistnum(AFI_IP, argv[0]);
6006 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006007 return CMD_WARNING;
6008
paul020709f2003-04-04 02:44:16 +00006009 ospf_routemap_unset (ospf, source);
6010 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006011}
6012
6013DEFUN (ospf_distribute_list_out,
6014 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006015 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006016 "Filter networks in routing updates\n"
6017 "Access-list name\n"
6018 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006019 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006020{
paul68980082003-03-25 05:07:42 +00006021 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006022 int source;
6023
6024 /* Get distribute source. */
Christian Frankebda3c322012-12-04 11:31:16 -08006025 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006026 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006027 return CMD_WARNING;
6028
paul68980082003-03-25 05:07:42 +00006029 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006030}
6031
6032DEFUN (no_ospf_distribute_list_out,
6033 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006034 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006035 NO_STR
6036 "Filter networks in routing updates\n"
6037 "Access-list name\n"
6038 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006039 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006040{
paul68980082003-03-25 05:07:42 +00006041 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006042 int source;
6043
Christian Frankebda3c322012-12-04 11:31:16 -08006044 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006045 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006046 return CMD_WARNING;
6047
paul68980082003-03-25 05:07:42 +00006048 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006049}
6050
6051/* Default information originate. */
Christian Franke6f2a6702013-09-30 12:27:52 +00006052DEFUN (ospf_default_information_originate,
paul718e3742002-12-13 20:15:29 +00006053 ospf_default_information_originate_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00006054 "default-information originate "
6055 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
paul718e3742002-12-13 20:15:29 +00006056 "Control distribution of default information\n"
6057 "Distribute a default route\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00006058 "Always advertise default route\n"
paul718e3742002-12-13 20:15:29 +00006059 "OSPF default metric\n"
6060 "OSPF metric\n"
paul718e3742002-12-13 20:15:29 +00006061 "OSPF metric type for default routes\n"
6062 "Set OSPF External Type 1 metrics\n"
6063 "Set OSPF External Type 2 metrics\n"
paul718e3742002-12-13 20:15:29 +00006064 "Route map reference\n"
6065 "Pointer to route-map entries\n")
6066{
paul020709f2003-04-04 02:44:16 +00006067 struct ospf *ospf = vty->index;
Christian Franke6f2a6702013-09-30 12:27:52 +00006068 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
paul718e3742002-12-13 20:15:29 +00006069 int type = -1;
6070 int metric = -1;
6071
Christian Franke6f2a6702013-09-30 12:27:52 +00006072 if (argc < 4)
6073 return CMD_WARNING; /* this should not happen */
6074
6075 /* Check whether "always" was specified */
6076 if (argv[0] != NULL)
6077 default_originate = DEFAULT_ORIGINATE_ALWAYS;
paul718e3742002-12-13 20:15:29 +00006078
6079 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00006080 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00006081 if (!str2metric (argv[1], &metric))
6082 return CMD_WARNING;
6083
Christian Franke6f2a6702013-09-30 12:27:52 +00006084 /* Get metric type. */
6085 if (argv[2] != NULL)
6086 if (!str2metric_type (argv[2], &type))
6087 return CMD_WARNING;
6088
6089 if (argv[3] != NULL)
6090 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
paul718e3742002-12-13 20:15:29 +00006091 else
paul020709f2003-04-04 02:44:16 +00006092 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006093
Christian Franke6f2a6702013-09-30 12:27:52 +00006094 return ospf_redistribute_default_set (ospf, default_originate,
paul020709f2003-04-04 02:44:16 +00006095 type, metric);
paul718e3742002-12-13 20:15:29 +00006096}
6097
paul718e3742002-12-13 20:15:29 +00006098DEFUN (no_ospf_default_information_originate,
6099 no_ospf_default_information_originate_cmd,
6100 "no default-information originate",
6101 NO_STR
6102 "Control distribution of default information\n"
6103 "Distribute a default route\n")
6104{
paul68980082003-03-25 05:07:42 +00006105 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006106 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006107
6108 p.family = AF_INET;
6109 p.prefix.s_addr = 0;
6110 p.prefixlen = 0;
6111
ajs5339cfd2005-09-19 13:28:05 +00006112 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006113
6114 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6115 ospf_external_info_delete (DEFAULT_ROUTE, p);
6116 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6117 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6118 }
6119
paul020709f2003-04-04 02:44:16 +00006120 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6121 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006122}
6123
6124DEFUN (ospf_default_metric,
6125 ospf_default_metric_cmd,
6126 "default-metric <0-16777214>",
6127 "Set metric of redistributed routes\n"
6128 "Default metric\n")
6129{
paul68980082003-03-25 05:07:42 +00006130 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006131 int metric = -1;
6132
6133 if (!str2metric (argv[0], &metric))
6134 return CMD_WARNING;
6135
paul68980082003-03-25 05:07:42 +00006136 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006137
6138 return CMD_SUCCESS;
6139}
6140
6141DEFUN (no_ospf_default_metric,
6142 no_ospf_default_metric_cmd,
6143 "no default-metric",
6144 NO_STR
6145 "Set metric of redistributed routes\n")
6146{
paul68980082003-03-25 05:07:42 +00006147 struct ospf *ospf = vty->index;
6148
6149 ospf->default_metric = -1;
6150
paul718e3742002-12-13 20:15:29 +00006151 return CMD_SUCCESS;
6152}
6153
6154ALIAS (no_ospf_default_metric,
6155 no_ospf_default_metric_val_cmd,
6156 "no default-metric <0-16777214>",
6157 NO_STR
6158 "Set metric of redistributed routes\n"
6159 "Default metric\n")
6160
6161DEFUN (ospf_distance,
6162 ospf_distance_cmd,
6163 "distance <1-255>",
6164 "Define an administrative distance\n"
6165 "OSPF Administrative distance\n")
6166{
paul68980082003-03-25 05:07:42 +00006167 struct ospf *ospf = vty->index;
6168
6169 ospf->distance_all = atoi (argv[0]);
6170
paul718e3742002-12-13 20:15:29 +00006171 return CMD_SUCCESS;
6172}
6173
6174DEFUN (no_ospf_distance,
6175 no_ospf_distance_cmd,
6176 "no distance <1-255>",
6177 NO_STR
6178 "Define an administrative distance\n"
6179 "OSPF Administrative distance\n")
6180{
paul68980082003-03-25 05:07:42 +00006181 struct ospf *ospf = vty->index;
6182
6183 ospf->distance_all = 0;
6184
paul718e3742002-12-13 20:15:29 +00006185 return CMD_SUCCESS;
6186}
6187
6188DEFUN (no_ospf_distance_ospf,
6189 no_ospf_distance_ospf_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00006190 "no distance ospf {intra-area|inter-area|external}",
paul718e3742002-12-13 20:15:29 +00006191 NO_STR
6192 "Define an administrative distance\n"
6193 "OSPF Administrative distance\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00006194 "OSPF Distance\n"
6195 "Intra-area routes\n"
6196 "Inter-area routes\n"
6197 "External routes\n")
paul718e3742002-12-13 20:15:29 +00006198{
paul68980082003-03-25 05:07:42 +00006199 struct ospf *ospf = vty->index;
6200
Christian Franke6f2a6702013-09-30 12:27:52 +00006201 if (argc < 3)
6202 return CMD_WARNING;
6203
6204 if (argv[0] != NULL)
6205 ospf->distance_intra = 0;
6206
6207 if (argv[1] != NULL)
6208 ospf->distance_inter = 0;
6209
6210 if (argv[2] != NULL)
6211 ospf->distance_external = 0;
6212
6213 if (argv[0] || argv[1] || argv[2])
6214 return CMD_SUCCESS;
6215
6216 /* If no arguments are given, clear all distance information */
paul68980082003-03-25 05:07:42 +00006217 ospf->distance_intra = 0;
6218 ospf->distance_inter = 0;
6219 ospf->distance_external = 0;
6220
paul718e3742002-12-13 20:15:29 +00006221 return CMD_SUCCESS;
6222}
6223
Christian Franke6f2a6702013-09-30 12:27:52 +00006224DEFUN (ospf_distance_ospf,
6225 ospf_distance_ospf_cmd,
6226 "distance ospf "
6227 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
paul718e3742002-12-13 20:15:29 +00006228 "Define an administrative distance\n"
6229 "OSPF Administrative distance\n"
6230 "Intra-area routes\n"
6231 "Distance for intra-area routes\n"
6232 "Inter-area routes\n"
6233 "Distance for inter-area routes\n"
6234 "External routes\n"
6235 "Distance for external routes\n")
6236{
paul68980082003-03-25 05:07:42 +00006237 struct ospf *ospf = vty->index;
6238
Christian Franke6f2a6702013-09-30 12:27:52 +00006239 if (argc < 3) /* should not happen */
6240 return CMD_WARNING;
paul68980082003-03-25 05:07:42 +00006241
Christian Franke6f2a6702013-09-30 12:27:52 +00006242 if (!argv[0] && !argv[1] && !argv[2])
6243 {
6244 vty_out(vty, "%% Command incomplete. (Arguments required)%s",
6245 VTY_NEWLINE);
6246 return CMD_WARNING;
6247 }
paul718e3742002-12-13 20:15:29 +00006248
Christian Franke6f2a6702013-09-30 12:27:52 +00006249 if (argv[0] != NULL)
6250 ospf->distance_intra = atoi(argv[0]);
paul68980082003-03-25 05:07:42 +00006251
Christian Franke6f2a6702013-09-30 12:27:52 +00006252 if (argv[1] != NULL)
6253 ospf->distance_inter = atoi(argv[1]);
paul68980082003-03-25 05:07:42 +00006254
Christian Franke6f2a6702013-09-30 12:27:52 +00006255 if (argv[2] != NULL)
6256 ospf->distance_external = atoi(argv[2]);
paul68980082003-03-25 05:07:42 +00006257
paul718e3742002-12-13 20:15:29 +00006258 return CMD_SUCCESS;
6259}
6260
6261DEFUN (ospf_distance_source,
6262 ospf_distance_source_cmd,
6263 "distance <1-255> A.B.C.D/M",
6264 "Administrative distance\n"
6265 "Distance value\n"
6266 "IP source prefix\n")
6267{
paul020709f2003-04-04 02:44:16 +00006268 struct ospf *ospf = vty->index;
6269
6270 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006271
paul718e3742002-12-13 20:15:29 +00006272 return CMD_SUCCESS;
6273}
6274
6275DEFUN (no_ospf_distance_source,
6276 no_ospf_distance_source_cmd,
6277 "no distance <1-255> A.B.C.D/M",
6278 NO_STR
6279 "Administrative distance\n"
6280 "Distance value\n"
6281 "IP source prefix\n")
6282{
paul020709f2003-04-04 02:44:16 +00006283 struct ospf *ospf = vty->index;
6284
6285 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6286
paul718e3742002-12-13 20:15:29 +00006287 return CMD_SUCCESS;
6288}
6289
6290DEFUN (ospf_distance_source_access_list,
6291 ospf_distance_source_access_list_cmd,
6292 "distance <1-255> A.B.C.D/M WORD",
6293 "Administrative distance\n"
6294 "Distance value\n"
6295 "IP source prefix\n"
6296 "Access list name\n")
6297{
paul020709f2003-04-04 02:44:16 +00006298 struct ospf *ospf = vty->index;
6299
6300 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6301
paul718e3742002-12-13 20:15:29 +00006302 return CMD_SUCCESS;
6303}
6304
6305DEFUN (no_ospf_distance_source_access_list,
6306 no_ospf_distance_source_access_list_cmd,
6307 "no distance <1-255> A.B.C.D/M WORD",
6308 NO_STR
6309 "Administrative distance\n"
6310 "Distance value\n"
6311 "IP source prefix\n"
6312 "Access list name\n")
6313{
paul020709f2003-04-04 02:44:16 +00006314 struct ospf *ospf = vty->index;
6315
6316 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6317
paul718e3742002-12-13 20:15:29 +00006318 return CMD_SUCCESS;
6319}
6320
vincentba682532005-09-29 13:52:57 +00006321DEFUN (ip_ospf_mtu_ignore,
6322 ip_ospf_mtu_ignore_addr_cmd,
6323 "ip ospf mtu-ignore A.B.C.D",
6324 "IP Information\n"
6325 "OSPF interface commands\n"
6326 "Disable mtu mismatch detection\n"
6327 "Address of interface")
6328{
6329 struct interface *ifp = vty->index;
6330 struct in_addr addr;
6331 int ret;
6332
6333 struct ospf_if_params *params;
6334 params = IF_DEF_PARAMS (ifp);
6335
6336 if (argc == 1)
6337 {
6338 ret = inet_aton(argv[0], &addr);
6339 if (!ret)
6340 {
6341 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6342 VTY_NEWLINE);
6343 return CMD_WARNING;
6344 }
6345 params = ospf_get_if_params (ifp, addr);
6346 ospf_if_update_params (ifp, addr);
6347 }
6348 params->mtu_ignore = 1;
6349 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6350 SET_IF_PARAM (params, mtu_ignore);
6351 else
6352 {
6353 UNSET_IF_PARAM (params, mtu_ignore);
6354 if (params != IF_DEF_PARAMS (ifp))
6355 {
6356 ospf_free_if_params (ifp, addr);
6357 ospf_if_update_params (ifp, addr);
6358 }
6359 }
6360 return CMD_SUCCESS;
6361}
6362
6363ALIAS (ip_ospf_mtu_ignore,
6364 ip_ospf_mtu_ignore_cmd,
6365 "ip ospf mtu-ignore",
6366 "IP Information\n"
6367 "OSPF interface commands\n"
6368 "Disable mtu mismatch detection\n")
6369
6370
6371DEFUN (no_ip_ospf_mtu_ignore,
6372 no_ip_ospf_mtu_ignore_addr_cmd,
6373 "no ip ospf mtu-ignore A.B.C.D",
6374 "IP Information\n"
6375 "OSPF interface commands\n"
6376 "Disable mtu mismatch detection\n"
6377 "Address of interface")
6378{
6379 struct interface *ifp = vty->index;
6380 struct in_addr addr;
6381 int ret;
6382
6383 struct ospf_if_params *params;
6384 params = IF_DEF_PARAMS (ifp);
6385
6386 if (argc == 1)
6387 {
6388 ret = inet_aton(argv[0], &addr);
6389 if (!ret)
6390 {
6391 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6392 VTY_NEWLINE);
6393 return CMD_WARNING;
6394 }
6395 params = ospf_get_if_params (ifp, addr);
6396 ospf_if_update_params (ifp, addr);
6397 }
6398 params->mtu_ignore = 0;
6399 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6400 SET_IF_PARAM (params, mtu_ignore);
6401 else
6402 {
6403 UNSET_IF_PARAM (params, mtu_ignore);
6404 if (params != IF_DEF_PARAMS (ifp))
6405 {
6406 ospf_free_if_params (ifp, addr);
6407 ospf_if_update_params (ifp, addr);
6408 }
6409 }
6410 return CMD_SUCCESS;
6411}
6412
6413ALIAS (no_ip_ospf_mtu_ignore,
6414 no_ip_ospf_mtu_ignore_cmd,
6415 "no ip ospf mtu-ignore",
6416 "IP Information\n"
6417 "OSPF interface commands\n"
6418 "Disable mtu mismatch detection\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02006419
paul88d6cf32005-10-29 12:50:09 +00006420DEFUN (ospf_max_metric_router_lsa_admin,
6421 ospf_max_metric_router_lsa_admin_cmd,
6422 "max-metric router-lsa administrative",
6423 "OSPF maximum / infinite-distance metric\n"
6424 "Advertise own Router-LSA with infinite distance (stub router)\n"
6425 "Administratively applied, for an indefinite period\n")
6426{
6427 struct listnode *ln;
6428 struct ospf_area *area;
6429 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006430
paul88d6cf32005-10-29 12:50:09 +00006431 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6432 {
6433 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6434
6435 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00006436 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006437 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006438
6439 /* Allows for areas configured later to get the property */
6440 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
6441
paul88d6cf32005-10-29 12:50:09 +00006442 return CMD_SUCCESS;
6443}
6444
6445DEFUN (no_ospf_max_metric_router_lsa_admin,
6446 no_ospf_max_metric_router_lsa_admin_cmd,
6447 "no max-metric router-lsa administrative",
6448 NO_STR
6449 "OSPF maximum / infinite-distance metric\n"
6450 "Advertise own Router-LSA with infinite distance (stub router)\n"
6451 "Administratively applied, for an indefinite period\n")
6452{
6453 struct listnode *ln;
6454 struct ospf_area *area;
6455 struct ospf *ospf = vty->index;
6456
6457 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6458 {
6459 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6460
6461 /* Don't trample on the start-up stub timer */
6462 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6463 && !area->t_stub_router)
6464 {
6465 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006466 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006467 }
6468 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006469 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00006470 return CMD_SUCCESS;
6471}
6472
6473DEFUN (ospf_max_metric_router_lsa_startup,
6474 ospf_max_metric_router_lsa_startup_cmd,
6475 "max-metric router-lsa on-startup <5-86400>",
6476 "OSPF maximum / infinite-distance metric\n"
6477 "Advertise own Router-LSA with infinite distance (stub router)\n"
6478 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6479 "Time (seconds) to advertise self as stub-router\n")
6480{
6481 unsigned int seconds;
6482 struct ospf *ospf = vty->index;
6483
6484 if (argc != 1)
6485 {
6486 vty_out (vty, "%% Must supply stub-router period");
6487 return CMD_WARNING;
6488 }
6489
6490 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6491
6492 ospf->stub_router_startup_time = seconds;
6493
6494 return CMD_SUCCESS;
6495}
6496
6497DEFUN (no_ospf_max_metric_router_lsa_startup,
6498 no_ospf_max_metric_router_lsa_startup_cmd,
6499 "no max-metric router-lsa on-startup",
6500 NO_STR
6501 "OSPF maximum / infinite-distance metric\n"
6502 "Advertise own Router-LSA with infinite distance (stub router)\n"
6503 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6504{
6505 struct listnode *ln;
6506 struct ospf_area *area;
6507 struct ospf *ospf = vty->index;
6508
6509 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6510
6511 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6512 {
6513 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6514 OSPF_TIMER_OFF (area->t_stub_router);
6515
6516 /* Don't trample on admin stub routed */
6517 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6518 {
6519 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006520 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006521 }
6522 }
6523 return CMD_SUCCESS;
6524}
6525
6526DEFUN (ospf_max_metric_router_lsa_shutdown,
6527 ospf_max_metric_router_lsa_shutdown_cmd,
6528 "max-metric router-lsa on-shutdown <5-86400>",
6529 "OSPF maximum / infinite-distance metric\n"
6530 "Advertise own Router-LSA with infinite distance (stub router)\n"
6531 "Advertise stub-router prior to full shutdown of OSPF\n"
6532 "Time (seconds) to wait till full shutdown\n")
6533{
6534 unsigned int seconds;
6535 struct ospf *ospf = vty->index;
6536
6537 if (argc != 1)
6538 {
6539 vty_out (vty, "%% Must supply stub-router shutdown period");
6540 return CMD_WARNING;
6541 }
6542
6543 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6544
6545 ospf->stub_router_shutdown_time = seconds;
6546
6547 return CMD_SUCCESS;
6548}
6549
6550DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6551 no_ospf_max_metric_router_lsa_shutdown_cmd,
6552 "no max-metric router-lsa on-shutdown",
6553 NO_STR
6554 "OSPF maximum / infinite-distance metric\n"
6555 "Advertise own Router-LSA with infinite distance (stub router)\n"
6556 "Advertise stub-router prior to full shutdown of OSPF\n")
6557{
6558 struct ospf *ospf = vty->index;
6559
6560 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6561
6562 return CMD_SUCCESS;
6563}
6564
6565static void
6566config_write_stub_router (struct vty *vty, struct ospf *ospf)
6567{
6568 struct listnode *ln;
6569 struct ospf_area *area;
6570
6571 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6572 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6573 ospf->stub_router_startup_time, VTY_NEWLINE);
6574 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6575 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6576 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6577 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6578 {
6579 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6580 {
6581 vty_out (vty, " max-metric router-lsa administrative%s",
6582 VTY_NEWLINE);
6583 break;
6584 }
6585 }
6586 return;
6587}
David Lamparter6b0655a2014-06-04 06:53:35 +02006588
paul4dadc292005-05-06 21:37:42 +00006589static void
paul718e3742002-12-13 20:15:29 +00006590show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6591{
6592 struct route_node *rn;
6593 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006594 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006595 struct ospf_path *path;
6596
6597 vty_out (vty, "============ OSPF network routing table ============%s",
6598 VTY_NEWLINE);
6599
6600 for (rn = route_top (rt); rn; rn = route_next (rn))
6601 if ((or = rn->info) != NULL)
6602 {
6603 char buf1[19];
6604 snprintf (buf1, 19, "%s/%d",
6605 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6606
6607 switch (or->path_type)
6608 {
6609 case OSPF_PATH_INTER_AREA:
6610 if (or->type == OSPF_DESTINATION_NETWORK)
6611 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6612 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6613 else if (or->type == OSPF_DESTINATION_DISCARD)
6614 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6615 break;
6616 case OSPF_PATH_INTRA_AREA:
6617 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6618 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6619 break;
6620 default:
6621 break;
6622 }
6623
6624 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006625 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006626 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006627 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00006628 {
6629 if (path->nexthop.s_addr == 0)
6630 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006631 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006632 else
6633 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006634 inet_ntoa (path->nexthop),
6635 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006636 }
6637 }
paul718e3742002-12-13 20:15:29 +00006638 }
6639 vty_out (vty, "%s", VTY_NEWLINE);
6640}
6641
paul4dadc292005-05-06 21:37:42 +00006642static void
paul718e3742002-12-13 20:15:29 +00006643show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6644{
6645 struct route_node *rn;
6646 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006647 struct listnode *pnode;
6648 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006649 struct ospf_path *path;
6650
6651 vty_out (vty, "============ OSPF router routing table =============%s",
6652 VTY_NEWLINE);
6653 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6654 if (rn->info)
6655 {
6656 int flag = 0;
6657
6658 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6659
paul1eb8ef22005-04-07 07:30:20 +00006660 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6661 {
6662 if (flag++)
6663 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006664
paul1eb8ef22005-04-07 07:30:20 +00006665 /* Show path. */
6666 vty_out (vty, "%s [%d] area: %s",
6667 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6668 or->cost, inet_ntoa (or->u.std.area_id));
6669 /* Show flags. */
6670 vty_out (vty, "%s%s%s",
6671 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6672 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6673 VTY_NEWLINE);
6674
6675 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6676 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006677 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00006678 {
6679 if (path->nexthop.s_addr == 0)
6680 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006681 "", ifindex2ifname (path->ifindex),
6682 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006683 else
6684 vty_out (vty, "%24s via %s, %s%s", "",
6685 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006686 ifindex2ifname (path->ifindex),
6687 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006688 }
paul1eb8ef22005-04-07 07:30:20 +00006689 }
6690 }
paul718e3742002-12-13 20:15:29 +00006691 }
6692 vty_out (vty, "%s", VTY_NEWLINE);
6693}
6694
paul4dadc292005-05-06 21:37:42 +00006695static void
paul718e3742002-12-13 20:15:29 +00006696show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6697{
6698 struct route_node *rn;
6699 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006700 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006701 struct ospf_path *path;
6702
6703 vty_out (vty, "============ OSPF external routing table ===========%s",
6704 VTY_NEWLINE);
6705 for (rn = route_top (rt); rn; rn = route_next (rn))
6706 if ((er = rn->info) != NULL)
6707 {
6708 char buf1[19];
6709 snprintf (buf1, 19, "%s/%d",
6710 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6711
6712 switch (er->path_type)
6713 {
6714 case OSPF_PATH_TYPE1_EXTERNAL:
6715 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6716 er->cost, er->u.ext.tag, VTY_NEWLINE);
6717 break;
6718 case OSPF_PATH_TYPE2_EXTERNAL:
6719 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6720 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6721 break;
6722 }
6723
paul1eb8ef22005-04-07 07:30:20 +00006724 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006725 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006726 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00006727 {
6728 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006729 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006730 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006731 else
6732 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006733 inet_ntoa (path->nexthop),
6734 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00006735 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006736 }
6737 }
6738 }
6739 vty_out (vty, "%s", VTY_NEWLINE);
6740}
6741
paul718e3742002-12-13 20:15:29 +00006742DEFUN (show_ip_ospf_border_routers,
6743 show_ip_ospf_border_routers_cmd,
6744 "show ip ospf border-routers",
6745 SHOW_STR
6746 IP_STR
6747 "show all the ABR's and ASBR's\n"
6748 "for this area\n")
6749{
paul020709f2003-04-04 02:44:16 +00006750 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006751
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006752 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006753 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006754 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006755 return CMD_SUCCESS;
6756 }
6757
paul68980082003-03-25 05:07:42 +00006758 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006759 {
6760 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6761 return CMD_SUCCESS;
6762 }
6763
6764 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006765 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006766
6767 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006768 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006769
6770 return CMD_SUCCESS;
6771}
paul718e3742002-12-13 20:15:29 +00006772
6773DEFUN (show_ip_ospf_route,
6774 show_ip_ospf_route_cmd,
6775 "show ip ospf route",
6776 SHOW_STR
6777 IP_STR
6778 "OSPF information\n"
6779 "OSPF routing table\n")
6780{
paul020709f2003-04-04 02:44:16 +00006781 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006782
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006783 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006784 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006785 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006786 return CMD_SUCCESS;
6787 }
6788
paul68980082003-03-25 05:07:42 +00006789 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006790 {
6791 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6792 return CMD_SUCCESS;
6793 }
6794
6795 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006796 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006797
6798 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006799 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006800
6801 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006802 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006803
6804 return CMD_SUCCESS;
6805}
6806
David Lamparter6b0655a2014-06-04 06:53:35 +02006807
hassoeb1ce602004-10-08 08:17:22 +00006808const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006809{
6810 "unknown",
6811 "standard",
6812 "ibm",
6813 "cisco",
6814 "shortcut"
6815};
6816
hassoeb1ce602004-10-08 08:17:22 +00006817const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006818{
6819 "default",
6820 "enable",
6821 "disable"
6822};
6823
6824
paul4dadc292005-05-06 21:37:42 +00006825static void
paul718e3742002-12-13 20:15:29 +00006826area_id2str (char *buf, int length, struct ospf_area *area)
6827{
6828 memset (buf, 0, length);
6829
6830 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6831 strncpy (buf, inet_ntoa (area->area_id), length);
6832 else
6833 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6834}
6835
David Lamparter6b0655a2014-06-04 06:53:35 +02006836
hassoeb1ce602004-10-08 08:17:22 +00006837const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006838{
6839 "unknown", /* should never be used. */
6840 "point-to-point",
6841 "broadcast",
6842 "non-broadcast",
6843 "point-to-multipoint",
6844 "virtual-link", /* should never be used. */
6845 "loopback"
6846};
6847
6848/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00006849static int
paul718e3742002-12-13 20:15:29 +00006850config_write_interface (struct vty *vty)
6851{
hasso52dc7ee2004-09-23 19:18:23 +00006852 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006853 struct interface *ifp;
6854 struct crypt_key *ck;
6855 int write = 0;
6856 struct route_node *rn = NULL;
6857 struct ospf_if_params *params;
6858
paul1eb8ef22005-04-07 07:30:20 +00006859 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006860 {
paul718e3742002-12-13 20:15:29 +00006861 if (memcmp (ifp->name, "VLINK", 5) == 0)
6862 continue;
6863
6864 vty_out (vty, "!%s", VTY_NEWLINE);
6865 vty_out (vty, "interface %s%s", ifp->name,
6866 VTY_NEWLINE);
6867 if (ifp->desc)
6868 vty_out (vty, " description %s%s", ifp->desc,
6869 VTY_NEWLINE);
6870
6871 write++;
6872
6873 params = IF_DEF_PARAMS (ifp);
6874
6875 do {
6876 /* Interface Network print. */
6877 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006878 params->type != OSPF_IFTYPE_LOOPBACK)
6879 {
ajsbc18d612004-12-15 15:07:19 +00006880 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006881 {
6882 vty_out (vty, " ip ospf network %s",
6883 ospf_int_type_str[params->type]);
6884 if (params != IF_DEF_PARAMS (ifp))
6885 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6886 vty_out (vty, "%s", VTY_NEWLINE);
6887 }
paul718e3742002-12-13 20:15:29 +00006888 }
6889
6890 /* OSPF interface authentication print */
6891 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6892 params->auth_type != OSPF_AUTH_NOTSET)
6893 {
hassoeb1ce602004-10-08 08:17:22 +00006894 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006895
6896 /* Translation tables are not that much help here due to syntax
6897 of the simple option */
6898 switch (params->auth_type)
6899 {
6900
6901 case OSPF_AUTH_NULL:
6902 auth_str = " null";
6903 break;
6904
6905 case OSPF_AUTH_SIMPLE:
6906 auth_str = "";
6907 break;
6908
6909 case OSPF_AUTH_CRYPTOGRAPHIC:
6910 auth_str = " message-digest";
6911 break;
6912
6913 default:
6914 auth_str = "";
6915 break;
6916 }
6917
6918 vty_out (vty, " ip ospf authentication%s", auth_str);
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 }
6923
6924 /* Simple Authentication Password print. */
6925 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6926 params->auth_simple[0] != '\0')
6927 {
6928 vty_out (vty, " ip ospf authentication-key %s",
6929 params->auth_simple);
6930 if (params != IF_DEF_PARAMS (ifp))
6931 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6932 vty_out (vty, "%s", VTY_NEWLINE);
6933 }
6934
6935 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00006936 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00006937 {
paul718e3742002-12-13 20:15:29 +00006938 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6939 ck->key_id, ck->auth_key);
6940 if (params != IF_DEF_PARAMS (ifp))
6941 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6942 vty_out (vty, "%s", VTY_NEWLINE);
6943 }
6944
6945 /* Interface Output Cost print. */
6946 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6947 {
6948 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6949 if (params != IF_DEF_PARAMS (ifp))
6950 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6951 vty_out (vty, "%s", VTY_NEWLINE);
6952 }
6953
6954 /* Hello Interval print. */
6955 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6956 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6957 {
6958 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6959 if (params != IF_DEF_PARAMS (ifp))
6960 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6961 vty_out (vty, "%s", VTY_NEWLINE);
6962 }
6963
6964
6965 /* Router Dead Interval print. */
6966 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6967 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6968 {
paulf9ad9372005-10-21 00:45:17 +00006969 vty_out (vty, " ip ospf dead-interval ");
6970
6971 /* fast hello ? */
6972 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
6973 vty_out (vty, "minimal hello-multiplier %d",
6974 params->fast_hello);
6975 else
6976 vty_out (vty, "%u", params->v_wait);
6977
paul718e3742002-12-13 20:15:29 +00006978 if (params != IF_DEF_PARAMS (ifp))
6979 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6980 vty_out (vty, "%s", VTY_NEWLINE);
6981 }
6982
6983 /* Router Priority print. */
6984 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6985 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6986 {
6987 vty_out (vty, " ip ospf priority %u", params->priority);
6988 if (params != IF_DEF_PARAMS (ifp))
6989 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6990 vty_out (vty, "%s", VTY_NEWLINE);
6991 }
6992
6993 /* Retransmit Interval print. */
6994 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6995 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6996 {
6997 vty_out (vty, " ip ospf retransmit-interval %u",
6998 params->retransmit_interval);
6999 if (params != IF_DEF_PARAMS (ifp))
7000 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7001 vty_out (vty, "%s", VTY_NEWLINE);
7002 }
7003
7004 /* Transmit Delay print. */
7005 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7006 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7007 {
7008 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7009 if (params != IF_DEF_PARAMS (ifp))
7010 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7011 vty_out (vty, "%s", VTY_NEWLINE);
7012 }
7013
Joakim Tjernlund738bce72009-08-07 13:48:15 +02007014 /* Area print. */
7015 if (OSPF_IF_PARAM_CONFIGURED (params, if_area))
7016 {
7017 vty_out (vty, " ip ospf area %s%s",
7018 inet_ntoa (params->if_area),
7019 VTY_NEWLINE);
7020 }
7021
vincentba682532005-09-29 13:52:57 +00007022 /* MTU ignore print. */
7023 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7024 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7025 {
7026 if (params->mtu_ignore == 0)
7027 vty_out (vty, " no ip ospf mtu-ignore");
7028 else
7029 vty_out (vty, " ip ospf mtu-ignore");
7030 if (params != IF_DEF_PARAMS (ifp))
7031 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7032 vty_out (vty, "%s", VTY_NEWLINE);
7033 }
7034
7035
paul718e3742002-12-13 20:15:29 +00007036 while (1)
7037 {
7038 if (rn == NULL)
7039 rn = route_top (IF_OIFS_PARAMS (ifp));
7040 else
7041 rn = route_next (rn);
7042
7043 if (rn == NULL)
7044 break;
7045 params = rn->info;
7046 if (params != NULL)
7047 break;
7048 }
7049 } while (rn);
7050
7051#ifdef HAVE_OPAQUE_LSA
7052 ospf_opaque_config_write_if (vty, ifp);
7053#endif /* HAVE_OPAQUE_LSA */
7054 }
7055
7056 return write;
7057}
7058
paul4dadc292005-05-06 21:37:42 +00007059static int
paul68980082003-03-25 05:07:42 +00007060config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007061{
7062 struct route_node *rn;
7063 u_char buf[INET_ADDRSTRLEN];
7064
7065 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007066 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007067 if (rn->info)
7068 {
7069 struct ospf_network *n = rn->info;
7070
7071 memset (buf, 0, INET_ADDRSTRLEN);
7072
7073 /* Create Area ID string by specified Area ID format. */
7074 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007075 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007076 else
hassoc9e52be2004-09-26 16:09:34 +00007077 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007078 (unsigned long int) ntohl (n->area_id.s_addr));
7079
7080 /* Network print. */
7081 vty_out (vty, " network %s/%d area %s%s",
7082 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7083 buf, VTY_NEWLINE);
7084 }
7085
7086 return 0;
7087}
7088
paul4dadc292005-05-06 21:37:42 +00007089static int
paul68980082003-03-25 05:07:42 +00007090config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007091{
hasso52dc7ee2004-09-23 19:18:23 +00007092 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007093 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007094 u_char buf[INET_ADDRSTRLEN];
7095
7096 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007097 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007098 {
paul718e3742002-12-13 20:15:29 +00007099 struct route_node *rn1;
7100
hassoc9e52be2004-09-26 16:09:34 +00007101 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007102
7103 if (area->auth_type != OSPF_AUTH_NULL)
7104 {
7105 if (area->auth_type == OSPF_AUTH_SIMPLE)
7106 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7107 else
7108 vty_out (vty, " area %s authentication message-digest%s",
7109 buf, VTY_NEWLINE);
7110 }
7111
7112 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7113 vty_out (vty, " area %s shortcut %s%s", buf,
7114 ospf_shortcut_mode_str[area->shortcut_configured],
7115 VTY_NEWLINE);
7116
7117 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007118 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007119 )
7120 {
paulb0a053b2003-06-22 09:04:47 +00007121 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007122 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007123 else if (area->external_routing == OSPF_AREA_NSSA)
7124 {
7125 vty_out (vty, " area %s nssa", buf);
7126 switch (area->NSSATranslatorRole)
7127 {
7128 case OSPF_NSSA_ROLE_NEVER:
7129 vty_out (vty, " translate-never");
7130 break;
7131 case OSPF_NSSA_ROLE_ALWAYS:
7132 vty_out (vty, " translate-always");
7133 break;
7134 case OSPF_NSSA_ROLE_CANDIDATE:
7135 default:
7136 vty_out (vty, " translate-candidate");
7137 }
7138 }
paul718e3742002-12-13 20:15:29 +00007139
7140 if (area->no_summary)
7141 vty_out (vty, " no-summary");
7142
7143 vty_out (vty, "%s", VTY_NEWLINE);
7144
7145 if (area->default_cost != 1)
7146 vty_out (vty, " area %s default-cost %d%s", buf,
7147 area->default_cost, VTY_NEWLINE);
7148 }
7149
7150 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7151 if (rn1->info)
7152 {
7153 struct ospf_area_range *range = rn1->info;
7154
7155 vty_out (vty, " area %s range %s/%d", buf,
7156 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7157
paul6c835672004-10-11 11:00:30 +00007158 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007159 vty_out (vty, " cost %d", range->cost_config);
7160
7161 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7162 vty_out (vty, " not-advertise");
7163
7164 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7165 vty_out (vty, " substitute %s/%d",
7166 inet_ntoa (range->subst_addr), range->subst_masklen);
7167
7168 vty_out (vty, "%s", VTY_NEWLINE);
7169 }
7170
7171 if (EXPORT_NAME (area))
7172 vty_out (vty, " area %s export-list %s%s", buf,
7173 EXPORT_NAME (area), VTY_NEWLINE);
7174
7175 if (IMPORT_NAME (area))
7176 vty_out (vty, " area %s import-list %s%s", buf,
7177 IMPORT_NAME (area), VTY_NEWLINE);
7178
7179 if (PREFIX_NAME_IN (area))
7180 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7181 PREFIX_NAME_IN (area), VTY_NEWLINE);
7182
7183 if (PREFIX_NAME_OUT (area))
7184 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7185 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7186 }
7187
7188 return 0;
7189}
7190
paul4dadc292005-05-06 21:37:42 +00007191static int
paul68980082003-03-25 05:07:42 +00007192config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007193{
7194 struct ospf_nbr_nbma *nbr_nbma;
7195 struct route_node *rn;
7196
7197 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007198 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007199 if ((nbr_nbma = rn->info))
7200 {
7201 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7202
7203 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7204 vty_out (vty, " priority %d", nbr_nbma->priority);
7205
7206 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7207 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7208
7209 vty_out (vty, "%s", VTY_NEWLINE);
7210 }
7211
7212 return 0;
7213}
7214
paul4dadc292005-05-06 21:37:42 +00007215static int
paul68980082003-03-25 05:07:42 +00007216config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007217{
hasso52dc7ee2004-09-23 19:18:23 +00007218 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007219 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007220 u_char buf[INET_ADDRSTRLEN];
7221
7222 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007223 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007224 {
hasso52dc7ee2004-09-23 19:18:23 +00007225 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007226 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007227 struct ospf_interface *oi;
7228
7229 if (vl_data != NULL)
7230 {
7231 memset (buf, 0, INET_ADDRSTRLEN);
7232
7233 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007234 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007235 else
hassoc9e52be2004-09-26 16:09:34 +00007236 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007237 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7238 oi = vl_data->vl_oi;
7239
7240 /* timers */
7241 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7242 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7243 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7244 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7245 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7246 buf,
7247 inet_ntoa (vl_data->vl_peer),
7248 OSPF_IF_PARAM (oi, v_hello),
7249 OSPF_IF_PARAM (oi, retransmit_interval),
7250 OSPF_IF_PARAM (oi, transmit_delay),
7251 OSPF_IF_PARAM (oi, v_wait),
7252 VTY_NEWLINE);
7253 else
7254 vty_out (vty, " area %s virtual-link %s%s", buf,
7255 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7256 /* Auth key */
7257 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7258 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7259 buf,
7260 inet_ntoa (vl_data->vl_peer),
7261 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7262 VTY_NEWLINE);
7263 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007264 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7265 n2, ck))
7266 vty_out (vty, " area %s virtual-link %s"
7267 " message-digest-key %d md5 %s%s",
7268 buf,
7269 inet_ntoa (vl_data->vl_peer),
7270 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007271
7272 }
7273 }
7274
7275 return 0;
7276}
7277
David Lamparter6b0655a2014-06-04 06:53:35 +02007278
paul4dadc292005-05-06 21:37:42 +00007279static int
paul68980082003-03-25 05:07:42 +00007280config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007281{
7282 int type;
7283
7284 /* redistribute print. */
7285 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Feng Luc99f3482014-10-16 09:52:36 +08007286 if (type != zclient->redist_default &&
7287 vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT))
paul718e3742002-12-13 20:15:29 +00007288 {
ajsf52d13c2005-10-01 17:38:06 +00007289 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007290 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007291 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007292
paul68980082003-03-25 05:07:42 +00007293 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007294 vty_out (vty, " metric-type 1");
7295
paul020709f2003-04-04 02:44:16 +00007296 if (ROUTEMAP_NAME (ospf, type))
7297 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007298
7299 vty_out (vty, "%s", VTY_NEWLINE);
7300 }
7301
7302 return 0;
7303}
7304
paul4dadc292005-05-06 21:37:42 +00007305static int
paul68980082003-03-25 05:07:42 +00007306config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007307{
paul68980082003-03-25 05:07:42 +00007308 if (ospf->default_metric != -1)
7309 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007310 VTY_NEWLINE);
7311 return 0;
7312}
7313
paul4dadc292005-05-06 21:37:42 +00007314static int
paul68980082003-03-25 05:07:42 +00007315config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007316{
7317 int type;
7318
paul68980082003-03-25 05:07:42 +00007319 if (ospf)
paul718e3742002-12-13 20:15:29 +00007320 {
7321 /* distribute-list print. */
7322 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007323 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007324 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007325 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007326 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007327
7328 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007329 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007330 {
paulc42c1772006-01-10 20:36:49 +00007331 vty_out (vty, " default-information originate");
7332 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7333 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007334
paul68980082003-03-25 05:07:42 +00007335 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007336 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007337 ospf->dmetric[DEFAULT_ROUTE].value);
7338 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007339 vty_out (vty, " metric-type 1");
7340
paul020709f2003-04-04 02:44:16 +00007341 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7342 vty_out (vty, " route-map %s",
7343 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007344
7345 vty_out (vty, "%s", VTY_NEWLINE);
7346 }
7347
7348 }
7349
7350 return 0;
7351}
7352
paul4dadc292005-05-06 21:37:42 +00007353static int
paul68980082003-03-25 05:07:42 +00007354config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007355{
7356 struct route_node *rn;
7357 struct ospf_distance *odistance;
7358
paul68980082003-03-25 05:07:42 +00007359 if (ospf->distance_all)
7360 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007361
paul68980082003-03-25 05:07:42 +00007362 if (ospf->distance_intra
7363 || ospf->distance_inter
7364 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007365 {
7366 vty_out (vty, " distance ospf");
7367
paul68980082003-03-25 05:07:42 +00007368 if (ospf->distance_intra)
7369 vty_out (vty, " intra-area %d", ospf->distance_intra);
7370 if (ospf->distance_inter)
7371 vty_out (vty, " inter-area %d", ospf->distance_inter);
7372 if (ospf->distance_external)
7373 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007374
7375 vty_out (vty, "%s", VTY_NEWLINE);
7376 }
7377
paul68980082003-03-25 05:07:42 +00007378 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007379 if ((odistance = rn->info) != NULL)
7380 {
7381 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7382 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7383 odistance->access_list ? odistance->access_list : "",
7384 VTY_NEWLINE);
7385 }
7386 return 0;
7387}
7388
7389/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007390static int
paul718e3742002-12-13 20:15:29 +00007391ospf_config_write (struct vty *vty)
7392{
paul020709f2003-04-04 02:44:16 +00007393 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007394 struct interface *ifp;
7395 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007396 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007397 int write = 0;
7398
paul020709f2003-04-04 02:44:16 +00007399 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007400 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007401 {
7402 /* `router ospf' print. */
7403 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7404
7405 write++;
7406
paul68980082003-03-25 05:07:42 +00007407 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007408 return write;
7409
7410 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007411 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007412 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007413 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007414
7415 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007416 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007417 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007418 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007419
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007420 /* log-adjacency-changes flag print. */
7421 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7422 {
7423 vty_out(vty, " log-adjacency-changes");
7424 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7425 vty_out(vty, " detail");
7426 vty_out(vty, "%s", VTY_NEWLINE);
7427 }
7428
paul718e3742002-12-13 20:15:29 +00007429 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007430 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007431 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7432
7433 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007434 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007435 {
7436 vty_out (vty, "! Important: ensure reference bandwidth "
7437 "is consistent across all routers%s", VTY_NEWLINE);
7438 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7439 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7440 }
paul718e3742002-12-13 20:15:29 +00007441
Michael Rossberg2ef762e2015-07-27 07:56:25 +02007442 /* LSA timers */
7443 if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL)
7444 vty_out (vty, " timers throttle lsa all %d%s",
7445 ospf->min_ls_interval, VTY_NEWLINE);
7446 if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL)
7447 vty_out (vty, " timers lsa arrival %d%s",
7448 ospf->min_ls_arrival, VTY_NEWLINE);
7449
paul718e3742002-12-13 20:15:29 +00007450 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007451 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007452 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7453 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7454 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007455 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007456 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007457
7458 /* Max-metric router-lsa print */
7459 config_write_stub_router (vty, ospf);
7460
paul718e3742002-12-13 20:15:29 +00007461 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007462 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007463 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007464 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007465
7466 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007467 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007468
7469 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007470 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
7471 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
7472
paul1eb8ef22005-04-07 07:30:20 +00007473 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007474 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
7475 && IF_DEF_PARAMS (ifp)->passive_interface !=
7476 ospf->passive_interface_default)
7477 {
7478 vty_out (vty, " %spassive-interface %s%s",
7479 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
7480 ifp->name, VTY_NEWLINE);
7481 }
paul1eb8ef22005-04-07 07:30:20 +00007482 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007483 {
7484 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
7485 continue;
7486 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
7487 passive_interface))
7488 {
7489 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
7490 continue;
7491 }
7492 else if (oi->params->passive_interface == ospf->passive_interface_default)
7493 continue;
7494
7495 vty_out (vty, " %spassive-interface %s %s%s",
7496 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00007497 oi->ifp->name,
7498 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007499 }
paul718e3742002-12-13 20:15:29 +00007500
7501 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007502 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007503
7504 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007505 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007506
7507 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007508 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007509
7510 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007511 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007512
7513 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007514 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007515
7516 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007517 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007518
7519 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007520 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007521
7522#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007523 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007524#endif /* HAVE_OPAQUE_LSA */
7525 }
7526
7527 return write;
7528}
7529
7530void
paul4dadc292005-05-06 21:37:42 +00007531ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007532{
7533 /* "show ip ospf" commands. */
7534 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7535 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7536
7537 /* "show ip ospf database" commands. */
7538 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7539 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7540 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7541 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7542 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7543 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7544 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7545 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7546 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7547 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7548 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7549 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7550 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7551 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7552
7553 /* "show ip ospf interface" commands. */
7554 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7555 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7556
7557 /* "show ip ospf neighbor" commands. */
7558 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7559 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7560 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7561 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7562 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7563 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7564 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7565 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7566 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7567 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7568 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7569 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7570 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7571 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7572
7573 /* "show ip ospf route" commands. */
7574 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7575 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007576 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7577 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007578}
7579
David Lamparter6b0655a2014-06-04 06:53:35 +02007580
paul718e3742002-12-13 20:15:29 +00007581/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007582static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00007583{
7584 INTERFACE_NODE,
7585 "%s(config-if)# ",
7586 1
7587};
7588
7589/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007590static void
7591ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007592{
7593 /* Install interface node. */
7594 install_node (&interface_node, config_write_interface);
7595
7596 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007597 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007598 install_default (INTERFACE_NODE);
7599
7600 /* "description" commands. */
7601 install_element (INTERFACE_NODE, &interface_desc_cmd);
7602 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7603
7604 /* "ip ospf authentication" commands. */
7605 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7606 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7607 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7608 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7609 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7610 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7611 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7612 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7613 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7614 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7615
7616 /* "ip ospf message-digest-key" commands. */
7617 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7618 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7619 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7620 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7621
7622 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007623 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
7624 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007625 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
7626 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007627 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007628 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7629
vincentba682532005-09-29 13:52:57 +00007630 /* "ip ospf mtu-ignore" commands. */
7631 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7632 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7633 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7634 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7635
paul718e3742002-12-13 20:15:29 +00007636 /* "ip ospf dead-interval" commands. */
7637 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7638 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007639 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7640 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007641 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7642 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007643
paul718e3742002-12-13 20:15:29 +00007644 /* "ip ospf hello-interval" commands. */
7645 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7646 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7647 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7648 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7649
7650 /* "ip ospf network" commands. */
7651 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7652 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7653
7654 /* "ip ospf priority" commands. */
7655 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7656 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7657 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7658 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7659
7660 /* "ip ospf retransmit-interval" commands. */
7661 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7662 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7663 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7664 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7665
7666 /* "ip ospf transmit-delay" commands. */
7667 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7668 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7669 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7670 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7671
Joakim Tjernlund738bce72009-08-07 13:48:15 +02007672 /* "ip ospf area" commands. */
7673 install_element (INTERFACE_NODE, &ip_ospf_area_cmd);
7674 install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd);
7675
paul718e3742002-12-13 20:15:29 +00007676 /* These commands are compatibitliy for previous version. */
7677 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7678 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7679 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7680 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007681 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
7682 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007683 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007684 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
7685 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007686 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007687 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7688 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7689 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7690 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7691 install_element (INTERFACE_NODE, &ospf_network_cmd);
7692 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7693 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7694 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7695 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7696 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7697 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7698 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7699}
7700
paul4dadc292005-05-06 21:37:42 +00007701static void
7702ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007703{
paul718e3742002-12-13 20:15:29 +00007704 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
paul718e3742002-12-13 20:15:29 +00007705 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7706
7707 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7708 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7709
paul718e3742002-12-13 20:15:29 +00007710 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
paul718e3742002-12-13 20:15:29 +00007711 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7712
7713 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7714 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7715 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7716
7717 install_element (OSPF_NODE, &ospf_distance_cmd);
7718 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7719 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
Christian Franke6f2a6702013-09-30 12:27:52 +00007720 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
paul718e3742002-12-13 20:15:29 +00007721#if 0
7722 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7723 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7724 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7725 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7726#endif /* 0 */
7727}
7728
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007729static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00007730{
7731 OSPF_NODE,
7732 "%s(config-router)# ",
7733 1
7734};
7735
David Lamparter6b0655a2014-06-04 06:53:35 +02007736
paul718e3742002-12-13 20:15:29 +00007737/* Install OSPF related vty commands. */
7738void
paul4dadc292005-05-06 21:37:42 +00007739ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007740{
7741 /* Install ospf top node. */
7742 install_node (&ospf_node, ospf_config_write);
7743
7744 /* "router ospf" commands. */
7745 install_element (CONFIG_NODE, &router_ospf_cmd);
7746 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7747
7748 install_default (OSPF_NODE);
7749
7750 /* "ospf router-id" commands. */
7751 install_element (OSPF_NODE, &ospf_router_id_cmd);
7752 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007753 install_element (OSPF_NODE, &router_ospf_id_cmd);
7754 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007755
7756 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007757 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7758 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007759 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00007760 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7761 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007762 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00007763
7764 /* "ospf abr-type" commands. */
7765 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7766 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7767
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007768 /* "ospf log-adjacency-changes" commands. */
7769 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
7770 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
7771 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
7772 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
7773
paul718e3742002-12-13 20:15:29 +00007774 /* "ospf rfc1583-compatible" commands. */
7775 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7776 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7777 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7778 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7779
7780 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007781 install_element (OSPF_NODE, &ospf_network_area_cmd);
7782 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007783
7784 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007785 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7786 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7787 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007788
7789 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007790 install_element (OSPF_NODE, &ospf_area_range_cmd);
7791 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7792 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7793 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7794 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7795 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7796 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7797 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7798 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7799 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7800 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007801
7802 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007803 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7804 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007805
paula2c62832003-04-23 17:01:31 +00007806 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7807 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007808
paula2c62832003-04-23 17:01:31 +00007809 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7810 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007811
paula2c62832003-04-23 17:01:31 +00007812 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7813 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007814
paula2c62832003-04-23 17:01:31 +00007815 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7816 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007817
paula2c62832003-04-23 17:01:31 +00007818 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7819 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7820 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007821
paula2c62832003-04-23 17:01:31 +00007822 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7823 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007824
paula2c62832003-04-23 17:01:31 +00007825 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7826 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007827
paula2c62832003-04-23 17:01:31 +00007828 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7829 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7830 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007831
paula2c62832003-04-23 17:01:31 +00007832 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7833 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7834 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007835
7836 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007837 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7838 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7839 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7840 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007841
paul718e3742002-12-13 20:15:29 +00007842 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007843 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7844 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7845 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7846 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7847 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7848 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007849
paula2c62832003-04-23 17:01:31 +00007850 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7851 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007852
paula2c62832003-04-23 17:01:31 +00007853 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7854 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007855
paula2c62832003-04-23 17:01:31 +00007856 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7857 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007858
paula2c62832003-04-23 17:01:31 +00007859 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7860 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007861
paula2c62832003-04-23 17:01:31 +00007862 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7863 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00007864
Michael Rossberg2ef762e2015-07-27 07:56:25 +02007865 /* LSA timer commands */
7866 install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd);
7867 install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd);
7868 install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd);
7869 install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd);
7870
paul88d6cf32005-10-29 12:50:09 +00007871 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00007872 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7873 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00007874 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
7875 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
7876
paul88d6cf32005-10-29 12:50:09 +00007877 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00007878 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7879 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7880 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007881
paul88d6cf32005-10-29 12:50:09 +00007882 /* max-metric commands */
7883 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
7884 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
7885 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
7886 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
7887 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
7888 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
7889
7890 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00007891 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7892 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007893
7894 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007895 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7896 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7897 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7898 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7899 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7900 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7901 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7902 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007903
7904 /* Init interface related vty commands. */
7905 ospf_vty_if_init ();
7906
7907 /* Init zebra related vty commands. */
7908 ospf_vty_zebra_init ();
7909}