blob: 2fcdedc1eb401eb855ebb0013897d68de5b707d3 [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
pauld24f6e22005-10-21 09:23:12 +00002236DEFUN (ospf_timers_throttle_spf,
2237 ospf_timers_throttle_spf_cmd,
2238 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2239 "Adjust routing timers\n"
2240 "Throttling adaptive timer\n"
2241 "OSPF SPF timers\n"
2242 "Delay (msec) from first change received till SPF calculation\n"
2243 "Initial hold time (msec) between consecutive SPF calculations\n"
2244 "Maximum hold time (msec)\n")
2245{
2246 unsigned int delay, hold, max;
2247
2248 if (argc != 3)
2249 {
2250 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2251 return CMD_WARNING;
2252 }
2253
2254 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2255 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2256 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2257
2258 return ospf_timers_spf_set (vty, delay, hold, max);
2259}
2260
2261DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002262 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002263 "timers spf <0-4294967295> <0-4294967295>",
2264 "Adjust routing timers\n"
2265 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002266 "Delay (s) between receiving a change to SPF calculation\n"
2267 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002268{
pauld24f6e22005-10-21 09:23:12 +00002269 unsigned int delay, hold;
2270
2271 if (argc != 2)
2272 {
2273 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2274 return CMD_WARNING;
2275 }
2276
paul4dadc292005-05-06 21:37:42 +00002277 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2278 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002279
2280 /* truncate down the second values if they're greater than 600000ms */
2281 if (delay > (600000 / 1000))
2282 delay = 600000;
2283 else if (delay == 0)
2284 /* 0s delay was probably specified because of lack of ms resolution */
2285 delay = OSPF_SPF_DELAY_DEFAULT;
2286 if (hold > (600000 / 1000))
2287 hold = 600000;
2288
2289 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002290}
2291
pauld24f6e22005-10-21 09:23:12 +00002292DEFUN (no_ospf_timers_throttle_spf,
2293 no_ospf_timers_throttle_spf_cmd,
2294 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002295 NO_STR
2296 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002297 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002298 "OSPF SPF timers\n")
2299{
pauld24f6e22005-10-21 09:23:12 +00002300 return ospf_timers_spf_set (vty,
2301 OSPF_SPF_DELAY_DEFAULT,
2302 OSPF_SPF_HOLDTIME_DEFAULT,
2303 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002304}
2305
pauld24f6e22005-10-21 09:23:12 +00002306ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2307 no_ospf_timers_spf_cmd,
2308 "no timers spf",
2309 NO_STR
2310 "Adjust routing timers\n"
2311 "OSPF SPF timers\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002312
paula2c62832003-04-23 17:01:31 +00002313DEFUN (ospf_neighbor,
2314 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002315 "neighbor A.B.C.D",
2316 NEIGHBOR_STR
2317 "Neighbor IP address\n")
2318{
2319 struct ospf *ospf = vty->index;
2320 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002321 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2322 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002323
2324 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2325
2326 if (argc > 1)
2327 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2328
2329 if (argc > 2)
2330 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2331
2332 ospf_nbr_nbma_set (ospf, nbr_addr);
2333 if (argc > 1)
2334 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2335 if (argc > 2)
Andrew Certain1a61ad12012-12-04 12:50:23 -08002336 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
paul718e3742002-12-13 20:15:29 +00002337
2338 return CMD_SUCCESS;
2339}
2340
paula2c62832003-04-23 17:01:31 +00002341ALIAS (ospf_neighbor,
2342 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002343 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2344 NEIGHBOR_STR
2345 "Neighbor IP address\n"
2346 "Neighbor Priority\n"
2347 "Priority\n"
2348 "Dead Neighbor Polling interval\n"
2349 "Seconds\n")
2350
paula2c62832003-04-23 17:01:31 +00002351ALIAS (ospf_neighbor,
2352 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002353 "neighbor A.B.C.D priority <0-255>",
2354 NEIGHBOR_STR
2355 "Neighbor IP address\n"
2356 "Neighbor Priority\n"
2357 "Seconds\n")
2358
paula2c62832003-04-23 17:01:31 +00002359DEFUN (ospf_neighbor_poll_interval,
2360 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002361 "neighbor A.B.C.D poll-interval <1-65535>",
2362 NEIGHBOR_STR
2363 "Neighbor IP address\n"
2364 "Dead Neighbor Polling interval\n"
2365 "Seconds\n")
2366{
2367 struct ospf *ospf = vty->index;
2368 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002369 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2370 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002371
2372 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2373
2374 if (argc > 1)
2375 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2376
2377 if (argc > 2)
2378 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2379
2380 ospf_nbr_nbma_set (ospf, nbr_addr);
2381 if (argc > 1)
2382 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2383 if (argc > 2)
2384 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2385
2386 return CMD_SUCCESS;
2387}
2388
paula2c62832003-04-23 17:01:31 +00002389ALIAS (ospf_neighbor_poll_interval,
2390 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002391 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2392 NEIGHBOR_STR
2393 "Neighbor address\n"
2394 "OSPF dead-router polling interval\n"
2395 "Seconds\n"
2396 "OSPF priority of non-broadcast neighbor\n"
2397 "Priority\n")
2398
paula2c62832003-04-23 17:01:31 +00002399DEFUN (no_ospf_neighbor,
2400 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002401 "no neighbor A.B.C.D",
2402 NO_STR
2403 NEIGHBOR_STR
2404 "Neighbor IP address\n")
2405{
2406 struct ospf *ospf = vty->index;
2407 struct in_addr nbr_addr;
paul718e3742002-12-13 20:15:29 +00002408
2409 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2410
Andrew Certain0798cee2012-12-04 13:43:42 -08002411 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
paul718e3742002-12-13 20:15:29 +00002412
2413 return CMD_SUCCESS;
2414}
2415
paula2c62832003-04-23 17:01:31 +00002416ALIAS (no_ospf_neighbor,
2417 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002418 "no neighbor A.B.C.D priority <0-255>",
2419 NO_STR
2420 NEIGHBOR_STR
2421 "Neighbor IP address\n"
2422 "Neighbor Priority\n"
2423 "Priority\n")
2424
paula2c62832003-04-23 17:01:31 +00002425ALIAS (no_ospf_neighbor,
2426 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002427 "no neighbor A.B.C.D poll-interval <1-65535>",
2428 NO_STR
2429 NEIGHBOR_STR
2430 "Neighbor IP address\n"
2431 "Dead Neighbor Polling interval\n"
2432 "Seconds\n")
2433
paula2c62832003-04-23 17:01:31 +00002434ALIAS (no_ospf_neighbor,
2435 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002436 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2437 NO_STR
2438 NEIGHBOR_STR
2439 "Neighbor IP address\n"
2440 "Neighbor Priority\n"
2441 "Priority\n"
2442 "Dead Neighbor Polling interval\n"
2443 "Seconds\n")
2444
David Lamparter6b0655a2014-06-04 06:53:35 +02002445
paula2c62832003-04-23 17:01:31 +00002446DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002447 "refresh timer <10-1800>",
2448 "Adjust refresh parameters\n"
2449 "Set refresh timer\n"
2450 "Timer value in seconds\n")
2451{
2452 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002453 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002454
2455 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2456 interval = (interval / 10) * 10;
2457
2458 ospf_timers_refresh_set (ospf, interval);
2459
2460 return CMD_SUCCESS;
2461}
2462
paula2c62832003-04-23 17:01:31 +00002463DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002464 "no refresh timer <10-1800>",
2465 "Adjust refresh parameters\n"
2466 "Unset refresh timer\n"
2467 "Timer value in seconds\n")
2468{
2469 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002470 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002471
2472 if (argc == 1)
2473 {
2474 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2475
2476 if (ospf->lsa_refresh_interval != interval ||
2477 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2478 return CMD_SUCCESS;
2479 }
2480
2481 ospf_timers_refresh_unset (ospf);
2482
2483 return CMD_SUCCESS;
2484}
2485
paula2c62832003-04-23 17:01:31 +00002486ALIAS (no_ospf_refresh_timer,
2487 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002488 "no refresh timer",
2489 "Adjust refresh parameters\n"
2490 "Unset refresh timer\n")
2491
paula2c62832003-04-23 17:01:31 +00002492DEFUN (ospf_auto_cost_reference_bandwidth,
2493 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002494 "auto-cost reference-bandwidth <1-4294967>",
2495 "Calculate OSPF interface cost according to bandwidth\n"
2496 "Use reference bandwidth method to assign OSPF cost\n"
2497 "The reference bandwidth in terms of Mbits per second\n")
2498{
paul68980082003-03-25 05:07:42 +00002499 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002500 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002501 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002502 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002503
2504 refbw = strtol (argv[0], NULL, 10);
2505 if (refbw < 1 || refbw > 4294967)
2506 {
2507 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2508 return CMD_WARNING;
2509 }
2510
2511 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002512 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002513 return CMD_SUCCESS;
2514
paul68980082003-03-25 05:07:42 +00002515 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002516 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2517 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002518
2519 return CMD_SUCCESS;
2520}
2521
paula2c62832003-04-23 17:01:31 +00002522DEFUN (no_ospf_auto_cost_reference_bandwidth,
2523 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002524 "no auto-cost reference-bandwidth",
2525 NO_STR
2526 "Calculate OSPF interface cost according to bandwidth\n"
2527 "Use reference bandwidth method to assign OSPF cost\n")
2528{
paul68980082003-03-25 05:07:42 +00002529 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002530 struct listnode *node, *nnode;
2531 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002532
paul68980082003-03-25 05:07:42 +00002533 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002534 return CMD_SUCCESS;
2535
paul68980082003-03-25 05:07:42 +00002536 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002537 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2538 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2539
paul1eb8ef22005-04-07 07:30:20 +00002540 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2541 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002542
2543 return CMD_SUCCESS;
2544}
2545
hassoeb1ce602004-10-08 08:17:22 +00002546const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002547{
2548 "Unknown",
2549 "Standard (RFC2328)",
2550 "Alternative IBM",
2551 "Alternative Cisco",
2552 "Alternative Shortcut"
2553};
2554
hassoeb1ce602004-10-08 08:17:22 +00002555const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002556{
2557 "Default",
2558 "Enabled",
2559 "Disabled"
2560};
2561
2562
David Lamparter6b0655a2014-06-04 06:53:35 +02002563
paul4dadc292005-05-06 21:37:42 +00002564static void
paul718e3742002-12-13 20:15:29 +00002565show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2566{
2567 /* Show Area ID. */
2568 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2569
2570 /* Show Area type/mode. */
2571 if (OSPF_IS_AREA_BACKBONE (area))
2572 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2573 else
2574 {
2575 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002576 vty_out (vty, " (Stub%s%s)",
2577 area->no_summary ? ", no summary" : "",
2578 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002579
paulb0a053b2003-06-22 09:04:47 +00002580 else if (area->external_routing == OSPF_AREA_NSSA)
2581 vty_out (vty, " (NSSA%s%s)",
2582 area->no_summary ? ", no summary" : "",
2583 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002584
2585 vty_out (vty, "%s", VTY_NEWLINE);
2586 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002587 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002588 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002589 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002590 }
2591
2592 /* Show number of interfaces. */
2593 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2594 "Active: %d%s", listcount (area->oiflist),
2595 area->act_ints, VTY_NEWLINE);
2596
paul718e3742002-12-13 20:15:29 +00002597 if (area->external_routing == OSPF_AREA_NSSA)
2598 {
2599 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 +00002600 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002601 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2602 VTY_NEWLINE);
2603 else if (area->NSSATranslatorState)
2604 {
2605 vty_out (vty, " We are an ABR and ");
2606 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2607 vty_out (vty, "the NSSA Elected Translator. %s",
2608 VTY_NEWLINE);
2609 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2610 vty_out (vty, "always an NSSA Translator. %s",
2611 VTY_NEWLINE);
2612 }
paul718e3742002-12-13 20:15:29 +00002613 else
paulb0a053b2003-06-22 09:04:47 +00002614 {
2615 vty_out (vty, " We are an ABR, but ");
2616 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2617 vty_out (vty, "not the NSSA Elected Translator. %s",
2618 VTY_NEWLINE);
2619 else
hassoc6b87812004-12-22 13:09:59 +00002620 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002621 VTY_NEWLINE);
2622 }
paul718e3742002-12-13 20:15:29 +00002623 }
paul88d6cf32005-10-29 12:50:09 +00002624 /* Stub-router state for this area */
2625 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2626 {
ajs649654a2005-11-16 20:17:52 +00002627 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002628 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2629 VTY_NEWLINE);
2630 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2631 vty_out (vty, " Administratively activated (indefinitely)%s",
2632 VTY_NEWLINE);
2633 if (area->t_stub_router)
2634 vty_out (vty, " Active from startup, %s remaining%s",
2635 ospf_timer_dump (area->t_stub_router, timebuf,
2636 sizeof(timebuf)), VTY_NEWLINE);
2637 }
2638
paul718e3742002-12-13 20:15:29 +00002639 /* Show number of fully adjacent neighbors. */
2640 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002641 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002642
2643 /* Show authentication type. */
2644 vty_out (vty, " Area has ");
2645 if (area->auth_type == OSPF_AUTH_NULL)
2646 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2647 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2648 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2649 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2650 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2651
2652 if (!OSPF_IS_AREA_BACKBONE (area))
2653 vty_out (vty, " Number of full virtual adjacencies going through"
2654 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2655
2656 /* Show SPF calculation times. */
2657 vty_out (vty, " SPF algorithm executed %d times%s",
2658 area->spf_calculation, VTY_NEWLINE);
2659
2660 /* Show number of LSA. */
2661 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002662 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2663 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2664 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2665 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2666 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2667 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2668 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2669 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2670 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2671 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2672 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2673 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2674 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2675 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2676 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2677#ifdef HAVE_OPAQUE_LSA
2678 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2679 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2680 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2681 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2682 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2683 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2684#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002685 vty_out (vty, "%s", VTY_NEWLINE);
2686}
2687
2688DEFUN (show_ip_ospf,
2689 show_ip_ospf_cmd,
2690 "show ip ospf",
2691 SHOW_STR
2692 IP_STR
2693 "OSPF information\n")
2694{
paul1eb8ef22005-04-07 07:30:20 +00002695 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002696 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002697 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002698 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002699 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002700
2701 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002702 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002703 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002704 {
2705 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2706 return CMD_SUCCESS;
2707 }
2708
2709 /* Show Router ID. */
2710 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002711 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002712 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002713
2714 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002715 if (ospf->t_deferred_shutdown)
2716 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2717 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002718 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002719 /* Show capability. */
2720 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2721 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2722 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002723 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002724 "enabled" : "disabled", VTY_NEWLINE);
2725#ifdef HAVE_OPAQUE_LSA
2726 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002727 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002728 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002729 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002730 " (origination blocked)" : "",
2731 VTY_NEWLINE);
2732#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002733
2734 /* Show stub-router configuration */
2735 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2736 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2737 {
2738 vty_out (vty, " Stub router advertisement is configured%s",
2739 VTY_NEWLINE);
2740 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2741 vty_out (vty, " Enabled for %us after start-up%s",
2742 ospf->stub_router_startup_time, VTY_NEWLINE);
2743 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2744 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2745 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2746 }
2747
paul718e3742002-12-13 20:15:29 +00002748 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002749 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2750 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2751 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2752 " Hold time multiplier is currently %d%s",
2753 ospf->spf_delay, VTY_NEWLINE,
2754 ospf->spf_holdtime, VTY_NEWLINE,
2755 ospf->spf_max_holdtime, VTY_NEWLINE,
2756 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002757 vty_out (vty, " SPF algorithm ");
2758 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2759 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002760 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002761 vty_out (vty, "last executed %s ago%s",
2762 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2763 VTY_NEWLINE);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -07002764 vty_out (vty, " Last SPF duration %s%s",
2765 ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)),
2766 VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002767 }
2768 else
2769 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002770 vty_out (vty, " SPF timer %s%s%s",
2771 (ospf->t_spf_calc ? "due in " : "is "),
2772 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2773 VTY_NEWLINE);
2774
paul718e3742002-12-13 20:15:29 +00002775 /* Show refresh parameters. */
2776 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002777 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002778
2779 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002780 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002781 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002782 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002783
paul68980082003-03-25 05:07:42 +00002784 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002785 vty_out (vty, " This router is an ASBR "
2786 "(injecting external routing information)%s", VTY_NEWLINE);
2787
2788 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002789 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2790 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2791 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2792#ifdef HAVE_OPAQUE_LSA
2793 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2794 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2795 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2796#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002797 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002798 vty_out (vty, " Number of areas attached to this router: %d%s",
2799 listcount (ospf->areas), VTY_NEWLINE);
2800
2801 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2802 {
2803 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2804 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2805 else
2806 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2807 }
2808
2809 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002810
2811 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002812 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2813 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002814
2815 return CMD_SUCCESS;
2816}
2817
David Lamparter6b0655a2014-06-04 06:53:35 +02002818
ajsfd651fa2005-03-29 16:08:16 +00002819static void
paul68980082003-03-25 05:07:42 +00002820show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2821 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002822{
ajsfd651fa2005-03-29 16:08:16 +00002823 int is_up;
paul718e3742002-12-13 20:15:29 +00002824 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002825 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002826
paul718e3742002-12-13 20:15:29 +00002827 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002828 vty_out (vty, "%s is %s%s", ifp->name,
2829 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002830 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2831 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2832 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002833
2834 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002835 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002836 {
2837 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2838 return;
2839 }
ajsfd651fa2005-03-29 16:08:16 +00002840 else if (!is_up)
2841 {
2842 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2843 VTY_NEWLINE);
2844 return;
2845 }
2846
paul718e3742002-12-13 20:15:29 +00002847 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2848 {
2849 struct ospf_interface *oi = rn->info;
2850
2851 if (oi == NULL)
2852 continue;
2853
2854 /* Show OSPF interface information. */
2855 vty_out (vty, " Internet Address %s/%d,",
2856 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2857
Paul Jakma9c27ef92006-05-04 07:32:57 +00002858 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2859 {
2860 struct in_addr *dest;
2861 const char *dstr;
2862
Andrew J. Schorre4529632006-12-12 19:18:21 +00002863 if (CONNECTED_PEER(oi->connected)
2864 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002865 dstr = "Peer";
2866 else
2867 dstr = "Broadcast";
2868
2869 /* For Vlinks, showing the peer address is probably more
2870 * informative than the local interface that is being used
2871 */
2872 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2873 dest = &oi->vl_data->peer_addr;
2874 else
2875 dest = &oi->connected->destination->u.prefix4;
2876
2877 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2878 }
hasso3fb9cd62004-10-19 19:44:43 +00002879
paul718e3742002-12-13 20:15:29 +00002880 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2881 VTY_NEWLINE);
2882
vincentba682532005-09-29 13:52:57 +00002883 vty_out (vty, " MTU mismatch detection:%s%s",
2884 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2885
paul718e3742002-12-13 20:15:29 +00002886 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002887 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002888 oi->output_cost, VTY_NEWLINE);
2889
2890 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2891 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2892 PRIORITY (oi), VTY_NEWLINE);
2893
2894 /* Show DR information. */
2895 if (DR (oi).s_addr == 0)
2896 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2897 else
2898 {
2899 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2900 if (nbr == NULL)
2901 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2902 else
2903 {
2904 vty_out (vty, " Designated Router (ID) %s,",
2905 inet_ntoa (nbr->router_id));
2906 vty_out (vty, " Interface Address %s%s",
2907 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2908 }
2909 }
2910
2911 /* Show BDR information. */
2912 if (BDR (oi).s_addr == 0)
2913 vty_out (vty, " No backup designated router on this network%s",
2914 VTY_NEWLINE);
2915 else
2916 {
2917 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2918 if (nbr == NULL)
2919 vty_out (vty, " No backup designated router on this network%s",
2920 VTY_NEWLINE);
2921 else
2922 {
2923 vty_out (vty, " Backup Designated Router (ID) %s,",
2924 inet_ntoa (nbr->router_id));
2925 vty_out (vty, " Interface Address %s%s",
2926 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2927 }
2928 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002929
2930 /* Next network-LSA sequence number we'll use, if we're elected DR */
2931 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2932 != OSPF_INITIAL_SEQUENCE_NUMBER)
2933 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2934 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2935
ajsba6454e2005-02-08 15:37:30 +00002936 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002937 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2938 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2939 {
2940 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2941 vty_out (vty, " OSPFAllRouters");
2942 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2943 vty_out (vty, " OSPFDesignatedRouters");
2944 }
2945 else
ajsba6454e2005-02-08 15:37:30 +00002946 vty_out (vty, " <None>");
2947 vty_out (vty, "%s", VTY_NEWLINE);
2948
paul718e3742002-12-13 20:15:29 +00002949 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002950 vty_out (vty, " Hello ");
2951 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2952 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2953 else
2954 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2955 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2956 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002957 OSPF_IF_PARAM (oi, v_wait),
2958 OSPF_IF_PARAM (oi, retransmit_interval),
2959 VTY_NEWLINE);
2960
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002961 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002962 {
ajs649654a2005-11-16 20:17:52 +00002963 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002964 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002965 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002966 VTY_NEWLINE);
2967 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002968 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002969 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2970
2971 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002972 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002973 VTY_NEWLINE);
2974 }
2975}
2976
2977DEFUN (show_ip_ospf_interface,
2978 show_ip_ospf_interface_cmd,
2979 "show ip ospf interface [INTERFACE]",
2980 SHOW_STR
2981 IP_STR
2982 "OSPF information\n"
2983 "Interface information\n"
2984 "Interface name\n")
2985{
2986 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002987 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002988 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002989
paul020709f2003-04-04 02:44:16 +00002990 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002991 if (ospf == NULL)
2992 {
2993 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2994 return CMD_SUCCESS;
2995 }
paul020709f2003-04-04 02:44:16 +00002996
paul718e3742002-12-13 20:15:29 +00002997 /* Show All Interfaces. */
2998 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002999 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3000 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003001 /* Interface name is specified. */
3002 else
3003 {
3004 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3005 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3006 else
paul68980082003-03-25 05:07:42 +00003007 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003008 }
3009
3010 return CMD_SUCCESS;
3011}
3012
paul4dadc292005-05-06 21:37:42 +00003013static void
pauld24f6e22005-10-21 09:23:12 +00003014show_ip_ospf_neighbour_header (struct vty *vty)
3015{
3016 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3017 VTY_NEWLINE,
3018 "Neighbor ID", "Pri", "State", "Dead Time",
3019 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3020 VTY_NEWLINE);
3021}
3022
3023static void
paul718e3742002-12-13 20:15:29 +00003024show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3025{
3026 struct route_node *rn;
3027 struct ospf_neighbor *nbr;
3028 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003029 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003030
3031 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3032 if ((nbr = rn->info))
3033 /* Do not show myself. */
3034 if (nbr != oi->nbr_self)
3035 /* Down state is not shown. */
3036 if (nbr->state != NSM_Down)
3037 {
3038 ospf_nbr_state_message (nbr, msgbuf, 16);
3039
3040 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003041 vty_out (vty, "%-15s %3d %-15s ",
3042 "-", nbr->priority,
3043 msgbuf);
3044 else
3045 vty_out (vty, "%-15s %3d %-15s ",
3046 inet_ntoa (nbr->router_id), nbr->priority,
3047 msgbuf);
3048
3049 vty_out (vty, "%9s ",
3050 ospf_timer_dump (nbr->t_inactivity, timebuf,
3051 sizeof(timebuf)));
3052
paul718e3742002-12-13 20:15:29 +00003053 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003054 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003055 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3056 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3057 VTY_NEWLINE);
3058 }
3059}
3060
3061DEFUN (show_ip_ospf_neighbor,
3062 show_ip_ospf_neighbor_cmd,
3063 "show ip ospf neighbor",
3064 SHOW_STR
3065 IP_STR
3066 "OSPF information\n"
3067 "Neighbor list\n")
3068{
paul020709f2003-04-04 02:44:16 +00003069 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003070 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003071 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003072
paul020709f2003-04-04 02:44:16 +00003073 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003074 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003075 {
3076 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3077 return CMD_SUCCESS;
3078 }
3079
pauld24f6e22005-10-21 09:23:12 +00003080 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003081
paul1eb8ef22005-04-07 07:30:20 +00003082 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3083 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003084
3085 return CMD_SUCCESS;
3086}
3087
3088DEFUN (show_ip_ospf_neighbor_all,
3089 show_ip_ospf_neighbor_all_cmd,
3090 "show ip ospf neighbor all",
3091 SHOW_STR
3092 IP_STR
3093 "OSPF information\n"
3094 "Neighbor list\n"
3095 "include down status neighbor\n")
3096{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003097 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003098 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003099 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003100
paul68980082003-03-25 05:07:42 +00003101 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003102 {
3103 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3104 return CMD_SUCCESS;
3105 }
pauld24f6e22005-10-21 09:23:12 +00003106
3107 show_ip_ospf_neighbour_header (vty);
3108
paul1eb8ef22005-04-07 07:30:20 +00003109 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003110 {
hasso52dc7ee2004-09-23 19:18:23 +00003111 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003112 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003113
3114 show_ip_ospf_neighbor_sub (vty, oi);
3115
3116 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003117 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003118 {
paul718e3742002-12-13 20:15:29 +00003119 if (nbr_nbma->nbr == NULL
3120 || nbr_nbma->nbr->state == NSM_Down)
3121 {
pauld24f6e22005-10-21 09:23:12 +00003122 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003123 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003124 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003125 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3126 0, 0, 0, VTY_NEWLINE);
3127 }
3128 }
3129 }
3130
3131 return CMD_SUCCESS;
3132}
3133
3134DEFUN (show_ip_ospf_neighbor_int,
3135 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003136 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003137 SHOW_STR
3138 IP_STR
3139 "OSPF information\n"
3140 "Neighbor list\n"
3141 "Interface name\n")
3142{
paul020709f2003-04-04 02:44:16 +00003143 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003144 struct interface *ifp;
3145 struct route_node *rn;
3146
3147 ifp = if_lookup_by_name (argv[0]);
3148 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003149 {
hassobb5b7552005-08-21 20:01:15 +00003150 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003151 return CMD_WARNING;
3152 }
3153
paul020709f2003-04-04 02:44:16 +00003154 ospf = ospf_lookup ();
3155 if (ospf == NULL)
3156 {
3157 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3158 return CMD_SUCCESS;
3159 }
pauld24f6e22005-10-21 09:23:12 +00003160
3161 show_ip_ospf_neighbour_header (vty);
3162
hassobb5b7552005-08-21 20:01:15 +00003163 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003164 {
hassobb5b7552005-08-21 20:01:15 +00003165 struct ospf_interface *oi = rn->info;
3166
3167 if (oi == NULL)
3168 continue;
3169
paul718e3742002-12-13 20:15:29 +00003170 show_ip_ospf_neighbor_sub (vty, oi);
3171 }
3172
3173 return CMD_SUCCESS;
3174}
3175
paul4dadc292005-05-06 21:37:42 +00003176static void
paul718e3742002-12-13 20:15:29 +00003177show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3178 struct ospf_nbr_nbma *nbr_nbma)
3179{
ajs649654a2005-11-16 20:17:52 +00003180 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003181
3182 /* Show neighbor ID. */
3183 vty_out (vty, " Neighbor %s,", "-");
3184
3185 /* Show interface address. */
3186 vty_out (vty, " interface address %s%s",
3187 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3188 /* Show Area ID. */
3189 vty_out (vty, " In the area %s via interface %s%s",
3190 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3191 /* Show neighbor priority and state. */
3192 vty_out (vty, " Neighbor priority is %d, State is %s,",
3193 nbr_nbma->priority, "Down");
3194 /* Show state changes. */
3195 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3196
3197 /* Show PollInterval */
3198 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3199
3200 /* Show poll-interval timer. */
3201 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003202 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3203 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003204
3205 /* Show poll-interval timer thread. */
3206 vty_out (vty, " Thread Poll Timer %s%s",
3207 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3208}
3209
paul4dadc292005-05-06 21:37:42 +00003210static void
paul718e3742002-12-13 20:15:29 +00003211show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3212 struct ospf_neighbor *nbr)
3213{
ajs649654a2005-11-16 20:17:52 +00003214 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003215
3216 /* Show neighbor ID. */
3217 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3218 vty_out (vty, " Neighbor %s,", "-");
3219 else
3220 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3221
3222 /* Show interface address. */
3223 vty_out (vty, " interface address %s%s",
3224 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3225 /* Show Area ID. */
3226 vty_out (vty, " In the area %s via interface %s%s",
3227 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3228 /* Show neighbor priority and state. */
3229 vty_out (vty, " Neighbor priority is %d, State is %s,",
3230 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3231 /* Show state changes. */
3232 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003233 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003234 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003235 struct timeval res
3236 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003237 vty_out (vty, " Most recent state change statistics:%s",
3238 VTY_NEWLINE);
3239 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003240 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003241 VTY_NEWLINE);
3242 }
3243 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3244 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003245 struct timeval res
3246 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003247 vty_out (vty, " Regressive change %s ago, due to %s%s",
3248 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3249 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003250 VTY_NEWLINE);
3251 }
paul718e3742002-12-13 20:15:29 +00003252 /* Show Designated Rotuer ID. */
3253 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3254 /* Show Backup Designated Rotuer ID. */
3255 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3256 /* Show options. */
3257 vty_out (vty, " Options %d %s%s", nbr->options,
3258 ospf_options_dump (nbr->options), VTY_NEWLINE);
3259 /* Show Router Dead interval timer. */
3260 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003261 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3262 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003263 /* Show Database Summary list. */
3264 vty_out (vty, " Database Summary List %d%s",
3265 ospf_db_summary_count (nbr), VTY_NEWLINE);
3266 /* Show Link State Request list. */
3267 vty_out (vty, " Link State Request List %ld%s",
3268 ospf_ls_request_count (nbr), VTY_NEWLINE);
3269 /* Show Link State Retransmission list. */
3270 vty_out (vty, " Link State Retransmission List %ld%s",
3271 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3272 /* Show inactivity timer thread. */
3273 vty_out (vty, " Thread Inactivity Timer %s%s",
3274 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3275 /* Show Database Description retransmission thread. */
3276 vty_out (vty, " Thread Database Description Retransmision %s%s",
3277 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3278 /* Show Link State Request Retransmission thread. */
3279 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3280 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3281 /* Show Link State Update Retransmission thread. */
3282 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3283 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3284}
3285
3286DEFUN (show_ip_ospf_neighbor_id,
3287 show_ip_ospf_neighbor_id_cmd,
3288 "show ip ospf neighbor A.B.C.D",
3289 SHOW_STR
3290 IP_STR
3291 "OSPF information\n"
3292 "Neighbor list\n"
3293 "Neighbor ID\n")
3294{
paul020709f2003-04-04 02:44:16 +00003295 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003296 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003297 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003298 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003299 struct in_addr router_id;
3300 int ret;
3301
3302 ret = inet_aton (argv[0], &router_id);
3303 if (!ret)
3304 {
3305 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3306 return CMD_WARNING;
3307 }
3308
paul020709f2003-04-04 02:44:16 +00003309 ospf = ospf_lookup ();
3310 if (ospf == NULL)
3311 {
3312 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3313 return CMD_SUCCESS;
3314 }
3315
paul1eb8ef22005-04-07 07:30:20 +00003316 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3317 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003318 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003319
paul718e3742002-12-13 20:15:29 +00003320 return CMD_SUCCESS;
3321}
3322
3323DEFUN (show_ip_ospf_neighbor_detail,
3324 show_ip_ospf_neighbor_detail_cmd,
3325 "show ip ospf neighbor detail",
3326 SHOW_STR
3327 IP_STR
3328 "OSPF information\n"
3329 "Neighbor list\n"
3330 "detail of all neighbors\n")
3331{
paul020709f2003-04-04 02:44:16 +00003332 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003333 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003334 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003335
paul020709f2003-04-04 02:44:16 +00003336 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003337 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003338 {
3339 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3340 return CMD_SUCCESS;
3341 }
paul718e3742002-12-13 20:15:29 +00003342
paul1eb8ef22005-04-07 07:30:20 +00003343 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003344 {
paul718e3742002-12-13 20:15:29 +00003345 struct route_node *rn;
3346 struct ospf_neighbor *nbr;
3347
3348 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3349 if ((nbr = rn->info))
3350 if (nbr != oi->nbr_self)
3351 if (nbr->state != NSM_Down)
3352 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3353 }
3354
3355 return CMD_SUCCESS;
3356}
3357
3358DEFUN (show_ip_ospf_neighbor_detail_all,
3359 show_ip_ospf_neighbor_detail_all_cmd,
3360 "show ip ospf neighbor detail all",
3361 SHOW_STR
3362 IP_STR
3363 "OSPF information\n"
3364 "Neighbor list\n"
3365 "detail of all neighbors\n"
3366 "include down status neighbor\n")
3367{
paul020709f2003-04-04 02:44:16 +00003368 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003369 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003370 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003371
paul020709f2003-04-04 02:44:16 +00003372 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003373 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003374 {
3375 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3376 return CMD_SUCCESS;
3377 }
paul718e3742002-12-13 20:15:29 +00003378
paul1eb8ef22005-04-07 07:30:20 +00003379 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003380 {
paul718e3742002-12-13 20:15:29 +00003381 struct route_node *rn;
3382 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003383 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003384
3385 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3386 if ((nbr = rn->info))
3387 if (nbr != oi->nbr_self)
3388 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3389 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3390
3391 if (oi->type == OSPF_IFTYPE_NBMA)
3392 {
hasso52dc7ee2004-09-23 19:18:23 +00003393 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003394
paul1eb8ef22005-04-07 07:30:20 +00003395 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3396 if (nbr_nbma->nbr == NULL
3397 || nbr_nbma->nbr->state == NSM_Down)
3398 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003399 }
3400 }
3401
3402 return CMD_SUCCESS;
3403}
3404
3405DEFUN (show_ip_ospf_neighbor_int_detail,
3406 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003407 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003408 SHOW_STR
3409 IP_STR
3410 "OSPF information\n"
3411 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003412 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003413 "detail of all neighbors")
3414{
paul020709f2003-04-04 02:44:16 +00003415 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003416 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003417 struct interface *ifp;
3418 struct route_node *rn, *nrn;
3419 struct ospf_neighbor *nbr;
3420
3421 ifp = if_lookup_by_name (argv[0]);
3422 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003423 {
hassobb5b7552005-08-21 20:01:15 +00003424 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003425 return CMD_WARNING;
3426 }
3427
paul020709f2003-04-04 02:44:16 +00003428 ospf = ospf_lookup ();
3429 if (ospf == NULL)
3430 {
3431 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3432 return CMD_SUCCESS;
3433 }
paul68980082003-03-25 05:07:42 +00003434
paul718e3742002-12-13 20:15:29 +00003435
hassobb5b7552005-08-21 20:01:15 +00003436 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3437 if ((oi = rn->info))
3438 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3439 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003440 if (nbr != oi->nbr_self)
3441 if (nbr->state != NSM_Down)
3442 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003443
3444 return CMD_SUCCESS;
3445}
3446
David Lamparter6b0655a2014-06-04 06:53:35 +02003447
paul718e3742002-12-13 20:15:29 +00003448/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003449static int
paul020709f2003-04-04 02:44:16 +00003450show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003451{
paul718e3742002-12-13 20:15:29 +00003452 struct router_lsa *rl;
3453 struct summary_lsa *sl;
3454 struct as_external_lsa *asel;
3455 struct prefix_ipv4 p;
3456
3457 if (lsa != NULL)
3458 /* If self option is set, check LSA self flag. */
3459 if (self == 0 || IS_LSA_SELF (lsa))
3460 {
3461 /* LSA common part show. */
3462 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3463 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3464 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3465 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3466 /* LSA specific part show. */
3467 switch (lsa->data->type)
3468 {
3469 case OSPF_ROUTER_LSA:
3470 rl = (struct router_lsa *) lsa->data;
3471 vty_out (vty, " %-d", ntohs (rl->links));
3472 break;
3473 case OSPF_SUMMARY_LSA:
3474 sl = (struct summary_lsa *) lsa->data;
3475
3476 p.family = AF_INET;
3477 p.prefix = sl->header.id;
3478 p.prefixlen = ip_masklen (sl->mask);
3479 apply_mask_ipv4 (&p);
3480
3481 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3482 break;
3483 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003484 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003485 asel = (struct as_external_lsa *) lsa->data;
3486
3487 p.family = AF_INET;
3488 p.prefix = asel->header.id;
3489 p.prefixlen = ip_masklen (asel->mask);
3490 apply_mask_ipv4 (&p);
3491
3492 vty_out (vty, " %s %s/%d [0x%lx]",
3493 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3494 inet_ntoa (p.prefix), p.prefixlen,
3495 (u_long)ntohl (asel->e[0].route_tag));
3496 break;
3497 case OSPF_NETWORK_LSA:
3498 case OSPF_ASBR_SUMMARY_LSA:
3499#ifdef HAVE_OPAQUE_LSA
3500 case OSPF_OPAQUE_LINK_LSA:
3501 case OSPF_OPAQUE_AREA_LSA:
3502 case OSPF_OPAQUE_AS_LSA:
3503#endif /* HAVE_OPAQUE_LSA */
3504 default:
3505 break;
3506 }
3507 vty_out (vty, VTY_NEWLINE);
3508 }
3509
3510 return 0;
3511}
3512
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003513static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003514{
3515 "unknown",
3516 "Router Link States",
3517 "Net Link States",
3518 "Summary Link States",
3519 "ASBR-Summary Link States",
3520 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003521 "Group Membership LSA",
3522 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003523#ifdef HAVE_OPAQUE_LSA
3524 "Type-8 LSA",
3525 "Link-Local Opaque-LSA",
3526 "Area-Local Opaque-LSA",
3527 "AS-external Opaque-LSA",
3528#endif /* HAVE_OPAQUE_LSA */
3529};
3530
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003531static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003532{
3533 "",
3534 "Link ID ADV Router Age Seq# CkSum Link count",
3535 "Link ID ADV Router Age Seq# CkSum",
3536 "Link ID ADV Router Age Seq# CkSum Route",
3537 "Link ID ADV Router Age Seq# CkSum",
3538 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003539 " --- header for Group Member ----",
3540 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003541#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003542 " --- type-8 ---",
3543 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3544 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3545 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3546#endif /* HAVE_OPAQUE_LSA */
3547};
3548
paul4dadc292005-05-06 21:37:42 +00003549static void
paul718e3742002-12-13 20:15:29 +00003550show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3551{
3552 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003553
paul718e3742002-12-13 20:15:29 +00003554 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003555 vty_out (vty, " Options: 0x%-2x : %s%s",
3556 lsa->data->options,
3557 ospf_options_dump(lsa->data->options),
3558 VTY_NEWLINE);
3559 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003560 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003561 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3562 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003563
3564 if (lsa->data->type == OSPF_ROUTER_LSA)
3565 {
3566 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3567
3568 if (rlsa->flags)
3569 vty_out (vty, " :%s%s%s%s",
3570 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3571 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3572 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3573 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3574
3575 vty_out (vty, "%s", VTY_NEWLINE);
3576 }
3577 vty_out (vty, " LS Type: %s%s",
3578 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3579 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3580 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3581 vty_out (vty, " Advertising Router: %s%s",
3582 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3583 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3584 VTY_NEWLINE);
3585 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3586 VTY_NEWLINE);
3587 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3588}
3589
hassoeb1ce602004-10-08 08:17:22 +00003590const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003591{
3592 "(null)",
3593 "another Router (point-to-point)",
3594 "a Transit Network",
3595 "Stub Network",
3596 "a Virtual Link",
3597};
3598
hassoeb1ce602004-10-08 08:17:22 +00003599const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003600{
3601 "(null)",
3602 "Neighboring Router ID",
3603 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003604 "Net",
paul718e3742002-12-13 20:15:29 +00003605 "Neighboring Router ID",
3606};
3607
hassoeb1ce602004-10-08 08:17:22 +00003608const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003609{
3610 "(null)",
3611 "Router Interface address",
3612 "Router Interface address",
3613 "Network Mask",
3614 "Router Interface address",
3615};
3616
3617/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003618static void
paul718e3742002-12-13 20:15:29 +00003619show_ip_ospf_database_router_links (struct vty *vty,
3620 struct router_lsa *rl)
3621{
3622 int len, i, type;
3623
3624 len = ntohs (rl->header.length) - 4;
3625 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3626 {
3627 type = rl->link[i].type;
3628
3629 vty_out (vty, " Link connected to: %s%s",
3630 link_type_desc[type], VTY_NEWLINE);
3631 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3632 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3633 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3634 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3635 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3636 vty_out (vty, " TOS 0 Metric: %d%s",
3637 ntohs (rl->link[i].metric), VTY_NEWLINE);
3638 vty_out (vty, "%s", VTY_NEWLINE);
3639 }
3640}
3641
3642/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003643static int
paul718e3742002-12-13 20:15:29 +00003644show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3645{
3646 if (lsa != NULL)
3647 {
3648 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3649
3650 show_ip_ospf_database_header (vty, lsa);
3651
3652 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3653 VTY_NEWLINE, VTY_NEWLINE);
3654
3655 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003656 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003657 }
3658
3659 return 0;
3660}
3661
3662/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003663static int
paul718e3742002-12-13 20:15:29 +00003664show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3665{
3666 int length, i;
3667
3668 if (lsa != NULL)
3669 {
3670 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3671
3672 show_ip_ospf_database_header (vty, lsa);
3673
3674 vty_out (vty, " Network Mask: /%d%s",
3675 ip_masklen (nl->mask), VTY_NEWLINE);
3676
3677 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3678
3679 for (i = 0; length > 0; i++, length -= 4)
3680 vty_out (vty, " Attached Router: %s%s",
3681 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3682
3683 vty_out (vty, "%s", VTY_NEWLINE);
3684 }
3685
3686 return 0;
3687}
3688
3689/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003690static int
paul718e3742002-12-13 20:15:29 +00003691show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3692{
3693 if (lsa != NULL)
3694 {
3695 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3696
3697 show_ip_ospf_database_header (vty, lsa);
3698
3699 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3700 VTY_NEWLINE);
3701 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3702 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003703 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003704 }
3705
3706 return 0;
3707}
3708
3709/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003710static int
paul718e3742002-12-13 20:15:29 +00003711show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3712{
3713 if (lsa != NULL)
3714 {
3715 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3716
3717 show_ip_ospf_database_header (vty, lsa);
3718
3719 vty_out (vty, " Network Mask: /%d%s",
3720 ip_masklen (sl->mask), VTY_NEWLINE);
3721 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3722 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003723 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003724 }
3725
3726 return 0;
3727}
3728
3729/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003730static int
paul718e3742002-12-13 20:15:29 +00003731show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3732{
3733 if (lsa != NULL)
3734 {
3735 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3736
3737 show_ip_ospf_database_header (vty, lsa);
3738
3739 vty_out (vty, " Network Mask: /%d%s",
3740 ip_masklen (al->mask), VTY_NEWLINE);
3741 vty_out (vty, " Metric Type: %s%s",
3742 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3743 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3744 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3745 vty_out (vty, " Metric: %d%s",
3746 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3747 vty_out (vty, " Forward Address: %s%s",
3748 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3749
3750 vty_out (vty, " External Route Tag: %lu%s%s",
3751 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3752 }
3753
3754 return 0;
3755}
3756
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003757#if 0
paul4dadc292005-05-06 21:37:42 +00003758static int
paul718e3742002-12-13 20:15:29 +00003759show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3760{
3761 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3762
3763 /* show_ip_ospf_database_header (vty, lsa); */
3764
ajs2a42e282004-12-08 18:43:03 +00003765 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003766 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003767 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003768 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3769 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003770 zlog_debug( " TOS: 0%s", "\n");
3771 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003772 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003773 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003774 inet_ntoa (al->e[0].fwd_addr), "\n");
3775
ajs2a42e282004-12-08 18:43:03 +00003776 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003777 ntohl (al->e[0].route_tag), "\n", "\n");
3778
3779 return 0;
3780}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003781#endif
paul718e3742002-12-13 20:15:29 +00003782
3783/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003784static int
paul718e3742002-12-13 20:15:29 +00003785show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3786{
3787 if (lsa != NULL)
3788 {
3789 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3790
3791 show_ip_ospf_database_header (vty, lsa);
3792
3793 vty_out (vty, " Network Mask: /%d%s",
3794 ip_masklen (al->mask), VTY_NEWLINE);
3795 vty_out (vty, " Metric Type: %s%s",
3796 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3797 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3798 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3799 vty_out (vty, " Metric: %d%s",
3800 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3801 vty_out (vty, " NSSA: Forward Address: %s%s",
3802 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3803
3804 vty_out (vty, " External Route Tag: %u%s%s",
3805 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3806 }
3807
3808 return 0;
3809}
3810
paul4dadc292005-05-06 21:37:42 +00003811static int
paul718e3742002-12-13 20:15:29 +00003812show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3813{
3814 return 0;
3815}
3816
3817#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003818static int
paul718e3742002-12-13 20:15:29 +00003819show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3820{
3821 if (lsa != NULL)
3822 {
3823 show_ip_ospf_database_header (vty, lsa);
3824 show_opaque_info_detail (vty, lsa);
3825
3826 vty_out (vty, "%s", VTY_NEWLINE);
3827 }
3828 return 0;
3829}
3830#endif /* HAVE_OPAQUE_LSA */
3831
3832int (*show_function[])(struct vty *, struct ospf_lsa *) =
3833{
3834 NULL,
3835 show_router_lsa_detail,
3836 show_network_lsa_detail,
3837 show_summary_lsa_detail,
3838 show_summary_asbr_lsa_detail,
3839 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003840 show_func_dummy,
3841 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003842#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003843 NULL, /* type-8 */
3844 show_opaque_lsa_detail,
3845 show_opaque_lsa_detail,
3846 show_opaque_lsa_detail,
3847#endif /* HAVE_OPAQUE_LSA */
3848};
3849
paul4dadc292005-05-06 21:37:42 +00003850static void
paul718e3742002-12-13 20:15:29 +00003851show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3852 struct in_addr *adv_router)
3853{
3854 memset (lp, 0, sizeof (struct prefix_ls));
3855 lp->family = 0;
3856 if (id == NULL)
3857 lp->prefixlen = 0;
3858 else if (adv_router == NULL)
3859 {
3860 lp->prefixlen = 32;
3861 lp->id = *id;
3862 }
3863 else
3864 {
3865 lp->prefixlen = 64;
3866 lp->id = *id;
3867 lp->adv_router = *adv_router;
3868 }
3869}
3870
paul4dadc292005-05-06 21:37:42 +00003871static void
paul718e3742002-12-13 20:15:29 +00003872show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3873 struct in_addr *id, struct in_addr *adv_router)
3874{
3875 struct prefix_ls lp;
3876 struct route_node *rn, *start;
3877 struct ospf_lsa *lsa;
3878
3879 show_lsa_prefix_set (vty, &lp, id, adv_router);
3880 start = route_node_get (rt, (struct prefix *) &lp);
3881 if (start)
3882 {
3883 route_lock_node (start);
3884 for (rn = start; rn; rn = route_next_until (rn, start))
3885 if ((lsa = rn->info))
3886 {
paul718e3742002-12-13 20:15:29 +00003887 if (show_function[lsa->data->type] != NULL)
3888 show_function[lsa->data->type] (vty, lsa);
3889 }
3890 route_unlock_node (start);
3891 }
3892}
3893
3894/* Show detail LSA information
3895 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003896static void
paul020709f2003-04-04 02:44:16 +00003897show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003898 struct in_addr *id, struct in_addr *adv_router)
3899{
hasso52dc7ee2004-09-23 19:18:23 +00003900 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003901 struct ospf_area *area;
3902
paul718e3742002-12-13 20:15:29 +00003903 switch (type)
3904 {
3905 case OSPF_AS_EXTERNAL_LSA:
3906#ifdef HAVE_OPAQUE_LSA
3907 case OSPF_OPAQUE_AS_LSA:
3908#endif /* HAVE_OPAQUE_LSA */
3909 vty_out (vty, " %s %s%s",
3910 show_database_desc[type],
3911 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003912 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003913 break;
3914 default:
paul1eb8ef22005-04-07 07:30:20 +00003915 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003916 {
paul718e3742002-12-13 20:15:29 +00003917 vty_out (vty, "%s %s (Area %s)%s%s",
3918 VTY_NEWLINE, show_database_desc[type],
3919 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3920 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3921 }
3922 break;
3923 }
3924}
3925
paul4dadc292005-05-06 21:37:42 +00003926static void
paul718e3742002-12-13 20:15:29 +00003927show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3928 struct in_addr *adv_router)
3929{
3930 struct route_node *rn;
3931 struct ospf_lsa *lsa;
3932
3933 for (rn = route_top (rt); rn; rn = route_next (rn))
3934 if ((lsa = rn->info))
3935 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3936 {
paul718e3742002-12-13 20:15:29 +00003937 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3938 continue;
paul718e3742002-12-13 20:15:29 +00003939 if (show_function[lsa->data->type] != NULL)
3940 show_function[lsa->data->type] (vty, lsa);
3941 }
3942}
3943
3944/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003945static void
paul020709f2003-04-04 02:44:16 +00003946show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003947 struct in_addr *adv_router)
3948{
hasso52dc7ee2004-09-23 19:18:23 +00003949 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003950 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003951
3952 switch (type)
3953 {
3954 case OSPF_AS_EXTERNAL_LSA:
3955#ifdef HAVE_OPAQUE_LSA
3956 case OSPF_OPAQUE_AS_LSA:
3957#endif /* HAVE_OPAQUE_LSA */
3958 vty_out (vty, " %s %s%s",
3959 show_database_desc[type],
3960 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003961 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003962 adv_router);
3963 break;
3964 default:
paul1eb8ef22005-04-07 07:30:20 +00003965 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003966 {
paul718e3742002-12-13 20:15:29 +00003967 vty_out (vty, "%s %s (Area %s)%s%s",
3968 VTY_NEWLINE, show_database_desc[type],
3969 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3970 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3971 adv_router);
3972 }
3973 break;
3974 }
3975}
3976
paul4dadc292005-05-06 21:37:42 +00003977static void
paul020709f2003-04-04 02:44:16 +00003978show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003979{
paul020709f2003-04-04 02:44:16 +00003980 struct ospf_lsa *lsa;
3981 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003982 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003983 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003984 int type;
3985
paul1eb8ef22005-04-07 07:30:20 +00003986 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003987 {
paul718e3742002-12-13 20:15:29 +00003988 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3989 {
3990 switch (type)
3991 {
3992 case OSPF_AS_EXTERNAL_LSA:
3993#ifdef HAVE_OPAQUE_LSA
3994 case OSPF_OPAQUE_AS_LSA:
3995#endif /* HAVE_OPAQUE_LSA */
3996 continue;
3997 default:
3998 break;
3999 }
4000 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4001 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4002 {
4003 vty_out (vty, " %s (Area %s)%s%s",
4004 show_database_desc[type],
4005 ospf_area_desc_string (area),
4006 VTY_NEWLINE, VTY_NEWLINE);
4007 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4008
paul020709f2003-04-04 02:44:16 +00004009 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4010 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00004011
4012 vty_out (vty, "%s", VTY_NEWLINE);
4013 }
4014 }
4015 }
4016
4017 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4018 {
4019 switch (type)
4020 {
4021 case OSPF_AS_EXTERNAL_LSA:
4022#ifdef HAVE_OPAQUE_LSA
4023 case OSPF_OPAQUE_AS_LSA:
4024#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004025 break;
paul718e3742002-12-13 20:15:29 +00004026 default:
4027 continue;
4028 }
paul68980082003-03-25 05:07:42 +00004029 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4030 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004031 {
4032 vty_out (vty, " %s%s%s",
4033 show_database_desc[type],
4034 VTY_NEWLINE, VTY_NEWLINE);
4035 vty_out (vty, "%s%s", show_database_header[type],
4036 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004037
4038 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4039 show_lsa_summary (vty, lsa, self);
4040
paul718e3742002-12-13 20:15:29 +00004041 vty_out (vty, "%s", VTY_NEWLINE);
4042 }
4043 }
4044
4045 vty_out (vty, "%s", VTY_NEWLINE);
4046}
4047
paul4dadc292005-05-06 21:37:42 +00004048static void
paul020709f2003-04-04 02:44:16 +00004049show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004050{
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004051 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00004052
4053 vty_out (vty, "%s MaxAge Link States:%s%s",
4054 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4055
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004056 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
paul1eb8ef22005-04-07 07:30:20 +00004057 {
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004058 struct ospf_lsa *lsa;
4059
4060 if ((lsa = rn->info) != NULL)
4061 {
4062 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4063 vty_out (vty, "Link State ID: %s%s",
4064 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4065 vty_out (vty, "Advertising Router: %s%s",
4066 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4067 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4068 vty_out (vty, "%s", VTY_NEWLINE);
4069 }
paul1eb8ef22005-04-07 07:30:20 +00004070 }
paul718e3742002-12-13 20:15:29 +00004071}
4072
paul718e3742002-12-13 20:15:29 +00004073#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4074#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004075
4076#ifdef HAVE_OPAQUE_LSA
4077#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4078#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4079#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4080#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4081#else /* HAVE_OPAQUE_LSA */
4082#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4083#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4084#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4085#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4086#endif /* HAVE_OPAQUE_LSA */
4087
4088#define OSPF_LSA_TYPES_CMD_STR \
4089 "asbr-summary|external|network|router|summary" \
4090 OSPF_LSA_TYPE_NSSA_CMD_STR \
4091 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4092
4093#define OSPF_LSA_TYPES_DESC \
4094 "ASBR summary link states\n" \
4095 "External link states\n" \
4096 "Network link states\n" \
4097 "Router link states\n" \
4098 "Network summary link states\n" \
4099 OSPF_LSA_TYPE_NSSA_DESC \
4100 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4101 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4102 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4103
4104DEFUN (show_ip_ospf_database,
4105 show_ip_ospf_database_cmd,
4106 "show ip ospf database",
4107 SHOW_STR
4108 IP_STR
4109 "OSPF information\n"
4110 "Database summary\n")
4111{
paul020709f2003-04-04 02:44:16 +00004112 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004113 int type, ret;
4114 struct in_addr id, adv_router;
4115
paul020709f2003-04-04 02:44:16 +00004116 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004117 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004118 {
4119 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4120 return CMD_SUCCESS;
4121 }
paul718e3742002-12-13 20:15:29 +00004122
4123 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004124 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004125
4126 /* Show all LSA. */
4127 if (argc == 0)
4128 {
paul020709f2003-04-04 02:44:16 +00004129 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004130 return CMD_SUCCESS;
4131 }
4132
4133 /* Set database type to show. */
4134 if (strncmp (argv[0], "r", 1) == 0)
4135 type = OSPF_ROUTER_LSA;
4136 else if (strncmp (argv[0], "ne", 2) == 0)
4137 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004138 else if (strncmp (argv[0], "ns", 2) == 0)
4139 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004140 else if (strncmp (argv[0], "su", 2) == 0)
4141 type = OSPF_SUMMARY_LSA;
4142 else if (strncmp (argv[0], "a", 1) == 0)
4143 type = OSPF_ASBR_SUMMARY_LSA;
4144 else if (strncmp (argv[0], "e", 1) == 0)
4145 type = OSPF_AS_EXTERNAL_LSA;
4146 else if (strncmp (argv[0], "se", 2) == 0)
4147 {
paul020709f2003-04-04 02:44:16 +00004148 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004149 return CMD_SUCCESS;
4150 }
4151 else if (strncmp (argv[0], "m", 1) == 0)
4152 {
paul020709f2003-04-04 02:44:16 +00004153 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004154 return CMD_SUCCESS;
4155 }
4156#ifdef HAVE_OPAQUE_LSA
4157 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4158 type = OSPF_OPAQUE_LINK_LSA;
4159 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4160 type = OSPF_OPAQUE_AREA_LSA;
4161 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4162 type = OSPF_OPAQUE_AS_LSA;
4163#endif /* HAVE_OPAQUE_LSA */
4164 else
4165 return CMD_WARNING;
4166
4167 /* `show ip ospf database LSA'. */
4168 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004169 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004170 else if (argc >= 2)
4171 {
4172 ret = inet_aton (argv[1], &id);
4173 if (!ret)
4174 return CMD_WARNING;
4175
4176 /* `show ip ospf database LSA ID'. */
4177 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004178 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004179 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4180 else if (argc == 3)
4181 {
4182 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004183 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004184 else
4185 {
4186 ret = inet_aton (argv[2], &adv_router);
4187 if (!ret)
4188 return CMD_WARNING;
4189 }
paul020709f2003-04-04 02:44:16 +00004190 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004191 }
4192 }
4193
4194 return CMD_SUCCESS;
4195}
4196
4197ALIAS (show_ip_ospf_database,
4198 show_ip_ospf_database_type_cmd,
4199 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4200 SHOW_STR
4201 IP_STR
4202 "OSPF information\n"
4203 "Database summary\n"
4204 OSPF_LSA_TYPES_DESC
4205 "LSAs in MaxAge list\n"
4206 "Self-originated link states\n")
4207
4208ALIAS (show_ip_ospf_database,
4209 show_ip_ospf_database_type_id_cmd,
4210 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4211 SHOW_STR
4212 IP_STR
4213 "OSPF information\n"
4214 "Database summary\n"
4215 OSPF_LSA_TYPES_DESC
4216 "Link State ID (as an IP address)\n")
4217
4218ALIAS (show_ip_ospf_database,
4219 show_ip_ospf_database_type_id_adv_router_cmd,
4220 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4221 SHOW_STR
4222 IP_STR
4223 "OSPF information\n"
4224 "Database summary\n"
4225 OSPF_LSA_TYPES_DESC
4226 "Link State ID (as an IP address)\n"
4227 "Advertising Router link states\n"
4228 "Advertising Router (as an IP address)\n")
4229
4230ALIAS (show_ip_ospf_database,
4231 show_ip_ospf_database_type_id_self_cmd,
4232 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4233 SHOW_STR
4234 IP_STR
4235 "OSPF information\n"
4236 "Database summary\n"
4237 OSPF_LSA_TYPES_DESC
4238 "Link State ID (as an IP address)\n"
4239 "Self-originated link states\n"
4240 "\n")
4241
4242DEFUN (show_ip_ospf_database_type_adv_router,
4243 show_ip_ospf_database_type_adv_router_cmd,
4244 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4245 SHOW_STR
4246 IP_STR
4247 "OSPF information\n"
4248 "Database summary\n"
4249 OSPF_LSA_TYPES_DESC
4250 "Advertising Router link states\n"
4251 "Advertising Router (as an IP address)\n")
4252{
paul020709f2003-04-04 02:44:16 +00004253 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004254 int type, ret;
4255 struct in_addr adv_router;
4256
paul020709f2003-04-04 02:44:16 +00004257 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004258 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004259 {
4260 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4261 return CMD_SUCCESS;
4262 }
paul718e3742002-12-13 20:15:29 +00004263
4264 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004265 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004266
4267 if (argc != 2)
4268 return CMD_WARNING;
4269
4270 /* Set database type to show. */
4271 if (strncmp (argv[0], "r", 1) == 0)
4272 type = OSPF_ROUTER_LSA;
4273 else if (strncmp (argv[0], "ne", 2) == 0)
4274 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004275 else if (strncmp (argv[0], "ns", 2) == 0)
4276 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004277 else if (strncmp (argv[0], "s", 1) == 0)
4278 type = OSPF_SUMMARY_LSA;
4279 else if (strncmp (argv[0], "a", 1) == 0)
4280 type = OSPF_ASBR_SUMMARY_LSA;
4281 else if (strncmp (argv[0], "e", 1) == 0)
4282 type = OSPF_AS_EXTERNAL_LSA;
4283#ifdef HAVE_OPAQUE_LSA
4284 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4285 type = OSPF_OPAQUE_LINK_LSA;
4286 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4287 type = OSPF_OPAQUE_AREA_LSA;
4288 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4289 type = OSPF_OPAQUE_AS_LSA;
4290#endif /* HAVE_OPAQUE_LSA */
4291 else
4292 return CMD_WARNING;
4293
4294 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4295 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004296 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004297 else
4298 {
4299 ret = inet_aton (argv[1], &adv_router);
4300 if (!ret)
4301 return CMD_WARNING;
4302 }
4303
paul020709f2003-04-04 02:44:16 +00004304 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004305
4306 return CMD_SUCCESS;
4307}
4308
4309ALIAS (show_ip_ospf_database_type_adv_router,
4310 show_ip_ospf_database_type_self_cmd,
4311 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4312 SHOW_STR
4313 IP_STR
4314 "OSPF information\n"
4315 "Database summary\n"
4316 OSPF_LSA_TYPES_DESC
4317 "Self-originated link states\n")
4318
David Lamparter6b0655a2014-06-04 06:53:35 +02004319
paul718e3742002-12-13 20:15:29 +00004320DEFUN (ip_ospf_authentication_args,
4321 ip_ospf_authentication_args_addr_cmd,
4322 "ip ospf authentication (null|message-digest) A.B.C.D",
4323 "IP Information\n"
4324 "OSPF interface commands\n"
4325 "Enable authentication on this interface\n"
4326 "Use null authentication\n"
4327 "Use message-digest authentication\n"
4328 "Address of interface")
4329{
4330 struct interface *ifp;
4331 struct in_addr addr;
4332 int ret;
4333 struct ospf_if_params *params;
4334
4335 ifp = vty->index;
4336 params = IF_DEF_PARAMS (ifp);
4337
4338 if (argc == 2)
4339 {
4340 ret = inet_aton(argv[1], &addr);
4341 if (!ret)
4342 {
4343 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4344 VTY_NEWLINE);
4345 return CMD_WARNING;
4346 }
4347
4348 params = ospf_get_if_params (ifp, addr);
4349 ospf_if_update_params (ifp, addr);
4350 }
4351
4352 /* Handle null authentication */
4353 if ( argv[0][0] == 'n' )
4354 {
4355 SET_IF_PARAM (params, auth_type);
4356 params->auth_type = OSPF_AUTH_NULL;
4357 return CMD_SUCCESS;
4358 }
4359
4360 /* Handle message-digest authentication */
4361 if ( argv[0][0] == 'm' )
4362 {
4363 SET_IF_PARAM (params, auth_type);
4364 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4365 return CMD_SUCCESS;
4366 }
4367
4368 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4369 return CMD_WARNING;
4370}
4371
4372ALIAS (ip_ospf_authentication_args,
4373 ip_ospf_authentication_args_cmd,
4374 "ip ospf authentication (null|message-digest)",
4375 "IP Information\n"
4376 "OSPF interface commands\n"
4377 "Enable authentication on this interface\n"
4378 "Use null authentication\n"
4379 "Use message-digest authentication\n")
4380
4381DEFUN (ip_ospf_authentication,
4382 ip_ospf_authentication_addr_cmd,
4383 "ip ospf authentication A.B.C.D",
4384 "IP Information\n"
4385 "OSPF interface commands\n"
4386 "Enable authentication on this interface\n"
4387 "Address of interface")
4388{
4389 struct interface *ifp;
4390 struct in_addr addr;
4391 int ret;
4392 struct ospf_if_params *params;
4393
4394 ifp = vty->index;
4395 params = IF_DEF_PARAMS (ifp);
4396
4397 if (argc == 1)
4398 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004399 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004400 if (!ret)
4401 {
4402 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4403 VTY_NEWLINE);
4404 return CMD_WARNING;
4405 }
4406
4407 params = ospf_get_if_params (ifp, addr);
4408 ospf_if_update_params (ifp, addr);
4409 }
4410
4411 SET_IF_PARAM (params, auth_type);
4412 params->auth_type = OSPF_AUTH_SIMPLE;
4413
4414 return CMD_SUCCESS;
4415}
4416
4417ALIAS (ip_ospf_authentication,
4418 ip_ospf_authentication_cmd,
4419 "ip ospf authentication",
4420 "IP Information\n"
4421 "OSPF interface commands\n"
4422 "Enable authentication on this interface\n")
4423
4424DEFUN (no_ip_ospf_authentication,
4425 no_ip_ospf_authentication_addr_cmd,
4426 "no ip ospf authentication A.B.C.D",
4427 NO_STR
4428 "IP Information\n"
4429 "OSPF interface commands\n"
4430 "Enable authentication on this interface\n"
4431 "Address of interface")
4432{
4433 struct interface *ifp;
4434 struct in_addr addr;
4435 int ret;
4436 struct ospf_if_params *params;
4437
4438 ifp = vty->index;
4439 params = IF_DEF_PARAMS (ifp);
4440
4441 if (argc == 1)
4442 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004443 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004444 if (!ret)
4445 {
4446 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4447 VTY_NEWLINE);
4448 return CMD_WARNING;
4449 }
4450
4451 params = ospf_lookup_if_params (ifp, addr);
4452 if (params == NULL)
4453 return CMD_SUCCESS;
4454 }
4455
4456 params->auth_type = OSPF_AUTH_NOTSET;
4457 UNSET_IF_PARAM (params, auth_type);
4458
4459 if (params != IF_DEF_PARAMS (ifp))
4460 {
4461 ospf_free_if_params (ifp, addr);
4462 ospf_if_update_params (ifp, addr);
4463 }
4464
4465 return CMD_SUCCESS;
4466}
4467
4468ALIAS (no_ip_ospf_authentication,
4469 no_ip_ospf_authentication_cmd,
4470 "no ip ospf authentication",
4471 NO_STR
4472 "IP Information\n"
4473 "OSPF interface commands\n"
4474 "Enable authentication on this interface\n")
4475
4476DEFUN (ip_ospf_authentication_key,
4477 ip_ospf_authentication_key_addr_cmd,
4478 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4479 "IP Information\n"
4480 "OSPF interface commands\n"
4481 "Authentication password (key)\n"
4482 "The OSPF password (key)\n"
4483 "Address of interface")
4484{
4485 struct interface *ifp;
4486 struct in_addr addr;
4487 int ret;
4488 struct ospf_if_params *params;
4489
4490 ifp = vty->index;
4491 params = IF_DEF_PARAMS (ifp);
4492
4493 if (argc == 2)
4494 {
4495 ret = inet_aton(argv[1], &addr);
4496 if (!ret)
4497 {
4498 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4499 VTY_NEWLINE);
4500 return CMD_WARNING;
4501 }
4502
4503 params = ospf_get_if_params (ifp, addr);
4504 ospf_if_update_params (ifp, addr);
4505 }
4506
4507
4508 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004509 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004510 SET_IF_PARAM (params, auth_simple);
4511
4512 return CMD_SUCCESS;
4513}
4514
4515ALIAS (ip_ospf_authentication_key,
4516 ip_ospf_authentication_key_cmd,
4517 "ip ospf authentication-key AUTH_KEY",
4518 "IP Information\n"
4519 "OSPF interface commands\n"
4520 "Authentication password (key)\n"
4521 "The OSPF password (key)")
4522
4523ALIAS (ip_ospf_authentication_key,
4524 ospf_authentication_key_cmd,
4525 "ospf authentication-key AUTH_KEY",
4526 "OSPF interface commands\n"
4527 "Authentication password (key)\n"
4528 "The OSPF password (key)")
4529
4530DEFUN (no_ip_ospf_authentication_key,
4531 no_ip_ospf_authentication_key_addr_cmd,
4532 "no ip ospf authentication-key A.B.C.D",
4533 NO_STR
4534 "IP Information\n"
4535 "OSPF interface commands\n"
4536 "Authentication password (key)\n"
4537 "Address of interface")
4538{
4539 struct interface *ifp;
4540 struct in_addr addr;
4541 int ret;
4542 struct ospf_if_params *params;
4543
4544 ifp = vty->index;
4545 params = IF_DEF_PARAMS (ifp);
4546
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004547 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004548 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004549 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004550 if (!ret)
4551 {
4552 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4553 VTY_NEWLINE);
4554 return CMD_WARNING;
4555 }
4556
4557 params = ospf_lookup_if_params (ifp, addr);
4558 if (params == NULL)
4559 return CMD_SUCCESS;
4560 }
4561
4562 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4563 UNSET_IF_PARAM (params, auth_simple);
4564
4565 if (params != IF_DEF_PARAMS (ifp))
4566 {
4567 ospf_free_if_params (ifp, addr);
4568 ospf_if_update_params (ifp, addr);
4569 }
4570
4571 return CMD_SUCCESS;
4572}
4573
4574ALIAS (no_ip_ospf_authentication_key,
4575 no_ip_ospf_authentication_key_cmd,
4576 "no ip ospf authentication-key",
4577 NO_STR
4578 "IP Information\n"
4579 "OSPF interface commands\n"
4580 "Authentication password (key)\n")
4581
4582ALIAS (no_ip_ospf_authentication_key,
4583 no_ospf_authentication_key_cmd,
4584 "no ospf authentication-key",
4585 NO_STR
4586 "OSPF interface commands\n"
4587 "Authentication password (key)\n")
4588
4589DEFUN (ip_ospf_message_digest_key,
4590 ip_ospf_message_digest_key_addr_cmd,
4591 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4592 "IP Information\n"
4593 "OSPF interface commands\n"
4594 "Message digest authentication password (key)\n"
4595 "Key ID\n"
4596 "Use MD5 algorithm\n"
4597 "The OSPF password (key)"
4598 "Address of interface")
4599{
4600 struct interface *ifp;
4601 struct crypt_key *ck;
4602 u_char key_id;
4603 struct in_addr addr;
4604 int ret;
4605 struct ospf_if_params *params;
4606
4607 ifp = vty->index;
4608 params = IF_DEF_PARAMS (ifp);
4609
4610 if (argc == 3)
4611 {
4612 ret = inet_aton(argv[2], &addr);
4613 if (!ret)
4614 {
4615 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4616 VTY_NEWLINE);
4617 return CMD_WARNING;
4618 }
4619
4620 params = ospf_get_if_params (ifp, addr);
4621 ospf_if_update_params (ifp, addr);
4622 }
4623
4624 key_id = strtol (argv[0], NULL, 10);
4625 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4626 {
4627 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4628 return CMD_WARNING;
4629 }
4630
4631 ck = ospf_crypt_key_new ();
4632 ck->key_id = (u_char) key_id;
4633 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004634 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004635
4636 ospf_crypt_key_add (params->auth_crypt, ck);
4637 SET_IF_PARAM (params, auth_crypt);
4638
4639 return CMD_SUCCESS;
4640}
4641
4642ALIAS (ip_ospf_message_digest_key,
4643 ip_ospf_message_digest_key_cmd,
4644 "ip ospf message-digest-key <1-255> md5 KEY",
4645 "IP Information\n"
4646 "OSPF interface commands\n"
4647 "Message digest authentication password (key)\n"
4648 "Key ID\n"
4649 "Use MD5 algorithm\n"
4650 "The OSPF password (key)")
4651
4652ALIAS (ip_ospf_message_digest_key,
4653 ospf_message_digest_key_cmd,
4654 "ospf message-digest-key <1-255> md5 KEY",
4655 "OSPF interface commands\n"
4656 "Message digest authentication password (key)\n"
4657 "Key ID\n"
4658 "Use MD5 algorithm\n"
4659 "The OSPF password (key)")
4660
4661DEFUN (no_ip_ospf_message_digest_key,
4662 no_ip_ospf_message_digest_key_addr_cmd,
4663 "no ip ospf message-digest-key <1-255> A.B.C.D",
4664 NO_STR
4665 "IP Information\n"
4666 "OSPF interface commands\n"
4667 "Message digest authentication password (key)\n"
4668 "Key ID\n"
4669 "Address of interface")
4670{
4671 struct interface *ifp;
4672 struct crypt_key *ck;
4673 int key_id;
4674 struct in_addr addr;
4675 int ret;
4676 struct ospf_if_params *params;
4677
4678 ifp = vty->index;
4679 params = IF_DEF_PARAMS (ifp);
4680
4681 if (argc == 2)
4682 {
4683 ret = inet_aton(argv[1], &addr);
4684 if (!ret)
4685 {
4686 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4687 VTY_NEWLINE);
4688 return CMD_WARNING;
4689 }
4690
4691 params = ospf_lookup_if_params (ifp, addr);
4692 if (params == NULL)
4693 return CMD_SUCCESS;
4694 }
4695
4696 key_id = strtol (argv[0], NULL, 10);
4697 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4698 if (ck == NULL)
4699 {
4700 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4701 return CMD_WARNING;
4702 }
4703
4704 ospf_crypt_key_delete (params->auth_crypt, key_id);
4705
4706 if (params != IF_DEF_PARAMS (ifp))
4707 {
4708 ospf_free_if_params (ifp, addr);
4709 ospf_if_update_params (ifp, addr);
4710 }
4711
4712 return CMD_SUCCESS;
4713}
4714
4715ALIAS (no_ip_ospf_message_digest_key,
4716 no_ip_ospf_message_digest_key_cmd,
4717 "no ip ospf message-digest-key <1-255>",
4718 NO_STR
4719 "IP Information\n"
4720 "OSPF interface commands\n"
4721 "Message digest authentication password (key)\n"
4722 "Key ID\n")
4723
4724ALIAS (no_ip_ospf_message_digest_key,
4725 no_ospf_message_digest_key_cmd,
4726 "no ospf message-digest-key <1-255>",
4727 NO_STR
4728 "OSPF interface commands\n"
4729 "Message digest authentication password (key)\n"
4730 "Key ID\n")
4731
4732DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004733 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004734 "ip ospf cost <1-65535> A.B.C.D",
4735 "IP Information\n"
4736 "OSPF interface commands\n"
4737 "Interface cost\n"
4738 "Cost\n"
4739 "Address of interface")
4740{
4741 struct interface *ifp = vty->index;
4742 u_int32_t cost;
4743 struct in_addr addr;
4744 int ret;
4745 struct ospf_if_params *params;
4746
4747 params = IF_DEF_PARAMS (ifp);
4748
4749 cost = strtol (argv[0], NULL, 10);
4750
4751 /* cost range is <1-65535>. */
4752 if (cost < 1 || cost > 65535)
4753 {
4754 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4755 return CMD_WARNING;
4756 }
4757
4758 if (argc == 2)
4759 {
4760 ret = inet_aton(argv[1], &addr);
4761 if (!ret)
4762 {
4763 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4764 VTY_NEWLINE);
4765 return CMD_WARNING;
4766 }
4767
4768 params = ospf_get_if_params (ifp, addr);
4769 ospf_if_update_params (ifp, addr);
4770 }
4771
4772 SET_IF_PARAM (params, output_cost_cmd);
4773 params->output_cost_cmd = cost;
4774
4775 ospf_if_recalculate_output_cost (ifp);
4776
4777 return CMD_SUCCESS;
4778}
4779
4780ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004781 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004782 "ip ospf cost <1-65535>",
4783 "IP Information\n"
4784 "OSPF interface commands\n"
4785 "Interface cost\n"
4786 "Cost")
4787
4788ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004789 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004790 "ospf cost <1-65535>",
4791 "OSPF interface commands\n"
4792 "Interface cost\n"
4793 "Cost")
4794
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004795ALIAS (ip_ospf_cost,
4796 ospf_cost_u32_inet4_cmd,
4797 "ospf cost <1-65535> A.B.C.D",
4798 "OSPF interface commands\n"
4799 "Interface cost\n"
4800 "Cost\n"
4801 "Address of interface")
4802
paul718e3742002-12-13 20:15:29 +00004803DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004804 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004805 "no ip ospf cost A.B.C.D",
4806 NO_STR
4807 "IP Information\n"
4808 "OSPF interface commands\n"
4809 "Interface cost\n"
4810 "Address of interface")
4811{
4812 struct interface *ifp = vty->index;
4813 struct in_addr addr;
4814 int ret;
4815 struct ospf_if_params *params;
4816
4817 ifp = vty->index;
4818 params = IF_DEF_PARAMS (ifp);
4819
4820 if (argc == 1)
4821 {
4822 ret = inet_aton(argv[0], &addr);
4823 if (!ret)
4824 {
4825 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4826 VTY_NEWLINE);
4827 return CMD_WARNING;
4828 }
4829
4830 params = ospf_lookup_if_params (ifp, addr);
4831 if (params == NULL)
4832 return CMD_SUCCESS;
4833 }
4834
4835 UNSET_IF_PARAM (params, output_cost_cmd);
4836
4837 if (params != IF_DEF_PARAMS (ifp))
4838 {
4839 ospf_free_if_params (ifp, addr);
4840 ospf_if_update_params (ifp, addr);
4841 }
4842
4843 ospf_if_recalculate_output_cost (ifp);
4844
4845 return CMD_SUCCESS;
4846}
4847
4848ALIAS (no_ip_ospf_cost,
4849 no_ip_ospf_cost_cmd,
4850 "no ip ospf cost",
4851 NO_STR
4852 "IP Information\n"
4853 "OSPF interface commands\n"
4854 "Interface cost\n")
4855
4856ALIAS (no_ip_ospf_cost,
4857 no_ospf_cost_cmd,
4858 "no ospf cost",
4859 NO_STR
4860 "OSPF interface commands\n"
4861 "Interface cost\n")
4862
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004863ALIAS (no_ip_ospf_cost,
4864 no_ospf_cost_inet4_cmd,
4865 "no ospf cost A.B.C.D",
4866 NO_STR
4867 "OSPF interface commands\n"
4868 "Interface cost\n"
4869 "Address of interface")
4870
Denis Ovsienko827341b2009-09-28 19:34:59 +04004871DEFUN (no_ip_ospf_cost2,
4872 no_ip_ospf_cost_u32_cmd,
4873 "no ip ospf cost <1-65535>",
4874 NO_STR
4875 "IP Information\n"
4876 "OSPF interface commands\n"
4877 "Interface cost\n"
4878 "Cost")
4879{
4880 struct interface *ifp = vty->index;
4881 struct in_addr addr;
4882 u_int32_t cost;
4883 int ret;
4884 struct ospf_if_params *params;
4885
4886 ifp = vty->index;
4887 params = IF_DEF_PARAMS (ifp);
4888
4889 /* According to the semantics we are mimicking "no ip ospf cost N" is
4890 * always treated as "no ip ospf cost" regardless of the actual value
4891 * of N already configured for the interface. Thus the first argument
4892 * is always checked to be a number, but is ignored after that.
4893 */
4894 cost = strtol (argv[0], NULL, 10);
4895 if (cost < 1 || cost > 65535)
4896 {
4897 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4898 return CMD_WARNING;
4899 }
4900
4901 if (argc == 2)
4902 {
4903 ret = inet_aton(argv[1], &addr);
4904 if (!ret)
4905 {
4906 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4907 VTY_NEWLINE);
4908 return CMD_WARNING;
4909 }
4910
4911 params = ospf_lookup_if_params (ifp, addr);
4912 if (params == NULL)
4913 return CMD_SUCCESS;
4914 }
4915
4916 UNSET_IF_PARAM (params, output_cost_cmd);
4917
4918 if (params != IF_DEF_PARAMS (ifp))
4919 {
4920 ospf_free_if_params (ifp, addr);
4921 ospf_if_update_params (ifp, addr);
4922 }
4923
4924 ospf_if_recalculate_output_cost (ifp);
4925
4926 return CMD_SUCCESS;
4927}
4928
4929ALIAS (no_ip_ospf_cost2,
4930 no_ospf_cost_u32_cmd,
4931 "no ospf cost <1-65535>",
4932 NO_STR
4933 "OSPF interface commands\n"
4934 "Interface cost\n"
4935 "Cost")
4936
4937ALIAS (no_ip_ospf_cost2,
4938 no_ip_ospf_cost_u32_inet4_cmd,
4939 "no ip ospf cost <1-65535> A.B.C.D",
4940 NO_STR
4941 "IP Information\n"
4942 "OSPF interface commands\n"
4943 "Interface cost\n"
4944 "Cost\n"
4945 "Address of interface")
4946
4947ALIAS (no_ip_ospf_cost2,
4948 no_ospf_cost_u32_inet4_cmd,
4949 "no ospf cost <1-65535> A.B.C.D",
4950 NO_STR
4951 "OSPF interface commands\n"
4952 "Interface cost\n"
4953 "Cost\n"
4954 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004955
paul4dadc292005-05-06 21:37:42 +00004956static void
paul718e3742002-12-13 20:15:29 +00004957ospf_nbr_timer_update (struct ospf_interface *oi)
4958{
4959 struct route_node *rn;
4960 struct ospf_neighbor *nbr;
4961
4962 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4963 if ((nbr = rn->info))
4964 {
4965 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4966 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4967 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4968 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4969 }
4970}
4971
paulf9ad9372005-10-21 00:45:17 +00004972static int
4973ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4974 const char *nbr_str,
4975 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004976{
4977 struct interface *ifp = vty->index;
4978 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004979 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004980 struct in_addr addr;
4981 int ret;
4982 struct ospf_if_params *params;
4983 struct ospf_interface *oi;
4984 struct route_node *rn;
4985
4986 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004987
4988 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004989 {
paulf9ad9372005-10-21 00:45:17 +00004990 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004991 if (!ret)
4992 {
4993 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4994 VTY_NEWLINE);
4995 return CMD_WARNING;
4996 }
4997
4998 params = ospf_get_if_params (ifp, addr);
4999 ospf_if_update_params (ifp, addr);
5000 }
5001
paulf9ad9372005-10-21 00:45:17 +00005002 if (interval_str)
5003 {
5004 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
5005 1, 65535);
5006
5007 /* reset fast_hello too, just to be sure */
5008 UNSET_IF_PARAM (params, fast_hello);
5009 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5010 }
5011 else if (fast_hello_str)
5012 {
5013 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5014 1, 10);
5015 /* 1s dead-interval with sub-second hellos desired */
5016 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5017 SET_IF_PARAM (params, fast_hello);
5018 params->fast_hello = hellomult;
5019 }
5020 else
5021 {
5022 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5023 VTY_NEWLINE);
5024 return CMD_WARNING;
5025 }
5026
paul718e3742002-12-13 20:15:29 +00005027 SET_IF_PARAM (params, v_wait);
5028 params->v_wait = seconds;
5029
5030 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005031 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005032 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005033 struct ospf *ospf;
5034 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005035 {
5036 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5037 if (oi)
5038 ospf_nbr_timer_update (oi);
5039 }
paul718e3742002-12-13 20:15:29 +00005040 }
5041 else
5042 {
5043 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5044 if ((oi = rn->info))
5045 ospf_nbr_timer_update (oi);
5046 }
5047
5048 return CMD_SUCCESS;
5049}
5050
paulf9ad9372005-10-21 00:45:17 +00005051
5052DEFUN (ip_ospf_dead_interval,
5053 ip_ospf_dead_interval_addr_cmd,
5054 "ip ospf dead-interval <1-65535> A.B.C.D",
5055 "IP Information\n"
5056 "OSPF interface commands\n"
5057 "Interval after which a neighbor is declared dead\n"
5058 "Seconds\n"
5059 "Address of interface\n")
5060{
5061 if (argc == 2)
5062 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5063 else
5064 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5065}
5066
paul718e3742002-12-13 20:15:29 +00005067ALIAS (ip_ospf_dead_interval,
5068 ip_ospf_dead_interval_cmd,
5069 "ip ospf dead-interval <1-65535>",
5070 "IP Information\n"
5071 "OSPF interface commands\n"
5072 "Interval after which a neighbor is declared dead\n"
5073 "Seconds\n")
5074
5075ALIAS (ip_ospf_dead_interval,
5076 ospf_dead_interval_cmd,
5077 "ospf dead-interval <1-65535>",
5078 "OSPF interface commands\n"
5079 "Interval after which a neighbor is declared dead\n"
5080 "Seconds\n")
5081
paulf9ad9372005-10-21 00:45:17 +00005082DEFUN (ip_ospf_dead_interval_minimal,
5083 ip_ospf_dead_interval_minimal_addr_cmd,
5084 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5085 "IP Information\n"
5086 "OSPF interface commands\n"
5087 "Interval after which a neighbor is declared dead\n"
5088 "Minimal 1s dead-interval with fast sub-second hellos\n"
5089 "Hello multiplier factor\n"
5090 "Number of Hellos to send each second\n"
5091 "Address of interface\n")
5092{
5093 if (argc == 2)
5094 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5095 else
5096 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5097}
5098
5099ALIAS (ip_ospf_dead_interval_minimal,
5100 ip_ospf_dead_interval_minimal_cmd,
5101 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5102 "IP Information\n"
5103 "OSPF interface commands\n"
5104 "Interval after which a neighbor is declared dead\n"
5105 "Minimal 1s dead-interval with fast sub-second hellos\n"
5106 "Hello multiplier factor\n"
5107 "Number of Hellos to send each second\n")
5108
paul718e3742002-12-13 20:15:29 +00005109DEFUN (no_ip_ospf_dead_interval,
5110 no_ip_ospf_dead_interval_addr_cmd,
5111 "no ip ospf dead-interval A.B.C.D",
5112 NO_STR
5113 "IP Information\n"
5114 "OSPF interface commands\n"
5115 "Interval after which a neighbor is declared dead\n"
5116 "Address of interface")
5117{
5118 struct interface *ifp = vty->index;
5119 struct in_addr addr;
5120 int ret;
5121 struct ospf_if_params *params;
5122 struct ospf_interface *oi;
5123 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005124
paul718e3742002-12-13 20:15:29 +00005125 ifp = vty->index;
5126 params = IF_DEF_PARAMS (ifp);
5127
5128 if (argc == 1)
5129 {
5130 ret = inet_aton(argv[0], &addr);
5131 if (!ret)
5132 {
5133 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5134 VTY_NEWLINE);
5135 return CMD_WARNING;
5136 }
5137
5138 params = ospf_lookup_if_params (ifp, addr);
5139 if (params == NULL)
5140 return CMD_SUCCESS;
5141 }
5142
5143 UNSET_IF_PARAM (params, v_wait);
5144 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005145
5146 UNSET_IF_PARAM (params, fast_hello);
5147 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5148
paul718e3742002-12-13 20:15:29 +00005149 if (params != IF_DEF_PARAMS (ifp))
5150 {
5151 ospf_free_if_params (ifp, addr);
5152 ospf_if_update_params (ifp, addr);
5153 }
5154
5155 /* Update timer values in neighbor structure. */
5156 if (argc == 1)
5157 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005158 struct ospf *ospf;
5159
5160 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005161 {
5162 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5163 if (oi)
5164 ospf_nbr_timer_update (oi);
5165 }
paul718e3742002-12-13 20:15:29 +00005166 }
5167 else
5168 {
5169 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5170 if ((oi = rn->info))
5171 ospf_nbr_timer_update (oi);
5172 }
5173
5174 return CMD_SUCCESS;
5175}
5176
5177ALIAS (no_ip_ospf_dead_interval,
5178 no_ip_ospf_dead_interval_cmd,
5179 "no ip ospf dead-interval",
5180 NO_STR
5181 "IP Information\n"
5182 "OSPF interface commands\n"
5183 "Interval after which a neighbor is declared dead\n")
5184
5185ALIAS (no_ip_ospf_dead_interval,
5186 no_ospf_dead_interval_cmd,
5187 "no ospf dead-interval",
5188 NO_STR
5189 "OSPF interface commands\n"
5190 "Interval after which a neighbor is declared dead\n")
5191
5192DEFUN (ip_ospf_hello_interval,
5193 ip_ospf_hello_interval_addr_cmd,
5194 "ip ospf hello-interval <1-65535> A.B.C.D",
5195 "IP Information\n"
5196 "OSPF interface commands\n"
5197 "Time between HELLO packets\n"
5198 "Seconds\n"
5199 "Address of interface")
5200{
5201 struct interface *ifp = vty->index;
5202 u_int32_t seconds;
5203 struct in_addr addr;
5204 int ret;
5205 struct ospf_if_params *params;
5206
5207 params = IF_DEF_PARAMS (ifp);
5208
5209 seconds = strtol (argv[0], NULL, 10);
5210
5211 /* HelloInterval range is <1-65535>. */
5212 if (seconds < 1 || seconds > 65535)
5213 {
5214 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5215 return CMD_WARNING;
5216 }
5217
5218 if (argc == 2)
5219 {
5220 ret = inet_aton(argv[1], &addr);
5221 if (!ret)
5222 {
5223 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5224 VTY_NEWLINE);
5225 return CMD_WARNING;
5226 }
5227
5228 params = ospf_get_if_params (ifp, addr);
5229 ospf_if_update_params (ifp, addr);
5230 }
5231
paulf9ad9372005-10-21 00:45:17 +00005232 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005233 params->v_hello = seconds;
5234
5235 return CMD_SUCCESS;
5236}
5237
5238ALIAS (ip_ospf_hello_interval,
5239 ip_ospf_hello_interval_cmd,
5240 "ip ospf hello-interval <1-65535>",
5241 "IP Information\n"
5242 "OSPF interface commands\n"
5243 "Time between HELLO packets\n"
5244 "Seconds\n")
5245
5246ALIAS (ip_ospf_hello_interval,
5247 ospf_hello_interval_cmd,
5248 "ospf hello-interval <1-65535>",
5249 "OSPF interface commands\n"
5250 "Time between HELLO packets\n"
5251 "Seconds\n")
5252
5253DEFUN (no_ip_ospf_hello_interval,
5254 no_ip_ospf_hello_interval_addr_cmd,
5255 "no ip ospf hello-interval A.B.C.D",
5256 NO_STR
5257 "IP Information\n"
5258 "OSPF interface commands\n"
5259 "Time between HELLO packets\n"
5260 "Address of interface")
5261{
5262 struct interface *ifp = vty->index;
5263 struct in_addr addr;
5264 int ret;
5265 struct ospf_if_params *params;
5266
5267 ifp = vty->index;
5268 params = IF_DEF_PARAMS (ifp);
5269
5270 if (argc == 1)
5271 {
5272 ret = inet_aton(argv[0], &addr);
5273 if (!ret)
5274 {
5275 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5276 VTY_NEWLINE);
5277 return CMD_WARNING;
5278 }
5279
5280 params = ospf_lookup_if_params (ifp, addr);
5281 if (params == NULL)
5282 return CMD_SUCCESS;
5283 }
5284
5285 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005286 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005287
5288 if (params != IF_DEF_PARAMS (ifp))
5289 {
5290 ospf_free_if_params (ifp, addr);
5291 ospf_if_update_params (ifp, addr);
5292 }
5293
5294 return CMD_SUCCESS;
5295}
5296
5297ALIAS (no_ip_ospf_hello_interval,
5298 no_ip_ospf_hello_interval_cmd,
5299 "no ip ospf hello-interval",
5300 NO_STR
5301 "IP Information\n"
5302 "OSPF interface commands\n"
5303 "Time between HELLO packets\n")
5304
5305ALIAS (no_ip_ospf_hello_interval,
5306 no_ospf_hello_interval_cmd,
5307 "no ospf hello-interval",
5308 NO_STR
5309 "OSPF interface commands\n"
5310 "Time between HELLO packets\n")
5311
5312DEFUN (ip_ospf_network,
5313 ip_ospf_network_cmd,
5314 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5315 "IP Information\n"
5316 "OSPF interface commands\n"
5317 "Network type\n"
5318 "Specify OSPF broadcast multi-access network\n"
5319 "Specify OSPF NBMA network\n"
5320 "Specify OSPF point-to-multipoint network\n"
5321 "Specify OSPF point-to-point network\n")
5322{
5323 struct interface *ifp = vty->index;
5324 int old_type = IF_DEF_PARAMS (ifp)->type;
5325 struct route_node *rn;
Christian Franke4b4bda92013-07-11 07:56:29 +00005326
5327 if (old_type == OSPF_IFTYPE_LOOPBACK)
5328 {
5329 vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
5330 return CMD_WARNING;
5331 }
5332
paul718e3742002-12-13 20:15:29 +00005333 if (strncmp (argv[0], "b", 1) == 0)
5334 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5335 else if (strncmp (argv[0], "n", 1) == 0)
5336 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5337 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5338 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5339 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5340 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5341
5342 if (IF_DEF_PARAMS (ifp)->type == old_type)
5343 return CMD_SUCCESS;
5344
5345 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5346
5347 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5348 {
5349 struct ospf_interface *oi = rn->info;
5350
5351 if (!oi)
5352 continue;
5353
5354 oi->type = IF_DEF_PARAMS (ifp)->type;
5355
5356 if (oi->state > ISM_Down)
5357 {
5358 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5359 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5360 }
5361 }
5362
5363 return CMD_SUCCESS;
5364}
5365
5366ALIAS (ip_ospf_network,
5367 ospf_network_cmd,
5368 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5369 "OSPF interface commands\n"
5370 "Network type\n"
5371 "Specify OSPF broadcast multi-access network\n"
5372 "Specify OSPF NBMA network\n"
5373 "Specify OSPF point-to-multipoint network\n"
5374 "Specify OSPF point-to-point network\n")
5375
5376DEFUN (no_ip_ospf_network,
5377 no_ip_ospf_network_cmd,
5378 "no ip ospf network",
5379 NO_STR
5380 "IP Information\n"
5381 "OSPF interface commands\n"
5382 "Network type\n")
5383{
5384 struct interface *ifp = vty->index;
5385 int old_type = IF_DEF_PARAMS (ifp)->type;
5386 struct route_node *rn;
5387
ajsbc18d612004-12-15 15:07:19 +00005388 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005389
5390 if (IF_DEF_PARAMS (ifp)->type == old_type)
5391 return CMD_SUCCESS;
5392
5393 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5394 {
5395 struct ospf_interface *oi = rn->info;
5396
5397 if (!oi)
5398 continue;
5399
5400 oi->type = IF_DEF_PARAMS (ifp)->type;
5401
5402 if (oi->state > ISM_Down)
5403 {
5404 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5405 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5406 }
5407 }
5408
5409 return CMD_SUCCESS;
5410}
5411
5412ALIAS (no_ip_ospf_network,
5413 no_ospf_network_cmd,
5414 "no ospf network",
5415 NO_STR
5416 "OSPF interface commands\n"
5417 "Network type\n")
5418
5419DEFUN (ip_ospf_priority,
5420 ip_ospf_priority_addr_cmd,
5421 "ip ospf priority <0-255> A.B.C.D",
5422 "IP Information\n"
5423 "OSPF interface commands\n"
5424 "Router priority\n"
5425 "Priority\n"
5426 "Address of interface")
5427{
5428 struct interface *ifp = vty->index;
Andrew Certain0798cee2012-12-04 13:43:42 -08005429 long priority;
paul718e3742002-12-13 20:15:29 +00005430 struct route_node *rn;
5431 struct in_addr addr;
5432 int ret;
5433 struct ospf_if_params *params;
5434
5435 params = IF_DEF_PARAMS (ifp);
5436
5437 priority = strtol (argv[0], NULL, 10);
5438
5439 /* Router Priority range is <0-255>. */
5440 if (priority < 0 || priority > 255)
5441 {
5442 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5443 return CMD_WARNING;
5444 }
5445
5446 if (argc == 2)
5447 {
5448 ret = inet_aton(argv[1], &addr);
5449 if (!ret)
5450 {
5451 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5452 VTY_NEWLINE);
5453 return CMD_WARNING;
5454 }
5455
5456 params = ospf_get_if_params (ifp, addr);
5457 ospf_if_update_params (ifp, addr);
5458 }
5459
5460 SET_IF_PARAM (params, priority);
5461 params->priority = priority;
5462
5463 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5464 {
5465 struct ospf_interface *oi = rn->info;
5466
5467 if (!oi)
5468 continue;
5469
5470
5471 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5472 {
5473 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5474 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5475 }
5476 }
5477
5478 return CMD_SUCCESS;
5479}
5480
5481ALIAS (ip_ospf_priority,
5482 ip_ospf_priority_cmd,
5483 "ip ospf priority <0-255>",
5484 "IP Information\n"
5485 "OSPF interface commands\n"
5486 "Router priority\n"
5487 "Priority\n")
5488
5489ALIAS (ip_ospf_priority,
5490 ospf_priority_cmd,
5491 "ospf priority <0-255>",
5492 "OSPF interface commands\n"
5493 "Router priority\n"
5494 "Priority\n")
5495
5496DEFUN (no_ip_ospf_priority,
5497 no_ip_ospf_priority_addr_cmd,
5498 "no ip ospf priority A.B.C.D",
5499 NO_STR
5500 "IP Information\n"
5501 "OSPF interface commands\n"
5502 "Router priority\n"
5503 "Address of interface")
5504{
5505 struct interface *ifp = vty->index;
5506 struct route_node *rn;
5507 struct in_addr addr;
5508 int ret;
5509 struct ospf_if_params *params;
5510
5511 ifp = vty->index;
5512 params = IF_DEF_PARAMS (ifp);
5513
5514 if (argc == 1)
5515 {
5516 ret = inet_aton(argv[0], &addr);
5517 if (!ret)
5518 {
5519 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5520 VTY_NEWLINE);
5521 return CMD_WARNING;
5522 }
5523
5524 params = ospf_lookup_if_params (ifp, addr);
5525 if (params == NULL)
5526 return CMD_SUCCESS;
5527 }
5528
5529 UNSET_IF_PARAM (params, priority);
5530 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5531
5532 if (params != IF_DEF_PARAMS (ifp))
5533 {
5534 ospf_free_if_params (ifp, addr);
5535 ospf_if_update_params (ifp, addr);
5536 }
5537
5538 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5539 {
5540 struct ospf_interface *oi = rn->info;
5541
5542 if (!oi)
5543 continue;
5544
5545
5546 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5547 {
5548 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5549 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5550 }
5551 }
5552
5553 return CMD_SUCCESS;
5554}
5555
5556ALIAS (no_ip_ospf_priority,
5557 no_ip_ospf_priority_cmd,
5558 "no ip ospf priority",
5559 NO_STR
5560 "IP Information\n"
5561 "OSPF interface commands\n"
5562 "Router priority\n")
5563
5564ALIAS (no_ip_ospf_priority,
5565 no_ospf_priority_cmd,
5566 "no ospf priority",
5567 NO_STR
5568 "OSPF interface commands\n"
5569 "Router priority\n")
5570
5571DEFUN (ip_ospf_retransmit_interval,
5572 ip_ospf_retransmit_interval_addr_cmd,
5573 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5574 "IP Information\n"
5575 "OSPF interface commands\n"
5576 "Time between retransmitting lost link state advertisements\n"
5577 "Seconds\n"
5578 "Address of interface")
5579{
5580 struct interface *ifp = vty->index;
5581 u_int32_t seconds;
5582 struct in_addr addr;
5583 int ret;
5584 struct ospf_if_params *params;
5585
5586 params = IF_DEF_PARAMS (ifp);
5587 seconds = strtol (argv[0], NULL, 10);
5588
5589 /* Retransmit Interval range is <3-65535>. */
5590 if (seconds < 3 || seconds > 65535)
5591 {
5592 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5593 return CMD_WARNING;
5594 }
5595
5596
5597 if (argc == 2)
5598 {
5599 ret = inet_aton(argv[1], &addr);
5600 if (!ret)
5601 {
5602 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5603 VTY_NEWLINE);
5604 return CMD_WARNING;
5605 }
5606
5607 params = ospf_get_if_params (ifp, addr);
5608 ospf_if_update_params (ifp, addr);
5609 }
5610
5611 SET_IF_PARAM (params, retransmit_interval);
5612 params->retransmit_interval = seconds;
5613
5614 return CMD_SUCCESS;
5615}
5616
5617ALIAS (ip_ospf_retransmit_interval,
5618 ip_ospf_retransmit_interval_cmd,
5619 "ip ospf retransmit-interval <3-65535>",
5620 "IP Information\n"
5621 "OSPF interface commands\n"
5622 "Time between retransmitting lost link state advertisements\n"
5623 "Seconds\n")
5624
5625ALIAS (ip_ospf_retransmit_interval,
5626 ospf_retransmit_interval_cmd,
5627 "ospf retransmit-interval <3-65535>",
5628 "OSPF interface commands\n"
5629 "Time between retransmitting lost link state advertisements\n"
5630 "Seconds\n")
5631
5632DEFUN (no_ip_ospf_retransmit_interval,
5633 no_ip_ospf_retransmit_interval_addr_cmd,
5634 "no ip ospf retransmit-interval A.B.C.D",
5635 NO_STR
5636 "IP Information\n"
5637 "OSPF interface commands\n"
5638 "Time between retransmitting lost link state advertisements\n"
5639 "Address of interface")
5640{
5641 struct interface *ifp = vty->index;
5642 struct in_addr addr;
5643 int ret;
5644 struct ospf_if_params *params;
5645
5646 ifp = vty->index;
5647 params = IF_DEF_PARAMS (ifp);
5648
5649 if (argc == 1)
5650 {
5651 ret = inet_aton(argv[0], &addr);
5652 if (!ret)
5653 {
5654 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5655 VTY_NEWLINE);
5656 return CMD_WARNING;
5657 }
5658
5659 params = ospf_lookup_if_params (ifp, addr);
5660 if (params == NULL)
5661 return CMD_SUCCESS;
5662 }
5663
5664 UNSET_IF_PARAM (params, retransmit_interval);
5665 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5666
5667 if (params != IF_DEF_PARAMS (ifp))
5668 {
5669 ospf_free_if_params (ifp, addr);
5670 ospf_if_update_params (ifp, addr);
5671 }
5672
5673 return CMD_SUCCESS;
5674}
5675
5676ALIAS (no_ip_ospf_retransmit_interval,
5677 no_ip_ospf_retransmit_interval_cmd,
5678 "no ip ospf retransmit-interval",
5679 NO_STR
5680 "IP Information\n"
5681 "OSPF interface commands\n"
5682 "Time between retransmitting lost link state advertisements\n")
5683
5684ALIAS (no_ip_ospf_retransmit_interval,
5685 no_ospf_retransmit_interval_cmd,
5686 "no ospf retransmit-interval",
5687 NO_STR
5688 "OSPF interface commands\n"
5689 "Time between retransmitting lost link state advertisements\n")
5690
5691DEFUN (ip_ospf_transmit_delay,
5692 ip_ospf_transmit_delay_addr_cmd,
5693 "ip ospf transmit-delay <1-65535> A.B.C.D",
5694 "IP Information\n"
5695 "OSPF interface commands\n"
5696 "Link state transmit delay\n"
5697 "Seconds\n"
5698 "Address of interface")
5699{
5700 struct interface *ifp = vty->index;
5701 u_int32_t seconds;
5702 struct in_addr addr;
5703 int ret;
5704 struct ospf_if_params *params;
5705
5706 params = IF_DEF_PARAMS (ifp);
5707 seconds = strtol (argv[0], NULL, 10);
5708
5709 /* Transmit Delay range is <1-65535>. */
5710 if (seconds < 1 || seconds > 65535)
5711 {
5712 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5713 return CMD_WARNING;
5714 }
5715
5716 if (argc == 2)
5717 {
5718 ret = inet_aton(argv[1], &addr);
5719 if (!ret)
5720 {
5721 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5722 VTY_NEWLINE);
5723 return CMD_WARNING;
5724 }
5725
5726 params = ospf_get_if_params (ifp, addr);
5727 ospf_if_update_params (ifp, addr);
5728 }
5729
5730 SET_IF_PARAM (params, transmit_delay);
5731 params->transmit_delay = seconds;
5732
5733 return CMD_SUCCESS;
5734}
5735
5736ALIAS (ip_ospf_transmit_delay,
5737 ip_ospf_transmit_delay_cmd,
5738 "ip ospf transmit-delay <1-65535>",
5739 "IP Information\n"
5740 "OSPF interface commands\n"
5741 "Link state transmit delay\n"
5742 "Seconds\n")
5743
5744ALIAS (ip_ospf_transmit_delay,
5745 ospf_transmit_delay_cmd,
5746 "ospf transmit-delay <1-65535>",
5747 "OSPF interface commands\n"
5748 "Link state transmit delay\n"
5749 "Seconds\n")
5750
5751DEFUN (no_ip_ospf_transmit_delay,
5752 no_ip_ospf_transmit_delay_addr_cmd,
5753 "no ip ospf transmit-delay A.B.C.D",
5754 NO_STR
5755 "IP Information\n"
5756 "OSPF interface commands\n"
5757 "Link state transmit delay\n"
5758 "Address of interface")
5759{
5760 struct interface *ifp = vty->index;
5761 struct in_addr addr;
5762 int ret;
5763 struct ospf_if_params *params;
5764
5765 ifp = vty->index;
5766 params = IF_DEF_PARAMS (ifp);
5767
5768 if (argc == 1)
5769 {
5770 ret = inet_aton(argv[0], &addr);
5771 if (!ret)
5772 {
5773 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5774 VTY_NEWLINE);
5775 return CMD_WARNING;
5776 }
5777
5778 params = ospf_lookup_if_params (ifp, addr);
5779 if (params == NULL)
5780 return CMD_SUCCESS;
5781 }
5782
5783 UNSET_IF_PARAM (params, transmit_delay);
5784 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5785
5786 if (params != IF_DEF_PARAMS (ifp))
5787 {
5788 ospf_free_if_params (ifp, addr);
5789 ospf_if_update_params (ifp, addr);
5790 }
5791
5792 return CMD_SUCCESS;
5793}
5794
5795ALIAS (no_ip_ospf_transmit_delay,
5796 no_ip_ospf_transmit_delay_cmd,
5797 "no ip ospf transmit-delay",
5798 NO_STR
5799 "IP Information\n"
5800 "OSPF interface commands\n"
5801 "Link state transmit delay\n")
5802
5803ALIAS (no_ip_ospf_transmit_delay,
5804 no_ospf_transmit_delay_cmd,
5805 "no ospf transmit-delay",
5806 NO_STR
5807 "OSPF interface commands\n"
5808 "Link state transmit delay\n")
5809
Christian Franke6f2a6702013-09-30 12:27:52 +00005810DEFUN (ospf_redistribute_source,
5811 ospf_redistribute_source_cmd,
5812 "redistribute " QUAGGA_REDIST_STR_OSPFD
5813 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
Paul Jakmad1c65c22006-06-27 08:01:43 +00005814 REDIST_STR
5815 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005816 "Metric for redistributed routes\n"
5817 "OSPF default metric\n"
5818 "OSPF exterior metric type for redistributed routes\n"
5819 "Set OSPF External Type 1 metrics\n"
5820 "Set OSPF External Type 2 metrics\n"
5821 "Route map reference\n"
5822 "Pointer to route-map entries\n")
5823{
paul020709f2003-04-04 02:44:16 +00005824 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005825 int source;
5826 int type = -1;
5827 int metric = -1;
5828
Christian Franke6f2a6702013-09-30 12:27:52 +00005829 if (argc < 4)
5830 return CMD_WARNING; /* should not happen */
5831
paul718e3742002-12-13 20:15:29 +00005832 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005833 source = proto_redistnum(AFI_IP, argv[0]);
5834 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005835 return CMD_WARNING;
5836
5837 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005838 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00005839 if (!str2metric (argv[1], &metric))
5840 return CMD_WARNING;
5841
5842 /* Get metric type. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005843 if (argv[2] != NULL)
paul718e3742002-12-13 20:15:29 +00005844 if (!str2metric_type (argv[2], &type))
5845 return CMD_WARNING;
5846
Christian Franke6f2a6702013-09-30 12:27:52 +00005847 if (argv[3] != NULL)
paul020709f2003-04-04 02:44:16 +00005848 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005849 else
paul020709f2003-04-04 02:44:16 +00005850 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005851
paul020709f2003-04-04 02:44:16 +00005852 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005853}
5854
paul718e3742002-12-13 20:15:29 +00005855DEFUN (no_ospf_redistribute_source,
5856 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005857 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005858 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005859 REDIST_STR
5860 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005861{
paul020709f2003-04-04 02:44:16 +00005862 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005863 int source;
5864
David Lampartere0ca5fd2009-09-16 01:52:42 +02005865 source = proto_redistnum(AFI_IP, argv[0]);
5866 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005867 return CMD_WARNING;
5868
paul020709f2003-04-04 02:44:16 +00005869 ospf_routemap_unset (ospf, source);
5870 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005871}
5872
5873DEFUN (ospf_distribute_list_out,
5874 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005875 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005876 "Filter networks in routing updates\n"
5877 "Access-list name\n"
5878 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005879 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005880{
paul68980082003-03-25 05:07:42 +00005881 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005882 int source;
5883
5884 /* Get distribute source. */
Christian Frankebda3c322012-12-04 11:31:16 -08005885 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02005886 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005887 return CMD_WARNING;
5888
paul68980082003-03-25 05:07:42 +00005889 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005890}
5891
5892DEFUN (no_ospf_distribute_list_out,
5893 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005894 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005895 NO_STR
5896 "Filter networks in routing updates\n"
5897 "Access-list name\n"
5898 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005899 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005900{
paul68980082003-03-25 05:07:42 +00005901 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005902 int source;
5903
Christian Frankebda3c322012-12-04 11:31:16 -08005904 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02005905 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005906 return CMD_WARNING;
5907
paul68980082003-03-25 05:07:42 +00005908 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005909}
5910
5911/* Default information originate. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005912DEFUN (ospf_default_information_originate,
paul718e3742002-12-13 20:15:29 +00005913 ospf_default_information_originate_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00005914 "default-information originate "
5915 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
paul718e3742002-12-13 20:15:29 +00005916 "Control distribution of default information\n"
5917 "Distribute a default route\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00005918 "Always advertise default route\n"
paul718e3742002-12-13 20:15:29 +00005919 "OSPF default metric\n"
5920 "OSPF metric\n"
paul718e3742002-12-13 20:15:29 +00005921 "OSPF metric type for default routes\n"
5922 "Set OSPF External Type 1 metrics\n"
5923 "Set OSPF External Type 2 metrics\n"
paul718e3742002-12-13 20:15:29 +00005924 "Route map reference\n"
5925 "Pointer to route-map entries\n")
5926{
paul020709f2003-04-04 02:44:16 +00005927 struct ospf *ospf = vty->index;
Christian Franke6f2a6702013-09-30 12:27:52 +00005928 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
paul718e3742002-12-13 20:15:29 +00005929 int type = -1;
5930 int metric = -1;
5931
Christian Franke6f2a6702013-09-30 12:27:52 +00005932 if (argc < 4)
5933 return CMD_WARNING; /* this should not happen */
5934
5935 /* Check whether "always" was specified */
5936 if (argv[0] != NULL)
5937 default_originate = DEFAULT_ORIGINATE_ALWAYS;
paul718e3742002-12-13 20:15:29 +00005938
5939 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005940 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00005941 if (!str2metric (argv[1], &metric))
5942 return CMD_WARNING;
5943
Christian Franke6f2a6702013-09-30 12:27:52 +00005944 /* Get metric type. */
5945 if (argv[2] != NULL)
5946 if (!str2metric_type (argv[2], &type))
5947 return CMD_WARNING;
5948
5949 if (argv[3] != NULL)
5950 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
paul718e3742002-12-13 20:15:29 +00005951 else
paul020709f2003-04-04 02:44:16 +00005952 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005953
Christian Franke6f2a6702013-09-30 12:27:52 +00005954 return ospf_redistribute_default_set (ospf, default_originate,
paul020709f2003-04-04 02:44:16 +00005955 type, metric);
paul718e3742002-12-13 20:15:29 +00005956}
5957
paul718e3742002-12-13 20:15:29 +00005958DEFUN (no_ospf_default_information_originate,
5959 no_ospf_default_information_originate_cmd,
5960 "no default-information originate",
5961 NO_STR
5962 "Control distribution of default information\n"
5963 "Distribute a default route\n")
5964{
paul68980082003-03-25 05:07:42 +00005965 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005966 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00005967
5968 p.family = AF_INET;
5969 p.prefix.s_addr = 0;
5970 p.prefixlen = 0;
5971
ajs5339cfd2005-09-19 13:28:05 +00005972 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00005973
5974 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
5975 ospf_external_info_delete (DEFAULT_ROUTE, p);
5976 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
5977 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
5978 }
5979
paul020709f2003-04-04 02:44:16 +00005980 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5981 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00005982}
5983
5984DEFUN (ospf_default_metric,
5985 ospf_default_metric_cmd,
5986 "default-metric <0-16777214>",
5987 "Set metric of redistributed routes\n"
5988 "Default metric\n")
5989{
paul68980082003-03-25 05:07:42 +00005990 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005991 int metric = -1;
5992
5993 if (!str2metric (argv[0], &metric))
5994 return CMD_WARNING;
5995
paul68980082003-03-25 05:07:42 +00005996 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00005997
5998 return CMD_SUCCESS;
5999}
6000
6001DEFUN (no_ospf_default_metric,
6002 no_ospf_default_metric_cmd,
6003 "no default-metric",
6004 NO_STR
6005 "Set metric of redistributed routes\n")
6006{
paul68980082003-03-25 05:07:42 +00006007 struct ospf *ospf = vty->index;
6008
6009 ospf->default_metric = -1;
6010
paul718e3742002-12-13 20:15:29 +00006011 return CMD_SUCCESS;
6012}
6013
6014ALIAS (no_ospf_default_metric,
6015 no_ospf_default_metric_val_cmd,
6016 "no default-metric <0-16777214>",
6017 NO_STR
6018 "Set metric of redistributed routes\n"
6019 "Default metric\n")
6020
6021DEFUN (ospf_distance,
6022 ospf_distance_cmd,
6023 "distance <1-255>",
6024 "Define an administrative distance\n"
6025 "OSPF Administrative distance\n")
6026{
paul68980082003-03-25 05:07:42 +00006027 struct ospf *ospf = vty->index;
6028
6029 ospf->distance_all = atoi (argv[0]);
6030
paul718e3742002-12-13 20:15:29 +00006031 return CMD_SUCCESS;
6032}
6033
6034DEFUN (no_ospf_distance,
6035 no_ospf_distance_cmd,
6036 "no distance <1-255>",
6037 NO_STR
6038 "Define an administrative distance\n"
6039 "OSPF Administrative distance\n")
6040{
paul68980082003-03-25 05:07:42 +00006041 struct ospf *ospf = vty->index;
6042
6043 ospf->distance_all = 0;
6044
paul718e3742002-12-13 20:15:29 +00006045 return CMD_SUCCESS;
6046}
6047
6048DEFUN (no_ospf_distance_ospf,
6049 no_ospf_distance_ospf_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00006050 "no distance ospf {intra-area|inter-area|external}",
paul718e3742002-12-13 20:15:29 +00006051 NO_STR
6052 "Define an administrative distance\n"
6053 "OSPF Administrative distance\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00006054 "OSPF Distance\n"
6055 "Intra-area routes\n"
6056 "Inter-area routes\n"
6057 "External routes\n")
paul718e3742002-12-13 20:15:29 +00006058{
paul68980082003-03-25 05:07:42 +00006059 struct ospf *ospf = vty->index;
6060
Christian Franke6f2a6702013-09-30 12:27:52 +00006061 if (argc < 3)
6062 return CMD_WARNING;
6063
6064 if (argv[0] != NULL)
6065 ospf->distance_intra = 0;
6066
6067 if (argv[1] != NULL)
6068 ospf->distance_inter = 0;
6069
6070 if (argv[2] != NULL)
6071 ospf->distance_external = 0;
6072
6073 if (argv[0] || argv[1] || argv[2])
6074 return CMD_SUCCESS;
6075
6076 /* If no arguments are given, clear all distance information */
paul68980082003-03-25 05:07:42 +00006077 ospf->distance_intra = 0;
6078 ospf->distance_inter = 0;
6079 ospf->distance_external = 0;
6080
paul718e3742002-12-13 20:15:29 +00006081 return CMD_SUCCESS;
6082}
6083
Christian Franke6f2a6702013-09-30 12:27:52 +00006084DEFUN (ospf_distance_ospf,
6085 ospf_distance_ospf_cmd,
6086 "distance ospf "
6087 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
paul718e3742002-12-13 20:15:29 +00006088 "Define an administrative distance\n"
6089 "OSPF Administrative distance\n"
6090 "Intra-area routes\n"
6091 "Distance for intra-area routes\n"
6092 "Inter-area routes\n"
6093 "Distance for inter-area routes\n"
6094 "External routes\n"
6095 "Distance for external routes\n")
6096{
paul68980082003-03-25 05:07:42 +00006097 struct ospf *ospf = vty->index;
6098
Christian Franke6f2a6702013-09-30 12:27:52 +00006099 if (argc < 3) /* should not happen */
6100 return CMD_WARNING;
paul68980082003-03-25 05:07:42 +00006101
Christian Franke6f2a6702013-09-30 12:27:52 +00006102 if (!argv[0] && !argv[1] && !argv[2])
6103 {
6104 vty_out(vty, "%% Command incomplete. (Arguments required)%s",
6105 VTY_NEWLINE);
6106 return CMD_WARNING;
6107 }
paul718e3742002-12-13 20:15:29 +00006108
Christian Franke6f2a6702013-09-30 12:27:52 +00006109 if (argv[0] != NULL)
6110 ospf->distance_intra = atoi(argv[0]);
paul68980082003-03-25 05:07:42 +00006111
Christian Franke6f2a6702013-09-30 12:27:52 +00006112 if (argv[1] != NULL)
6113 ospf->distance_inter = atoi(argv[1]);
paul68980082003-03-25 05:07:42 +00006114
Christian Franke6f2a6702013-09-30 12:27:52 +00006115 if (argv[2] != NULL)
6116 ospf->distance_external = atoi(argv[2]);
paul68980082003-03-25 05:07:42 +00006117
paul718e3742002-12-13 20:15:29 +00006118 return CMD_SUCCESS;
6119}
6120
6121DEFUN (ospf_distance_source,
6122 ospf_distance_source_cmd,
6123 "distance <1-255> A.B.C.D/M",
6124 "Administrative distance\n"
6125 "Distance value\n"
6126 "IP source prefix\n")
6127{
paul020709f2003-04-04 02:44:16 +00006128 struct ospf *ospf = vty->index;
6129
6130 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006131
paul718e3742002-12-13 20:15:29 +00006132 return CMD_SUCCESS;
6133}
6134
6135DEFUN (no_ospf_distance_source,
6136 no_ospf_distance_source_cmd,
6137 "no distance <1-255> A.B.C.D/M",
6138 NO_STR
6139 "Administrative distance\n"
6140 "Distance value\n"
6141 "IP source prefix\n")
6142{
paul020709f2003-04-04 02:44:16 +00006143 struct ospf *ospf = vty->index;
6144
6145 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6146
paul718e3742002-12-13 20:15:29 +00006147 return CMD_SUCCESS;
6148}
6149
6150DEFUN (ospf_distance_source_access_list,
6151 ospf_distance_source_access_list_cmd,
6152 "distance <1-255> A.B.C.D/M WORD",
6153 "Administrative distance\n"
6154 "Distance value\n"
6155 "IP source prefix\n"
6156 "Access list name\n")
6157{
paul020709f2003-04-04 02:44:16 +00006158 struct ospf *ospf = vty->index;
6159
6160 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6161
paul718e3742002-12-13 20:15:29 +00006162 return CMD_SUCCESS;
6163}
6164
6165DEFUN (no_ospf_distance_source_access_list,
6166 no_ospf_distance_source_access_list_cmd,
6167 "no distance <1-255> A.B.C.D/M WORD",
6168 NO_STR
6169 "Administrative distance\n"
6170 "Distance value\n"
6171 "IP source prefix\n"
6172 "Access list name\n")
6173{
paul020709f2003-04-04 02:44:16 +00006174 struct ospf *ospf = vty->index;
6175
6176 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6177
paul718e3742002-12-13 20:15:29 +00006178 return CMD_SUCCESS;
6179}
6180
vincentba682532005-09-29 13:52:57 +00006181DEFUN (ip_ospf_mtu_ignore,
6182 ip_ospf_mtu_ignore_addr_cmd,
6183 "ip ospf mtu-ignore A.B.C.D",
6184 "IP Information\n"
6185 "OSPF interface commands\n"
6186 "Disable mtu mismatch detection\n"
6187 "Address of interface")
6188{
6189 struct interface *ifp = vty->index;
6190 struct in_addr addr;
6191 int ret;
6192
6193 struct ospf_if_params *params;
6194 params = IF_DEF_PARAMS (ifp);
6195
6196 if (argc == 1)
6197 {
6198 ret = inet_aton(argv[0], &addr);
6199 if (!ret)
6200 {
6201 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6202 VTY_NEWLINE);
6203 return CMD_WARNING;
6204 }
6205 params = ospf_get_if_params (ifp, addr);
6206 ospf_if_update_params (ifp, addr);
6207 }
6208 params->mtu_ignore = 1;
6209 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6210 SET_IF_PARAM (params, mtu_ignore);
6211 else
6212 {
6213 UNSET_IF_PARAM (params, mtu_ignore);
6214 if (params != IF_DEF_PARAMS (ifp))
6215 {
6216 ospf_free_if_params (ifp, addr);
6217 ospf_if_update_params (ifp, addr);
6218 }
6219 }
6220 return CMD_SUCCESS;
6221}
6222
6223ALIAS (ip_ospf_mtu_ignore,
6224 ip_ospf_mtu_ignore_cmd,
6225 "ip ospf mtu-ignore",
6226 "IP Information\n"
6227 "OSPF interface commands\n"
6228 "Disable mtu mismatch detection\n")
6229
6230
6231DEFUN (no_ip_ospf_mtu_ignore,
6232 no_ip_ospf_mtu_ignore_addr_cmd,
6233 "no ip ospf mtu-ignore A.B.C.D",
6234 "IP Information\n"
6235 "OSPF interface commands\n"
6236 "Disable mtu mismatch detection\n"
6237 "Address of interface")
6238{
6239 struct interface *ifp = vty->index;
6240 struct in_addr addr;
6241 int ret;
6242
6243 struct ospf_if_params *params;
6244 params = IF_DEF_PARAMS (ifp);
6245
6246 if (argc == 1)
6247 {
6248 ret = inet_aton(argv[0], &addr);
6249 if (!ret)
6250 {
6251 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6252 VTY_NEWLINE);
6253 return CMD_WARNING;
6254 }
6255 params = ospf_get_if_params (ifp, addr);
6256 ospf_if_update_params (ifp, addr);
6257 }
6258 params->mtu_ignore = 0;
6259 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6260 SET_IF_PARAM (params, mtu_ignore);
6261 else
6262 {
6263 UNSET_IF_PARAM (params, mtu_ignore);
6264 if (params != IF_DEF_PARAMS (ifp))
6265 {
6266 ospf_free_if_params (ifp, addr);
6267 ospf_if_update_params (ifp, addr);
6268 }
6269 }
6270 return CMD_SUCCESS;
6271}
6272
6273ALIAS (no_ip_ospf_mtu_ignore,
6274 no_ip_ospf_mtu_ignore_cmd,
6275 "no ip ospf mtu-ignore",
6276 "IP Information\n"
6277 "OSPF interface commands\n"
6278 "Disable mtu mismatch detection\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02006279
paul88d6cf32005-10-29 12:50:09 +00006280DEFUN (ospf_max_metric_router_lsa_admin,
6281 ospf_max_metric_router_lsa_admin_cmd,
6282 "max-metric router-lsa administrative",
6283 "OSPF maximum / infinite-distance metric\n"
6284 "Advertise own Router-LSA with infinite distance (stub router)\n"
6285 "Administratively applied, for an indefinite period\n")
6286{
6287 struct listnode *ln;
6288 struct ospf_area *area;
6289 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006290
paul88d6cf32005-10-29 12:50:09 +00006291 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6292 {
6293 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6294
6295 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00006296 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006297 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006298
6299 /* Allows for areas configured later to get the property */
6300 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
6301
paul88d6cf32005-10-29 12:50:09 +00006302 return CMD_SUCCESS;
6303}
6304
6305DEFUN (no_ospf_max_metric_router_lsa_admin,
6306 no_ospf_max_metric_router_lsa_admin_cmd,
6307 "no max-metric router-lsa administrative",
6308 NO_STR
6309 "OSPF maximum / infinite-distance metric\n"
6310 "Advertise own Router-LSA with infinite distance (stub router)\n"
6311 "Administratively applied, for an indefinite period\n")
6312{
6313 struct listnode *ln;
6314 struct ospf_area *area;
6315 struct ospf *ospf = vty->index;
6316
6317 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6318 {
6319 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6320
6321 /* Don't trample on the start-up stub timer */
6322 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6323 && !area->t_stub_router)
6324 {
6325 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006326 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006327 }
6328 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006329 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00006330 return CMD_SUCCESS;
6331}
6332
6333DEFUN (ospf_max_metric_router_lsa_startup,
6334 ospf_max_metric_router_lsa_startup_cmd,
6335 "max-metric router-lsa on-startup <5-86400>",
6336 "OSPF maximum / infinite-distance metric\n"
6337 "Advertise own Router-LSA with infinite distance (stub router)\n"
6338 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6339 "Time (seconds) to advertise self as stub-router\n")
6340{
6341 unsigned int seconds;
6342 struct ospf *ospf = vty->index;
6343
6344 if (argc != 1)
6345 {
6346 vty_out (vty, "%% Must supply stub-router period");
6347 return CMD_WARNING;
6348 }
6349
6350 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6351
6352 ospf->stub_router_startup_time = seconds;
6353
6354 return CMD_SUCCESS;
6355}
6356
6357DEFUN (no_ospf_max_metric_router_lsa_startup,
6358 no_ospf_max_metric_router_lsa_startup_cmd,
6359 "no max-metric router-lsa on-startup",
6360 NO_STR
6361 "OSPF maximum / infinite-distance metric\n"
6362 "Advertise own Router-LSA with infinite distance (stub router)\n"
6363 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6364{
6365 struct listnode *ln;
6366 struct ospf_area *area;
6367 struct ospf *ospf = vty->index;
6368
6369 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6370
6371 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6372 {
6373 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6374 OSPF_TIMER_OFF (area->t_stub_router);
6375
6376 /* Don't trample on admin stub routed */
6377 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6378 {
6379 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006380 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006381 }
6382 }
6383 return CMD_SUCCESS;
6384}
6385
6386DEFUN (ospf_max_metric_router_lsa_shutdown,
6387 ospf_max_metric_router_lsa_shutdown_cmd,
6388 "max-metric router-lsa on-shutdown <5-86400>",
6389 "OSPF maximum / infinite-distance metric\n"
6390 "Advertise own Router-LSA with infinite distance (stub router)\n"
6391 "Advertise stub-router prior to full shutdown of OSPF\n"
6392 "Time (seconds) to wait till full shutdown\n")
6393{
6394 unsigned int seconds;
6395 struct ospf *ospf = vty->index;
6396
6397 if (argc != 1)
6398 {
6399 vty_out (vty, "%% Must supply stub-router shutdown period");
6400 return CMD_WARNING;
6401 }
6402
6403 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6404
6405 ospf->stub_router_shutdown_time = seconds;
6406
6407 return CMD_SUCCESS;
6408}
6409
6410DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6411 no_ospf_max_metric_router_lsa_shutdown_cmd,
6412 "no max-metric router-lsa on-shutdown",
6413 NO_STR
6414 "OSPF maximum / infinite-distance metric\n"
6415 "Advertise own Router-LSA with infinite distance (stub router)\n"
6416 "Advertise stub-router prior to full shutdown of OSPF\n")
6417{
6418 struct ospf *ospf = vty->index;
6419
6420 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6421
6422 return CMD_SUCCESS;
6423}
6424
6425static void
6426config_write_stub_router (struct vty *vty, struct ospf *ospf)
6427{
6428 struct listnode *ln;
6429 struct ospf_area *area;
6430
6431 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6432 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6433 ospf->stub_router_startup_time, VTY_NEWLINE);
6434 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6435 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6436 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6437 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6438 {
6439 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6440 {
6441 vty_out (vty, " max-metric router-lsa administrative%s",
6442 VTY_NEWLINE);
6443 break;
6444 }
6445 }
6446 return;
6447}
David Lamparter6b0655a2014-06-04 06:53:35 +02006448
paul4dadc292005-05-06 21:37:42 +00006449static void
paul718e3742002-12-13 20:15:29 +00006450show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6451{
6452 struct route_node *rn;
6453 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006454 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006455 struct ospf_path *path;
6456
6457 vty_out (vty, "============ OSPF network routing table ============%s",
6458 VTY_NEWLINE);
6459
6460 for (rn = route_top (rt); rn; rn = route_next (rn))
6461 if ((or = rn->info) != NULL)
6462 {
6463 char buf1[19];
6464 snprintf (buf1, 19, "%s/%d",
6465 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6466
6467 switch (or->path_type)
6468 {
6469 case OSPF_PATH_INTER_AREA:
6470 if (or->type == OSPF_DESTINATION_NETWORK)
6471 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6472 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6473 else if (or->type == OSPF_DESTINATION_DISCARD)
6474 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6475 break;
6476 case OSPF_PATH_INTRA_AREA:
6477 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6478 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6479 break;
6480 default:
6481 break;
6482 }
6483
6484 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006485 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006486 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006487 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00006488 {
6489 if (path->nexthop.s_addr == 0)
6490 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006491 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006492 else
6493 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006494 inet_ntoa (path->nexthop),
6495 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006496 }
6497 }
paul718e3742002-12-13 20:15:29 +00006498 }
6499 vty_out (vty, "%s", VTY_NEWLINE);
6500}
6501
paul4dadc292005-05-06 21:37:42 +00006502static void
paul718e3742002-12-13 20:15:29 +00006503show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6504{
6505 struct route_node *rn;
6506 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006507 struct listnode *pnode;
6508 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006509 struct ospf_path *path;
6510
6511 vty_out (vty, "============ OSPF router routing table =============%s",
6512 VTY_NEWLINE);
6513 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6514 if (rn->info)
6515 {
6516 int flag = 0;
6517
6518 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6519
paul1eb8ef22005-04-07 07:30:20 +00006520 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6521 {
6522 if (flag++)
6523 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006524
paul1eb8ef22005-04-07 07:30:20 +00006525 /* Show path. */
6526 vty_out (vty, "%s [%d] area: %s",
6527 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6528 or->cost, inet_ntoa (or->u.std.area_id));
6529 /* Show flags. */
6530 vty_out (vty, "%s%s%s",
6531 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6532 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6533 VTY_NEWLINE);
6534
6535 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6536 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006537 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00006538 {
6539 if (path->nexthop.s_addr == 0)
6540 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006541 "", ifindex2ifname (path->ifindex),
6542 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006543 else
6544 vty_out (vty, "%24s via %s, %s%s", "",
6545 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006546 ifindex2ifname (path->ifindex),
6547 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006548 }
paul1eb8ef22005-04-07 07:30:20 +00006549 }
6550 }
paul718e3742002-12-13 20:15:29 +00006551 }
6552 vty_out (vty, "%s", VTY_NEWLINE);
6553}
6554
paul4dadc292005-05-06 21:37:42 +00006555static void
paul718e3742002-12-13 20:15:29 +00006556show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6557{
6558 struct route_node *rn;
6559 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006560 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006561 struct ospf_path *path;
6562
6563 vty_out (vty, "============ OSPF external routing table ===========%s",
6564 VTY_NEWLINE);
6565 for (rn = route_top (rt); rn; rn = route_next (rn))
6566 if ((er = rn->info) != NULL)
6567 {
6568 char buf1[19];
6569 snprintf (buf1, 19, "%s/%d",
6570 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6571
6572 switch (er->path_type)
6573 {
6574 case OSPF_PATH_TYPE1_EXTERNAL:
6575 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6576 er->cost, er->u.ext.tag, VTY_NEWLINE);
6577 break;
6578 case OSPF_PATH_TYPE2_EXTERNAL:
6579 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6580 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6581 break;
6582 }
6583
paul1eb8ef22005-04-07 07:30:20 +00006584 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006585 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006586 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00006587 {
6588 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006589 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006590 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006591 else
6592 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006593 inet_ntoa (path->nexthop),
6594 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00006595 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006596 }
6597 }
6598 }
6599 vty_out (vty, "%s", VTY_NEWLINE);
6600}
6601
paul718e3742002-12-13 20:15:29 +00006602DEFUN (show_ip_ospf_border_routers,
6603 show_ip_ospf_border_routers_cmd,
6604 "show ip ospf border-routers",
6605 SHOW_STR
6606 IP_STR
6607 "show all the ABR's and ASBR's\n"
6608 "for this area\n")
6609{
paul020709f2003-04-04 02:44:16 +00006610 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006611
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006612 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006613 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006614 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006615 return CMD_SUCCESS;
6616 }
6617
paul68980082003-03-25 05:07:42 +00006618 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006619 {
6620 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6621 return CMD_SUCCESS;
6622 }
6623
6624 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006625 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006626
6627 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006628 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006629
6630 return CMD_SUCCESS;
6631}
paul718e3742002-12-13 20:15:29 +00006632
6633DEFUN (show_ip_ospf_route,
6634 show_ip_ospf_route_cmd,
6635 "show ip ospf route",
6636 SHOW_STR
6637 IP_STR
6638 "OSPF information\n"
6639 "OSPF routing table\n")
6640{
paul020709f2003-04-04 02:44:16 +00006641 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006642
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006643 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006644 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006645 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006646 return CMD_SUCCESS;
6647 }
6648
paul68980082003-03-25 05:07:42 +00006649 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006650 {
6651 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6652 return CMD_SUCCESS;
6653 }
6654
6655 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006656 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006657
6658 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006659 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006660
6661 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006662 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006663
6664 return CMD_SUCCESS;
6665}
6666
David Lamparter6b0655a2014-06-04 06:53:35 +02006667
hassoeb1ce602004-10-08 08:17:22 +00006668const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006669{
6670 "unknown",
6671 "standard",
6672 "ibm",
6673 "cisco",
6674 "shortcut"
6675};
6676
hassoeb1ce602004-10-08 08:17:22 +00006677const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006678{
6679 "default",
6680 "enable",
6681 "disable"
6682};
6683
6684
paul4dadc292005-05-06 21:37:42 +00006685static void
paul718e3742002-12-13 20:15:29 +00006686area_id2str (char *buf, int length, struct ospf_area *area)
6687{
6688 memset (buf, 0, length);
6689
6690 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6691 strncpy (buf, inet_ntoa (area->area_id), length);
6692 else
6693 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6694}
6695
David Lamparter6b0655a2014-06-04 06:53:35 +02006696
hassoeb1ce602004-10-08 08:17:22 +00006697const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006698{
6699 "unknown", /* should never be used. */
6700 "point-to-point",
6701 "broadcast",
6702 "non-broadcast",
6703 "point-to-multipoint",
6704 "virtual-link", /* should never be used. */
6705 "loopback"
6706};
6707
6708/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00006709static int
paul718e3742002-12-13 20:15:29 +00006710config_write_interface (struct vty *vty)
6711{
hasso52dc7ee2004-09-23 19:18:23 +00006712 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006713 struct interface *ifp;
6714 struct crypt_key *ck;
6715 int write = 0;
6716 struct route_node *rn = NULL;
6717 struct ospf_if_params *params;
6718
paul1eb8ef22005-04-07 07:30:20 +00006719 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006720 {
paul718e3742002-12-13 20:15:29 +00006721 if (memcmp (ifp->name, "VLINK", 5) == 0)
6722 continue;
6723
6724 vty_out (vty, "!%s", VTY_NEWLINE);
6725 vty_out (vty, "interface %s%s", ifp->name,
6726 VTY_NEWLINE);
6727 if (ifp->desc)
6728 vty_out (vty, " description %s%s", ifp->desc,
6729 VTY_NEWLINE);
6730
6731 write++;
6732
6733 params = IF_DEF_PARAMS (ifp);
6734
6735 do {
6736 /* Interface Network print. */
6737 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006738 params->type != OSPF_IFTYPE_LOOPBACK)
6739 {
ajsbc18d612004-12-15 15:07:19 +00006740 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006741 {
6742 vty_out (vty, " ip ospf network %s",
6743 ospf_int_type_str[params->type]);
6744 if (params != IF_DEF_PARAMS (ifp))
6745 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6746 vty_out (vty, "%s", VTY_NEWLINE);
6747 }
paul718e3742002-12-13 20:15:29 +00006748 }
6749
6750 /* OSPF interface authentication print */
6751 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6752 params->auth_type != OSPF_AUTH_NOTSET)
6753 {
hassoeb1ce602004-10-08 08:17:22 +00006754 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006755
6756 /* Translation tables are not that much help here due to syntax
6757 of the simple option */
6758 switch (params->auth_type)
6759 {
6760
6761 case OSPF_AUTH_NULL:
6762 auth_str = " null";
6763 break;
6764
6765 case OSPF_AUTH_SIMPLE:
6766 auth_str = "";
6767 break;
6768
6769 case OSPF_AUTH_CRYPTOGRAPHIC:
6770 auth_str = " message-digest";
6771 break;
6772
6773 default:
6774 auth_str = "";
6775 break;
6776 }
6777
6778 vty_out (vty, " ip ospf authentication%s", auth_str);
6779 if (params != IF_DEF_PARAMS (ifp))
6780 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6781 vty_out (vty, "%s", VTY_NEWLINE);
6782 }
6783
6784 /* Simple Authentication Password print. */
6785 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6786 params->auth_simple[0] != '\0')
6787 {
6788 vty_out (vty, " ip ospf authentication-key %s",
6789 params->auth_simple);
6790 if (params != IF_DEF_PARAMS (ifp))
6791 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6792 vty_out (vty, "%s", VTY_NEWLINE);
6793 }
6794
6795 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00006796 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00006797 {
paul718e3742002-12-13 20:15:29 +00006798 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6799 ck->key_id, ck->auth_key);
6800 if (params != IF_DEF_PARAMS (ifp))
6801 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6802 vty_out (vty, "%s", VTY_NEWLINE);
6803 }
6804
6805 /* Interface Output Cost print. */
6806 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6807 {
6808 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6809 if (params != IF_DEF_PARAMS (ifp))
6810 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6811 vty_out (vty, "%s", VTY_NEWLINE);
6812 }
6813
6814 /* Hello Interval print. */
6815 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6816 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6817 {
6818 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6819 if (params != IF_DEF_PARAMS (ifp))
6820 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6821 vty_out (vty, "%s", VTY_NEWLINE);
6822 }
6823
6824
6825 /* Router Dead Interval print. */
6826 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6827 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6828 {
paulf9ad9372005-10-21 00:45:17 +00006829 vty_out (vty, " ip ospf dead-interval ");
6830
6831 /* fast hello ? */
6832 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
6833 vty_out (vty, "minimal hello-multiplier %d",
6834 params->fast_hello);
6835 else
6836 vty_out (vty, "%u", params->v_wait);
6837
paul718e3742002-12-13 20:15:29 +00006838 if (params != IF_DEF_PARAMS (ifp))
6839 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6840 vty_out (vty, "%s", VTY_NEWLINE);
6841 }
6842
6843 /* Router Priority print. */
6844 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6845 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6846 {
6847 vty_out (vty, " ip ospf priority %u", params->priority);
6848 if (params != IF_DEF_PARAMS (ifp))
6849 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6850 vty_out (vty, "%s", VTY_NEWLINE);
6851 }
6852
6853 /* Retransmit Interval print. */
6854 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6855 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6856 {
6857 vty_out (vty, " ip ospf retransmit-interval %u",
6858 params->retransmit_interval);
6859 if (params != IF_DEF_PARAMS (ifp))
6860 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6861 vty_out (vty, "%s", VTY_NEWLINE);
6862 }
6863
6864 /* Transmit Delay print. */
6865 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6866 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6867 {
6868 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6869 if (params != IF_DEF_PARAMS (ifp))
6870 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6871 vty_out (vty, "%s", VTY_NEWLINE);
6872 }
6873
vincentba682532005-09-29 13:52:57 +00006874 /* MTU ignore print. */
6875 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
6876 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6877 {
6878 if (params->mtu_ignore == 0)
6879 vty_out (vty, " no ip ospf mtu-ignore");
6880 else
6881 vty_out (vty, " ip ospf mtu-ignore");
6882 if (params != IF_DEF_PARAMS (ifp))
6883 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6884 vty_out (vty, "%s", VTY_NEWLINE);
6885 }
6886
6887
paul718e3742002-12-13 20:15:29 +00006888 while (1)
6889 {
6890 if (rn == NULL)
6891 rn = route_top (IF_OIFS_PARAMS (ifp));
6892 else
6893 rn = route_next (rn);
6894
6895 if (rn == NULL)
6896 break;
6897 params = rn->info;
6898 if (params != NULL)
6899 break;
6900 }
6901 } while (rn);
6902
6903#ifdef HAVE_OPAQUE_LSA
6904 ospf_opaque_config_write_if (vty, ifp);
6905#endif /* HAVE_OPAQUE_LSA */
6906 }
6907
6908 return write;
6909}
6910
paul4dadc292005-05-06 21:37:42 +00006911static int
paul68980082003-03-25 05:07:42 +00006912config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006913{
6914 struct route_node *rn;
6915 u_char buf[INET_ADDRSTRLEN];
6916
6917 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006918 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006919 if (rn->info)
6920 {
6921 struct ospf_network *n = rn->info;
6922
6923 memset (buf, 0, INET_ADDRSTRLEN);
6924
6925 /* Create Area ID string by specified Area ID format. */
6926 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006927 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006928 else
hassoc9e52be2004-09-26 16:09:34 +00006929 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006930 (unsigned long int) ntohl (n->area_id.s_addr));
6931
6932 /* Network print. */
6933 vty_out (vty, " network %s/%d area %s%s",
6934 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6935 buf, VTY_NEWLINE);
6936 }
6937
6938 return 0;
6939}
6940
paul4dadc292005-05-06 21:37:42 +00006941static int
paul68980082003-03-25 05:07:42 +00006942config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006943{
hasso52dc7ee2004-09-23 19:18:23 +00006944 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00006945 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00006946 u_char buf[INET_ADDRSTRLEN];
6947
6948 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00006949 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00006950 {
paul718e3742002-12-13 20:15:29 +00006951 struct route_node *rn1;
6952
hassoc9e52be2004-09-26 16:09:34 +00006953 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006954
6955 if (area->auth_type != OSPF_AUTH_NULL)
6956 {
6957 if (area->auth_type == OSPF_AUTH_SIMPLE)
6958 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6959 else
6960 vty_out (vty, " area %s authentication message-digest%s",
6961 buf, VTY_NEWLINE);
6962 }
6963
6964 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6965 vty_out (vty, " area %s shortcut %s%s", buf,
6966 ospf_shortcut_mode_str[area->shortcut_configured],
6967 VTY_NEWLINE);
6968
6969 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006970 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006971 )
6972 {
paulb0a053b2003-06-22 09:04:47 +00006973 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006974 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006975 else if (area->external_routing == OSPF_AREA_NSSA)
6976 {
6977 vty_out (vty, " area %s nssa", buf);
6978 switch (area->NSSATranslatorRole)
6979 {
6980 case OSPF_NSSA_ROLE_NEVER:
6981 vty_out (vty, " translate-never");
6982 break;
6983 case OSPF_NSSA_ROLE_ALWAYS:
6984 vty_out (vty, " translate-always");
6985 break;
6986 case OSPF_NSSA_ROLE_CANDIDATE:
6987 default:
6988 vty_out (vty, " translate-candidate");
6989 }
6990 }
paul718e3742002-12-13 20:15:29 +00006991
6992 if (area->no_summary)
6993 vty_out (vty, " no-summary");
6994
6995 vty_out (vty, "%s", VTY_NEWLINE);
6996
6997 if (area->default_cost != 1)
6998 vty_out (vty, " area %s default-cost %d%s", buf,
6999 area->default_cost, VTY_NEWLINE);
7000 }
7001
7002 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7003 if (rn1->info)
7004 {
7005 struct ospf_area_range *range = rn1->info;
7006
7007 vty_out (vty, " area %s range %s/%d", buf,
7008 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7009
paul6c835672004-10-11 11:00:30 +00007010 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007011 vty_out (vty, " cost %d", range->cost_config);
7012
7013 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7014 vty_out (vty, " not-advertise");
7015
7016 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7017 vty_out (vty, " substitute %s/%d",
7018 inet_ntoa (range->subst_addr), range->subst_masklen);
7019
7020 vty_out (vty, "%s", VTY_NEWLINE);
7021 }
7022
7023 if (EXPORT_NAME (area))
7024 vty_out (vty, " area %s export-list %s%s", buf,
7025 EXPORT_NAME (area), VTY_NEWLINE);
7026
7027 if (IMPORT_NAME (area))
7028 vty_out (vty, " area %s import-list %s%s", buf,
7029 IMPORT_NAME (area), VTY_NEWLINE);
7030
7031 if (PREFIX_NAME_IN (area))
7032 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7033 PREFIX_NAME_IN (area), VTY_NEWLINE);
7034
7035 if (PREFIX_NAME_OUT (area))
7036 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7037 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7038 }
7039
7040 return 0;
7041}
7042
paul4dadc292005-05-06 21:37:42 +00007043static int
paul68980082003-03-25 05:07:42 +00007044config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007045{
7046 struct ospf_nbr_nbma *nbr_nbma;
7047 struct route_node *rn;
7048
7049 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007050 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007051 if ((nbr_nbma = rn->info))
7052 {
7053 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7054
7055 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7056 vty_out (vty, " priority %d", nbr_nbma->priority);
7057
7058 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7059 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7060
7061 vty_out (vty, "%s", VTY_NEWLINE);
7062 }
7063
7064 return 0;
7065}
7066
paul4dadc292005-05-06 21:37:42 +00007067static int
paul68980082003-03-25 05:07:42 +00007068config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007069{
hasso52dc7ee2004-09-23 19:18:23 +00007070 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007071 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007072 u_char buf[INET_ADDRSTRLEN];
7073
7074 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007075 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007076 {
hasso52dc7ee2004-09-23 19:18:23 +00007077 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007078 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007079 struct ospf_interface *oi;
7080
7081 if (vl_data != NULL)
7082 {
7083 memset (buf, 0, INET_ADDRSTRLEN);
7084
7085 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007086 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007087 else
hassoc9e52be2004-09-26 16:09:34 +00007088 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007089 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7090 oi = vl_data->vl_oi;
7091
7092 /* timers */
7093 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7094 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7095 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7096 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7097 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7098 buf,
7099 inet_ntoa (vl_data->vl_peer),
7100 OSPF_IF_PARAM (oi, v_hello),
7101 OSPF_IF_PARAM (oi, retransmit_interval),
7102 OSPF_IF_PARAM (oi, transmit_delay),
7103 OSPF_IF_PARAM (oi, v_wait),
7104 VTY_NEWLINE);
7105 else
7106 vty_out (vty, " area %s virtual-link %s%s", buf,
7107 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7108 /* Auth key */
7109 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7110 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7111 buf,
7112 inet_ntoa (vl_data->vl_peer),
7113 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7114 VTY_NEWLINE);
7115 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007116 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7117 n2, ck))
7118 vty_out (vty, " area %s virtual-link %s"
7119 " message-digest-key %d md5 %s%s",
7120 buf,
7121 inet_ntoa (vl_data->vl_peer),
7122 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007123
7124 }
7125 }
7126
7127 return 0;
7128}
7129
David Lamparter6b0655a2014-06-04 06:53:35 +02007130
paul4dadc292005-05-06 21:37:42 +00007131static int
paul68980082003-03-25 05:07:42 +00007132config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007133{
7134 int type;
7135
7136 /* redistribute print. */
7137 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7138 if (type != zclient->redist_default && zclient->redist[type])
7139 {
ajsf52d13c2005-10-01 17:38:06 +00007140 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007141 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007142 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007143
paul68980082003-03-25 05:07:42 +00007144 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007145 vty_out (vty, " metric-type 1");
7146
paul020709f2003-04-04 02:44:16 +00007147 if (ROUTEMAP_NAME (ospf, type))
7148 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007149
7150 vty_out (vty, "%s", VTY_NEWLINE);
7151 }
7152
7153 return 0;
7154}
7155
paul4dadc292005-05-06 21:37:42 +00007156static int
paul68980082003-03-25 05:07:42 +00007157config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007158{
paul68980082003-03-25 05:07:42 +00007159 if (ospf->default_metric != -1)
7160 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007161 VTY_NEWLINE);
7162 return 0;
7163}
7164
paul4dadc292005-05-06 21:37:42 +00007165static int
paul68980082003-03-25 05:07:42 +00007166config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007167{
7168 int type;
7169
paul68980082003-03-25 05:07:42 +00007170 if (ospf)
paul718e3742002-12-13 20:15:29 +00007171 {
7172 /* distribute-list print. */
7173 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007174 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007175 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007176 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007177 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007178
7179 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007180 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007181 {
paulc42c1772006-01-10 20:36:49 +00007182 vty_out (vty, " default-information originate");
7183 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7184 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007185
paul68980082003-03-25 05:07:42 +00007186 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007187 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007188 ospf->dmetric[DEFAULT_ROUTE].value);
7189 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007190 vty_out (vty, " metric-type 1");
7191
paul020709f2003-04-04 02:44:16 +00007192 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7193 vty_out (vty, " route-map %s",
7194 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007195
7196 vty_out (vty, "%s", VTY_NEWLINE);
7197 }
7198
7199 }
7200
7201 return 0;
7202}
7203
paul4dadc292005-05-06 21:37:42 +00007204static int
paul68980082003-03-25 05:07:42 +00007205config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007206{
7207 struct route_node *rn;
7208 struct ospf_distance *odistance;
7209
paul68980082003-03-25 05:07:42 +00007210 if (ospf->distance_all)
7211 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007212
paul68980082003-03-25 05:07:42 +00007213 if (ospf->distance_intra
7214 || ospf->distance_inter
7215 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007216 {
7217 vty_out (vty, " distance ospf");
7218
paul68980082003-03-25 05:07:42 +00007219 if (ospf->distance_intra)
7220 vty_out (vty, " intra-area %d", ospf->distance_intra);
7221 if (ospf->distance_inter)
7222 vty_out (vty, " inter-area %d", ospf->distance_inter);
7223 if (ospf->distance_external)
7224 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007225
7226 vty_out (vty, "%s", VTY_NEWLINE);
7227 }
7228
paul68980082003-03-25 05:07:42 +00007229 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007230 if ((odistance = rn->info) != NULL)
7231 {
7232 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7233 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7234 odistance->access_list ? odistance->access_list : "",
7235 VTY_NEWLINE);
7236 }
7237 return 0;
7238}
7239
7240/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007241static int
paul718e3742002-12-13 20:15:29 +00007242ospf_config_write (struct vty *vty)
7243{
paul020709f2003-04-04 02:44:16 +00007244 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007245 struct interface *ifp;
7246 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007247 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007248 int write = 0;
7249
paul020709f2003-04-04 02:44:16 +00007250 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007251 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007252 {
7253 /* `router ospf' print. */
7254 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7255
7256 write++;
7257
paul68980082003-03-25 05:07:42 +00007258 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007259 return write;
7260
7261 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007262 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007263 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007264 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007265
7266 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007267 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007268 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007269 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007270
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007271 /* log-adjacency-changes flag print. */
7272 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7273 {
7274 vty_out(vty, " log-adjacency-changes");
7275 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7276 vty_out(vty, " detail");
7277 vty_out(vty, "%s", VTY_NEWLINE);
7278 }
7279
paul718e3742002-12-13 20:15:29 +00007280 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007281 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007282 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7283
7284 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007285 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007286 {
7287 vty_out (vty, "! Important: ensure reference bandwidth "
7288 "is consistent across all routers%s", VTY_NEWLINE);
7289 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7290 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7291 }
paul718e3742002-12-13 20:15:29 +00007292
7293 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007294 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007295 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7296 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7297 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007298 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007299 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007300
7301 /* Max-metric router-lsa print */
7302 config_write_stub_router (vty, ospf);
7303
paul718e3742002-12-13 20:15:29 +00007304 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007305 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007306 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007307 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007308
7309 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007310 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007311
7312 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007313 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
7314 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
7315
paul1eb8ef22005-04-07 07:30:20 +00007316 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007317 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
7318 && IF_DEF_PARAMS (ifp)->passive_interface !=
7319 ospf->passive_interface_default)
7320 {
7321 vty_out (vty, " %spassive-interface %s%s",
7322 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
7323 ifp->name, VTY_NEWLINE);
7324 }
paul1eb8ef22005-04-07 07:30:20 +00007325 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007326 {
7327 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
7328 continue;
7329 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
7330 passive_interface))
7331 {
7332 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
7333 continue;
7334 }
7335 else if (oi->params->passive_interface == ospf->passive_interface_default)
7336 continue;
7337
7338 vty_out (vty, " %spassive-interface %s %s%s",
7339 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00007340 oi->ifp->name,
7341 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007342 }
paul718e3742002-12-13 20:15:29 +00007343
7344 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007345 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007346
7347 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007348 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007349
7350 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007351 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007352
7353 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007354 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007355
7356 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007357 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007358
7359 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007360 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007361
7362 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007363 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007364
7365#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007366 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007367#endif /* HAVE_OPAQUE_LSA */
7368 }
7369
7370 return write;
7371}
7372
7373void
paul4dadc292005-05-06 21:37:42 +00007374ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007375{
7376 /* "show ip ospf" commands. */
7377 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7378 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7379
7380 /* "show ip ospf database" commands. */
7381 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7382 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7383 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7384 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7385 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7386 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7387 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7388 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7389 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7390 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7391 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7392 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7393 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7394 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7395
7396 /* "show ip ospf interface" commands. */
7397 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7398 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7399
7400 /* "show ip ospf neighbor" commands. */
7401 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7402 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7403 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7404 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7405 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7406 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7407 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7408 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7409 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7410 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7411 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7412 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7413 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7414 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7415
7416 /* "show ip ospf route" commands. */
7417 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7418 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007419 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7420 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007421}
7422
David Lamparter6b0655a2014-06-04 06:53:35 +02007423
paul718e3742002-12-13 20:15:29 +00007424/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007425static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00007426{
7427 INTERFACE_NODE,
7428 "%s(config-if)# ",
7429 1
7430};
7431
7432/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007433static void
7434ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007435{
7436 /* Install interface node. */
7437 install_node (&interface_node, config_write_interface);
7438
7439 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007440 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007441 install_default (INTERFACE_NODE);
7442
7443 /* "description" commands. */
7444 install_element (INTERFACE_NODE, &interface_desc_cmd);
7445 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7446
7447 /* "ip ospf authentication" commands. */
7448 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7449 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7450 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7451 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7452 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7453 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7454 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7455 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7456 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7457 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7458
7459 /* "ip ospf message-digest-key" commands. */
7460 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7461 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7462 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7463 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7464
7465 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007466 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
7467 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007468 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
7469 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007470 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007471 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7472
vincentba682532005-09-29 13:52:57 +00007473 /* "ip ospf mtu-ignore" commands. */
7474 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7475 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7476 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7477 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7478
paul718e3742002-12-13 20:15:29 +00007479 /* "ip ospf dead-interval" commands. */
7480 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7481 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007482 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7483 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007484 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7485 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007486
paul718e3742002-12-13 20:15:29 +00007487 /* "ip ospf hello-interval" commands. */
7488 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7489 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7490 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7491 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7492
7493 /* "ip ospf network" commands. */
7494 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7495 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7496
7497 /* "ip ospf priority" commands. */
7498 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7499 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7500 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7501 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7502
7503 /* "ip ospf retransmit-interval" commands. */
7504 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7505 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7506 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7507 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7508
7509 /* "ip ospf transmit-delay" commands. */
7510 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7511 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7512 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7513 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7514
7515 /* These commands are compatibitliy for previous version. */
7516 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7517 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7518 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7519 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007520 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
7521 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007522 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007523 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
7524 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007525 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007526 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7527 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7528 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7529 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7530 install_element (INTERFACE_NODE, &ospf_network_cmd);
7531 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7532 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7533 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7534 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7535 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7536 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7537 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7538}
7539
paul4dadc292005-05-06 21:37:42 +00007540static void
7541ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007542{
paul718e3742002-12-13 20:15:29 +00007543 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
paul718e3742002-12-13 20:15:29 +00007544 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7545
7546 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7547 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7548
paul718e3742002-12-13 20:15:29 +00007549 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
paul718e3742002-12-13 20:15:29 +00007550 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7551
7552 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7553 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7554 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7555
7556 install_element (OSPF_NODE, &ospf_distance_cmd);
7557 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7558 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
Christian Franke6f2a6702013-09-30 12:27:52 +00007559 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
paul718e3742002-12-13 20:15:29 +00007560#if 0
7561 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7562 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7563 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7564 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7565#endif /* 0 */
7566}
7567
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007568static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00007569{
7570 OSPF_NODE,
7571 "%s(config-router)# ",
7572 1
7573};
7574
David Lamparter6b0655a2014-06-04 06:53:35 +02007575
paul718e3742002-12-13 20:15:29 +00007576/* Install OSPF related vty commands. */
7577void
paul4dadc292005-05-06 21:37:42 +00007578ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007579{
7580 /* Install ospf top node. */
7581 install_node (&ospf_node, ospf_config_write);
7582
7583 /* "router ospf" commands. */
7584 install_element (CONFIG_NODE, &router_ospf_cmd);
7585 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7586
7587 install_default (OSPF_NODE);
7588
7589 /* "ospf router-id" commands. */
7590 install_element (OSPF_NODE, &ospf_router_id_cmd);
7591 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007592 install_element (OSPF_NODE, &router_ospf_id_cmd);
7593 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007594
7595 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007596 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7597 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007598 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00007599 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7600 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007601 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00007602
7603 /* "ospf abr-type" commands. */
7604 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7605 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7606
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007607 /* "ospf log-adjacency-changes" commands. */
7608 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
7609 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
7610 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
7611 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
7612
paul718e3742002-12-13 20:15:29 +00007613 /* "ospf rfc1583-compatible" commands. */
7614 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7615 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7616 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7617 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7618
7619 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007620 install_element (OSPF_NODE, &ospf_network_area_cmd);
7621 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007622
7623 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007624 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7625 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7626 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007627
7628 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007629 install_element (OSPF_NODE, &ospf_area_range_cmd);
7630 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7631 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7632 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7633 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7634 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7635 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7636 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7637 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7638 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7639 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007640
7641 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007642 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7643 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007644
paula2c62832003-04-23 17:01:31 +00007645 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7646 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007647
paula2c62832003-04-23 17:01:31 +00007648 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7649 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007650
paula2c62832003-04-23 17:01:31 +00007651 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7652 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007653
paula2c62832003-04-23 17:01:31 +00007654 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7655 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007656
paula2c62832003-04-23 17:01:31 +00007657 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7658 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7659 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007660
paula2c62832003-04-23 17:01:31 +00007661 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7662 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007663
paula2c62832003-04-23 17:01:31 +00007664 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7665 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007666
paula2c62832003-04-23 17:01:31 +00007667 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7668 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7669 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007670
paula2c62832003-04-23 17:01:31 +00007671 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7672 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7673 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007674
7675 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007676 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7677 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7678 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7679 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007680
paul718e3742002-12-13 20:15:29 +00007681 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007682 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7683 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7684 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7685 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7686 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7687 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007688
paula2c62832003-04-23 17:01:31 +00007689 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7690 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007691
paula2c62832003-04-23 17:01:31 +00007692 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7693 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007694
paula2c62832003-04-23 17:01:31 +00007695 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7696 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007697
paula2c62832003-04-23 17:01:31 +00007698 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7699 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007700
paula2c62832003-04-23 17:01:31 +00007701 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00007703
7704 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00007705 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7706 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00007707 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
7708 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
7709
paul88d6cf32005-10-29 12:50:09 +00007710 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00007711 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7712 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7713 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007714
paul88d6cf32005-10-29 12:50:09 +00007715 /* max-metric commands */
7716 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
7717 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
7718 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
7719 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
7720 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
7721 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
7722
7723 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00007724 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7725 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007726
7727 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007728 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7729 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7730 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7731 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7732 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7733 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7734 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7735 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007736
7737 /* Init interface related vty commands. */
7738 ospf_vty_if_init ();
7739
7740 /* Init zebra related vty commands. */
7741 ospf_vty_zebra_init ();
7742}