blob: 97fcffd11b0af4795b136ea0f5e2a7f6166a2dbe [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
257ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
258 struct in_addr addr,
259 struct ospf_if_params *params, u_char value)
260{
261 u_char dflt;
262
263 params->passive_interface = value;
264 if (params != IF_DEF_PARAMS (ifp))
265 {
266 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
267 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
268 else
269 dflt = ospf->passive_interface_default;
270
271 if (value != dflt)
272 SET_IF_PARAM (params, passive_interface);
273 else
274 UNSET_IF_PARAM (params, passive_interface);
275
276 ospf_free_if_params (ifp, addr);
277 ospf_if_update_params (ifp, addr);
278 }
279 else
280 {
281 if (value != ospf->passive_interface_default)
282 SET_IF_PARAM (params, passive_interface);
283 else
284 UNSET_IF_PARAM (params, passive_interface);
285 }
286}
287
paula2c62832003-04-23 17:01:31 +0000288DEFUN (ospf_passive_interface,
289 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000290 "passive-interface IFNAME A.B.C.D",
291 "Suppress routing updates on an interface\n"
292 "Interface's name\n")
293{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000294 struct interface *ifp;
295 struct in_addr addr;
296 int ret;
297 struct ospf_if_params *params;
298 struct route_node *rn;
299 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000300
Andrew J. Schorr43540882006-11-28 16:36:39 +0000301 if (argc == 0)
302 {
303 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
304 return CMD_SUCCESS;
305 }
306
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000307 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000308
309 params = IF_DEF_PARAMS (ifp);
310
Andrew J. Schorr43540882006-11-28 16:36:39 +0000311 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000312 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000313 ret = inet_aton(argv[1], &addr);
314 if (!ret)
315 {
316 vty_out (vty, "Please specify interface address by A.B.C.D%s",
317 VTY_NEWLINE);
318 return CMD_WARNING;
319 }
paul718e3742002-12-13 20:15:29 +0000320
Andrew J. Schorr43540882006-11-28 16:36:39 +0000321 params = ospf_get_if_params (ifp, addr);
322 ospf_if_update_params (ifp, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000323 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000324 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
325
ajsba6454e2005-02-08 15:37:30 +0000326 /* XXX We should call ospf_if_set_multicast on exactly those
327 * interfaces for which the passive property changed. It is too much
328 * work to determine this set, so we do this for every interface.
329 * This is safe and reasonable because ospf_if_set_multicast uses a
330 * record of joined groups to avoid systems calls if the desired
331 * memberships match the current memership.
332 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000333
ajsba6454e2005-02-08 15:37:30 +0000334 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
335 {
336 struct ospf_interface *oi = rn->info;
337
338 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000339 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000340 }
341 /*
342 * XXX It is not clear what state transitions the interface needs to
343 * undergo when going from active to passive. Fixing this will
344 * require precise identification of interfaces having such a
345 * transition.
346 */
347
paul718e3742002-12-13 20:15:29 +0000348 return CMD_SUCCESS;
349}
350
paula2c62832003-04-23 17:01:31 +0000351ALIAS (ospf_passive_interface,
352 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000353 "passive-interface IFNAME",
354 "Suppress routing updates on an interface\n"
355 "Interface's name\n")
356
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000357ALIAS (ospf_passive_interface,
358 ospf_passive_interface_default_cmd,
359 "passive-interface default",
360 "Suppress routing updates on an interface\n"
361 "Suppress routing updates on interfaces by default\n")
362
paula2c62832003-04-23 17:01:31 +0000363DEFUN (no_ospf_passive_interface,
364 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000365 "no passive-interface IFNAME A.B.C.D",
366 NO_STR
367 "Allow routing updates on an interface\n"
368 "Interface's name\n")
369{
370 struct interface *ifp;
371 struct in_addr addr;
372 struct ospf_if_params *params;
373 int ret;
ajsba6454e2005-02-08 15:37:30 +0000374 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000375 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000376
377 if (argc == 0)
378 {
379 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
380 return CMD_SUCCESS;
381 }
paul718e3742002-12-13 20:15:29 +0000382
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000383 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000384
385 params = IF_DEF_PARAMS (ifp);
386
Andrew J. Schorr43540882006-11-28 16:36:39 +0000387 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000388 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000389 ret = inet_aton(argv[1], &addr);
390 if (!ret)
391 {
392 vty_out (vty, "Please specify interface address by A.B.C.D%s",
393 VTY_NEWLINE);
394 return CMD_WARNING;
395 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000396
Andrew J. Schorr43540882006-11-28 16:36:39 +0000397 params = ospf_lookup_if_params (ifp, addr);
398 if (params == NULL)
399 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000400 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000401 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
ajsba6454e2005-02-08 15:37:30 +0000402
403 /* XXX We should call ospf_if_set_multicast on exactly those
404 * interfaces for which the passive property changed. It is too much
405 * work to determine this set, so we do this for every interface.
406 * This is safe and reasonable because ospf_if_set_multicast uses a
407 * record of joined groups to avoid systems calls if the desired
408 * memberships match the current memership.
409 */
410 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
411 {
412 struct ospf_interface *oi = rn->info;
413
414 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
415 ospf_if_set_multicast(oi);
416 }
417
paul718e3742002-12-13 20:15:29 +0000418 return CMD_SUCCESS;
419}
420
paula2c62832003-04-23 17:01:31 +0000421ALIAS (no_ospf_passive_interface,
422 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000423 "no passive-interface IFNAME",
424 NO_STR
425 "Allow routing updates on an interface\n"
426 "Interface's name\n")
427
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000428ALIAS (no_ospf_passive_interface,
429 no_ospf_passive_interface_default_cmd,
430 "no passive-interface default",
431 NO_STR
432 "Allow routing updates on an interface\n"
433 "Allow routing updates on interfaces by default\n")
434
paula2c62832003-04-23 17:01:31 +0000435DEFUN (ospf_network_area,
436 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000437 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
438 "Enable routing on an IP network\n"
439 "OSPF network prefix\n"
440 "Set the OSPF area ID\n"
441 "OSPF area ID in IP address format\n"
442 "OSPF area ID as a decimal value\n")
443{
444 struct ospf *ospf= vty->index;
445 struct prefix_ipv4 p;
446 struct in_addr area_id;
447 int ret, format;
448
449 /* Get network prefix and Area ID. */
450 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
451 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
452
453 ret = ospf_network_set (ospf, &p, area_id);
454 if (ret == 0)
455 {
456 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
457 return CMD_WARNING;
458 }
459
460 return CMD_SUCCESS;
461}
462
paula2c62832003-04-23 17:01:31 +0000463DEFUN (no_ospf_network_area,
464 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000465 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
466 NO_STR
467 "Enable routing on an IP network\n"
468 "OSPF network prefix\n"
469 "Set the OSPF area ID\n"
470 "OSPF area ID in IP address format\n"
471 "OSPF area ID as a decimal value\n")
472{
473 struct ospf *ospf = (struct ospf *) vty->index;
474 struct prefix_ipv4 p;
475 struct in_addr area_id;
476 int ret, format;
477
478 /* Get network prefix and Area ID. */
479 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
480 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
481
482 ret = ospf_network_unset (ospf, &p, area_id);
483 if (ret == 0)
484 {
485 vty_out (vty, "Can't find specified network area configuration.%s",
486 VTY_NEWLINE);
487 return CMD_WARNING;
488 }
489
490 return CMD_SUCCESS;
491}
492
David Lamparter6b0655a2014-06-04 06:53:35 +0200493
paula2c62832003-04-23 17:01:31 +0000494DEFUN (ospf_area_range,
495 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000496 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
497 "OSPF area parameters\n"
498 "OSPF area ID in IP address format\n"
499 "OSPF area ID as a decimal value\n"
500 "Summarize routes matching address/mask (border routers only)\n"
501 "Area range prefix\n")
502{
503 struct ospf *ospf = vty->index;
504 struct prefix_ipv4 p;
505 struct in_addr area_id;
506 int format;
507 u_int32_t cost;
508
509 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
510 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
511
512 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
513 if (argc > 2)
514 {
paul4dadc292005-05-06 21:37:42 +0000515 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000516 ospf_area_range_cost_set (ospf, area_id, &p, cost);
517 }
518
519 return CMD_SUCCESS;
520}
521
paula2c62832003-04-23 17:01:31 +0000522ALIAS (ospf_area_range,
523 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000524 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
525 "OSPF area parameters\n"
526 "OSPF area ID in IP address format\n"
527 "OSPF area ID as a decimal value\n"
528 "OSPF area range for route advertise (default)\n"
529 "Area range prefix\n"
530 "Advertise this range (default)\n")
531
paula2c62832003-04-23 17:01:31 +0000532ALIAS (ospf_area_range,
533 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000534 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
535 "OSPF area parameters\n"
536 "OSPF area ID in IP address format\n"
537 "OSPF area ID as a decimal value\n"
538 "Summarize routes matching address/mask (border routers only)\n"
539 "Area range prefix\n"
540 "User specified metric for this range\n"
541 "Advertised metric for this range\n")
542
paula2c62832003-04-23 17:01:31 +0000543ALIAS (ospf_area_range,
544 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000545 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
546 "OSPF area parameters\n"
547 "OSPF area ID in IP address format\n"
548 "OSPF area ID as a decimal value\n"
549 "Summarize routes matching address/mask (border routers only)\n"
550 "Area range prefix\n"
551 "Advertise this range (default)\n"
552 "User specified metric for this range\n"
553 "Advertised metric for this range\n")
554
paula2c62832003-04-23 17:01:31 +0000555DEFUN (ospf_area_range_not_advertise,
556 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000557 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
558 "OSPF area parameters\n"
559 "OSPF area ID in IP address format\n"
560 "OSPF area ID as a decimal value\n"
561 "Summarize routes matching address/mask (border routers only)\n"
562 "Area range prefix\n"
563 "DoNotAdvertise this range\n")
564{
565 struct ospf *ospf = vty->index;
566 struct prefix_ipv4 p;
567 struct in_addr area_id;
568 int format;
569
570 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
571 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
572
573 ospf_area_range_set (ospf, area_id, &p, 0);
574
575 return CMD_SUCCESS;
576}
577
paula2c62832003-04-23 17:01:31 +0000578DEFUN (no_ospf_area_range,
579 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000580 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
581 NO_STR
582 "OSPF area parameters\n"
583 "OSPF area ID in IP address format\n"
584 "OSPF area ID as a decimal value\n"
585 "Summarize routes matching address/mask (border routers only)\n"
586 "Area range prefix\n")
587{
588 struct ospf *ospf = vty->index;
589 struct prefix_ipv4 p;
590 struct in_addr area_id;
591 int format;
592
593 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
594 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
595
596 ospf_area_range_unset (ospf, area_id, &p);
597
598 return CMD_SUCCESS;
599}
600
paula2c62832003-04-23 17:01:31 +0000601ALIAS (no_ospf_area_range,
602 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000603 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
604 NO_STR
605 "OSPF area parameters\n"
606 "OSPF area ID in IP address format\n"
607 "OSPF area ID as a decimal value\n"
608 "Summarize routes matching address/mask (border routers only)\n"
609 "Area range prefix\n"
610 "Advertise this range (default)\n"
611 "DoNotAdvertise this range\n")
612
paula2c62832003-04-23 17:01:31 +0000613ALIAS (no_ospf_area_range,
614 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000615 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
616 NO_STR
617 "OSPF area parameters\n"
618 "OSPF area ID in IP address format\n"
619 "OSPF area ID as a decimal value\n"
620 "Summarize routes matching address/mask (border routers only)\n"
621 "Area range prefix\n"
622 "User specified metric for this range\n"
623 "Advertised metric for this range\n")
624
paula2c62832003-04-23 17:01:31 +0000625ALIAS (no_ospf_area_range,
626 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000627 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
628 NO_STR
629 "OSPF area parameters\n"
630 "OSPF area ID in IP address format\n"
631 "OSPF area ID as a decimal value\n"
632 "Summarize routes matching address/mask (border routers only)\n"
633 "Area range prefix\n"
634 "Advertise this range (default)\n"
635 "User specified metric for this range\n"
636 "Advertised metric for this range\n")
David Lamparter6b0655a2014-06-04 06:53:35 +0200637
paula2c62832003-04-23 17:01:31 +0000638DEFUN (ospf_area_range_substitute,
639 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000640 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
641 "OSPF area parameters\n"
642 "OSPF area ID in IP address format\n"
643 "OSPF area ID as a decimal value\n"
644 "Summarize routes matching address/mask (border routers only)\n"
645 "Area range prefix\n"
646 "Announce area range as another prefix\n"
647 "Network prefix to be announced instead of range\n")
648{
649 struct ospf *ospf = vty->index;
650 struct prefix_ipv4 p, s;
651 struct in_addr area_id;
652 int format;
653
654 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
655 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
656 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
657
658 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
659
660 return CMD_SUCCESS;
661}
662
paula2c62832003-04-23 17:01:31 +0000663DEFUN (no_ospf_area_range_substitute,
664 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000665 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
666 NO_STR
667 "OSPF area parameters\n"
668 "OSPF area ID in IP address format\n"
669 "OSPF area ID as a decimal value\n"
670 "Summarize routes matching address/mask (border routers only)\n"
671 "Area range prefix\n"
672 "Announce area range as another prefix\n"
673 "Network prefix to be announced instead of range\n")
674{
675 struct ospf *ospf = vty->index;
676 struct prefix_ipv4 p, s;
677 struct in_addr area_id;
678 int format;
679
680 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
681 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
682 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
683
684 ospf_area_range_substitute_unset (ospf, area_id, &p);
685
686 return CMD_SUCCESS;
687}
688
David Lamparter6b0655a2014-06-04 06:53:35 +0200689
paul718e3742002-12-13 20:15:29 +0000690/* Command Handler Logic in VLink stuff is delicate!!
691
692 ALTER AT YOUR OWN RISK!!!!
693
694 Various dummy values are used to represent 'NoChange' state for
695 VLink configuration NOT being changed by a VLink command, and
696 special syntax is used within the command strings so that the
697 typed in command verbs can be seen in the configuration command
698 bacckend handler. This is to drastically reduce the verbeage
699 required to coe up with a reasonably compatible Cisco VLink command
700
701 - Matthew Grant <grantma@anathoth.gen.nz>
702 Wed, 21 Feb 2001 15:13:52 +1300
703 */
704
705
706/* Configuration data for virtual links
707 */
708struct ospf_vl_config_data {
709 struct vty *vty; /* vty stuff */
710 struct in_addr area_id; /* area ID from command line */
711 int format; /* command line area ID format */
712 struct in_addr vl_peer; /* command line vl_peer */
713 int auth_type; /* Authehntication type, if given */
714 char *auth_key; /* simple password if present */
715 int crypto_key_id; /* Cryptographic key ID */
716 char *md5_key; /* MD5 authentication key */
717 int hello_interval; /* Obvious what these are... */
718 int retransmit_interval;
719 int transmit_delay;
720 int dead_interval;
721};
722
paul4dadc292005-05-06 21:37:42 +0000723static void
paul718e3742002-12-13 20:15:29 +0000724ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
725 struct vty *vty)
726{
727 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
728 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
729 vl_config->vty = vty;
730}
731
paul4dadc292005-05-06 21:37:42 +0000732static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000733ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000734{
735 struct ospf_area *area;
736 struct ospf_vl_data *vl_data;
737 struct vty *vty;
738 struct in_addr area_id;
739
740 vty = vl_config->vty;
741 area_id = vl_config->area_id;
742
743 if (area_id.s_addr == OSPF_AREA_BACKBONE)
744 {
745 vty_out (vty,
746 "Configuring VLs over the backbone is not allowed%s",
747 VTY_NEWLINE);
748 return NULL;
749 }
paul68980082003-03-25 05:07:42 +0000750 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000751
752 if (area->external_routing != OSPF_AREA_DEFAULT)
753 {
754 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
755 vty_out (vty, "Area %s is %s%s",
756 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000757 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000758 VTY_NEWLINE);
759 else
760 vty_out (vty, "Area %ld is %s%s",
761 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000762 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000763 VTY_NEWLINE);
764 return NULL;
765 }
766
Paul Jakma9c27ef92006-05-04 07:32:57 +0000767 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000768 {
769 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
770 if (vl_data->vl_oi == NULL)
771 {
paul68980082003-03-25 05:07:42 +0000772 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
773 ospf_vl_add (ospf, vl_data);
774 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000775 }
776 }
777 return vl_data;
778}
779
780
paul4dadc292005-05-06 21:37:42 +0000781static int
paul718e3742002-12-13 20:15:29 +0000782ospf_vl_set_security (struct ospf_vl_data *vl_data,
783 struct ospf_vl_config_data *vl_config)
784{
785 struct crypt_key *ck;
786 struct vty *vty;
787 struct interface *ifp = vl_data->vl_oi->ifp;
788
789 vty = vl_config->vty;
790
791 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
792 {
793 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
794 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
795 }
796
797 if (vl_config->auth_key)
798 {
799 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000800 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000801 OSPF_AUTH_SIMPLE_SIZE);
802 }
803 else if (vl_config->md5_key)
804 {
805 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
806 != NULL)
807 {
808 vty_out (vty, "OSPF: Key %d already exists%s",
809 vl_config->crypto_key_id, VTY_NEWLINE);
810 return CMD_WARNING;
811 }
812 ck = ospf_crypt_key_new ();
813 ck->key_id = vl_config->crypto_key_id;
814 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000815 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000816
817 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
818 }
819 else if (vl_config->crypto_key_id != 0)
820 {
821 /* Delete a key */
822
823 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
824 vl_config->crypto_key_id) == NULL)
825 {
826 vty_out (vty, "OSPF: Key %d does not exist%s",
827 vl_config->crypto_key_id, VTY_NEWLINE);
828 return CMD_WARNING;
829 }
830
831 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
832
833 }
834
835 return CMD_SUCCESS;
836}
837
paul4dadc292005-05-06 21:37:42 +0000838static int
paul718e3742002-12-13 20:15:29 +0000839ospf_vl_set_timers (struct ospf_vl_data *vl_data,
840 struct ospf_vl_config_data *vl_config)
841{
842 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
843 /* Virtual Link data initialised to defaults, so only set
844 if a value given */
845 if (vl_config->hello_interval)
846 {
847 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
848 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
849 }
850
851 if (vl_config->dead_interval)
852 {
853 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
854 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
855 }
856
857 if (vl_config->retransmit_interval)
858 {
859 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
860 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
861 }
862
863 if (vl_config->transmit_delay)
864 {
865 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
866 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
867 }
868
869 return CMD_SUCCESS;
870}
871
872
873
874/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000875static int
paul68980082003-03-25 05:07:42 +0000876ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000877{
878 struct ospf_vl_data *vl_data;
879 int ret;
880
paul68980082003-03-25 05:07:42 +0000881 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000882 if (!vl_data)
883 return CMD_WARNING;
884
885 /* Process this one first as it can have a fatal result, which can
886 only logically occur if the virtual link exists already
887 Thus a command error does not result in a change to the
888 running configuration such as unexpectedly altered timer
889 values etc.*/
890 ret = ospf_vl_set_security (vl_data, vl_config);
891 if (ret != CMD_SUCCESS)
892 return ret;
893
894 /* Set any time based parameters, these area already range checked */
895
896 ret = ospf_vl_set_timers (vl_data, vl_config);
897 if (ret != CMD_SUCCESS)
898 return ret;
899
900 return CMD_SUCCESS;
901
902}
903
904/* This stuff exists to make specifying all the alias commands A LOT simpler
905 */
906#define VLINK_HELPSTR_IPADDR \
907 "OSPF area parameters\n" \
908 "OSPF area ID in IP address format\n" \
909 "OSPF area ID as a decimal value\n" \
910 "Configure a virtual link\n" \
911 "Router ID of the remote ABR\n"
912
913#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
914 "Enable authentication on this virtual link\n" \
915 "dummy string \n"
916
917#define VLINK_HELPSTR_AUTHTYPE_ALL \
918 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
919 "Use null authentication\n" \
920 "Use message-digest authentication\n"
921
922#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
923 "Time between HELLO packets\n" \
924 "Time between retransmitting lost link state advertisements\n" \
925 "Link state transmit delay\n" \
926 "Interval after which a neighbor is declared dead\n"
927
928#define VLINK_HELPSTR_TIME_PARAM \
929 VLINK_HELPSTR_TIME_PARAM_NOSECS \
930 "Seconds\n"
931
932#define VLINK_HELPSTR_AUTH_SIMPLE \
933 "Authentication password (key)\n" \
934 "The OSPF password (key)"
935
936#define VLINK_HELPSTR_AUTH_MD5 \
937 "Message digest authentication password (key)\n" \
938 "dummy string \n" \
939 "Key ID\n" \
940 "Use MD5 algorithm\n" \
941 "The OSPF password (key)"
942
paula2c62832003-04-23 17:01:31 +0000943DEFUN (ospf_area_vlink,
944 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000945 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
946 VLINK_HELPSTR_IPADDR)
947{
paul68980082003-03-25 05:07:42 +0000948 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000949 struct ospf_vl_config_data vl_config;
950 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
951 char md5_key[OSPF_AUTH_MD5_SIZE+1];
952 int i;
953 int ret;
954
955 ospf_vl_config_data_init(&vl_config, vty);
956
957 /* Read off first 2 parameters and check them */
958 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
959 if (ret < 0)
960 {
961 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
962 return CMD_WARNING;
963 }
964
965 ret = inet_aton (argv[1], &vl_config.vl_peer);
966 if (! ret)
967 {
968 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
969 VTY_NEWLINE);
970 return CMD_WARNING;
971 }
972
973 if (argc <=2)
974 {
975 /* Thats all folks! - BUGS B. strikes again!!!*/
976
paul68980082003-03-25 05:07:42 +0000977 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000978 }
979
980 /* Deal with other parameters */
981 for (i=2; i < argc; i++)
982 {
983
984 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
985
986 switch (argv[i][0])
987 {
988
989 case 'a':
990 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
991 {
992 /* authentication-key - this option can occur anywhere on
993 command line. At start of command line
994 must check for authentication option. */
995 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
996 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
997 vl_config.auth_key = auth_key;
998 i++;
999 }
1000 else if (strncmp (argv[i], "authentication", 14) == 0)
1001 {
1002 /* authentication - this option can only occur at start
1003 of command line */
1004 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1005 if ((i+1) < argc)
1006 {
1007 if (strncmp (argv[i+1], "n", 1) == 0)
1008 {
1009 /* "authentication null" */
1010 vl_config.auth_type = OSPF_AUTH_NULL;
1011 i++;
1012 }
1013 else if (strncmp (argv[i+1], "m", 1) == 0
1014 && strcmp (argv[i+1], "message-digest-") != 0)
1015 {
1016 /* "authentication message-digest" */
1017 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1018 i++;
1019 }
1020 }
1021 }
1022 break;
1023
1024 case 'm':
1025 /* message-digest-key */
1026 i++;
1027 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1028 if (vl_config.crypto_key_id < 0)
1029 return CMD_WARNING;
1030 i++;
1031 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1032 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1033 vl_config.md5_key = md5_key;
1034 break;
1035
1036 case 'h':
1037 /* Hello interval */
1038 i++;
1039 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1040 if (vl_config.hello_interval < 0)
1041 return CMD_WARNING;
1042 break;
1043
1044 case 'r':
1045 /* Retransmit Interval */
1046 i++;
1047 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1048 if (vl_config.retransmit_interval < 0)
1049 return CMD_WARNING;
1050 break;
1051
1052 case 't':
1053 /* Transmit Delay */
1054 i++;
1055 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1056 if (vl_config.transmit_delay < 0)
1057 return CMD_WARNING;
1058 break;
1059
1060 case 'd':
1061 /* Dead Interval */
1062 i++;
1063 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1064 if (vl_config.dead_interval < 0)
1065 return CMD_WARNING;
1066 break;
1067 }
1068 }
1069
1070
1071 /* Action configuration */
1072
paul68980082003-03-25 05:07:42 +00001073 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001074
1075}
1076
paula2c62832003-04-23 17:01:31 +00001077DEFUN (no_ospf_area_vlink,
1078 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001079 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1080 NO_STR
1081 VLINK_HELPSTR_IPADDR)
1082{
paul68980082003-03-25 05:07:42 +00001083 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001084 struct ospf_area *area;
1085 struct ospf_vl_config_data vl_config;
1086 struct ospf_vl_data *vl_data = NULL;
1087 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1088 int i;
1089 int ret, format;
1090
1091 ospf_vl_config_data_init(&vl_config, vty);
1092
1093 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1094 if (ret < 0)
1095 {
1096 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1097 return CMD_WARNING;
1098 }
1099
paul68980082003-03-25 05:07:42 +00001100 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001101 if (!area)
1102 {
1103 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1104 return CMD_WARNING;
1105 }
1106
1107 ret = inet_aton (argv[1], &vl_config.vl_peer);
1108 if (! ret)
1109 {
1110 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1111 VTY_NEWLINE);
1112 return CMD_WARNING;
1113 }
1114
1115 if (argc <=2)
1116 {
1117 /* Basic VLink no command */
1118 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001119 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001120 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001121
paul68980082003-03-25 05:07:42 +00001122 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001123
1124 return CMD_SUCCESS;
1125 }
1126
1127 /* If we are down here, we are reseting parameters */
1128
1129 /* Deal with other parameters */
1130 for (i=2; i < argc; i++)
1131 {
paul718e3742002-12-13 20:15:29 +00001132 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1133
1134 switch (argv[i][0])
1135 {
1136
1137 case 'a':
1138 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1139 {
1140 /* authentication-key - this option can occur anywhere on
1141 command line. At start of command line
1142 must check for authentication option. */
1143 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1144 vl_config.auth_key = auth_key;
1145 }
1146 else if (strncmp (argv[i], "authentication", 14) == 0)
1147 {
1148 /* authentication - this option can only occur at start
1149 of command line */
1150 vl_config.auth_type = OSPF_AUTH_NOTSET;
1151 }
1152 break;
1153
1154 case 'm':
1155 /* message-digest-key */
1156 /* Delete one key */
1157 i++;
1158 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1159 if (vl_config.crypto_key_id < 0)
1160 return CMD_WARNING;
1161 vl_config.md5_key = NULL;
1162 break;
1163
1164 case 'h':
1165 /* Hello interval */
1166 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1167 break;
1168
1169 case 'r':
1170 /* Retransmit Interval */
1171 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1172 break;
1173
1174 case 't':
1175 /* Transmit Delay */
1176 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1177 break;
1178
1179 case 'd':
1180 /* Dead Interval */
1181 i++;
1182 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1183 break;
1184 }
1185 }
1186
1187
1188 /* Action configuration */
1189
paul68980082003-03-25 05:07:42 +00001190 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001191}
1192
paula2c62832003-04-23 17:01:31 +00001193ALIAS (ospf_area_vlink,
1194 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001195 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1196 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1197 VLINK_HELPSTR_IPADDR
1198 VLINK_HELPSTR_TIME_PARAM)
1199
paula2c62832003-04-23 17:01:31 +00001200ALIAS (no_ospf_area_vlink,
1201 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001202 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM)
1207
paula2c62832003-04-23 17:01:31 +00001208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1213 VLINK_HELPSTR_IPADDR
1214 VLINK_HELPSTR_TIME_PARAM
1215 VLINK_HELPSTR_TIME_PARAM)
1216
paula2c62832003-04-23 17:01:31 +00001217ALIAS (no_ospf_area_vlink,
1218 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001219 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1220 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1221 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1222 NO_STR
1223 VLINK_HELPSTR_IPADDR
1224 VLINK_HELPSTR_TIME_PARAM
1225 VLINK_HELPSTR_TIME_PARAM)
1226
paula2c62832003-04-23 17:01:31 +00001227ALIAS (ospf_area_vlink,
1228 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001229 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1230 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1231 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1232 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1233 VLINK_HELPSTR_IPADDR
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM
1236 VLINK_HELPSTR_TIME_PARAM)
1237
paula2c62832003-04-23 17:01:31 +00001238ALIAS (no_ospf_area_vlink,
1239 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001240 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1241 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1242 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1243 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1244 NO_STR
1245 VLINK_HELPSTR_IPADDR
1246 VLINK_HELPSTR_TIME_PARAM
1247 VLINK_HELPSTR_TIME_PARAM
1248 VLINK_HELPSTR_TIME_PARAM)
1249
paula2c62832003-04-23 17:01:31 +00001250ALIAS (ospf_area_vlink,
1251 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001252 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1254 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1255 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1256 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_TIME_PARAM
1259 VLINK_HELPSTR_TIME_PARAM
1260 VLINK_HELPSTR_TIME_PARAM
1261 VLINK_HELPSTR_TIME_PARAM)
1262
paula2c62832003-04-23 17:01:31 +00001263ALIAS (no_ospf_area_vlink,
1264 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001265 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1267 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1268 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1269 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_TIME_PARAM
1273 VLINK_HELPSTR_TIME_PARAM
1274 VLINK_HELPSTR_TIME_PARAM
1275 VLINK_HELPSTR_TIME_PARAM)
1276
paula2c62832003-04-23 17:01:31 +00001277ALIAS (ospf_area_vlink,
1278 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001279 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1280 "(authentication|) (message-digest|null)",
1281 VLINK_HELPSTR_IPADDR
1282 VLINK_HELPSTR_AUTHTYPE_ALL)
1283
paula2c62832003-04-23 17:01:31 +00001284ALIAS (ospf_area_vlink,
1285 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001286 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1287 "(authentication|)",
1288 VLINK_HELPSTR_IPADDR
1289 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1290
paula2c62832003-04-23 17:01:31 +00001291ALIAS (no_ospf_area_vlink,
1292 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001293 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1294 "(authentication|)",
1295 NO_STR
1296 VLINK_HELPSTR_IPADDR
1297 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1298
paula2c62832003-04-23 17:01:31 +00001299ALIAS (ospf_area_vlink,
1300 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001301 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1302 "(message-digest-key|) <1-255> md5 KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTH_MD5)
1305
paula2c62832003-04-23 17:01:31 +00001306ALIAS (no_ospf_area_vlink,
1307 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001308 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1309 "(message-digest-key|) <1-255>",
1310 NO_STR
1311 VLINK_HELPSTR_IPADDR
1312 VLINK_HELPSTR_AUTH_MD5)
1313
paula2c62832003-04-23 17:01:31 +00001314ALIAS (ospf_area_vlink,
1315 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001316 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1317 "(authentication-key|) AUTH_KEY",
1318 VLINK_HELPSTR_IPADDR
1319 VLINK_HELPSTR_AUTH_SIMPLE)
1320
paula2c62832003-04-23 17:01:31 +00001321ALIAS (no_ospf_area_vlink,
1322 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001323 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1324 "(authentication-key|)",
1325 NO_STR
1326 VLINK_HELPSTR_IPADDR
1327 VLINK_HELPSTR_AUTH_SIMPLE)
1328
paula2c62832003-04-23 17:01:31 +00001329ALIAS (ospf_area_vlink,
1330 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001331 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1332 "(authentication|) (message-digest|null) "
1333 "(authentication-key|) AUTH_KEY",
1334 VLINK_HELPSTR_IPADDR
1335 VLINK_HELPSTR_AUTHTYPE_ALL
1336 VLINK_HELPSTR_AUTH_SIMPLE)
1337
paula2c62832003-04-23 17:01:31 +00001338ALIAS (ospf_area_vlink,
1339 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001340 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1341 "(authentication|) "
1342 "(authentication-key|) AUTH_KEY",
1343 VLINK_HELPSTR_IPADDR
1344 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1345 VLINK_HELPSTR_AUTH_SIMPLE)
1346
paula2c62832003-04-23 17:01:31 +00001347ALIAS (no_ospf_area_vlink,
1348 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001349 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1350 "(authentication|) "
1351 "(authentication-key|)",
1352 NO_STR
1353 VLINK_HELPSTR_IPADDR
1354 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1355 VLINK_HELPSTR_AUTH_SIMPLE)
1356
paula2c62832003-04-23 17:01:31 +00001357ALIAS (ospf_area_vlink,
1358 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001359 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1360 "(authentication|) (message-digest|null) "
1361 "(message-digest-key|) <1-255> md5 KEY",
1362 VLINK_HELPSTR_IPADDR
1363 VLINK_HELPSTR_AUTHTYPE_ALL
1364 VLINK_HELPSTR_AUTH_MD5)
1365
paula2c62832003-04-23 17:01:31 +00001366ALIAS (ospf_area_vlink,
1367 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001368 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1369 "(authentication|) "
1370 "(message-digest-key|) <1-255> md5 KEY",
1371 VLINK_HELPSTR_IPADDR
1372 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1373 VLINK_HELPSTR_AUTH_MD5)
1374
paula2c62832003-04-23 17:01:31 +00001375ALIAS (no_ospf_area_vlink,
1376 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001377 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1378 "(authentication|) "
1379 "(message-digest-key|)",
1380 NO_STR
1381 VLINK_HELPSTR_IPADDR
1382 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1383 VLINK_HELPSTR_AUTH_MD5)
1384
David Lamparter6b0655a2014-06-04 06:53:35 +02001385
paula2c62832003-04-23 17:01:31 +00001386DEFUN (ospf_area_shortcut,
1387 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1389 "OSPF area parameters\n"
1390 "OSPF area ID in IP address format\n"
1391 "OSPF area ID as a decimal value\n"
1392 "Configure the area's shortcutting mode\n"
1393 "Set default shortcutting behavior\n"
1394 "Enable shortcutting through the area\n"
1395 "Disable shortcutting through the area\n")
1396{
paul68980082003-03-25 05:07:42 +00001397 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001398 struct ospf_area *area;
1399 struct in_addr area_id;
1400 int mode;
1401 int format;
1402
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1404
paul68980082003-03-25 05:07:42 +00001405 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001406
1407 if (strncmp (argv[1], "de", 2) == 0)
1408 mode = OSPF_SHORTCUT_DEFAULT;
1409 else if (strncmp (argv[1], "di", 2) == 0)
1410 mode = OSPF_SHORTCUT_DISABLE;
1411 else if (strncmp (argv[1], "e", 1) == 0)
1412 mode = OSPF_SHORTCUT_ENABLE;
1413 else
1414 return CMD_WARNING;
1415
paul68980082003-03-25 05:07:42 +00001416 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001417
paul68980082003-03-25 05:07:42 +00001418 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001419 vty_out (vty, "Shortcut area setting will take effect "
1420 "only when the router is configured as Shortcut ABR%s",
1421 VTY_NEWLINE);
1422
1423 return CMD_SUCCESS;
1424}
1425
paula2c62832003-04-23 17:01:31 +00001426DEFUN (no_ospf_area_shortcut,
1427 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001428 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1429 NO_STR
1430 "OSPF area parameters\n"
1431 "OSPF area ID in IP address format\n"
1432 "OSPF area ID as a decimal value\n"
1433 "Deconfigure the area's shortcutting mode\n"
1434 "Deconfigure enabled shortcutting through the area\n"
1435 "Deconfigure disabled shortcutting through the area\n")
1436{
paul68980082003-03-25 05:07:42 +00001437 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001438 struct ospf_area *area;
1439 struct in_addr area_id;
1440 int format;
1441
1442 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1443
paul68980082003-03-25 05:07:42 +00001444 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001445 if (!area)
1446 return CMD_SUCCESS;
1447
paul68980082003-03-25 05:07:42 +00001448 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001449
1450 return CMD_SUCCESS;
1451}
1452
David Lamparter6b0655a2014-06-04 06:53:35 +02001453
paula2c62832003-04-23 17:01:31 +00001454DEFUN (ospf_area_stub,
1455 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001456 "area (A.B.C.D|<0-4294967295>) stub",
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n")
1461{
1462 struct ospf *ospf = vty->index;
1463 struct in_addr area_id;
1464 int ret, format;
1465
1466 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1467
1468 ret = ospf_area_stub_set (ospf, area_id);
1469 if (ret == 0)
1470 {
1471 vty_out (vty, "First deconfigure all virtual link through this area%s",
1472 VTY_NEWLINE);
1473 return CMD_WARNING;
1474 }
1475
1476 ospf_area_no_summary_unset (ospf, area_id);
1477
1478 return CMD_SUCCESS;
1479}
1480
paula2c62832003-04-23 17:01:31 +00001481DEFUN (ospf_area_stub_no_summary,
1482 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001483 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1484 "OSPF stub parameters\n"
1485 "OSPF area ID in IP address format\n"
1486 "OSPF area ID as a decimal value\n"
1487 "Configure OSPF area as stub\n"
1488 "Do not inject inter-area routes into stub\n")
1489{
1490 struct ospf *ospf = vty->index;
1491 struct in_addr area_id;
1492 int ret, format;
1493
1494 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1495
1496 ret = ospf_area_stub_set (ospf, area_id);
1497 if (ret == 0)
1498 {
paulb0a053b2003-06-22 09:04:47 +00001499 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001500 VTY_NEWLINE);
1501 return CMD_WARNING;
1502 }
1503
1504 ospf_area_no_summary_set (ospf, area_id);
1505
1506 return CMD_SUCCESS;
1507}
1508
paula2c62832003-04-23 17:01:31 +00001509DEFUN (no_ospf_area_stub,
1510 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001511 "no area (A.B.C.D|<0-4294967295>) stub",
1512 NO_STR
1513 "OSPF area parameters\n"
1514 "OSPF area ID in IP address format\n"
1515 "OSPF area ID as a decimal value\n"
1516 "Configure OSPF area as stub\n")
1517{
1518 struct ospf *ospf = vty->index;
1519 struct in_addr area_id;
1520 int format;
1521
1522 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1523
1524 ospf_area_stub_unset (ospf, area_id);
1525 ospf_area_no_summary_unset (ospf, area_id);
1526
1527 return CMD_SUCCESS;
1528}
1529
paula2c62832003-04-23 17:01:31 +00001530DEFUN (no_ospf_area_stub_no_summary,
1531 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001532 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1533 NO_STR
1534 "OSPF area parameters\n"
1535 "OSPF area ID in IP address format\n"
1536 "OSPF area ID as a decimal value\n"
1537 "Configure OSPF area as stub\n"
1538 "Do not inject inter-area routes into area\n")
1539{
1540 struct ospf *ospf = vty->index;
1541 struct in_addr area_id;
1542 int format;
1543
1544 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1545 ospf_area_no_summary_unset (ospf, area_id);
1546
1547 return CMD_SUCCESS;
1548}
1549
paul4dadc292005-05-06 21:37:42 +00001550static int
paul6c835672004-10-11 11:00:30 +00001551ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1552 int nosum)
paul718e3742002-12-13 20:15:29 +00001553{
1554 struct ospf *ospf = vty->index;
1555 struct in_addr area_id;
1556 int ret, format;
1557
1558 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1559
1560 ret = ospf_area_nssa_set (ospf, area_id);
1561 if (ret == 0)
1562 {
1563 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1564 VTY_NEWLINE);
1565 return CMD_WARNING;
1566 }
1567
1568 if (argc > 1)
1569 {
1570 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001571 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001572 OSPF_NSSA_ROLE_CANDIDATE);
1573 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001574 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001575 OSPF_NSSA_ROLE_NEVER);
1576 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001577 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001578 OSPF_NSSA_ROLE_ALWAYS);
1579 }
paulb0a053b2003-06-22 09:04:47 +00001580 else
1581 {
1582 ospf_area_nssa_translator_role_set (ospf, area_id,
1583 OSPF_NSSA_ROLE_CANDIDATE);
1584 }
paul718e3742002-12-13 20:15:29 +00001585
paulb0a053b2003-06-22 09:04:47 +00001586 if (nosum)
paul718e3742002-12-13 20:15:29 +00001587 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001588 else
1589 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001590
paulb0a053b2003-06-22 09:04:47 +00001591 ospf_schedule_abr_task (ospf);
1592
paul718e3742002-12-13 20:15:29 +00001593 return CMD_SUCCESS;
1594}
1595
paulb0a053b2003-06-22 09:04:47 +00001596DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001597 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001598 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Configure NSSA-ABR for translate election (default)\n"
1604 "Configure NSSA-ABR to never translate\n"
1605 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001606 "Do not inject inter-area routes into nssa\n")
1607{
1608 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1609}
paul718e3742002-12-13 20:15:29 +00001610
paulb0a053b2003-06-22 09:04:47 +00001611DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001612 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001613 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1614 "OSPF area parameters\n"
1615 "OSPF area ID in IP address format\n"
1616 "OSPF area ID as a decimal value\n"
1617 "Configure OSPF area as nssa\n"
1618 "Configure NSSA-ABR for translate election (default)\n"
1619 "Configure NSSA-ABR to never translate\n"
1620 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001621{
1622 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1623}
1624
1625DEFUN (ospf_area_nssa,
1626 ospf_area_nssa_cmd,
1627 "area (A.B.C.D|<0-4294967295>) nssa",
1628 "OSPF area parameters\n"
1629 "OSPF area ID in IP address format\n"
1630 "OSPF area ID as a decimal value\n"
1631 "Configure OSPF area as nssa\n")
1632{
1633 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1634}
paul718e3742002-12-13 20:15:29 +00001635
paula2c62832003-04-23 17:01:31 +00001636DEFUN (ospf_area_nssa_no_summary,
1637 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001638 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1639 "OSPF area parameters\n"
1640 "OSPF area ID in IP address format\n"
1641 "OSPF area ID as a decimal value\n"
1642 "Configure OSPF area as nssa\n"
1643 "Do not inject inter-area routes into nssa\n")
1644{
paulb0a053b2003-06-22 09:04:47 +00001645 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001646}
1647
paula2c62832003-04-23 17:01:31 +00001648DEFUN (no_ospf_area_nssa,
1649 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001650 "no area (A.B.C.D|<0-4294967295>) nssa",
1651 NO_STR
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Configure OSPF area as nssa\n")
1656{
1657 struct ospf *ospf = vty->index;
1658 struct in_addr area_id;
1659 int format;
1660
1661 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1662
1663 ospf_area_nssa_unset (ospf, area_id);
1664 ospf_area_no_summary_unset (ospf, area_id);
1665
paulb0a053b2003-06-22 09:04:47 +00001666 ospf_schedule_abr_task (ospf);
1667
paul718e3742002-12-13 20:15:29 +00001668 return CMD_SUCCESS;
1669}
1670
paula2c62832003-04-23 17:01:31 +00001671DEFUN (no_ospf_area_nssa_no_summary,
1672 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001673 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1674 NO_STR
1675 "OSPF area parameters\n"
1676 "OSPF area ID in IP address format\n"
1677 "OSPF area ID as a decimal value\n"
1678 "Configure OSPF area as nssa\n"
1679 "Do not inject inter-area routes into nssa\n")
1680{
1681 struct ospf *ospf = vty->index;
1682 struct in_addr area_id;
1683 int format;
1684
1685 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1686 ospf_area_no_summary_unset (ospf, area_id);
1687
1688 return CMD_SUCCESS;
1689}
1690
paula2c62832003-04-23 17:01:31 +00001691DEFUN (ospf_area_default_cost,
1692 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001693 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the summary-default cost of a NSSA or stub area\n"
1698 "Stub's advertised default summary cost\n")
1699{
paul68980082003-03-25 05:07:42 +00001700 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 u_int32_t cost;
1704 int format;
vincentba682532005-09-29 13:52:57 +00001705 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001706
1707 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1708 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1709
paul68980082003-03-25 05:07:42 +00001710 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001711
1712 if (area->external_routing == OSPF_AREA_DEFAULT)
1713 {
1714 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1715 return CMD_WARNING;
1716 }
1717
1718 area->default_cost = cost;
1719
vincentba682532005-09-29 13:52:57 +00001720 p.family = AF_INET;
1721 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1722 p.prefixlen = 0;
1723 if (IS_DEBUG_OSPF_EVENT)
1724 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1725 "announcing 0.0.0.0/0 to area %s",
1726 inet_ntoa (area->area_id));
1727 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1728
paul718e3742002-12-13 20:15:29 +00001729 return CMD_SUCCESS;
1730}
1731
paula2c62832003-04-23 17:01:31 +00001732DEFUN (no_ospf_area_default_cost,
1733 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001734 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1735 NO_STR
1736 "OSPF area parameters\n"
1737 "OSPF area ID in IP address format\n"
1738 "OSPF area ID as a decimal value\n"
1739 "Set the summary-default cost of a NSSA or stub area\n"
1740 "Stub's advertised default summary cost\n")
1741{
paul68980082003-03-25 05:07:42 +00001742 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001743 struct ospf_area *area;
1744 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001745 int format;
vincentba682532005-09-29 13:52:57 +00001746 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001747
1748 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
Andrew Certain0798cee2012-12-04 13:43:42 -08001749 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
paul718e3742002-12-13 20:15:29 +00001750
paul68980082003-03-25 05:07:42 +00001751 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001752 if (area == NULL)
1753 return CMD_SUCCESS;
1754
1755 if (area->external_routing == OSPF_AREA_DEFAULT)
1756 {
1757 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1758 return CMD_WARNING;
1759 }
1760
1761 area->default_cost = 1;
1762
vincentba682532005-09-29 13:52:57 +00001763 p.family = AF_INET;
1764 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1765 p.prefixlen = 0;
1766 if (IS_DEBUG_OSPF_EVENT)
1767 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1768 "announcing 0.0.0.0/0 to area %s",
1769 inet_ntoa (area->area_id));
1770 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1771
1772
paul68980082003-03-25 05:07:42 +00001773 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001774
1775 return CMD_SUCCESS;
1776}
1777
paula2c62832003-04-23 17:01:31 +00001778DEFUN (ospf_area_export_list,
1779 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001780 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1781 "OSPF area parameters\n"
1782 "OSPF area ID in IP address format\n"
1783 "OSPF area ID as a decimal value\n"
1784 "Set the filter for networks announced to other areas\n"
1785 "Name of the access-list\n")
1786{
paul68980082003-03-25 05:07:42 +00001787 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001788 struct ospf_area *area;
1789 struct in_addr area_id;
1790 int format;
1791
hasso52930762004-04-19 18:26:53 +00001792 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1793
paul68980082003-03-25 05:07:42 +00001794 area = ospf_area_get (ospf, area_id, format);
1795 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001796
1797 return CMD_SUCCESS;
1798}
1799
paula2c62832003-04-23 17:01:31 +00001800DEFUN (no_ospf_area_export_list,
1801 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001802 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1803 NO_STR
1804 "OSPF area parameters\n"
1805 "OSPF area ID in IP address format\n"
1806 "OSPF area ID as a decimal value\n"
1807 "Unset the filter for networks announced to other areas\n"
1808 "Name of the access-list\n")
1809{
paul68980082003-03-25 05:07:42 +00001810 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001811 struct ospf_area *area;
1812 struct in_addr area_id;
1813 int format;
1814
hasso52930762004-04-19 18:26:53 +00001815 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1816
paul68980082003-03-25 05:07:42 +00001817 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001818 if (area == NULL)
1819 return CMD_SUCCESS;
1820
paul68980082003-03-25 05:07:42 +00001821 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001822
1823 return CMD_SUCCESS;
1824}
1825
1826
paula2c62832003-04-23 17:01:31 +00001827DEFUN (ospf_area_import_list,
1828 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001829 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1830 "OSPF area parameters\n"
1831 "OSPF area ID in IP address format\n"
1832 "OSPF area ID as a decimal value\n"
1833 "Set the filter for networks from other areas announced to the specified one\n"
1834 "Name of the access-list\n")
1835{
paul68980082003-03-25 05:07:42 +00001836 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001837 struct ospf_area *area;
1838 struct in_addr area_id;
1839 int format;
1840
hasso52930762004-04-19 18:26:53 +00001841 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1842
paul68980082003-03-25 05:07:42 +00001843 area = ospf_area_get (ospf, area_id, format);
1844 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001845
1846 return CMD_SUCCESS;
1847}
1848
paula2c62832003-04-23 17:01:31 +00001849DEFUN (no_ospf_area_import_list,
1850 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001851 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1852 NO_STR
1853 "OSPF area parameters\n"
1854 "OSPF area ID in IP address format\n"
1855 "OSPF area ID as a decimal value\n"
1856 "Unset the filter for networks announced to other areas\n"
1857 "Name of the access-list\n")
1858{
paul68980082003-03-25 05:07:42 +00001859 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001860 struct ospf_area *area;
1861 struct in_addr area_id;
1862 int format;
1863
hasso52930762004-04-19 18:26:53 +00001864 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1865
paul68980082003-03-25 05:07:42 +00001866 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001867 if (area == NULL)
1868 return CMD_SUCCESS;
1869
paul68980082003-03-25 05:07:42 +00001870 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001871
1872 return CMD_SUCCESS;
1873}
1874
paula2c62832003-04-23 17:01:31 +00001875DEFUN (ospf_area_filter_list,
1876 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001877 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1878 "OSPF area parameters\n"
1879 "OSPF area ID in IP address format\n"
1880 "OSPF area ID as a decimal value\n"
1881 "Filter networks between OSPF areas\n"
1882 "Filter prefixes between OSPF areas\n"
1883 "Name of an IP prefix-list\n"
1884 "Filter networks sent to this area\n"
1885 "Filter networks sent from this area\n")
1886{
paul68980082003-03-25 05:07:42 +00001887 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001888 struct ospf_area *area;
1889 struct in_addr area_id;
1890 struct prefix_list *plist;
1891 int format;
1892
1893 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1894
paul68980082003-03-25 05:07:42 +00001895 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001896 plist = prefix_list_lookup (AFI_IP, argv[1]);
1897 if (strncmp (argv[2], "in", 2) == 0)
1898 {
1899 PREFIX_LIST_IN (area) = plist;
1900 if (PREFIX_NAME_IN (area))
1901 free (PREFIX_NAME_IN (area));
1902
1903 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001904 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001905 }
1906 else
1907 {
1908 PREFIX_LIST_OUT (area) = plist;
1909 if (PREFIX_NAME_OUT (area))
1910 free (PREFIX_NAME_OUT (area));
1911
1912 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001913 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001914 }
1915
1916 return CMD_SUCCESS;
1917}
1918
paula2c62832003-04-23 17:01:31 +00001919DEFUN (no_ospf_area_filter_list,
1920 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001921 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1922 NO_STR
1923 "OSPF area parameters\n"
1924 "OSPF area ID in IP address format\n"
1925 "OSPF area ID as a decimal value\n"
1926 "Filter networks between OSPF areas\n"
1927 "Filter prefixes between OSPF areas\n"
1928 "Name of an IP prefix-list\n"
1929 "Filter networks sent to this area\n"
1930 "Filter networks sent from this area\n")
1931{
paul68980082003-03-25 05:07:42 +00001932 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001933 struct ospf_area *area;
1934 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001935 int format;
1936
1937 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1938
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001939 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1940 return CMD_SUCCESS;
1941
paul718e3742002-12-13 20:15:29 +00001942 if (strncmp (argv[2], "in", 2) == 0)
1943 {
1944 if (PREFIX_NAME_IN (area))
1945 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1946 return CMD_SUCCESS;
1947
1948 PREFIX_LIST_IN (area) = NULL;
1949 if (PREFIX_NAME_IN (area))
1950 free (PREFIX_NAME_IN (area));
1951
1952 PREFIX_NAME_IN (area) = NULL;
1953
paul68980082003-03-25 05:07:42 +00001954 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001955 }
1956 else
1957 {
1958 if (PREFIX_NAME_OUT (area))
1959 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1960 return CMD_SUCCESS;
1961
1962 PREFIX_LIST_OUT (area) = NULL;
1963 if (PREFIX_NAME_OUT (area))
1964 free (PREFIX_NAME_OUT (area));
1965
1966 PREFIX_NAME_OUT (area) = NULL;
1967
paul68980082003-03-25 05:07:42 +00001968 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001969 }
1970
1971 return CMD_SUCCESS;
1972}
1973
David Lamparter6b0655a2014-06-04 06:53:35 +02001974
paula2c62832003-04-23 17:01:31 +00001975DEFUN (ospf_area_authentication_message_digest,
1976 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001977 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1978 "OSPF area parameters\n"
Christian Franke2b005152013-09-30 12:27:49 +00001979 "OSPF area ID in IP address format\n"
1980 "OSPF area ID as a decimal value\n"
paul718e3742002-12-13 20:15:29 +00001981 "Enable authentication\n"
1982 "Use message-digest authentication\n")
1983{
paul68980082003-03-25 05:07:42 +00001984 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001985 struct ospf_area *area;
1986 struct in_addr area_id;
1987 int format;
1988
1989 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1990
paul68980082003-03-25 05:07:42 +00001991 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001992 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1993
1994 return CMD_SUCCESS;
1995}
1996
paula2c62832003-04-23 17:01:31 +00001997DEFUN (ospf_area_authentication,
1998 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001999 "area (A.B.C.D|<0-4294967295>) authentication",
2000 "OSPF area parameters\n"
2001 "OSPF area ID in IP address format\n"
2002 "OSPF area ID as a decimal value\n"
2003 "Enable authentication\n")
2004{
paul68980082003-03-25 05:07:42 +00002005 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002006 struct ospf_area *area;
2007 struct in_addr area_id;
2008 int format;
2009
2010 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2011
paul68980082003-03-25 05:07:42 +00002012 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002013 area->auth_type = OSPF_AUTH_SIMPLE;
2014
2015 return CMD_SUCCESS;
2016}
2017
paula2c62832003-04-23 17:01:31 +00002018DEFUN (no_ospf_area_authentication,
2019 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002020 "no area (A.B.C.D|<0-4294967295>) authentication",
2021 NO_STR
2022 "OSPF area parameters\n"
2023 "OSPF area ID in IP address format\n"
2024 "OSPF area ID as a decimal value\n"
2025 "Enable authentication\n")
2026{
paul68980082003-03-25 05:07:42 +00002027 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002028 struct ospf_area *area;
2029 struct in_addr area_id;
2030 int format;
2031
2032 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2033
paul68980082003-03-25 05:07:42 +00002034 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002035 if (area == NULL)
2036 return CMD_SUCCESS;
2037
2038 area->auth_type = OSPF_AUTH_NULL;
2039
paul68980082003-03-25 05:07:42 +00002040 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002041
2042 return CMD_SUCCESS;
2043}
2044
David Lamparter6b0655a2014-06-04 06:53:35 +02002045
paul718e3742002-12-13 20:15:29 +00002046DEFUN (ospf_abr_type,
2047 ospf_abr_type_cmd,
2048 "ospf abr-type (cisco|ibm|shortcut|standard)",
2049 "OSPF specific commands\n"
2050 "Set OSPF ABR type\n"
2051 "Alternative ABR, cisco implementation\n"
2052 "Alternative ABR, IBM implementation\n"
2053 "Shortcut ABR\n"
2054 "Standard behavior (RFC2328)\n")
2055{
paul68980082003-03-25 05:07:42 +00002056 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002057 u_char abr_type = OSPF_ABR_UNKNOWN;
2058
2059 if (strncmp (argv[0], "c", 1) == 0)
2060 abr_type = OSPF_ABR_CISCO;
2061 else if (strncmp (argv[0], "i", 1) == 0)
2062 abr_type = OSPF_ABR_IBM;
2063 else if (strncmp (argv[0], "sh", 2) == 0)
2064 abr_type = OSPF_ABR_SHORTCUT;
2065 else if (strncmp (argv[0], "st", 2) == 0)
2066 abr_type = OSPF_ABR_STAND;
2067 else
2068 return CMD_WARNING;
2069
2070 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002071 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002072 {
paul68980082003-03-25 05:07:42 +00002073 ospf->abr_type = abr_type;
2074 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002075 }
2076
2077 return CMD_SUCCESS;
2078}
2079
2080DEFUN (no_ospf_abr_type,
2081 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002082 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002083 NO_STR
2084 "OSPF specific commands\n"
2085 "Set OSPF ABR type\n"
2086 "Alternative ABR, cisco implementation\n"
2087 "Alternative ABR, IBM implementation\n"
2088 "Shortcut ABR\n")
2089{
paul68980082003-03-25 05:07:42 +00002090 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002091 u_char abr_type = OSPF_ABR_UNKNOWN;
2092
2093 if (strncmp (argv[0], "c", 1) == 0)
2094 abr_type = OSPF_ABR_CISCO;
2095 else if (strncmp (argv[0], "i", 1) == 0)
2096 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002097 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002098 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002099 else if (strncmp (argv[0], "st", 2) == 0)
2100 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002101 else
2102 return CMD_WARNING;
2103
2104 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002105 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002106 {
pauld57834f2005-07-12 20:04:22 +00002107 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002108 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002109 }
2110
2111 return CMD_SUCCESS;
2112}
2113
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002114DEFUN (ospf_log_adjacency_changes,
2115 ospf_log_adjacency_changes_cmd,
2116 "log-adjacency-changes",
2117 "Log changes in adjacency state\n")
2118{
2119 struct ospf *ospf = vty->index;
2120
2121 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2122 return CMD_SUCCESS;
2123}
2124
2125DEFUN (ospf_log_adjacency_changes_detail,
2126 ospf_log_adjacency_changes_detail_cmd,
2127 "log-adjacency-changes detail",
2128 "Log changes in adjacency state\n"
2129 "Log all state changes\n")
2130{
2131 struct ospf *ospf = vty->index;
2132
2133 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2134 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2135 return CMD_SUCCESS;
2136}
2137
2138DEFUN (no_ospf_log_adjacency_changes,
2139 no_ospf_log_adjacency_changes_cmd,
2140 "no log-adjacency-changes",
2141 NO_STR
2142 "Log changes in adjacency state\n")
2143{
2144 struct ospf *ospf = vty->index;
2145
2146 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2147 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2148 return CMD_SUCCESS;
2149}
2150
2151DEFUN (no_ospf_log_adjacency_changes_detail,
2152 no_ospf_log_adjacency_changes_detail_cmd,
2153 "no log-adjacency-changes detail",
2154 NO_STR
2155 "Log changes in adjacency state\n"
2156 "Log all state changes\n")
2157{
2158 struct ospf *ospf = vty->index;
2159
2160 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2161 return CMD_SUCCESS;
2162}
2163
paul718e3742002-12-13 20:15:29 +00002164DEFUN (ospf_compatible_rfc1583,
2165 ospf_compatible_rfc1583_cmd,
2166 "compatible rfc1583",
2167 "OSPF compatibility list\n"
2168 "compatible with RFC 1583\n")
2169{
2170 struct ospf *ospf = vty->index;
2171
2172 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2173 {
2174 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002175 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002176 }
2177 return CMD_SUCCESS;
2178}
2179
2180DEFUN (no_ospf_compatible_rfc1583,
2181 no_ospf_compatible_rfc1583_cmd,
2182 "no compatible rfc1583",
2183 NO_STR
2184 "OSPF compatibility list\n"
2185 "compatible with RFC 1583\n")
2186{
2187 struct ospf *ospf = vty->index;
2188
2189 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2190 {
2191 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002192 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002193 }
2194 return CMD_SUCCESS;
2195}
2196
2197ALIAS (ospf_compatible_rfc1583,
2198 ospf_rfc1583_flag_cmd,
2199 "ospf rfc1583compatibility",
2200 "OSPF specific commands\n"
2201 "Enable the RFC1583Compatibility flag\n")
2202
2203ALIAS (no_ospf_compatible_rfc1583,
2204 no_ospf_rfc1583_flag_cmd,
2205 "no ospf rfc1583compatibility",
2206 NO_STR
2207 "OSPF specific commands\n"
2208 "Disable the RFC1583Compatibility flag\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002209
pauld24f6e22005-10-21 09:23:12 +00002210static int
2211ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2212 unsigned int hold,
2213 unsigned int max)
2214{
2215 struct ospf *ospf = vty->index;
2216
2217 ospf->spf_delay = delay;
2218 ospf->spf_holdtime = hold;
2219 ospf->spf_max_holdtime = max;
2220
2221 return CMD_SUCCESS;
2222}
paul718e3742002-12-13 20:15:29 +00002223
pauld24f6e22005-10-21 09:23:12 +00002224DEFUN (ospf_timers_throttle_spf,
2225 ospf_timers_throttle_spf_cmd,
2226 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2227 "Adjust routing timers\n"
2228 "Throttling adaptive timer\n"
2229 "OSPF SPF timers\n"
2230 "Delay (msec) from first change received till SPF calculation\n"
2231 "Initial hold time (msec) between consecutive SPF calculations\n"
2232 "Maximum hold time (msec)\n")
2233{
2234 unsigned int delay, hold, max;
2235
2236 if (argc != 3)
2237 {
2238 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2239 return CMD_WARNING;
2240 }
2241
2242 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2243 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2244 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2245
2246 return ospf_timers_spf_set (vty, delay, hold, max);
2247}
2248
2249DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002250 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002251 "timers spf <0-4294967295> <0-4294967295>",
2252 "Adjust routing timers\n"
2253 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002254 "Delay (s) between receiving a change to SPF calculation\n"
2255 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002256{
pauld24f6e22005-10-21 09:23:12 +00002257 unsigned int delay, hold;
2258
2259 if (argc != 2)
2260 {
2261 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2262 return CMD_WARNING;
2263 }
2264
paul4dadc292005-05-06 21:37:42 +00002265 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2266 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002267
2268 /* truncate down the second values if they're greater than 600000ms */
2269 if (delay > (600000 / 1000))
2270 delay = 600000;
2271 else if (delay == 0)
2272 /* 0s delay was probably specified because of lack of ms resolution */
2273 delay = OSPF_SPF_DELAY_DEFAULT;
2274 if (hold > (600000 / 1000))
2275 hold = 600000;
2276
2277 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002278}
2279
pauld24f6e22005-10-21 09:23:12 +00002280DEFUN (no_ospf_timers_throttle_spf,
2281 no_ospf_timers_throttle_spf_cmd,
2282 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002283 NO_STR
2284 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002285 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002286 "OSPF SPF timers\n")
2287{
pauld24f6e22005-10-21 09:23:12 +00002288 return ospf_timers_spf_set (vty,
2289 OSPF_SPF_DELAY_DEFAULT,
2290 OSPF_SPF_HOLDTIME_DEFAULT,
2291 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002292}
2293
pauld24f6e22005-10-21 09:23:12 +00002294ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2295 no_ospf_timers_spf_cmd,
2296 "no timers spf",
2297 NO_STR
2298 "Adjust routing timers\n"
2299 "OSPF SPF timers\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002300
paula2c62832003-04-23 17:01:31 +00002301DEFUN (ospf_neighbor,
2302 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002303 "neighbor A.B.C.D",
2304 NEIGHBOR_STR
2305 "Neighbor IP address\n")
2306{
2307 struct ospf *ospf = vty->index;
2308 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002309 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2310 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002311
2312 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2313
2314 if (argc > 1)
2315 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2316
2317 if (argc > 2)
2318 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2319
2320 ospf_nbr_nbma_set (ospf, nbr_addr);
2321 if (argc > 1)
2322 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2323 if (argc > 2)
Andrew Certain1a61ad12012-12-04 12:50:23 -08002324 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
paul718e3742002-12-13 20:15:29 +00002325
2326 return CMD_SUCCESS;
2327}
2328
paula2c62832003-04-23 17:01:31 +00002329ALIAS (ospf_neighbor,
2330 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002331 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2332 NEIGHBOR_STR
2333 "Neighbor IP address\n"
2334 "Neighbor Priority\n"
2335 "Priority\n"
2336 "Dead Neighbor Polling interval\n"
2337 "Seconds\n")
2338
paula2c62832003-04-23 17:01:31 +00002339ALIAS (ospf_neighbor,
2340 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002341 "neighbor A.B.C.D priority <0-255>",
2342 NEIGHBOR_STR
2343 "Neighbor IP address\n"
2344 "Neighbor Priority\n"
2345 "Seconds\n")
2346
paula2c62832003-04-23 17:01:31 +00002347DEFUN (ospf_neighbor_poll_interval,
2348 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002349 "neighbor A.B.C.D poll-interval <1-65535>",
2350 NEIGHBOR_STR
2351 "Neighbor IP address\n"
2352 "Dead Neighbor Polling interval\n"
2353 "Seconds\n")
2354{
2355 struct ospf *ospf = vty->index;
2356 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002357 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2358 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002359
2360 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2361
2362 if (argc > 1)
2363 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2364
2365 if (argc > 2)
2366 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2367
2368 ospf_nbr_nbma_set (ospf, nbr_addr);
2369 if (argc > 1)
2370 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2371 if (argc > 2)
2372 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2373
2374 return CMD_SUCCESS;
2375}
2376
paula2c62832003-04-23 17:01:31 +00002377ALIAS (ospf_neighbor_poll_interval,
2378 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002379 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2380 NEIGHBOR_STR
2381 "Neighbor address\n"
2382 "OSPF dead-router polling interval\n"
2383 "Seconds\n"
2384 "OSPF priority of non-broadcast neighbor\n"
2385 "Priority\n")
2386
paula2c62832003-04-23 17:01:31 +00002387DEFUN (no_ospf_neighbor,
2388 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002389 "no neighbor A.B.C.D",
2390 NO_STR
2391 NEIGHBOR_STR
2392 "Neighbor IP address\n")
2393{
2394 struct ospf *ospf = vty->index;
2395 struct in_addr nbr_addr;
paul718e3742002-12-13 20:15:29 +00002396
2397 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2398
Andrew Certain0798cee2012-12-04 13:43:42 -08002399 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
paul718e3742002-12-13 20:15:29 +00002400
2401 return CMD_SUCCESS;
2402}
2403
paula2c62832003-04-23 17:01:31 +00002404ALIAS (no_ospf_neighbor,
2405 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002406 "no neighbor A.B.C.D priority <0-255>",
2407 NO_STR
2408 NEIGHBOR_STR
2409 "Neighbor IP address\n"
2410 "Neighbor Priority\n"
2411 "Priority\n")
2412
paula2c62832003-04-23 17:01:31 +00002413ALIAS (no_ospf_neighbor,
2414 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002415 "no neighbor A.B.C.D poll-interval <1-65535>",
2416 NO_STR
2417 NEIGHBOR_STR
2418 "Neighbor IP address\n"
2419 "Dead Neighbor Polling interval\n"
2420 "Seconds\n")
2421
paula2c62832003-04-23 17:01:31 +00002422ALIAS (no_ospf_neighbor,
2423 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002424 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2425 NO_STR
2426 NEIGHBOR_STR
2427 "Neighbor IP address\n"
2428 "Neighbor Priority\n"
2429 "Priority\n"
2430 "Dead Neighbor Polling interval\n"
2431 "Seconds\n")
2432
David Lamparter6b0655a2014-06-04 06:53:35 +02002433
paula2c62832003-04-23 17:01:31 +00002434DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002435 "refresh timer <10-1800>",
2436 "Adjust refresh parameters\n"
2437 "Set refresh timer\n"
2438 "Timer value in seconds\n")
2439{
2440 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002441 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002442
2443 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2444 interval = (interval / 10) * 10;
2445
2446 ospf_timers_refresh_set (ospf, interval);
2447
2448 return CMD_SUCCESS;
2449}
2450
paula2c62832003-04-23 17:01:31 +00002451DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002452 "no refresh timer <10-1800>",
2453 "Adjust refresh parameters\n"
2454 "Unset refresh timer\n"
2455 "Timer value in seconds\n")
2456{
2457 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002458 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002459
2460 if (argc == 1)
2461 {
2462 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2463
2464 if (ospf->lsa_refresh_interval != interval ||
2465 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2466 return CMD_SUCCESS;
2467 }
2468
2469 ospf_timers_refresh_unset (ospf);
2470
2471 return CMD_SUCCESS;
2472}
2473
paula2c62832003-04-23 17:01:31 +00002474ALIAS (no_ospf_refresh_timer,
2475 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002476 "no refresh timer",
2477 "Adjust refresh parameters\n"
2478 "Unset refresh timer\n")
2479
paula2c62832003-04-23 17:01:31 +00002480DEFUN (ospf_auto_cost_reference_bandwidth,
2481 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002482 "auto-cost reference-bandwidth <1-4294967>",
2483 "Calculate OSPF interface cost according to bandwidth\n"
2484 "Use reference bandwidth method to assign OSPF cost\n"
2485 "The reference bandwidth in terms of Mbits per second\n")
2486{
paul68980082003-03-25 05:07:42 +00002487 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002488 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002489 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002490 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002491
2492 refbw = strtol (argv[0], NULL, 10);
2493 if (refbw < 1 || refbw > 4294967)
2494 {
2495 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2496 return CMD_WARNING;
2497 }
2498
2499 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002500 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002501 return CMD_SUCCESS;
2502
paul68980082003-03-25 05:07:42 +00002503 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002504 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2505 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002506
2507 return CMD_SUCCESS;
2508}
2509
paula2c62832003-04-23 17:01:31 +00002510DEFUN (no_ospf_auto_cost_reference_bandwidth,
2511 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002512 "no auto-cost reference-bandwidth",
2513 NO_STR
2514 "Calculate OSPF interface cost according to bandwidth\n"
2515 "Use reference bandwidth method to assign OSPF cost\n")
2516{
paul68980082003-03-25 05:07:42 +00002517 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002518 struct listnode *node, *nnode;
2519 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002520
paul68980082003-03-25 05:07:42 +00002521 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002522 return CMD_SUCCESS;
2523
paul68980082003-03-25 05:07:42 +00002524 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002525 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2526 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2527
paul1eb8ef22005-04-07 07:30:20 +00002528 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2529 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002530
2531 return CMD_SUCCESS;
2532}
2533
hassoeb1ce602004-10-08 08:17:22 +00002534const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002535{
2536 "Unknown",
2537 "Standard (RFC2328)",
2538 "Alternative IBM",
2539 "Alternative Cisco",
2540 "Alternative Shortcut"
2541};
2542
hassoeb1ce602004-10-08 08:17:22 +00002543const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002544{
2545 "Default",
2546 "Enabled",
2547 "Disabled"
2548};
2549
2550
David Lamparter6b0655a2014-06-04 06:53:35 +02002551
paul4dadc292005-05-06 21:37:42 +00002552static void
paul718e3742002-12-13 20:15:29 +00002553show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2554{
2555 /* Show Area ID. */
2556 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2557
2558 /* Show Area type/mode. */
2559 if (OSPF_IS_AREA_BACKBONE (area))
2560 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2561 else
2562 {
2563 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002564 vty_out (vty, " (Stub%s%s)",
2565 area->no_summary ? ", no summary" : "",
2566 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002567
paulb0a053b2003-06-22 09:04:47 +00002568 else if (area->external_routing == OSPF_AREA_NSSA)
2569 vty_out (vty, " (NSSA%s%s)",
2570 area->no_summary ? ", no summary" : "",
2571 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002572
2573 vty_out (vty, "%s", VTY_NEWLINE);
2574 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002575 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002576 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002577 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002578 }
2579
2580 /* Show number of interfaces. */
2581 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2582 "Active: %d%s", listcount (area->oiflist),
2583 area->act_ints, VTY_NEWLINE);
2584
paul718e3742002-12-13 20:15:29 +00002585 if (area->external_routing == OSPF_AREA_NSSA)
2586 {
2587 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 +00002588 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002589 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2590 VTY_NEWLINE);
2591 else if (area->NSSATranslatorState)
2592 {
2593 vty_out (vty, " We are an ABR and ");
2594 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2595 vty_out (vty, "the NSSA Elected Translator. %s",
2596 VTY_NEWLINE);
2597 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2598 vty_out (vty, "always an NSSA Translator. %s",
2599 VTY_NEWLINE);
2600 }
paul718e3742002-12-13 20:15:29 +00002601 else
paulb0a053b2003-06-22 09:04:47 +00002602 {
2603 vty_out (vty, " We are an ABR, but ");
2604 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2605 vty_out (vty, "not the NSSA Elected Translator. %s",
2606 VTY_NEWLINE);
2607 else
hassoc6b87812004-12-22 13:09:59 +00002608 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002609 VTY_NEWLINE);
2610 }
paul718e3742002-12-13 20:15:29 +00002611 }
paul88d6cf32005-10-29 12:50:09 +00002612 /* Stub-router state for this area */
2613 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2614 {
ajs649654a2005-11-16 20:17:52 +00002615 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002616 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2617 VTY_NEWLINE);
2618 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2619 vty_out (vty, " Administratively activated (indefinitely)%s",
2620 VTY_NEWLINE);
2621 if (area->t_stub_router)
2622 vty_out (vty, " Active from startup, %s remaining%s",
2623 ospf_timer_dump (area->t_stub_router, timebuf,
2624 sizeof(timebuf)), VTY_NEWLINE);
2625 }
2626
paul718e3742002-12-13 20:15:29 +00002627 /* Show number of fully adjacent neighbors. */
2628 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002629 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002630
2631 /* Show authentication type. */
2632 vty_out (vty, " Area has ");
2633 if (area->auth_type == OSPF_AUTH_NULL)
2634 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2635 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2636 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2637 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2638 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2639
2640 if (!OSPF_IS_AREA_BACKBONE (area))
2641 vty_out (vty, " Number of full virtual adjacencies going through"
2642 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2643
2644 /* Show SPF calculation times. */
2645 vty_out (vty, " SPF algorithm executed %d times%s",
2646 area->spf_calculation, VTY_NEWLINE);
2647
2648 /* Show number of LSA. */
2649 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002650 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2651 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2652 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2653 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2654 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2655 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2656 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2657 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2658 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2659 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2660 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2661 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2662 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2663 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2664 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2665#ifdef HAVE_OPAQUE_LSA
2666 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2667 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2668 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2669 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2670 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2671 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2672#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002673 vty_out (vty, "%s", VTY_NEWLINE);
2674}
2675
2676DEFUN (show_ip_ospf,
2677 show_ip_ospf_cmd,
2678 "show ip ospf",
2679 SHOW_STR
2680 IP_STR
2681 "OSPF information\n")
2682{
paul1eb8ef22005-04-07 07:30:20 +00002683 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002684 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002685 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002686 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002687 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002688
2689 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002690 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002691 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002692 {
2693 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2694 return CMD_SUCCESS;
2695 }
2696
2697 /* Show Router ID. */
2698 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002699 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002700 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002701
2702 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002703 if (ospf->t_deferred_shutdown)
2704 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2705 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002706 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002707 /* Show capability. */
2708 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2709 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2710 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002711 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002712 "enabled" : "disabled", VTY_NEWLINE);
2713#ifdef HAVE_OPAQUE_LSA
2714 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002715 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002716 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002717 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002718 " (origination blocked)" : "",
2719 VTY_NEWLINE);
2720#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002721
2722 /* Show stub-router configuration */
2723 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2724 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2725 {
2726 vty_out (vty, " Stub router advertisement is configured%s",
2727 VTY_NEWLINE);
2728 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2729 vty_out (vty, " Enabled for %us after start-up%s",
2730 ospf->stub_router_startup_time, VTY_NEWLINE);
2731 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2732 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2733 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2734 }
2735
paul718e3742002-12-13 20:15:29 +00002736 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002737 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2738 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2739 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2740 " Hold time multiplier is currently %d%s",
2741 ospf->spf_delay, VTY_NEWLINE,
2742 ospf->spf_holdtime, VTY_NEWLINE,
2743 ospf->spf_max_holdtime, VTY_NEWLINE,
2744 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002745 vty_out (vty, " SPF algorithm ");
2746 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2747 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002748 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002749 vty_out (vty, "last executed %s ago%s",
2750 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2751 VTY_NEWLINE);
2752 }
2753 else
2754 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002755 vty_out (vty, " SPF timer %s%s%s",
2756 (ospf->t_spf_calc ? "due in " : "is "),
2757 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2758 VTY_NEWLINE);
2759
paul718e3742002-12-13 20:15:29 +00002760 /* Show refresh parameters. */
2761 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002762 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002763
2764 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002765 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002766 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002767 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002768
paul68980082003-03-25 05:07:42 +00002769 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002770 vty_out (vty, " This router is an ASBR "
2771 "(injecting external routing information)%s", VTY_NEWLINE);
2772
2773 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002774 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2775 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2776 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2777#ifdef HAVE_OPAQUE_LSA
2778 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2779 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2780 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2781#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002782 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002783 vty_out (vty, " Number of areas attached to this router: %d%s",
2784 listcount (ospf->areas), VTY_NEWLINE);
2785
2786 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2787 {
2788 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2789 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2790 else
2791 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2792 }
2793
2794 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002795
2796 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002797 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2798 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002799
2800 return CMD_SUCCESS;
2801}
2802
David Lamparter6b0655a2014-06-04 06:53:35 +02002803
ajsfd651fa2005-03-29 16:08:16 +00002804static void
paul68980082003-03-25 05:07:42 +00002805show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2806 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002807{
ajsfd651fa2005-03-29 16:08:16 +00002808 int is_up;
paul718e3742002-12-13 20:15:29 +00002809 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002810 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002811
paul718e3742002-12-13 20:15:29 +00002812 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002813 vty_out (vty, "%s is %s%s", ifp->name,
2814 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002815 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2816 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2817 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002818
2819 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002820 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002821 {
2822 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2823 return;
2824 }
ajsfd651fa2005-03-29 16:08:16 +00002825 else if (!is_up)
2826 {
2827 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2828 VTY_NEWLINE);
2829 return;
2830 }
2831
paul718e3742002-12-13 20:15:29 +00002832 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2833 {
2834 struct ospf_interface *oi = rn->info;
2835
2836 if (oi == NULL)
2837 continue;
2838
2839 /* Show OSPF interface information. */
2840 vty_out (vty, " Internet Address %s/%d,",
2841 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2842
Paul Jakma9c27ef92006-05-04 07:32:57 +00002843 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2844 {
2845 struct in_addr *dest;
2846 const char *dstr;
2847
Andrew J. Schorre4529632006-12-12 19:18:21 +00002848 if (CONNECTED_PEER(oi->connected)
2849 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002850 dstr = "Peer";
2851 else
2852 dstr = "Broadcast";
2853
2854 /* For Vlinks, showing the peer address is probably more
2855 * informative than the local interface that is being used
2856 */
2857 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2858 dest = &oi->vl_data->peer_addr;
2859 else
2860 dest = &oi->connected->destination->u.prefix4;
2861
2862 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2863 }
hasso3fb9cd62004-10-19 19:44:43 +00002864
paul718e3742002-12-13 20:15:29 +00002865 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2866 VTY_NEWLINE);
2867
vincentba682532005-09-29 13:52:57 +00002868 vty_out (vty, " MTU mismatch detection:%s%s",
2869 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2870
paul718e3742002-12-13 20:15:29 +00002871 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002872 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002873 oi->output_cost, VTY_NEWLINE);
2874
2875 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2876 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2877 PRIORITY (oi), VTY_NEWLINE);
2878
2879 /* Show DR information. */
2880 if (DR (oi).s_addr == 0)
2881 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2882 else
2883 {
2884 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2885 if (nbr == NULL)
2886 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2887 else
2888 {
2889 vty_out (vty, " Designated Router (ID) %s,",
2890 inet_ntoa (nbr->router_id));
2891 vty_out (vty, " Interface Address %s%s",
2892 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2893 }
2894 }
2895
2896 /* Show BDR information. */
2897 if (BDR (oi).s_addr == 0)
2898 vty_out (vty, " No backup designated router on this network%s",
2899 VTY_NEWLINE);
2900 else
2901 {
2902 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2903 if (nbr == NULL)
2904 vty_out (vty, " No backup designated router on this network%s",
2905 VTY_NEWLINE);
2906 else
2907 {
2908 vty_out (vty, " Backup Designated Router (ID) %s,",
2909 inet_ntoa (nbr->router_id));
2910 vty_out (vty, " Interface Address %s%s",
2911 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2912 }
2913 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002914
2915 /* Next network-LSA sequence number we'll use, if we're elected DR */
2916 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2917 != OSPF_INITIAL_SEQUENCE_NUMBER)
2918 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2919 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2920
ajsba6454e2005-02-08 15:37:30 +00002921 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002922 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2923 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2924 {
2925 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2926 vty_out (vty, " OSPFAllRouters");
2927 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2928 vty_out (vty, " OSPFDesignatedRouters");
2929 }
2930 else
ajsba6454e2005-02-08 15:37:30 +00002931 vty_out (vty, " <None>");
2932 vty_out (vty, "%s", VTY_NEWLINE);
2933
paul718e3742002-12-13 20:15:29 +00002934 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002935 vty_out (vty, " Hello ");
2936 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2937 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2938 else
2939 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2940 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2941 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002942 OSPF_IF_PARAM (oi, v_wait),
2943 OSPF_IF_PARAM (oi, retransmit_interval),
2944 VTY_NEWLINE);
2945
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002946 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002947 {
ajs649654a2005-11-16 20:17:52 +00002948 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002949 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002950 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002951 VTY_NEWLINE);
2952 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002953 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002954 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2955
2956 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002957 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002958 VTY_NEWLINE);
2959 }
2960}
2961
2962DEFUN (show_ip_ospf_interface,
2963 show_ip_ospf_interface_cmd,
2964 "show ip ospf interface [INTERFACE]",
2965 SHOW_STR
2966 IP_STR
2967 "OSPF information\n"
2968 "Interface information\n"
2969 "Interface name\n")
2970{
2971 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002972 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002973 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002974
paul020709f2003-04-04 02:44:16 +00002975 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002976 if (ospf == NULL)
2977 {
2978 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2979 return CMD_SUCCESS;
2980 }
paul020709f2003-04-04 02:44:16 +00002981
paul718e3742002-12-13 20:15:29 +00002982 /* Show All Interfaces. */
2983 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002984 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2985 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002986 /* Interface name is specified. */
2987 else
2988 {
2989 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2990 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2991 else
paul68980082003-03-25 05:07:42 +00002992 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002993 }
2994
2995 return CMD_SUCCESS;
2996}
2997
paul4dadc292005-05-06 21:37:42 +00002998static void
pauld24f6e22005-10-21 09:23:12 +00002999show_ip_ospf_neighbour_header (struct vty *vty)
3000{
3001 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3002 VTY_NEWLINE,
3003 "Neighbor ID", "Pri", "State", "Dead Time",
3004 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3005 VTY_NEWLINE);
3006}
3007
3008static void
paul718e3742002-12-13 20:15:29 +00003009show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3010{
3011 struct route_node *rn;
3012 struct ospf_neighbor *nbr;
3013 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003014 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003015
3016 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3017 if ((nbr = rn->info))
3018 /* Do not show myself. */
3019 if (nbr != oi->nbr_self)
3020 /* Down state is not shown. */
3021 if (nbr->state != NSM_Down)
3022 {
3023 ospf_nbr_state_message (nbr, msgbuf, 16);
3024
3025 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003026 vty_out (vty, "%-15s %3d %-15s ",
3027 "-", nbr->priority,
3028 msgbuf);
3029 else
3030 vty_out (vty, "%-15s %3d %-15s ",
3031 inet_ntoa (nbr->router_id), nbr->priority,
3032 msgbuf);
3033
3034 vty_out (vty, "%9s ",
3035 ospf_timer_dump (nbr->t_inactivity, timebuf,
3036 sizeof(timebuf)));
3037
paul718e3742002-12-13 20:15:29 +00003038 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003039 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003040 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3041 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3042 VTY_NEWLINE);
3043 }
3044}
3045
3046DEFUN (show_ip_ospf_neighbor,
3047 show_ip_ospf_neighbor_cmd,
3048 "show ip ospf neighbor",
3049 SHOW_STR
3050 IP_STR
3051 "OSPF information\n"
3052 "Neighbor list\n")
3053{
paul020709f2003-04-04 02:44:16 +00003054 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003055 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003056 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003057
paul020709f2003-04-04 02:44:16 +00003058 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003059 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003060 {
3061 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3062 return CMD_SUCCESS;
3063 }
3064
pauld24f6e22005-10-21 09:23:12 +00003065 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003066
paul1eb8ef22005-04-07 07:30:20 +00003067 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3068 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003069
3070 return CMD_SUCCESS;
3071}
3072
3073DEFUN (show_ip_ospf_neighbor_all,
3074 show_ip_ospf_neighbor_all_cmd,
3075 "show ip ospf neighbor all",
3076 SHOW_STR
3077 IP_STR
3078 "OSPF information\n"
3079 "Neighbor list\n"
3080 "include down status neighbor\n")
3081{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003082 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003083 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003084 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003085
paul68980082003-03-25 05:07:42 +00003086 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003087 {
3088 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3089 return CMD_SUCCESS;
3090 }
pauld24f6e22005-10-21 09:23:12 +00003091
3092 show_ip_ospf_neighbour_header (vty);
3093
paul1eb8ef22005-04-07 07:30:20 +00003094 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003095 {
hasso52dc7ee2004-09-23 19:18:23 +00003096 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003097 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003098
3099 show_ip_ospf_neighbor_sub (vty, oi);
3100
3101 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003102 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003103 {
paul718e3742002-12-13 20:15:29 +00003104 if (nbr_nbma->nbr == NULL
3105 || nbr_nbma->nbr->state == NSM_Down)
3106 {
pauld24f6e22005-10-21 09:23:12 +00003107 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003108 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003109 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003110 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3111 0, 0, 0, VTY_NEWLINE);
3112 }
3113 }
3114 }
3115
3116 return CMD_SUCCESS;
3117}
3118
3119DEFUN (show_ip_ospf_neighbor_int,
3120 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003121 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003122 SHOW_STR
3123 IP_STR
3124 "OSPF information\n"
3125 "Neighbor list\n"
3126 "Interface name\n")
3127{
paul020709f2003-04-04 02:44:16 +00003128 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003129 struct interface *ifp;
3130 struct route_node *rn;
3131
3132 ifp = if_lookup_by_name (argv[0]);
3133 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003134 {
hassobb5b7552005-08-21 20:01:15 +00003135 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003136 return CMD_WARNING;
3137 }
3138
paul020709f2003-04-04 02:44:16 +00003139 ospf = ospf_lookup ();
3140 if (ospf == NULL)
3141 {
3142 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3143 return CMD_SUCCESS;
3144 }
pauld24f6e22005-10-21 09:23:12 +00003145
3146 show_ip_ospf_neighbour_header (vty);
3147
hassobb5b7552005-08-21 20:01:15 +00003148 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003149 {
hassobb5b7552005-08-21 20:01:15 +00003150 struct ospf_interface *oi = rn->info;
3151
3152 if (oi == NULL)
3153 continue;
3154
paul718e3742002-12-13 20:15:29 +00003155 show_ip_ospf_neighbor_sub (vty, oi);
3156 }
3157
3158 return CMD_SUCCESS;
3159}
3160
paul4dadc292005-05-06 21:37:42 +00003161static void
paul718e3742002-12-13 20:15:29 +00003162show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3163 struct ospf_nbr_nbma *nbr_nbma)
3164{
ajs649654a2005-11-16 20:17:52 +00003165 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003166
3167 /* Show neighbor ID. */
3168 vty_out (vty, " Neighbor %s,", "-");
3169
3170 /* Show interface address. */
3171 vty_out (vty, " interface address %s%s",
3172 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3173 /* Show Area ID. */
3174 vty_out (vty, " In the area %s via interface %s%s",
3175 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3176 /* Show neighbor priority and state. */
3177 vty_out (vty, " Neighbor priority is %d, State is %s,",
3178 nbr_nbma->priority, "Down");
3179 /* Show state changes. */
3180 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3181
3182 /* Show PollInterval */
3183 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3184
3185 /* Show poll-interval timer. */
3186 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003187 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3188 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003189
3190 /* Show poll-interval timer thread. */
3191 vty_out (vty, " Thread Poll Timer %s%s",
3192 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3193}
3194
paul4dadc292005-05-06 21:37:42 +00003195static void
paul718e3742002-12-13 20:15:29 +00003196show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3197 struct ospf_neighbor *nbr)
3198{
ajs649654a2005-11-16 20:17:52 +00003199 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003200
3201 /* Show neighbor ID. */
3202 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3203 vty_out (vty, " Neighbor %s,", "-");
3204 else
3205 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3206
3207 /* Show interface address. */
3208 vty_out (vty, " interface address %s%s",
3209 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3210 /* Show Area ID. */
3211 vty_out (vty, " In the area %s via interface %s%s",
3212 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3213 /* Show neighbor priority and state. */
3214 vty_out (vty, " Neighbor priority is %d, State is %s,",
3215 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3216 /* Show state changes. */
3217 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003218 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003219 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003220 struct timeval res
3221 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003222 vty_out (vty, " Most recent state change statistics:%s",
3223 VTY_NEWLINE);
3224 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003225 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003226 VTY_NEWLINE);
3227 }
3228 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3229 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003230 struct timeval res
3231 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003232 vty_out (vty, " Regressive change %s ago, due to %s%s",
3233 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3234 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003235 VTY_NEWLINE);
3236 }
paul718e3742002-12-13 20:15:29 +00003237 /* Show Designated Rotuer ID. */
3238 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3239 /* Show Backup Designated Rotuer ID. */
3240 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3241 /* Show options. */
3242 vty_out (vty, " Options %d %s%s", nbr->options,
3243 ospf_options_dump (nbr->options), VTY_NEWLINE);
3244 /* Show Router Dead interval timer. */
3245 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003246 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3247 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003248 /* Show Database Summary list. */
3249 vty_out (vty, " Database Summary List %d%s",
3250 ospf_db_summary_count (nbr), VTY_NEWLINE);
3251 /* Show Link State Request list. */
3252 vty_out (vty, " Link State Request List %ld%s",
3253 ospf_ls_request_count (nbr), VTY_NEWLINE);
3254 /* Show Link State Retransmission list. */
3255 vty_out (vty, " Link State Retransmission List %ld%s",
3256 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3257 /* Show inactivity timer thread. */
3258 vty_out (vty, " Thread Inactivity Timer %s%s",
3259 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3260 /* Show Database Description retransmission thread. */
3261 vty_out (vty, " Thread Database Description Retransmision %s%s",
3262 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3263 /* Show Link State Request Retransmission thread. */
3264 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3265 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3266 /* Show Link State Update Retransmission thread. */
3267 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3268 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3269}
3270
3271DEFUN (show_ip_ospf_neighbor_id,
3272 show_ip_ospf_neighbor_id_cmd,
3273 "show ip ospf neighbor A.B.C.D",
3274 SHOW_STR
3275 IP_STR
3276 "OSPF information\n"
3277 "Neighbor list\n"
3278 "Neighbor ID\n")
3279{
paul020709f2003-04-04 02:44:16 +00003280 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003281 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003282 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003283 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003284 struct in_addr router_id;
3285 int ret;
3286
3287 ret = inet_aton (argv[0], &router_id);
3288 if (!ret)
3289 {
3290 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3291 return CMD_WARNING;
3292 }
3293
paul020709f2003-04-04 02:44:16 +00003294 ospf = ospf_lookup ();
3295 if (ospf == NULL)
3296 {
3297 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3298 return CMD_SUCCESS;
3299 }
3300
paul1eb8ef22005-04-07 07:30:20 +00003301 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3302 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003303 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003304
paul718e3742002-12-13 20:15:29 +00003305 return CMD_SUCCESS;
3306}
3307
3308DEFUN (show_ip_ospf_neighbor_detail,
3309 show_ip_ospf_neighbor_detail_cmd,
3310 "show ip ospf neighbor detail",
3311 SHOW_STR
3312 IP_STR
3313 "OSPF information\n"
3314 "Neighbor list\n"
3315 "detail of all neighbors\n")
3316{
paul020709f2003-04-04 02:44:16 +00003317 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003318 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003319 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003320
paul020709f2003-04-04 02:44:16 +00003321 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003322 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003323 {
3324 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3325 return CMD_SUCCESS;
3326 }
paul718e3742002-12-13 20:15:29 +00003327
paul1eb8ef22005-04-07 07:30:20 +00003328 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003329 {
paul718e3742002-12-13 20:15:29 +00003330 struct route_node *rn;
3331 struct ospf_neighbor *nbr;
3332
3333 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3334 if ((nbr = rn->info))
3335 if (nbr != oi->nbr_self)
3336 if (nbr->state != NSM_Down)
3337 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3338 }
3339
3340 return CMD_SUCCESS;
3341}
3342
3343DEFUN (show_ip_ospf_neighbor_detail_all,
3344 show_ip_ospf_neighbor_detail_all_cmd,
3345 "show ip ospf neighbor detail all",
3346 SHOW_STR
3347 IP_STR
3348 "OSPF information\n"
3349 "Neighbor list\n"
3350 "detail of all neighbors\n"
3351 "include down status neighbor\n")
3352{
paul020709f2003-04-04 02:44:16 +00003353 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003354 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003355 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003356
paul020709f2003-04-04 02:44:16 +00003357 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003358 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003359 {
3360 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3361 return CMD_SUCCESS;
3362 }
paul718e3742002-12-13 20:15:29 +00003363
paul1eb8ef22005-04-07 07:30:20 +00003364 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003365 {
paul718e3742002-12-13 20:15:29 +00003366 struct route_node *rn;
3367 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003368 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003369
3370 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3371 if ((nbr = rn->info))
3372 if (nbr != oi->nbr_self)
3373 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3374 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3375
3376 if (oi->type == OSPF_IFTYPE_NBMA)
3377 {
hasso52dc7ee2004-09-23 19:18:23 +00003378 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003379
paul1eb8ef22005-04-07 07:30:20 +00003380 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3381 if (nbr_nbma->nbr == NULL
3382 || nbr_nbma->nbr->state == NSM_Down)
3383 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003384 }
3385 }
3386
3387 return CMD_SUCCESS;
3388}
3389
3390DEFUN (show_ip_ospf_neighbor_int_detail,
3391 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003392 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003393 SHOW_STR
3394 IP_STR
3395 "OSPF information\n"
3396 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003397 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003398 "detail of all neighbors")
3399{
paul020709f2003-04-04 02:44:16 +00003400 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003401 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003402 struct interface *ifp;
3403 struct route_node *rn, *nrn;
3404 struct ospf_neighbor *nbr;
3405
3406 ifp = if_lookup_by_name (argv[0]);
3407 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003408 {
hassobb5b7552005-08-21 20:01:15 +00003409 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003410 return CMD_WARNING;
3411 }
3412
paul020709f2003-04-04 02:44:16 +00003413 ospf = ospf_lookup ();
3414 if (ospf == NULL)
3415 {
3416 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3417 return CMD_SUCCESS;
3418 }
paul68980082003-03-25 05:07:42 +00003419
paul718e3742002-12-13 20:15:29 +00003420
hassobb5b7552005-08-21 20:01:15 +00003421 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3422 if ((oi = rn->info))
3423 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3424 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003425 if (nbr != oi->nbr_self)
3426 if (nbr->state != NSM_Down)
3427 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003428
3429 return CMD_SUCCESS;
3430}
3431
David Lamparter6b0655a2014-06-04 06:53:35 +02003432
paul718e3742002-12-13 20:15:29 +00003433/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003434static int
paul020709f2003-04-04 02:44:16 +00003435show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003436{
paul718e3742002-12-13 20:15:29 +00003437 struct router_lsa *rl;
3438 struct summary_lsa *sl;
3439 struct as_external_lsa *asel;
3440 struct prefix_ipv4 p;
3441
3442 if (lsa != NULL)
3443 /* If self option is set, check LSA self flag. */
3444 if (self == 0 || IS_LSA_SELF (lsa))
3445 {
3446 /* LSA common part show. */
3447 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3448 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3449 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3450 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3451 /* LSA specific part show. */
3452 switch (lsa->data->type)
3453 {
3454 case OSPF_ROUTER_LSA:
3455 rl = (struct router_lsa *) lsa->data;
3456 vty_out (vty, " %-d", ntohs (rl->links));
3457 break;
3458 case OSPF_SUMMARY_LSA:
3459 sl = (struct summary_lsa *) lsa->data;
3460
3461 p.family = AF_INET;
3462 p.prefix = sl->header.id;
3463 p.prefixlen = ip_masklen (sl->mask);
3464 apply_mask_ipv4 (&p);
3465
3466 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3467 break;
3468 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003469 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003470 asel = (struct as_external_lsa *) lsa->data;
3471
3472 p.family = AF_INET;
3473 p.prefix = asel->header.id;
3474 p.prefixlen = ip_masklen (asel->mask);
3475 apply_mask_ipv4 (&p);
3476
3477 vty_out (vty, " %s %s/%d [0x%lx]",
3478 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3479 inet_ntoa (p.prefix), p.prefixlen,
3480 (u_long)ntohl (asel->e[0].route_tag));
3481 break;
3482 case OSPF_NETWORK_LSA:
3483 case OSPF_ASBR_SUMMARY_LSA:
3484#ifdef HAVE_OPAQUE_LSA
3485 case OSPF_OPAQUE_LINK_LSA:
3486 case OSPF_OPAQUE_AREA_LSA:
3487 case OSPF_OPAQUE_AS_LSA:
3488#endif /* HAVE_OPAQUE_LSA */
3489 default:
3490 break;
3491 }
3492 vty_out (vty, VTY_NEWLINE);
3493 }
3494
3495 return 0;
3496}
3497
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003498static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003499{
3500 "unknown",
3501 "Router Link States",
3502 "Net Link States",
3503 "Summary Link States",
3504 "ASBR-Summary Link States",
3505 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003506 "Group Membership LSA",
3507 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003508#ifdef HAVE_OPAQUE_LSA
3509 "Type-8 LSA",
3510 "Link-Local Opaque-LSA",
3511 "Area-Local Opaque-LSA",
3512 "AS-external Opaque-LSA",
3513#endif /* HAVE_OPAQUE_LSA */
3514};
3515
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003516static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003517{
3518 "",
3519 "Link ID ADV Router Age Seq# CkSum Link count",
3520 "Link ID ADV Router Age Seq# CkSum",
3521 "Link ID ADV Router Age Seq# CkSum Route",
3522 "Link ID ADV Router Age Seq# CkSum",
3523 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003524 " --- header for Group Member ----",
3525 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003526#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003527 " --- type-8 ---",
3528 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3529 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3530 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3531#endif /* HAVE_OPAQUE_LSA */
3532};
3533
paul4dadc292005-05-06 21:37:42 +00003534static void
paul718e3742002-12-13 20:15:29 +00003535show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3536{
3537 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003538
paul718e3742002-12-13 20:15:29 +00003539 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003540 vty_out (vty, " Options: 0x%-2x : %s%s",
3541 lsa->data->options,
3542 ospf_options_dump(lsa->data->options),
3543 VTY_NEWLINE);
3544 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003545 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003546 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3547 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003548
3549 if (lsa->data->type == OSPF_ROUTER_LSA)
3550 {
3551 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3552
3553 if (rlsa->flags)
3554 vty_out (vty, " :%s%s%s%s",
3555 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3556 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3557 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3558 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3559
3560 vty_out (vty, "%s", VTY_NEWLINE);
3561 }
3562 vty_out (vty, " LS Type: %s%s",
3563 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3564 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3565 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3566 vty_out (vty, " Advertising Router: %s%s",
3567 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3568 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3569 VTY_NEWLINE);
3570 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3571 VTY_NEWLINE);
3572 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3573}
3574
hassoeb1ce602004-10-08 08:17:22 +00003575const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003576{
3577 "(null)",
3578 "another Router (point-to-point)",
3579 "a Transit Network",
3580 "Stub Network",
3581 "a Virtual Link",
3582};
3583
hassoeb1ce602004-10-08 08:17:22 +00003584const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003585{
3586 "(null)",
3587 "Neighboring Router ID",
3588 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003589 "Net",
paul718e3742002-12-13 20:15:29 +00003590 "Neighboring Router ID",
3591};
3592
hassoeb1ce602004-10-08 08:17:22 +00003593const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003594{
3595 "(null)",
3596 "Router Interface address",
3597 "Router Interface address",
3598 "Network Mask",
3599 "Router Interface address",
3600};
3601
3602/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003603static void
paul718e3742002-12-13 20:15:29 +00003604show_ip_ospf_database_router_links (struct vty *vty,
3605 struct router_lsa *rl)
3606{
3607 int len, i, type;
3608
3609 len = ntohs (rl->header.length) - 4;
3610 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3611 {
3612 type = rl->link[i].type;
3613
3614 vty_out (vty, " Link connected to: %s%s",
3615 link_type_desc[type], VTY_NEWLINE);
3616 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3617 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3618 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3619 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3620 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3621 vty_out (vty, " TOS 0 Metric: %d%s",
3622 ntohs (rl->link[i].metric), VTY_NEWLINE);
3623 vty_out (vty, "%s", VTY_NEWLINE);
3624 }
3625}
3626
3627/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003628static int
paul718e3742002-12-13 20:15:29 +00003629show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3630{
3631 if (lsa != NULL)
3632 {
3633 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3634
3635 show_ip_ospf_database_header (vty, lsa);
3636
3637 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3638 VTY_NEWLINE, VTY_NEWLINE);
3639
3640 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003641 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003642 }
3643
3644 return 0;
3645}
3646
3647/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003648static int
paul718e3742002-12-13 20:15:29 +00003649show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3650{
3651 int length, i;
3652
3653 if (lsa != NULL)
3654 {
3655 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3656
3657 show_ip_ospf_database_header (vty, lsa);
3658
3659 vty_out (vty, " Network Mask: /%d%s",
3660 ip_masklen (nl->mask), VTY_NEWLINE);
3661
3662 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3663
3664 for (i = 0; length > 0; i++, length -= 4)
3665 vty_out (vty, " Attached Router: %s%s",
3666 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3667
3668 vty_out (vty, "%s", VTY_NEWLINE);
3669 }
3670
3671 return 0;
3672}
3673
3674/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003675static int
paul718e3742002-12-13 20:15:29 +00003676show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3677{
3678 if (lsa != NULL)
3679 {
3680 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3681
3682 show_ip_ospf_database_header (vty, lsa);
3683
3684 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3685 VTY_NEWLINE);
3686 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3687 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003688 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003689 }
3690
3691 return 0;
3692}
3693
3694/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003695static int
paul718e3742002-12-13 20:15:29 +00003696show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3697{
3698 if (lsa != NULL)
3699 {
3700 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3701
3702 show_ip_ospf_database_header (vty, lsa);
3703
3704 vty_out (vty, " Network Mask: /%d%s",
3705 ip_masklen (sl->mask), VTY_NEWLINE);
3706 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3707 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003708 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003709 }
3710
3711 return 0;
3712}
3713
3714/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003715static int
paul718e3742002-12-13 20:15:29 +00003716show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3717{
3718 if (lsa != NULL)
3719 {
3720 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3721
3722 show_ip_ospf_database_header (vty, lsa);
3723
3724 vty_out (vty, " Network Mask: /%d%s",
3725 ip_masklen (al->mask), VTY_NEWLINE);
3726 vty_out (vty, " Metric Type: %s%s",
3727 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3728 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3729 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3730 vty_out (vty, " Metric: %d%s",
3731 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3732 vty_out (vty, " Forward Address: %s%s",
3733 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3734
3735 vty_out (vty, " External Route Tag: %lu%s%s",
3736 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3737 }
3738
3739 return 0;
3740}
3741
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003742#if 0
paul4dadc292005-05-06 21:37:42 +00003743static int
paul718e3742002-12-13 20:15:29 +00003744show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3745{
3746 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3747
3748 /* show_ip_ospf_database_header (vty, lsa); */
3749
ajs2a42e282004-12-08 18:43:03 +00003750 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003751 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003752 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003753 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3754 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003755 zlog_debug( " TOS: 0%s", "\n");
3756 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003757 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003758 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003759 inet_ntoa (al->e[0].fwd_addr), "\n");
3760
ajs2a42e282004-12-08 18:43:03 +00003761 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003762 ntohl (al->e[0].route_tag), "\n", "\n");
3763
3764 return 0;
3765}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003766#endif
paul718e3742002-12-13 20:15:29 +00003767
3768/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003769static int
paul718e3742002-12-13 20:15:29 +00003770show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3771{
3772 if (lsa != NULL)
3773 {
3774 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3775
3776 show_ip_ospf_database_header (vty, lsa);
3777
3778 vty_out (vty, " Network Mask: /%d%s",
3779 ip_masklen (al->mask), VTY_NEWLINE);
3780 vty_out (vty, " Metric Type: %s%s",
3781 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3782 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3783 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3784 vty_out (vty, " Metric: %d%s",
3785 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3786 vty_out (vty, " NSSA: Forward Address: %s%s",
3787 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3788
3789 vty_out (vty, " External Route Tag: %u%s%s",
3790 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3791 }
3792
3793 return 0;
3794}
3795
paul4dadc292005-05-06 21:37:42 +00003796static int
paul718e3742002-12-13 20:15:29 +00003797show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3798{
3799 return 0;
3800}
3801
3802#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003803static int
paul718e3742002-12-13 20:15:29 +00003804show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3805{
3806 if (lsa != NULL)
3807 {
3808 show_ip_ospf_database_header (vty, lsa);
3809 show_opaque_info_detail (vty, lsa);
3810
3811 vty_out (vty, "%s", VTY_NEWLINE);
3812 }
3813 return 0;
3814}
3815#endif /* HAVE_OPAQUE_LSA */
3816
3817int (*show_function[])(struct vty *, struct ospf_lsa *) =
3818{
3819 NULL,
3820 show_router_lsa_detail,
3821 show_network_lsa_detail,
3822 show_summary_lsa_detail,
3823 show_summary_asbr_lsa_detail,
3824 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003825 show_func_dummy,
3826 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003827#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003828 NULL, /* type-8 */
3829 show_opaque_lsa_detail,
3830 show_opaque_lsa_detail,
3831 show_opaque_lsa_detail,
3832#endif /* HAVE_OPAQUE_LSA */
3833};
3834
paul4dadc292005-05-06 21:37:42 +00003835static void
paul718e3742002-12-13 20:15:29 +00003836show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3837 struct in_addr *adv_router)
3838{
3839 memset (lp, 0, sizeof (struct prefix_ls));
3840 lp->family = 0;
3841 if (id == NULL)
3842 lp->prefixlen = 0;
3843 else if (adv_router == NULL)
3844 {
3845 lp->prefixlen = 32;
3846 lp->id = *id;
3847 }
3848 else
3849 {
3850 lp->prefixlen = 64;
3851 lp->id = *id;
3852 lp->adv_router = *adv_router;
3853 }
3854}
3855
paul4dadc292005-05-06 21:37:42 +00003856static void
paul718e3742002-12-13 20:15:29 +00003857show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3858 struct in_addr *id, struct in_addr *adv_router)
3859{
3860 struct prefix_ls lp;
3861 struct route_node *rn, *start;
3862 struct ospf_lsa *lsa;
3863
3864 show_lsa_prefix_set (vty, &lp, id, adv_router);
3865 start = route_node_get (rt, (struct prefix *) &lp);
3866 if (start)
3867 {
3868 route_lock_node (start);
3869 for (rn = start; rn; rn = route_next_until (rn, start))
3870 if ((lsa = rn->info))
3871 {
paul718e3742002-12-13 20:15:29 +00003872 if (show_function[lsa->data->type] != NULL)
3873 show_function[lsa->data->type] (vty, lsa);
3874 }
3875 route_unlock_node (start);
3876 }
3877}
3878
3879/* Show detail LSA information
3880 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003881static void
paul020709f2003-04-04 02:44:16 +00003882show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003883 struct in_addr *id, struct in_addr *adv_router)
3884{
hasso52dc7ee2004-09-23 19:18:23 +00003885 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003886 struct ospf_area *area;
3887
paul718e3742002-12-13 20:15:29 +00003888 switch (type)
3889 {
3890 case OSPF_AS_EXTERNAL_LSA:
3891#ifdef HAVE_OPAQUE_LSA
3892 case OSPF_OPAQUE_AS_LSA:
3893#endif /* HAVE_OPAQUE_LSA */
3894 vty_out (vty, " %s %s%s",
3895 show_database_desc[type],
3896 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003897 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003898 break;
3899 default:
paul1eb8ef22005-04-07 07:30:20 +00003900 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003901 {
paul718e3742002-12-13 20:15:29 +00003902 vty_out (vty, "%s %s (Area %s)%s%s",
3903 VTY_NEWLINE, show_database_desc[type],
3904 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3905 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3906 }
3907 break;
3908 }
3909}
3910
paul4dadc292005-05-06 21:37:42 +00003911static void
paul718e3742002-12-13 20:15:29 +00003912show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3913 struct in_addr *adv_router)
3914{
3915 struct route_node *rn;
3916 struct ospf_lsa *lsa;
3917
3918 for (rn = route_top (rt); rn; rn = route_next (rn))
3919 if ((lsa = rn->info))
3920 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3921 {
paul718e3742002-12-13 20:15:29 +00003922 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3923 continue;
paul718e3742002-12-13 20:15:29 +00003924 if (show_function[lsa->data->type] != NULL)
3925 show_function[lsa->data->type] (vty, lsa);
3926 }
3927}
3928
3929/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003930static void
paul020709f2003-04-04 02:44:16 +00003931show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003932 struct in_addr *adv_router)
3933{
hasso52dc7ee2004-09-23 19:18:23 +00003934 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003935 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003936
3937 switch (type)
3938 {
3939 case OSPF_AS_EXTERNAL_LSA:
3940#ifdef HAVE_OPAQUE_LSA
3941 case OSPF_OPAQUE_AS_LSA:
3942#endif /* HAVE_OPAQUE_LSA */
3943 vty_out (vty, " %s %s%s",
3944 show_database_desc[type],
3945 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003946 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003947 adv_router);
3948 break;
3949 default:
paul1eb8ef22005-04-07 07:30:20 +00003950 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003951 {
paul718e3742002-12-13 20:15:29 +00003952 vty_out (vty, "%s %s (Area %s)%s%s",
3953 VTY_NEWLINE, show_database_desc[type],
3954 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3955 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3956 adv_router);
3957 }
3958 break;
3959 }
3960}
3961
paul4dadc292005-05-06 21:37:42 +00003962static void
paul020709f2003-04-04 02:44:16 +00003963show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003964{
paul020709f2003-04-04 02:44:16 +00003965 struct ospf_lsa *lsa;
3966 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003967 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003968 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003969 int type;
3970
paul1eb8ef22005-04-07 07:30:20 +00003971 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003972 {
paul718e3742002-12-13 20:15:29 +00003973 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3974 {
3975 switch (type)
3976 {
3977 case OSPF_AS_EXTERNAL_LSA:
3978#ifdef HAVE_OPAQUE_LSA
3979 case OSPF_OPAQUE_AS_LSA:
3980#endif /* HAVE_OPAQUE_LSA */
3981 continue;
3982 default:
3983 break;
3984 }
3985 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3986 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3987 {
3988 vty_out (vty, " %s (Area %s)%s%s",
3989 show_database_desc[type],
3990 ospf_area_desc_string (area),
3991 VTY_NEWLINE, VTY_NEWLINE);
3992 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3993
paul020709f2003-04-04 02:44:16 +00003994 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3995 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003996
3997 vty_out (vty, "%s", VTY_NEWLINE);
3998 }
3999 }
4000 }
4001
4002 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4003 {
4004 switch (type)
4005 {
4006 case OSPF_AS_EXTERNAL_LSA:
4007#ifdef HAVE_OPAQUE_LSA
4008 case OSPF_OPAQUE_AS_LSA:
4009#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004010 break;
paul718e3742002-12-13 20:15:29 +00004011 default:
4012 continue;
4013 }
paul68980082003-03-25 05:07:42 +00004014 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4015 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004016 {
4017 vty_out (vty, " %s%s%s",
4018 show_database_desc[type],
4019 VTY_NEWLINE, VTY_NEWLINE);
4020 vty_out (vty, "%s%s", show_database_header[type],
4021 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004022
4023 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4024 show_lsa_summary (vty, lsa, self);
4025
paul718e3742002-12-13 20:15:29 +00004026 vty_out (vty, "%s", VTY_NEWLINE);
4027 }
4028 }
4029
4030 vty_out (vty, "%s", VTY_NEWLINE);
4031}
4032
paul4dadc292005-05-06 21:37:42 +00004033static void
paul020709f2003-04-04 02:44:16 +00004034show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004035{
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004036 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00004037
4038 vty_out (vty, "%s MaxAge Link States:%s%s",
4039 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4040
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004041 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
paul1eb8ef22005-04-07 07:30:20 +00004042 {
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004043 struct ospf_lsa *lsa;
4044
4045 if ((lsa = rn->info) != NULL)
4046 {
4047 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4048 vty_out (vty, "Link State ID: %s%s",
4049 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4050 vty_out (vty, "Advertising Router: %s%s",
4051 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4052 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4053 vty_out (vty, "%s", VTY_NEWLINE);
4054 }
paul1eb8ef22005-04-07 07:30:20 +00004055 }
paul718e3742002-12-13 20:15:29 +00004056}
4057
paul718e3742002-12-13 20:15:29 +00004058#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4059#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004060
4061#ifdef HAVE_OPAQUE_LSA
4062#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4063#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4064#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4065#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4066#else /* HAVE_OPAQUE_LSA */
4067#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4068#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4069#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4070#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4071#endif /* HAVE_OPAQUE_LSA */
4072
4073#define OSPF_LSA_TYPES_CMD_STR \
4074 "asbr-summary|external|network|router|summary" \
4075 OSPF_LSA_TYPE_NSSA_CMD_STR \
4076 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4077
4078#define OSPF_LSA_TYPES_DESC \
4079 "ASBR summary link states\n" \
4080 "External link states\n" \
4081 "Network link states\n" \
4082 "Router link states\n" \
4083 "Network summary link states\n" \
4084 OSPF_LSA_TYPE_NSSA_DESC \
4085 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4086 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4087 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4088
4089DEFUN (show_ip_ospf_database,
4090 show_ip_ospf_database_cmd,
4091 "show ip ospf database",
4092 SHOW_STR
4093 IP_STR
4094 "OSPF information\n"
4095 "Database summary\n")
4096{
paul020709f2003-04-04 02:44:16 +00004097 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004098 int type, ret;
4099 struct in_addr id, adv_router;
4100
paul020709f2003-04-04 02:44:16 +00004101 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004102 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004103 {
4104 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4105 return CMD_SUCCESS;
4106 }
paul718e3742002-12-13 20:15:29 +00004107
4108 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004109 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004110
4111 /* Show all LSA. */
4112 if (argc == 0)
4113 {
paul020709f2003-04-04 02:44:16 +00004114 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004115 return CMD_SUCCESS;
4116 }
4117
4118 /* Set database type to show. */
4119 if (strncmp (argv[0], "r", 1) == 0)
4120 type = OSPF_ROUTER_LSA;
4121 else if (strncmp (argv[0], "ne", 2) == 0)
4122 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004123 else if (strncmp (argv[0], "ns", 2) == 0)
4124 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004125 else if (strncmp (argv[0], "su", 2) == 0)
4126 type = OSPF_SUMMARY_LSA;
4127 else if (strncmp (argv[0], "a", 1) == 0)
4128 type = OSPF_ASBR_SUMMARY_LSA;
4129 else if (strncmp (argv[0], "e", 1) == 0)
4130 type = OSPF_AS_EXTERNAL_LSA;
4131 else if (strncmp (argv[0], "se", 2) == 0)
4132 {
paul020709f2003-04-04 02:44:16 +00004133 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004134 return CMD_SUCCESS;
4135 }
4136 else if (strncmp (argv[0], "m", 1) == 0)
4137 {
paul020709f2003-04-04 02:44:16 +00004138 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004139 return CMD_SUCCESS;
4140 }
4141#ifdef HAVE_OPAQUE_LSA
4142 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4143 type = OSPF_OPAQUE_LINK_LSA;
4144 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4145 type = OSPF_OPAQUE_AREA_LSA;
4146 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4147 type = OSPF_OPAQUE_AS_LSA;
4148#endif /* HAVE_OPAQUE_LSA */
4149 else
4150 return CMD_WARNING;
4151
4152 /* `show ip ospf database LSA'. */
4153 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004154 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004155 else if (argc >= 2)
4156 {
4157 ret = inet_aton (argv[1], &id);
4158 if (!ret)
4159 return CMD_WARNING;
4160
4161 /* `show ip ospf database LSA ID'. */
4162 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004163 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004164 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4165 else if (argc == 3)
4166 {
4167 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004168 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004169 else
4170 {
4171 ret = inet_aton (argv[2], &adv_router);
4172 if (!ret)
4173 return CMD_WARNING;
4174 }
paul020709f2003-04-04 02:44:16 +00004175 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004176 }
4177 }
4178
4179 return CMD_SUCCESS;
4180}
4181
4182ALIAS (show_ip_ospf_database,
4183 show_ip_ospf_database_type_cmd,
4184 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4185 SHOW_STR
4186 IP_STR
4187 "OSPF information\n"
4188 "Database summary\n"
4189 OSPF_LSA_TYPES_DESC
4190 "LSAs in MaxAge list\n"
4191 "Self-originated link states\n")
4192
4193ALIAS (show_ip_ospf_database,
4194 show_ip_ospf_database_type_id_cmd,
4195 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4196 SHOW_STR
4197 IP_STR
4198 "OSPF information\n"
4199 "Database summary\n"
4200 OSPF_LSA_TYPES_DESC
4201 "Link State ID (as an IP address)\n")
4202
4203ALIAS (show_ip_ospf_database,
4204 show_ip_ospf_database_type_id_adv_router_cmd,
4205 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4206 SHOW_STR
4207 IP_STR
4208 "OSPF information\n"
4209 "Database summary\n"
4210 OSPF_LSA_TYPES_DESC
4211 "Link State ID (as an IP address)\n"
4212 "Advertising Router link states\n"
4213 "Advertising Router (as an IP address)\n")
4214
4215ALIAS (show_ip_ospf_database,
4216 show_ip_ospf_database_type_id_self_cmd,
4217 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4218 SHOW_STR
4219 IP_STR
4220 "OSPF information\n"
4221 "Database summary\n"
4222 OSPF_LSA_TYPES_DESC
4223 "Link State ID (as an IP address)\n"
4224 "Self-originated link states\n"
4225 "\n")
4226
4227DEFUN (show_ip_ospf_database_type_adv_router,
4228 show_ip_ospf_database_type_adv_router_cmd,
4229 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4230 SHOW_STR
4231 IP_STR
4232 "OSPF information\n"
4233 "Database summary\n"
4234 OSPF_LSA_TYPES_DESC
4235 "Advertising Router link states\n"
4236 "Advertising Router (as an IP address)\n")
4237{
paul020709f2003-04-04 02:44:16 +00004238 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004239 int type, ret;
4240 struct in_addr adv_router;
4241
paul020709f2003-04-04 02:44:16 +00004242 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004243 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004244 {
4245 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4246 return CMD_SUCCESS;
4247 }
paul718e3742002-12-13 20:15:29 +00004248
4249 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004250 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004251
4252 if (argc != 2)
4253 return CMD_WARNING;
4254
4255 /* Set database type to show. */
4256 if (strncmp (argv[0], "r", 1) == 0)
4257 type = OSPF_ROUTER_LSA;
4258 else if (strncmp (argv[0], "ne", 2) == 0)
4259 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004260 else if (strncmp (argv[0], "ns", 2) == 0)
4261 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004262 else if (strncmp (argv[0], "s", 1) == 0)
4263 type = OSPF_SUMMARY_LSA;
4264 else if (strncmp (argv[0], "a", 1) == 0)
4265 type = OSPF_ASBR_SUMMARY_LSA;
4266 else if (strncmp (argv[0], "e", 1) == 0)
4267 type = OSPF_AS_EXTERNAL_LSA;
4268#ifdef HAVE_OPAQUE_LSA
4269 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4270 type = OSPF_OPAQUE_LINK_LSA;
4271 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4272 type = OSPF_OPAQUE_AREA_LSA;
4273 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4274 type = OSPF_OPAQUE_AS_LSA;
4275#endif /* HAVE_OPAQUE_LSA */
4276 else
4277 return CMD_WARNING;
4278
4279 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4280 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004281 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004282 else
4283 {
4284 ret = inet_aton (argv[1], &adv_router);
4285 if (!ret)
4286 return CMD_WARNING;
4287 }
4288
paul020709f2003-04-04 02:44:16 +00004289 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004290
4291 return CMD_SUCCESS;
4292}
4293
4294ALIAS (show_ip_ospf_database_type_adv_router,
4295 show_ip_ospf_database_type_self_cmd,
4296 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4297 SHOW_STR
4298 IP_STR
4299 "OSPF information\n"
4300 "Database summary\n"
4301 OSPF_LSA_TYPES_DESC
4302 "Self-originated link states\n")
4303
David Lamparter6b0655a2014-06-04 06:53:35 +02004304
paul718e3742002-12-13 20:15:29 +00004305DEFUN (ip_ospf_authentication_args,
4306 ip_ospf_authentication_args_addr_cmd,
4307 "ip ospf authentication (null|message-digest) A.B.C.D",
4308 "IP Information\n"
4309 "OSPF interface commands\n"
4310 "Enable authentication on this interface\n"
4311 "Use null authentication\n"
4312 "Use message-digest authentication\n"
4313 "Address of interface")
4314{
4315 struct interface *ifp;
4316 struct in_addr addr;
4317 int ret;
4318 struct ospf_if_params *params;
4319
4320 ifp = vty->index;
4321 params = IF_DEF_PARAMS (ifp);
4322
4323 if (argc == 2)
4324 {
4325 ret = inet_aton(argv[1], &addr);
4326 if (!ret)
4327 {
4328 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4329 VTY_NEWLINE);
4330 return CMD_WARNING;
4331 }
4332
4333 params = ospf_get_if_params (ifp, addr);
4334 ospf_if_update_params (ifp, addr);
4335 }
4336
4337 /* Handle null authentication */
4338 if ( argv[0][0] == 'n' )
4339 {
4340 SET_IF_PARAM (params, auth_type);
4341 params->auth_type = OSPF_AUTH_NULL;
4342 return CMD_SUCCESS;
4343 }
4344
4345 /* Handle message-digest authentication */
4346 if ( argv[0][0] == 'm' )
4347 {
4348 SET_IF_PARAM (params, auth_type);
4349 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4350 return CMD_SUCCESS;
4351 }
4352
4353 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4354 return CMD_WARNING;
4355}
4356
4357ALIAS (ip_ospf_authentication_args,
4358 ip_ospf_authentication_args_cmd,
4359 "ip ospf authentication (null|message-digest)",
4360 "IP Information\n"
4361 "OSPF interface commands\n"
4362 "Enable authentication on this interface\n"
4363 "Use null authentication\n"
4364 "Use message-digest authentication\n")
4365
4366DEFUN (ip_ospf_authentication,
4367 ip_ospf_authentication_addr_cmd,
4368 "ip ospf authentication A.B.C.D",
4369 "IP Information\n"
4370 "OSPF interface commands\n"
4371 "Enable authentication on this interface\n"
4372 "Address of interface")
4373{
4374 struct interface *ifp;
4375 struct in_addr addr;
4376 int ret;
4377 struct ospf_if_params *params;
4378
4379 ifp = vty->index;
4380 params = IF_DEF_PARAMS (ifp);
4381
4382 if (argc == 1)
4383 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004384 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004385 if (!ret)
4386 {
4387 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4388 VTY_NEWLINE);
4389 return CMD_WARNING;
4390 }
4391
4392 params = ospf_get_if_params (ifp, addr);
4393 ospf_if_update_params (ifp, addr);
4394 }
4395
4396 SET_IF_PARAM (params, auth_type);
4397 params->auth_type = OSPF_AUTH_SIMPLE;
4398
4399 return CMD_SUCCESS;
4400}
4401
4402ALIAS (ip_ospf_authentication,
4403 ip_ospf_authentication_cmd,
4404 "ip ospf authentication",
4405 "IP Information\n"
4406 "OSPF interface commands\n"
4407 "Enable authentication on this interface\n")
4408
4409DEFUN (no_ip_ospf_authentication,
4410 no_ip_ospf_authentication_addr_cmd,
4411 "no ip ospf authentication A.B.C.D",
4412 NO_STR
4413 "IP Information\n"
4414 "OSPF interface commands\n"
4415 "Enable authentication on this interface\n"
4416 "Address of interface")
4417{
4418 struct interface *ifp;
4419 struct in_addr addr;
4420 int ret;
4421 struct ospf_if_params *params;
4422
4423 ifp = vty->index;
4424 params = IF_DEF_PARAMS (ifp);
4425
4426 if (argc == 1)
4427 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004428 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004429 if (!ret)
4430 {
4431 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4432 VTY_NEWLINE);
4433 return CMD_WARNING;
4434 }
4435
4436 params = ospf_lookup_if_params (ifp, addr);
4437 if (params == NULL)
4438 return CMD_SUCCESS;
4439 }
4440
4441 params->auth_type = OSPF_AUTH_NOTSET;
4442 UNSET_IF_PARAM (params, auth_type);
4443
4444 if (params != IF_DEF_PARAMS (ifp))
4445 {
4446 ospf_free_if_params (ifp, addr);
4447 ospf_if_update_params (ifp, addr);
4448 }
4449
4450 return CMD_SUCCESS;
4451}
4452
4453ALIAS (no_ip_ospf_authentication,
4454 no_ip_ospf_authentication_cmd,
4455 "no ip ospf authentication",
4456 NO_STR
4457 "IP Information\n"
4458 "OSPF interface commands\n"
4459 "Enable authentication on this interface\n")
4460
4461DEFUN (ip_ospf_authentication_key,
4462 ip_ospf_authentication_key_addr_cmd,
4463 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4464 "IP Information\n"
4465 "OSPF interface commands\n"
4466 "Authentication password (key)\n"
4467 "The OSPF password (key)\n"
4468 "Address of interface")
4469{
4470 struct interface *ifp;
4471 struct in_addr addr;
4472 int ret;
4473 struct ospf_if_params *params;
4474
4475 ifp = vty->index;
4476 params = IF_DEF_PARAMS (ifp);
4477
4478 if (argc == 2)
4479 {
4480 ret = inet_aton(argv[1], &addr);
4481 if (!ret)
4482 {
4483 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4484 VTY_NEWLINE);
4485 return CMD_WARNING;
4486 }
4487
4488 params = ospf_get_if_params (ifp, addr);
4489 ospf_if_update_params (ifp, addr);
4490 }
4491
4492
4493 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004494 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004495 SET_IF_PARAM (params, auth_simple);
4496
4497 return CMD_SUCCESS;
4498}
4499
4500ALIAS (ip_ospf_authentication_key,
4501 ip_ospf_authentication_key_cmd,
4502 "ip ospf authentication-key AUTH_KEY",
4503 "IP Information\n"
4504 "OSPF interface commands\n"
4505 "Authentication password (key)\n"
4506 "The OSPF password (key)")
4507
4508ALIAS (ip_ospf_authentication_key,
4509 ospf_authentication_key_cmd,
4510 "ospf authentication-key AUTH_KEY",
4511 "OSPF interface commands\n"
4512 "Authentication password (key)\n"
4513 "The OSPF password (key)")
4514
4515DEFUN (no_ip_ospf_authentication_key,
4516 no_ip_ospf_authentication_key_addr_cmd,
4517 "no ip ospf authentication-key A.B.C.D",
4518 NO_STR
4519 "IP Information\n"
4520 "OSPF interface commands\n"
4521 "Authentication password (key)\n"
4522 "Address of interface")
4523{
4524 struct interface *ifp;
4525 struct in_addr addr;
4526 int ret;
4527 struct ospf_if_params *params;
4528
4529 ifp = vty->index;
4530 params = IF_DEF_PARAMS (ifp);
4531
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004532 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004533 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004534 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004535 if (!ret)
4536 {
4537 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4538 VTY_NEWLINE);
4539 return CMD_WARNING;
4540 }
4541
4542 params = ospf_lookup_if_params (ifp, addr);
4543 if (params == NULL)
4544 return CMD_SUCCESS;
4545 }
4546
4547 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4548 UNSET_IF_PARAM (params, auth_simple);
4549
4550 if (params != IF_DEF_PARAMS (ifp))
4551 {
4552 ospf_free_if_params (ifp, addr);
4553 ospf_if_update_params (ifp, addr);
4554 }
4555
4556 return CMD_SUCCESS;
4557}
4558
4559ALIAS (no_ip_ospf_authentication_key,
4560 no_ip_ospf_authentication_key_cmd,
4561 "no ip ospf authentication-key",
4562 NO_STR
4563 "IP Information\n"
4564 "OSPF interface commands\n"
4565 "Authentication password (key)\n")
4566
4567ALIAS (no_ip_ospf_authentication_key,
4568 no_ospf_authentication_key_cmd,
4569 "no ospf authentication-key",
4570 NO_STR
4571 "OSPF interface commands\n"
4572 "Authentication password (key)\n")
4573
4574DEFUN (ip_ospf_message_digest_key,
4575 ip_ospf_message_digest_key_addr_cmd,
4576 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4577 "IP Information\n"
4578 "OSPF interface commands\n"
4579 "Message digest authentication password (key)\n"
4580 "Key ID\n"
4581 "Use MD5 algorithm\n"
4582 "The OSPF password (key)"
4583 "Address of interface")
4584{
4585 struct interface *ifp;
4586 struct crypt_key *ck;
4587 u_char key_id;
4588 struct in_addr addr;
4589 int ret;
4590 struct ospf_if_params *params;
4591
4592 ifp = vty->index;
4593 params = IF_DEF_PARAMS (ifp);
4594
4595 if (argc == 3)
4596 {
4597 ret = inet_aton(argv[2], &addr);
4598 if (!ret)
4599 {
4600 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4601 VTY_NEWLINE);
4602 return CMD_WARNING;
4603 }
4604
4605 params = ospf_get_if_params (ifp, addr);
4606 ospf_if_update_params (ifp, addr);
4607 }
4608
4609 key_id = strtol (argv[0], NULL, 10);
4610 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4611 {
4612 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4613 return CMD_WARNING;
4614 }
4615
4616 ck = ospf_crypt_key_new ();
4617 ck->key_id = (u_char) key_id;
4618 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004619 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004620
4621 ospf_crypt_key_add (params->auth_crypt, ck);
4622 SET_IF_PARAM (params, auth_crypt);
4623
4624 return CMD_SUCCESS;
4625}
4626
4627ALIAS (ip_ospf_message_digest_key,
4628 ip_ospf_message_digest_key_cmd,
4629 "ip ospf message-digest-key <1-255> md5 KEY",
4630 "IP Information\n"
4631 "OSPF interface commands\n"
4632 "Message digest authentication password (key)\n"
4633 "Key ID\n"
4634 "Use MD5 algorithm\n"
4635 "The OSPF password (key)")
4636
4637ALIAS (ip_ospf_message_digest_key,
4638 ospf_message_digest_key_cmd,
4639 "ospf message-digest-key <1-255> md5 KEY",
4640 "OSPF interface commands\n"
4641 "Message digest authentication password (key)\n"
4642 "Key ID\n"
4643 "Use MD5 algorithm\n"
4644 "The OSPF password (key)")
4645
4646DEFUN (no_ip_ospf_message_digest_key,
4647 no_ip_ospf_message_digest_key_addr_cmd,
4648 "no ip ospf message-digest-key <1-255> A.B.C.D",
4649 NO_STR
4650 "IP Information\n"
4651 "OSPF interface commands\n"
4652 "Message digest authentication password (key)\n"
4653 "Key ID\n"
4654 "Address of interface")
4655{
4656 struct interface *ifp;
4657 struct crypt_key *ck;
4658 int key_id;
4659 struct in_addr addr;
4660 int ret;
4661 struct ospf_if_params *params;
4662
4663 ifp = vty->index;
4664 params = IF_DEF_PARAMS (ifp);
4665
4666 if (argc == 2)
4667 {
4668 ret = inet_aton(argv[1], &addr);
4669 if (!ret)
4670 {
4671 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4672 VTY_NEWLINE);
4673 return CMD_WARNING;
4674 }
4675
4676 params = ospf_lookup_if_params (ifp, addr);
4677 if (params == NULL)
4678 return CMD_SUCCESS;
4679 }
4680
4681 key_id = strtol (argv[0], NULL, 10);
4682 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4683 if (ck == NULL)
4684 {
4685 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4686 return CMD_WARNING;
4687 }
4688
4689 ospf_crypt_key_delete (params->auth_crypt, key_id);
4690
4691 if (params != IF_DEF_PARAMS (ifp))
4692 {
4693 ospf_free_if_params (ifp, addr);
4694 ospf_if_update_params (ifp, addr);
4695 }
4696
4697 return CMD_SUCCESS;
4698}
4699
4700ALIAS (no_ip_ospf_message_digest_key,
4701 no_ip_ospf_message_digest_key_cmd,
4702 "no ip ospf message-digest-key <1-255>",
4703 NO_STR
4704 "IP Information\n"
4705 "OSPF interface commands\n"
4706 "Message digest authentication password (key)\n"
4707 "Key ID\n")
4708
4709ALIAS (no_ip_ospf_message_digest_key,
4710 no_ospf_message_digest_key_cmd,
4711 "no ospf message-digest-key <1-255>",
4712 NO_STR
4713 "OSPF interface commands\n"
4714 "Message digest authentication password (key)\n"
4715 "Key ID\n")
4716
4717DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004718 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004719 "ip ospf cost <1-65535> A.B.C.D",
4720 "IP Information\n"
4721 "OSPF interface commands\n"
4722 "Interface cost\n"
4723 "Cost\n"
4724 "Address of interface")
4725{
4726 struct interface *ifp = vty->index;
4727 u_int32_t cost;
4728 struct in_addr addr;
4729 int ret;
4730 struct ospf_if_params *params;
4731
4732 params = IF_DEF_PARAMS (ifp);
4733
4734 cost = strtol (argv[0], NULL, 10);
4735
4736 /* cost range is <1-65535>. */
4737 if (cost < 1 || cost > 65535)
4738 {
4739 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4740 return CMD_WARNING;
4741 }
4742
4743 if (argc == 2)
4744 {
4745 ret = inet_aton(argv[1], &addr);
4746 if (!ret)
4747 {
4748 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4749 VTY_NEWLINE);
4750 return CMD_WARNING;
4751 }
4752
4753 params = ospf_get_if_params (ifp, addr);
4754 ospf_if_update_params (ifp, addr);
4755 }
4756
4757 SET_IF_PARAM (params, output_cost_cmd);
4758 params->output_cost_cmd = cost;
4759
4760 ospf_if_recalculate_output_cost (ifp);
4761
4762 return CMD_SUCCESS;
4763}
4764
4765ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004766 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004767 "ip ospf cost <1-65535>",
4768 "IP Information\n"
4769 "OSPF interface commands\n"
4770 "Interface cost\n"
4771 "Cost")
4772
4773ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004774 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004775 "ospf cost <1-65535>",
4776 "OSPF interface commands\n"
4777 "Interface cost\n"
4778 "Cost")
4779
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004780ALIAS (ip_ospf_cost,
4781 ospf_cost_u32_inet4_cmd,
4782 "ospf cost <1-65535> A.B.C.D",
4783 "OSPF interface commands\n"
4784 "Interface cost\n"
4785 "Cost\n"
4786 "Address of interface")
4787
paul718e3742002-12-13 20:15:29 +00004788DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004789 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004790 "no ip ospf cost A.B.C.D",
4791 NO_STR
4792 "IP Information\n"
4793 "OSPF interface commands\n"
4794 "Interface cost\n"
4795 "Address of interface")
4796{
4797 struct interface *ifp = vty->index;
4798 struct in_addr addr;
4799 int ret;
4800 struct ospf_if_params *params;
4801
4802 ifp = vty->index;
4803 params = IF_DEF_PARAMS (ifp);
4804
4805 if (argc == 1)
4806 {
4807 ret = inet_aton(argv[0], &addr);
4808 if (!ret)
4809 {
4810 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4811 VTY_NEWLINE);
4812 return CMD_WARNING;
4813 }
4814
4815 params = ospf_lookup_if_params (ifp, addr);
4816 if (params == NULL)
4817 return CMD_SUCCESS;
4818 }
4819
4820 UNSET_IF_PARAM (params, output_cost_cmd);
4821
4822 if (params != IF_DEF_PARAMS (ifp))
4823 {
4824 ospf_free_if_params (ifp, addr);
4825 ospf_if_update_params (ifp, addr);
4826 }
4827
4828 ospf_if_recalculate_output_cost (ifp);
4829
4830 return CMD_SUCCESS;
4831}
4832
4833ALIAS (no_ip_ospf_cost,
4834 no_ip_ospf_cost_cmd,
4835 "no ip ospf cost",
4836 NO_STR
4837 "IP Information\n"
4838 "OSPF interface commands\n"
4839 "Interface cost\n")
4840
4841ALIAS (no_ip_ospf_cost,
4842 no_ospf_cost_cmd,
4843 "no ospf cost",
4844 NO_STR
4845 "OSPF interface commands\n"
4846 "Interface cost\n")
4847
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004848ALIAS (no_ip_ospf_cost,
4849 no_ospf_cost_inet4_cmd,
4850 "no ospf cost A.B.C.D",
4851 NO_STR
4852 "OSPF interface commands\n"
4853 "Interface cost\n"
4854 "Address of interface")
4855
Denis Ovsienko827341b2009-09-28 19:34:59 +04004856DEFUN (no_ip_ospf_cost2,
4857 no_ip_ospf_cost_u32_cmd,
4858 "no ip ospf cost <1-65535>",
4859 NO_STR
4860 "IP Information\n"
4861 "OSPF interface commands\n"
4862 "Interface cost\n"
4863 "Cost")
4864{
4865 struct interface *ifp = vty->index;
4866 struct in_addr addr;
4867 u_int32_t cost;
4868 int ret;
4869 struct ospf_if_params *params;
4870
4871 ifp = vty->index;
4872 params = IF_DEF_PARAMS (ifp);
4873
4874 /* According to the semantics we are mimicking "no ip ospf cost N" is
4875 * always treated as "no ip ospf cost" regardless of the actual value
4876 * of N already configured for the interface. Thus the first argument
4877 * is always checked to be a number, but is ignored after that.
4878 */
4879 cost = strtol (argv[0], NULL, 10);
4880 if (cost < 1 || cost > 65535)
4881 {
4882 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4883 return CMD_WARNING;
4884 }
4885
4886 if (argc == 2)
4887 {
4888 ret = inet_aton(argv[1], &addr);
4889 if (!ret)
4890 {
4891 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4892 VTY_NEWLINE);
4893 return CMD_WARNING;
4894 }
4895
4896 params = ospf_lookup_if_params (ifp, addr);
4897 if (params == NULL)
4898 return CMD_SUCCESS;
4899 }
4900
4901 UNSET_IF_PARAM (params, output_cost_cmd);
4902
4903 if (params != IF_DEF_PARAMS (ifp))
4904 {
4905 ospf_free_if_params (ifp, addr);
4906 ospf_if_update_params (ifp, addr);
4907 }
4908
4909 ospf_if_recalculate_output_cost (ifp);
4910
4911 return CMD_SUCCESS;
4912}
4913
4914ALIAS (no_ip_ospf_cost2,
4915 no_ospf_cost_u32_cmd,
4916 "no ospf cost <1-65535>",
4917 NO_STR
4918 "OSPF interface commands\n"
4919 "Interface cost\n"
4920 "Cost")
4921
4922ALIAS (no_ip_ospf_cost2,
4923 no_ip_ospf_cost_u32_inet4_cmd,
4924 "no ip ospf cost <1-65535> A.B.C.D",
4925 NO_STR
4926 "IP Information\n"
4927 "OSPF interface commands\n"
4928 "Interface cost\n"
4929 "Cost\n"
4930 "Address of interface")
4931
4932ALIAS (no_ip_ospf_cost2,
4933 no_ospf_cost_u32_inet4_cmd,
4934 "no ospf cost <1-65535> A.B.C.D",
4935 NO_STR
4936 "OSPF interface commands\n"
4937 "Interface cost\n"
4938 "Cost\n"
4939 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004940
paul4dadc292005-05-06 21:37:42 +00004941static void
paul718e3742002-12-13 20:15:29 +00004942ospf_nbr_timer_update (struct ospf_interface *oi)
4943{
4944 struct route_node *rn;
4945 struct ospf_neighbor *nbr;
4946
4947 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4948 if ((nbr = rn->info))
4949 {
4950 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4951 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4952 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4953 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4954 }
4955}
4956
paulf9ad9372005-10-21 00:45:17 +00004957static int
4958ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4959 const char *nbr_str,
4960 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004961{
4962 struct interface *ifp = vty->index;
4963 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004964 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004965 struct in_addr addr;
4966 int ret;
4967 struct ospf_if_params *params;
4968 struct ospf_interface *oi;
4969 struct route_node *rn;
4970
4971 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004972
4973 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004974 {
paulf9ad9372005-10-21 00:45:17 +00004975 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004976 if (!ret)
4977 {
4978 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4979 VTY_NEWLINE);
4980 return CMD_WARNING;
4981 }
4982
4983 params = ospf_get_if_params (ifp, addr);
4984 ospf_if_update_params (ifp, addr);
4985 }
4986
paulf9ad9372005-10-21 00:45:17 +00004987 if (interval_str)
4988 {
4989 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4990 1, 65535);
4991
4992 /* reset fast_hello too, just to be sure */
4993 UNSET_IF_PARAM (params, fast_hello);
4994 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4995 }
4996 else if (fast_hello_str)
4997 {
4998 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4999 1, 10);
5000 /* 1s dead-interval with sub-second hellos desired */
5001 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5002 SET_IF_PARAM (params, fast_hello);
5003 params->fast_hello = hellomult;
5004 }
5005 else
5006 {
5007 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5008 VTY_NEWLINE);
5009 return CMD_WARNING;
5010 }
5011
paul718e3742002-12-13 20:15:29 +00005012 SET_IF_PARAM (params, v_wait);
5013 params->v_wait = seconds;
5014
5015 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005016 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005017 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005018 struct ospf *ospf;
5019 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005020 {
5021 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5022 if (oi)
5023 ospf_nbr_timer_update (oi);
5024 }
paul718e3742002-12-13 20:15:29 +00005025 }
5026 else
5027 {
5028 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5029 if ((oi = rn->info))
5030 ospf_nbr_timer_update (oi);
5031 }
5032
5033 return CMD_SUCCESS;
5034}
5035
paulf9ad9372005-10-21 00:45:17 +00005036
5037DEFUN (ip_ospf_dead_interval,
5038 ip_ospf_dead_interval_addr_cmd,
5039 "ip ospf dead-interval <1-65535> A.B.C.D",
5040 "IP Information\n"
5041 "OSPF interface commands\n"
5042 "Interval after which a neighbor is declared dead\n"
5043 "Seconds\n"
5044 "Address of interface\n")
5045{
5046 if (argc == 2)
5047 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5048 else
5049 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5050}
5051
paul718e3742002-12-13 20:15:29 +00005052ALIAS (ip_ospf_dead_interval,
5053 ip_ospf_dead_interval_cmd,
5054 "ip ospf dead-interval <1-65535>",
5055 "IP Information\n"
5056 "OSPF interface commands\n"
5057 "Interval after which a neighbor is declared dead\n"
5058 "Seconds\n")
5059
5060ALIAS (ip_ospf_dead_interval,
5061 ospf_dead_interval_cmd,
5062 "ospf dead-interval <1-65535>",
5063 "OSPF interface commands\n"
5064 "Interval after which a neighbor is declared dead\n"
5065 "Seconds\n")
5066
paulf9ad9372005-10-21 00:45:17 +00005067DEFUN (ip_ospf_dead_interval_minimal,
5068 ip_ospf_dead_interval_minimal_addr_cmd,
5069 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5070 "IP Information\n"
5071 "OSPF interface commands\n"
5072 "Interval after which a neighbor is declared dead\n"
5073 "Minimal 1s dead-interval with fast sub-second hellos\n"
5074 "Hello multiplier factor\n"
5075 "Number of Hellos to send each second\n"
5076 "Address of interface\n")
5077{
5078 if (argc == 2)
5079 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5080 else
5081 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5082}
5083
5084ALIAS (ip_ospf_dead_interval_minimal,
5085 ip_ospf_dead_interval_minimal_cmd,
5086 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5087 "IP Information\n"
5088 "OSPF interface commands\n"
5089 "Interval after which a neighbor is declared dead\n"
5090 "Minimal 1s dead-interval with fast sub-second hellos\n"
5091 "Hello multiplier factor\n"
5092 "Number of Hellos to send each second\n")
5093
paul718e3742002-12-13 20:15:29 +00005094DEFUN (no_ip_ospf_dead_interval,
5095 no_ip_ospf_dead_interval_addr_cmd,
5096 "no ip ospf dead-interval A.B.C.D",
5097 NO_STR
5098 "IP Information\n"
5099 "OSPF interface commands\n"
5100 "Interval after which a neighbor is declared dead\n"
5101 "Address of interface")
5102{
5103 struct interface *ifp = vty->index;
5104 struct in_addr addr;
5105 int ret;
5106 struct ospf_if_params *params;
5107 struct ospf_interface *oi;
5108 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005109
paul718e3742002-12-13 20:15:29 +00005110 ifp = vty->index;
5111 params = IF_DEF_PARAMS (ifp);
5112
5113 if (argc == 1)
5114 {
5115 ret = inet_aton(argv[0], &addr);
5116 if (!ret)
5117 {
5118 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5119 VTY_NEWLINE);
5120 return CMD_WARNING;
5121 }
5122
5123 params = ospf_lookup_if_params (ifp, addr);
5124 if (params == NULL)
5125 return CMD_SUCCESS;
5126 }
5127
5128 UNSET_IF_PARAM (params, v_wait);
5129 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005130
5131 UNSET_IF_PARAM (params, fast_hello);
5132 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5133
paul718e3742002-12-13 20:15:29 +00005134 if (params != IF_DEF_PARAMS (ifp))
5135 {
5136 ospf_free_if_params (ifp, addr);
5137 ospf_if_update_params (ifp, addr);
5138 }
5139
5140 /* Update timer values in neighbor structure. */
5141 if (argc == 1)
5142 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005143 struct ospf *ospf;
5144
5145 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005146 {
5147 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5148 if (oi)
5149 ospf_nbr_timer_update (oi);
5150 }
paul718e3742002-12-13 20:15:29 +00005151 }
5152 else
5153 {
5154 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5155 if ((oi = rn->info))
5156 ospf_nbr_timer_update (oi);
5157 }
5158
5159 return CMD_SUCCESS;
5160}
5161
5162ALIAS (no_ip_ospf_dead_interval,
5163 no_ip_ospf_dead_interval_cmd,
5164 "no ip ospf dead-interval",
5165 NO_STR
5166 "IP Information\n"
5167 "OSPF interface commands\n"
5168 "Interval after which a neighbor is declared dead\n")
5169
5170ALIAS (no_ip_ospf_dead_interval,
5171 no_ospf_dead_interval_cmd,
5172 "no ospf dead-interval",
5173 NO_STR
5174 "OSPF interface commands\n"
5175 "Interval after which a neighbor is declared dead\n")
5176
5177DEFUN (ip_ospf_hello_interval,
5178 ip_ospf_hello_interval_addr_cmd,
5179 "ip ospf hello-interval <1-65535> A.B.C.D",
5180 "IP Information\n"
5181 "OSPF interface commands\n"
5182 "Time between HELLO packets\n"
5183 "Seconds\n"
5184 "Address of interface")
5185{
5186 struct interface *ifp = vty->index;
5187 u_int32_t seconds;
5188 struct in_addr addr;
5189 int ret;
5190 struct ospf_if_params *params;
5191
5192 params = IF_DEF_PARAMS (ifp);
5193
5194 seconds = strtol (argv[0], NULL, 10);
5195
5196 /* HelloInterval range is <1-65535>. */
5197 if (seconds < 1 || seconds > 65535)
5198 {
5199 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5200 return CMD_WARNING;
5201 }
5202
5203 if (argc == 2)
5204 {
5205 ret = inet_aton(argv[1], &addr);
5206 if (!ret)
5207 {
5208 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5209 VTY_NEWLINE);
5210 return CMD_WARNING;
5211 }
5212
5213 params = ospf_get_if_params (ifp, addr);
5214 ospf_if_update_params (ifp, addr);
5215 }
5216
paulf9ad9372005-10-21 00:45:17 +00005217 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005218 params->v_hello = seconds;
5219
5220 return CMD_SUCCESS;
5221}
5222
5223ALIAS (ip_ospf_hello_interval,
5224 ip_ospf_hello_interval_cmd,
5225 "ip ospf hello-interval <1-65535>",
5226 "IP Information\n"
5227 "OSPF interface commands\n"
5228 "Time between HELLO packets\n"
5229 "Seconds\n")
5230
5231ALIAS (ip_ospf_hello_interval,
5232 ospf_hello_interval_cmd,
5233 "ospf hello-interval <1-65535>",
5234 "OSPF interface commands\n"
5235 "Time between HELLO packets\n"
5236 "Seconds\n")
5237
5238DEFUN (no_ip_ospf_hello_interval,
5239 no_ip_ospf_hello_interval_addr_cmd,
5240 "no ip ospf hello-interval A.B.C.D",
5241 NO_STR
5242 "IP Information\n"
5243 "OSPF interface commands\n"
5244 "Time between HELLO packets\n"
5245 "Address of interface")
5246{
5247 struct interface *ifp = vty->index;
5248 struct in_addr addr;
5249 int ret;
5250 struct ospf_if_params *params;
5251
5252 ifp = vty->index;
5253 params = IF_DEF_PARAMS (ifp);
5254
5255 if (argc == 1)
5256 {
5257 ret = inet_aton(argv[0], &addr);
5258 if (!ret)
5259 {
5260 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5261 VTY_NEWLINE);
5262 return CMD_WARNING;
5263 }
5264
5265 params = ospf_lookup_if_params (ifp, addr);
5266 if (params == NULL)
5267 return CMD_SUCCESS;
5268 }
5269
5270 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005271 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005272
5273 if (params != IF_DEF_PARAMS (ifp))
5274 {
5275 ospf_free_if_params (ifp, addr);
5276 ospf_if_update_params (ifp, addr);
5277 }
5278
5279 return CMD_SUCCESS;
5280}
5281
5282ALIAS (no_ip_ospf_hello_interval,
5283 no_ip_ospf_hello_interval_cmd,
5284 "no ip ospf hello-interval",
5285 NO_STR
5286 "IP Information\n"
5287 "OSPF interface commands\n"
5288 "Time between HELLO packets\n")
5289
5290ALIAS (no_ip_ospf_hello_interval,
5291 no_ospf_hello_interval_cmd,
5292 "no ospf hello-interval",
5293 NO_STR
5294 "OSPF interface commands\n"
5295 "Time between HELLO packets\n")
5296
5297DEFUN (ip_ospf_network,
5298 ip_ospf_network_cmd,
5299 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5300 "IP Information\n"
5301 "OSPF interface commands\n"
5302 "Network type\n"
5303 "Specify OSPF broadcast multi-access network\n"
5304 "Specify OSPF NBMA network\n"
5305 "Specify OSPF point-to-multipoint network\n"
5306 "Specify OSPF point-to-point network\n")
5307{
5308 struct interface *ifp = vty->index;
5309 int old_type = IF_DEF_PARAMS (ifp)->type;
5310 struct route_node *rn;
Christian Franke4b4bda92013-07-11 07:56:29 +00005311
5312 if (old_type == OSPF_IFTYPE_LOOPBACK)
5313 {
5314 vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
5315 return CMD_WARNING;
5316 }
5317
paul718e3742002-12-13 20:15:29 +00005318 if (strncmp (argv[0], "b", 1) == 0)
5319 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5320 else if (strncmp (argv[0], "n", 1) == 0)
5321 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5322 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5323 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5324 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5325 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5326
5327 if (IF_DEF_PARAMS (ifp)->type == old_type)
5328 return CMD_SUCCESS;
5329
5330 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5331
5332 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5333 {
5334 struct ospf_interface *oi = rn->info;
5335
5336 if (!oi)
5337 continue;
5338
5339 oi->type = IF_DEF_PARAMS (ifp)->type;
5340
5341 if (oi->state > ISM_Down)
5342 {
5343 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5344 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5345 }
5346 }
5347
5348 return CMD_SUCCESS;
5349}
5350
5351ALIAS (ip_ospf_network,
5352 ospf_network_cmd,
5353 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5354 "OSPF interface commands\n"
5355 "Network type\n"
5356 "Specify OSPF broadcast multi-access network\n"
5357 "Specify OSPF NBMA network\n"
5358 "Specify OSPF point-to-multipoint network\n"
5359 "Specify OSPF point-to-point network\n")
5360
5361DEFUN (no_ip_ospf_network,
5362 no_ip_ospf_network_cmd,
5363 "no ip ospf network",
5364 NO_STR
5365 "IP Information\n"
5366 "OSPF interface commands\n"
5367 "Network type\n")
5368{
5369 struct interface *ifp = vty->index;
5370 int old_type = IF_DEF_PARAMS (ifp)->type;
5371 struct route_node *rn;
5372
ajsbc18d612004-12-15 15:07:19 +00005373 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005374
5375 if (IF_DEF_PARAMS (ifp)->type == old_type)
5376 return CMD_SUCCESS;
5377
5378 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5379 {
5380 struct ospf_interface *oi = rn->info;
5381
5382 if (!oi)
5383 continue;
5384
5385 oi->type = IF_DEF_PARAMS (ifp)->type;
5386
5387 if (oi->state > ISM_Down)
5388 {
5389 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5390 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5391 }
5392 }
5393
5394 return CMD_SUCCESS;
5395}
5396
5397ALIAS (no_ip_ospf_network,
5398 no_ospf_network_cmd,
5399 "no ospf network",
5400 NO_STR
5401 "OSPF interface commands\n"
5402 "Network type\n")
5403
5404DEFUN (ip_ospf_priority,
5405 ip_ospf_priority_addr_cmd,
5406 "ip ospf priority <0-255> A.B.C.D",
5407 "IP Information\n"
5408 "OSPF interface commands\n"
5409 "Router priority\n"
5410 "Priority\n"
5411 "Address of interface")
5412{
5413 struct interface *ifp = vty->index;
Andrew Certain0798cee2012-12-04 13:43:42 -08005414 long priority;
paul718e3742002-12-13 20:15:29 +00005415 struct route_node *rn;
5416 struct in_addr addr;
5417 int ret;
5418 struct ospf_if_params *params;
5419
5420 params = IF_DEF_PARAMS (ifp);
5421
5422 priority = strtol (argv[0], NULL, 10);
5423
5424 /* Router Priority range is <0-255>. */
5425 if (priority < 0 || priority > 255)
5426 {
5427 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5428 return CMD_WARNING;
5429 }
5430
5431 if (argc == 2)
5432 {
5433 ret = inet_aton(argv[1], &addr);
5434 if (!ret)
5435 {
5436 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5437 VTY_NEWLINE);
5438 return CMD_WARNING;
5439 }
5440
5441 params = ospf_get_if_params (ifp, addr);
5442 ospf_if_update_params (ifp, addr);
5443 }
5444
5445 SET_IF_PARAM (params, priority);
5446 params->priority = priority;
5447
5448 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5449 {
5450 struct ospf_interface *oi = rn->info;
5451
5452 if (!oi)
5453 continue;
5454
5455
5456 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5457 {
5458 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5459 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5460 }
5461 }
5462
5463 return CMD_SUCCESS;
5464}
5465
5466ALIAS (ip_ospf_priority,
5467 ip_ospf_priority_cmd,
5468 "ip ospf priority <0-255>",
5469 "IP Information\n"
5470 "OSPF interface commands\n"
5471 "Router priority\n"
5472 "Priority\n")
5473
5474ALIAS (ip_ospf_priority,
5475 ospf_priority_cmd,
5476 "ospf priority <0-255>",
5477 "OSPF interface commands\n"
5478 "Router priority\n"
5479 "Priority\n")
5480
5481DEFUN (no_ip_ospf_priority,
5482 no_ip_ospf_priority_addr_cmd,
5483 "no ip ospf priority A.B.C.D",
5484 NO_STR
5485 "IP Information\n"
5486 "OSPF interface commands\n"
5487 "Router priority\n"
5488 "Address of interface")
5489{
5490 struct interface *ifp = vty->index;
5491 struct route_node *rn;
5492 struct in_addr addr;
5493 int ret;
5494 struct ospf_if_params *params;
5495
5496 ifp = vty->index;
5497 params = IF_DEF_PARAMS (ifp);
5498
5499 if (argc == 1)
5500 {
5501 ret = inet_aton(argv[0], &addr);
5502 if (!ret)
5503 {
5504 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5505 VTY_NEWLINE);
5506 return CMD_WARNING;
5507 }
5508
5509 params = ospf_lookup_if_params (ifp, addr);
5510 if (params == NULL)
5511 return CMD_SUCCESS;
5512 }
5513
5514 UNSET_IF_PARAM (params, priority);
5515 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5516
5517 if (params != IF_DEF_PARAMS (ifp))
5518 {
5519 ospf_free_if_params (ifp, addr);
5520 ospf_if_update_params (ifp, addr);
5521 }
5522
5523 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5524 {
5525 struct ospf_interface *oi = rn->info;
5526
5527 if (!oi)
5528 continue;
5529
5530
5531 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5532 {
5533 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5534 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5535 }
5536 }
5537
5538 return CMD_SUCCESS;
5539}
5540
5541ALIAS (no_ip_ospf_priority,
5542 no_ip_ospf_priority_cmd,
5543 "no ip ospf priority",
5544 NO_STR
5545 "IP Information\n"
5546 "OSPF interface commands\n"
5547 "Router priority\n")
5548
5549ALIAS (no_ip_ospf_priority,
5550 no_ospf_priority_cmd,
5551 "no ospf priority",
5552 NO_STR
5553 "OSPF interface commands\n"
5554 "Router priority\n")
5555
5556DEFUN (ip_ospf_retransmit_interval,
5557 ip_ospf_retransmit_interval_addr_cmd,
5558 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5559 "IP Information\n"
5560 "OSPF interface commands\n"
5561 "Time between retransmitting lost link state advertisements\n"
5562 "Seconds\n"
5563 "Address of interface")
5564{
5565 struct interface *ifp = vty->index;
5566 u_int32_t seconds;
5567 struct in_addr addr;
5568 int ret;
5569 struct ospf_if_params *params;
5570
5571 params = IF_DEF_PARAMS (ifp);
5572 seconds = strtol (argv[0], NULL, 10);
5573
5574 /* Retransmit Interval range is <3-65535>. */
5575 if (seconds < 3 || seconds > 65535)
5576 {
5577 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5578 return CMD_WARNING;
5579 }
5580
5581
5582 if (argc == 2)
5583 {
5584 ret = inet_aton(argv[1], &addr);
5585 if (!ret)
5586 {
5587 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5588 VTY_NEWLINE);
5589 return CMD_WARNING;
5590 }
5591
5592 params = ospf_get_if_params (ifp, addr);
5593 ospf_if_update_params (ifp, addr);
5594 }
5595
5596 SET_IF_PARAM (params, retransmit_interval);
5597 params->retransmit_interval = seconds;
5598
5599 return CMD_SUCCESS;
5600}
5601
5602ALIAS (ip_ospf_retransmit_interval,
5603 ip_ospf_retransmit_interval_cmd,
5604 "ip ospf retransmit-interval <3-65535>",
5605 "IP Information\n"
5606 "OSPF interface commands\n"
5607 "Time between retransmitting lost link state advertisements\n"
5608 "Seconds\n")
5609
5610ALIAS (ip_ospf_retransmit_interval,
5611 ospf_retransmit_interval_cmd,
5612 "ospf retransmit-interval <3-65535>",
5613 "OSPF interface commands\n"
5614 "Time between retransmitting lost link state advertisements\n"
5615 "Seconds\n")
5616
5617DEFUN (no_ip_ospf_retransmit_interval,
5618 no_ip_ospf_retransmit_interval_addr_cmd,
5619 "no ip ospf retransmit-interval A.B.C.D",
5620 NO_STR
5621 "IP Information\n"
5622 "OSPF interface commands\n"
5623 "Time between retransmitting lost link state advertisements\n"
5624 "Address of interface")
5625{
5626 struct interface *ifp = vty->index;
5627 struct in_addr addr;
5628 int ret;
5629 struct ospf_if_params *params;
5630
5631 ifp = vty->index;
5632 params = IF_DEF_PARAMS (ifp);
5633
5634 if (argc == 1)
5635 {
5636 ret = inet_aton(argv[0], &addr);
5637 if (!ret)
5638 {
5639 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5640 VTY_NEWLINE);
5641 return CMD_WARNING;
5642 }
5643
5644 params = ospf_lookup_if_params (ifp, addr);
5645 if (params == NULL)
5646 return CMD_SUCCESS;
5647 }
5648
5649 UNSET_IF_PARAM (params, retransmit_interval);
5650 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5651
5652 if (params != IF_DEF_PARAMS (ifp))
5653 {
5654 ospf_free_if_params (ifp, addr);
5655 ospf_if_update_params (ifp, addr);
5656 }
5657
5658 return CMD_SUCCESS;
5659}
5660
5661ALIAS (no_ip_ospf_retransmit_interval,
5662 no_ip_ospf_retransmit_interval_cmd,
5663 "no ip ospf retransmit-interval",
5664 NO_STR
5665 "IP Information\n"
5666 "OSPF interface commands\n"
5667 "Time between retransmitting lost link state advertisements\n")
5668
5669ALIAS (no_ip_ospf_retransmit_interval,
5670 no_ospf_retransmit_interval_cmd,
5671 "no ospf retransmit-interval",
5672 NO_STR
5673 "OSPF interface commands\n"
5674 "Time between retransmitting lost link state advertisements\n")
5675
5676DEFUN (ip_ospf_transmit_delay,
5677 ip_ospf_transmit_delay_addr_cmd,
5678 "ip ospf transmit-delay <1-65535> A.B.C.D",
5679 "IP Information\n"
5680 "OSPF interface commands\n"
5681 "Link state transmit delay\n"
5682 "Seconds\n"
5683 "Address of interface")
5684{
5685 struct interface *ifp = vty->index;
5686 u_int32_t seconds;
5687 struct in_addr addr;
5688 int ret;
5689 struct ospf_if_params *params;
5690
5691 params = IF_DEF_PARAMS (ifp);
5692 seconds = strtol (argv[0], NULL, 10);
5693
5694 /* Transmit Delay range is <1-65535>. */
5695 if (seconds < 1 || seconds > 65535)
5696 {
5697 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5698 return CMD_WARNING;
5699 }
5700
5701 if (argc == 2)
5702 {
5703 ret = inet_aton(argv[1], &addr);
5704 if (!ret)
5705 {
5706 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5707 VTY_NEWLINE);
5708 return CMD_WARNING;
5709 }
5710
5711 params = ospf_get_if_params (ifp, addr);
5712 ospf_if_update_params (ifp, addr);
5713 }
5714
5715 SET_IF_PARAM (params, transmit_delay);
5716 params->transmit_delay = seconds;
5717
5718 return CMD_SUCCESS;
5719}
5720
5721ALIAS (ip_ospf_transmit_delay,
5722 ip_ospf_transmit_delay_cmd,
5723 "ip ospf transmit-delay <1-65535>",
5724 "IP Information\n"
5725 "OSPF interface commands\n"
5726 "Link state transmit delay\n"
5727 "Seconds\n")
5728
5729ALIAS (ip_ospf_transmit_delay,
5730 ospf_transmit_delay_cmd,
5731 "ospf transmit-delay <1-65535>",
5732 "OSPF interface commands\n"
5733 "Link state transmit delay\n"
5734 "Seconds\n")
5735
5736DEFUN (no_ip_ospf_transmit_delay,
5737 no_ip_ospf_transmit_delay_addr_cmd,
5738 "no ip ospf transmit-delay A.B.C.D",
5739 NO_STR
5740 "IP Information\n"
5741 "OSPF interface commands\n"
5742 "Link state transmit delay\n"
5743 "Address of interface")
5744{
5745 struct interface *ifp = vty->index;
5746 struct in_addr addr;
5747 int ret;
5748 struct ospf_if_params *params;
5749
5750 ifp = vty->index;
5751 params = IF_DEF_PARAMS (ifp);
5752
5753 if (argc == 1)
5754 {
5755 ret = inet_aton(argv[0], &addr);
5756 if (!ret)
5757 {
5758 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5759 VTY_NEWLINE);
5760 return CMD_WARNING;
5761 }
5762
5763 params = ospf_lookup_if_params (ifp, addr);
5764 if (params == NULL)
5765 return CMD_SUCCESS;
5766 }
5767
5768 UNSET_IF_PARAM (params, transmit_delay);
5769 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5770
5771 if (params != IF_DEF_PARAMS (ifp))
5772 {
5773 ospf_free_if_params (ifp, addr);
5774 ospf_if_update_params (ifp, addr);
5775 }
5776
5777 return CMD_SUCCESS;
5778}
5779
5780ALIAS (no_ip_ospf_transmit_delay,
5781 no_ip_ospf_transmit_delay_cmd,
5782 "no ip ospf transmit-delay",
5783 NO_STR
5784 "IP Information\n"
5785 "OSPF interface commands\n"
5786 "Link state transmit delay\n")
5787
5788ALIAS (no_ip_ospf_transmit_delay,
5789 no_ospf_transmit_delay_cmd,
5790 "no ospf transmit-delay",
5791 NO_STR
5792 "OSPF interface commands\n"
5793 "Link state transmit delay\n")
5794
Christian Franke6f2a6702013-09-30 12:27:52 +00005795DEFUN (ospf_redistribute_source,
5796 ospf_redistribute_source_cmd,
5797 "redistribute " QUAGGA_REDIST_STR_OSPFD
5798 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
Paul Jakmad1c65c22006-06-27 08:01:43 +00005799 REDIST_STR
5800 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005801 "Metric for redistributed routes\n"
5802 "OSPF default metric\n"
5803 "OSPF exterior metric type for redistributed routes\n"
5804 "Set OSPF External Type 1 metrics\n"
5805 "Set OSPF External Type 2 metrics\n"
5806 "Route map reference\n"
5807 "Pointer to route-map entries\n")
5808{
paul020709f2003-04-04 02:44:16 +00005809 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005810 int source;
5811 int type = -1;
5812 int metric = -1;
5813
Christian Franke6f2a6702013-09-30 12:27:52 +00005814 if (argc < 4)
5815 return CMD_WARNING; /* should not happen */
5816
paul718e3742002-12-13 20:15:29 +00005817 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005818 source = proto_redistnum(AFI_IP, argv[0]);
5819 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005820 return CMD_WARNING;
5821
5822 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005823 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00005824 if (!str2metric (argv[1], &metric))
5825 return CMD_WARNING;
5826
5827 /* Get metric type. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005828 if (argv[2] != NULL)
paul718e3742002-12-13 20:15:29 +00005829 if (!str2metric_type (argv[2], &type))
5830 return CMD_WARNING;
5831
Christian Franke6f2a6702013-09-30 12:27:52 +00005832 if (argv[3] != NULL)
paul020709f2003-04-04 02:44:16 +00005833 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005834 else
paul020709f2003-04-04 02:44:16 +00005835 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005836
paul020709f2003-04-04 02:44:16 +00005837 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005838}
5839
paul718e3742002-12-13 20:15:29 +00005840DEFUN (no_ospf_redistribute_source,
5841 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005842 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005843 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005844 REDIST_STR
5845 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005846{
paul020709f2003-04-04 02:44:16 +00005847 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005848 int source;
5849
David Lampartere0ca5fd2009-09-16 01:52:42 +02005850 source = proto_redistnum(AFI_IP, argv[0]);
5851 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005852 return CMD_WARNING;
5853
paul020709f2003-04-04 02:44:16 +00005854 ospf_routemap_unset (ospf, source);
5855 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005856}
5857
5858DEFUN (ospf_distribute_list_out,
5859 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005860 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005861 "Filter networks in routing updates\n"
5862 "Access-list name\n"
5863 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005864 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005865{
paul68980082003-03-25 05:07:42 +00005866 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005867 int source;
5868
5869 /* Get distribute source. */
Christian Frankebda3c322012-12-04 11:31:16 -08005870 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02005871 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005872 return CMD_WARNING;
5873
paul68980082003-03-25 05:07:42 +00005874 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005875}
5876
5877DEFUN (no_ospf_distribute_list_out,
5878 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005879 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005880 NO_STR
5881 "Filter networks in routing updates\n"
5882 "Access-list name\n"
5883 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005884 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005885{
paul68980082003-03-25 05:07:42 +00005886 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005887 int source;
5888
Christian Frankebda3c322012-12-04 11:31:16 -08005889 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02005890 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005891 return CMD_WARNING;
5892
paul68980082003-03-25 05:07:42 +00005893 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005894}
5895
5896/* Default information originate. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005897DEFUN (ospf_default_information_originate,
paul718e3742002-12-13 20:15:29 +00005898 ospf_default_information_originate_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00005899 "default-information originate "
5900 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
paul718e3742002-12-13 20:15:29 +00005901 "Control distribution of default information\n"
5902 "Distribute a default route\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00005903 "Always advertise default route\n"
paul718e3742002-12-13 20:15:29 +00005904 "OSPF default metric\n"
5905 "OSPF metric\n"
paul718e3742002-12-13 20:15:29 +00005906 "OSPF metric type for default routes\n"
5907 "Set OSPF External Type 1 metrics\n"
5908 "Set OSPF External Type 2 metrics\n"
paul718e3742002-12-13 20:15:29 +00005909 "Route map reference\n"
5910 "Pointer to route-map entries\n")
5911{
paul020709f2003-04-04 02:44:16 +00005912 struct ospf *ospf = vty->index;
Christian Franke6f2a6702013-09-30 12:27:52 +00005913 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
paul718e3742002-12-13 20:15:29 +00005914 int type = -1;
5915 int metric = -1;
5916
Christian Franke6f2a6702013-09-30 12:27:52 +00005917 if (argc < 4)
5918 return CMD_WARNING; /* this should not happen */
5919
5920 /* Check whether "always" was specified */
5921 if (argv[0] != NULL)
5922 default_originate = DEFAULT_ORIGINATE_ALWAYS;
paul718e3742002-12-13 20:15:29 +00005923
5924 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00005925 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00005926 if (!str2metric (argv[1], &metric))
5927 return CMD_WARNING;
5928
Christian Franke6f2a6702013-09-30 12:27:52 +00005929 /* Get metric type. */
5930 if (argv[2] != NULL)
5931 if (!str2metric_type (argv[2], &type))
5932 return CMD_WARNING;
5933
5934 if (argv[3] != NULL)
5935 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
paul718e3742002-12-13 20:15:29 +00005936 else
paul020709f2003-04-04 02:44:16 +00005937 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005938
Christian Franke6f2a6702013-09-30 12:27:52 +00005939 return ospf_redistribute_default_set (ospf, default_originate,
paul020709f2003-04-04 02:44:16 +00005940 type, metric);
paul718e3742002-12-13 20:15:29 +00005941}
5942
paul718e3742002-12-13 20:15:29 +00005943DEFUN (no_ospf_default_information_originate,
5944 no_ospf_default_information_originate_cmd,
5945 "no default-information originate",
5946 NO_STR
5947 "Control distribution of default information\n"
5948 "Distribute a default route\n")
5949{
paul68980082003-03-25 05:07:42 +00005950 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005951 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00005952
5953 p.family = AF_INET;
5954 p.prefix.s_addr = 0;
5955 p.prefixlen = 0;
5956
ajs5339cfd2005-09-19 13:28:05 +00005957 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00005958
5959 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
5960 ospf_external_info_delete (DEFAULT_ROUTE, p);
5961 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
5962 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
5963 }
5964
paul020709f2003-04-04 02:44:16 +00005965 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5966 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00005967}
5968
5969DEFUN (ospf_default_metric,
5970 ospf_default_metric_cmd,
5971 "default-metric <0-16777214>",
5972 "Set metric of redistributed routes\n"
5973 "Default metric\n")
5974{
paul68980082003-03-25 05:07:42 +00005975 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005976 int metric = -1;
5977
5978 if (!str2metric (argv[0], &metric))
5979 return CMD_WARNING;
5980
paul68980082003-03-25 05:07:42 +00005981 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00005982
5983 return CMD_SUCCESS;
5984}
5985
5986DEFUN (no_ospf_default_metric,
5987 no_ospf_default_metric_cmd,
5988 "no default-metric",
5989 NO_STR
5990 "Set metric of redistributed routes\n")
5991{
paul68980082003-03-25 05:07:42 +00005992 struct ospf *ospf = vty->index;
5993
5994 ospf->default_metric = -1;
5995
paul718e3742002-12-13 20:15:29 +00005996 return CMD_SUCCESS;
5997}
5998
5999ALIAS (no_ospf_default_metric,
6000 no_ospf_default_metric_val_cmd,
6001 "no default-metric <0-16777214>",
6002 NO_STR
6003 "Set metric of redistributed routes\n"
6004 "Default metric\n")
6005
6006DEFUN (ospf_distance,
6007 ospf_distance_cmd,
6008 "distance <1-255>",
6009 "Define an administrative distance\n"
6010 "OSPF Administrative distance\n")
6011{
paul68980082003-03-25 05:07:42 +00006012 struct ospf *ospf = vty->index;
6013
6014 ospf->distance_all = atoi (argv[0]);
6015
paul718e3742002-12-13 20:15:29 +00006016 return CMD_SUCCESS;
6017}
6018
6019DEFUN (no_ospf_distance,
6020 no_ospf_distance_cmd,
6021 "no distance <1-255>",
6022 NO_STR
6023 "Define an administrative distance\n"
6024 "OSPF Administrative distance\n")
6025{
paul68980082003-03-25 05:07:42 +00006026 struct ospf *ospf = vty->index;
6027
6028 ospf->distance_all = 0;
6029
paul718e3742002-12-13 20:15:29 +00006030 return CMD_SUCCESS;
6031}
6032
6033DEFUN (no_ospf_distance_ospf,
6034 no_ospf_distance_ospf_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00006035 "no distance ospf {intra-area|inter-area|external}",
paul718e3742002-12-13 20:15:29 +00006036 NO_STR
6037 "Define an administrative distance\n"
6038 "OSPF Administrative distance\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00006039 "OSPF Distance\n"
6040 "Intra-area routes\n"
6041 "Inter-area routes\n"
6042 "External routes\n")
paul718e3742002-12-13 20:15:29 +00006043{
paul68980082003-03-25 05:07:42 +00006044 struct ospf *ospf = vty->index;
6045
Christian Franke6f2a6702013-09-30 12:27:52 +00006046 if (argc < 3)
6047 return CMD_WARNING;
6048
6049 if (argv[0] != NULL)
6050 ospf->distance_intra = 0;
6051
6052 if (argv[1] != NULL)
6053 ospf->distance_inter = 0;
6054
6055 if (argv[2] != NULL)
6056 ospf->distance_external = 0;
6057
6058 if (argv[0] || argv[1] || argv[2])
6059 return CMD_SUCCESS;
6060
6061 /* If no arguments are given, clear all distance information */
paul68980082003-03-25 05:07:42 +00006062 ospf->distance_intra = 0;
6063 ospf->distance_inter = 0;
6064 ospf->distance_external = 0;
6065
paul718e3742002-12-13 20:15:29 +00006066 return CMD_SUCCESS;
6067}
6068
Christian Franke6f2a6702013-09-30 12:27:52 +00006069DEFUN (ospf_distance_ospf,
6070 ospf_distance_ospf_cmd,
6071 "distance ospf "
6072 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
paul718e3742002-12-13 20:15:29 +00006073 "Define an administrative distance\n"
6074 "OSPF Administrative distance\n"
6075 "Intra-area routes\n"
6076 "Distance for intra-area routes\n"
6077 "Inter-area routes\n"
6078 "Distance for inter-area routes\n"
6079 "External routes\n"
6080 "Distance for external routes\n")
6081{
paul68980082003-03-25 05:07:42 +00006082 struct ospf *ospf = vty->index;
6083
Christian Franke6f2a6702013-09-30 12:27:52 +00006084 if (argc < 3) /* should not happen */
6085 return CMD_WARNING;
paul68980082003-03-25 05:07:42 +00006086
Christian Franke6f2a6702013-09-30 12:27:52 +00006087 if (!argv[0] && !argv[1] && !argv[2])
6088 {
6089 vty_out(vty, "%% Command incomplete. (Arguments required)%s",
6090 VTY_NEWLINE);
6091 return CMD_WARNING;
6092 }
paul718e3742002-12-13 20:15:29 +00006093
Christian Franke6f2a6702013-09-30 12:27:52 +00006094 if (argv[0] != NULL)
6095 ospf->distance_intra = atoi(argv[0]);
paul68980082003-03-25 05:07:42 +00006096
Christian Franke6f2a6702013-09-30 12:27:52 +00006097 if (argv[1] != NULL)
6098 ospf->distance_inter = atoi(argv[1]);
paul68980082003-03-25 05:07:42 +00006099
Christian Franke6f2a6702013-09-30 12:27:52 +00006100 if (argv[2] != NULL)
6101 ospf->distance_external = atoi(argv[2]);
paul68980082003-03-25 05:07:42 +00006102
paul718e3742002-12-13 20:15:29 +00006103 return CMD_SUCCESS;
6104}
6105
6106DEFUN (ospf_distance_source,
6107 ospf_distance_source_cmd,
6108 "distance <1-255> A.B.C.D/M",
6109 "Administrative distance\n"
6110 "Distance value\n"
6111 "IP source prefix\n")
6112{
paul020709f2003-04-04 02:44:16 +00006113 struct ospf *ospf = vty->index;
6114
6115 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006116
paul718e3742002-12-13 20:15:29 +00006117 return CMD_SUCCESS;
6118}
6119
6120DEFUN (no_ospf_distance_source,
6121 no_ospf_distance_source_cmd,
6122 "no distance <1-255> A.B.C.D/M",
6123 NO_STR
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_unset (vty, ospf, argv[0], argv[1], NULL);
6131
paul718e3742002-12-13 20:15:29 +00006132 return CMD_SUCCESS;
6133}
6134
6135DEFUN (ospf_distance_source_access_list,
6136 ospf_distance_source_access_list_cmd,
6137 "distance <1-255> A.B.C.D/M WORD",
6138 "Administrative distance\n"
6139 "Distance value\n"
6140 "IP source prefix\n"
6141 "Access list name\n")
6142{
paul020709f2003-04-04 02:44:16 +00006143 struct ospf *ospf = vty->index;
6144
6145 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6146
paul718e3742002-12-13 20:15:29 +00006147 return CMD_SUCCESS;
6148}
6149
6150DEFUN (no_ospf_distance_source_access_list,
6151 no_ospf_distance_source_access_list_cmd,
6152 "no distance <1-255> A.B.C.D/M WORD",
6153 NO_STR
6154 "Administrative distance\n"
6155 "Distance value\n"
6156 "IP source prefix\n"
6157 "Access list name\n")
6158{
paul020709f2003-04-04 02:44:16 +00006159 struct ospf *ospf = vty->index;
6160
6161 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6162
paul718e3742002-12-13 20:15:29 +00006163 return CMD_SUCCESS;
6164}
6165
vincentba682532005-09-29 13:52:57 +00006166DEFUN (ip_ospf_mtu_ignore,
6167 ip_ospf_mtu_ignore_addr_cmd,
6168 "ip ospf mtu-ignore A.B.C.D",
6169 "IP Information\n"
6170 "OSPF interface commands\n"
6171 "Disable mtu mismatch detection\n"
6172 "Address of interface")
6173{
6174 struct interface *ifp = vty->index;
6175 struct in_addr addr;
6176 int ret;
6177
6178 struct ospf_if_params *params;
6179 params = IF_DEF_PARAMS (ifp);
6180
6181 if (argc == 1)
6182 {
6183 ret = inet_aton(argv[0], &addr);
6184 if (!ret)
6185 {
6186 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6187 VTY_NEWLINE);
6188 return CMD_WARNING;
6189 }
6190 params = ospf_get_if_params (ifp, addr);
6191 ospf_if_update_params (ifp, addr);
6192 }
6193 params->mtu_ignore = 1;
6194 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6195 SET_IF_PARAM (params, mtu_ignore);
6196 else
6197 {
6198 UNSET_IF_PARAM (params, mtu_ignore);
6199 if (params != IF_DEF_PARAMS (ifp))
6200 {
6201 ospf_free_if_params (ifp, addr);
6202 ospf_if_update_params (ifp, addr);
6203 }
6204 }
6205 return CMD_SUCCESS;
6206}
6207
6208ALIAS (ip_ospf_mtu_ignore,
6209 ip_ospf_mtu_ignore_cmd,
6210 "ip ospf mtu-ignore",
6211 "IP Information\n"
6212 "OSPF interface commands\n"
6213 "Disable mtu mismatch detection\n")
6214
6215
6216DEFUN (no_ip_ospf_mtu_ignore,
6217 no_ip_ospf_mtu_ignore_addr_cmd,
6218 "no ip ospf mtu-ignore A.B.C.D",
6219 "IP Information\n"
6220 "OSPF interface commands\n"
6221 "Disable mtu mismatch detection\n"
6222 "Address of interface")
6223{
6224 struct interface *ifp = vty->index;
6225 struct in_addr addr;
6226 int ret;
6227
6228 struct ospf_if_params *params;
6229 params = IF_DEF_PARAMS (ifp);
6230
6231 if (argc == 1)
6232 {
6233 ret = inet_aton(argv[0], &addr);
6234 if (!ret)
6235 {
6236 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6237 VTY_NEWLINE);
6238 return CMD_WARNING;
6239 }
6240 params = ospf_get_if_params (ifp, addr);
6241 ospf_if_update_params (ifp, addr);
6242 }
6243 params->mtu_ignore = 0;
6244 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6245 SET_IF_PARAM (params, mtu_ignore);
6246 else
6247 {
6248 UNSET_IF_PARAM (params, mtu_ignore);
6249 if (params != IF_DEF_PARAMS (ifp))
6250 {
6251 ospf_free_if_params (ifp, addr);
6252 ospf_if_update_params (ifp, addr);
6253 }
6254 }
6255 return CMD_SUCCESS;
6256}
6257
6258ALIAS (no_ip_ospf_mtu_ignore,
6259 no_ip_ospf_mtu_ignore_cmd,
6260 "no ip ospf mtu-ignore",
6261 "IP Information\n"
6262 "OSPF interface commands\n"
6263 "Disable mtu mismatch detection\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02006264
paul88d6cf32005-10-29 12:50:09 +00006265DEFUN (ospf_max_metric_router_lsa_admin,
6266 ospf_max_metric_router_lsa_admin_cmd,
6267 "max-metric router-lsa administrative",
6268 "OSPF maximum / infinite-distance metric\n"
6269 "Advertise own Router-LSA with infinite distance (stub router)\n"
6270 "Administratively applied, for an indefinite period\n")
6271{
6272 struct listnode *ln;
6273 struct ospf_area *area;
6274 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006275
paul88d6cf32005-10-29 12:50:09 +00006276 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6277 {
6278 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6279
6280 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00006281 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006282 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006283
6284 /* Allows for areas configured later to get the property */
6285 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
6286
paul88d6cf32005-10-29 12:50:09 +00006287 return CMD_SUCCESS;
6288}
6289
6290DEFUN (no_ospf_max_metric_router_lsa_admin,
6291 no_ospf_max_metric_router_lsa_admin_cmd,
6292 "no max-metric router-lsa administrative",
6293 NO_STR
6294 "OSPF maximum / infinite-distance metric\n"
6295 "Advertise own Router-LSA with infinite distance (stub router)\n"
6296 "Administratively applied, for an indefinite period\n")
6297{
6298 struct listnode *ln;
6299 struct ospf_area *area;
6300 struct ospf *ospf = vty->index;
6301
6302 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6303 {
6304 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6305
6306 /* Don't trample on the start-up stub timer */
6307 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6308 && !area->t_stub_router)
6309 {
6310 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006311 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006312 }
6313 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006314 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00006315 return CMD_SUCCESS;
6316}
6317
6318DEFUN (ospf_max_metric_router_lsa_startup,
6319 ospf_max_metric_router_lsa_startup_cmd,
6320 "max-metric router-lsa on-startup <5-86400>",
6321 "OSPF maximum / infinite-distance metric\n"
6322 "Advertise own Router-LSA with infinite distance (stub router)\n"
6323 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6324 "Time (seconds) to advertise self as stub-router\n")
6325{
6326 unsigned int seconds;
6327 struct ospf *ospf = vty->index;
6328
6329 if (argc != 1)
6330 {
6331 vty_out (vty, "%% Must supply stub-router period");
6332 return CMD_WARNING;
6333 }
6334
6335 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6336
6337 ospf->stub_router_startup_time = seconds;
6338
6339 return CMD_SUCCESS;
6340}
6341
6342DEFUN (no_ospf_max_metric_router_lsa_startup,
6343 no_ospf_max_metric_router_lsa_startup_cmd,
6344 "no max-metric router-lsa on-startup",
6345 NO_STR
6346 "OSPF maximum / infinite-distance metric\n"
6347 "Advertise own Router-LSA with infinite distance (stub router)\n"
6348 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6349{
6350 struct listnode *ln;
6351 struct ospf_area *area;
6352 struct ospf *ospf = vty->index;
6353
6354 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6355
6356 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6357 {
6358 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6359 OSPF_TIMER_OFF (area->t_stub_router);
6360
6361 /* Don't trample on admin stub routed */
6362 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6363 {
6364 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006365 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006366 }
6367 }
6368 return CMD_SUCCESS;
6369}
6370
6371DEFUN (ospf_max_metric_router_lsa_shutdown,
6372 ospf_max_metric_router_lsa_shutdown_cmd,
6373 "max-metric router-lsa on-shutdown <5-86400>",
6374 "OSPF maximum / infinite-distance metric\n"
6375 "Advertise own Router-LSA with infinite distance (stub router)\n"
6376 "Advertise stub-router prior to full shutdown of OSPF\n"
6377 "Time (seconds) to wait till full shutdown\n")
6378{
6379 unsigned int seconds;
6380 struct ospf *ospf = vty->index;
6381
6382 if (argc != 1)
6383 {
6384 vty_out (vty, "%% Must supply stub-router shutdown period");
6385 return CMD_WARNING;
6386 }
6387
6388 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6389
6390 ospf->stub_router_shutdown_time = seconds;
6391
6392 return CMD_SUCCESS;
6393}
6394
6395DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6396 no_ospf_max_metric_router_lsa_shutdown_cmd,
6397 "no max-metric router-lsa on-shutdown",
6398 NO_STR
6399 "OSPF maximum / infinite-distance metric\n"
6400 "Advertise own Router-LSA with infinite distance (stub router)\n"
6401 "Advertise stub-router prior to full shutdown of OSPF\n")
6402{
6403 struct ospf *ospf = vty->index;
6404
6405 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6406
6407 return CMD_SUCCESS;
6408}
6409
6410static void
6411config_write_stub_router (struct vty *vty, struct ospf *ospf)
6412{
6413 struct listnode *ln;
6414 struct ospf_area *area;
6415
6416 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6417 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6418 ospf->stub_router_startup_time, VTY_NEWLINE);
6419 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6420 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6421 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6422 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6423 {
6424 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6425 {
6426 vty_out (vty, " max-metric router-lsa administrative%s",
6427 VTY_NEWLINE);
6428 break;
6429 }
6430 }
6431 return;
6432}
David Lamparter6b0655a2014-06-04 06:53:35 +02006433
paul4dadc292005-05-06 21:37:42 +00006434static void
paul718e3742002-12-13 20:15:29 +00006435show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6436{
6437 struct route_node *rn;
6438 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006439 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006440 struct ospf_path *path;
6441
6442 vty_out (vty, "============ OSPF network routing table ============%s",
6443 VTY_NEWLINE);
6444
6445 for (rn = route_top (rt); rn; rn = route_next (rn))
6446 if ((or = rn->info) != NULL)
6447 {
6448 char buf1[19];
6449 snprintf (buf1, 19, "%s/%d",
6450 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6451
6452 switch (or->path_type)
6453 {
6454 case OSPF_PATH_INTER_AREA:
6455 if (or->type == OSPF_DESTINATION_NETWORK)
6456 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6457 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6458 else if (or->type == OSPF_DESTINATION_DISCARD)
6459 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6460 break;
6461 case OSPF_PATH_INTRA_AREA:
6462 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6463 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6464 break;
6465 default:
6466 break;
6467 }
6468
6469 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006470 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006471 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006472 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00006473 {
6474 if (path->nexthop.s_addr == 0)
6475 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006476 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006477 else
6478 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006479 inet_ntoa (path->nexthop),
6480 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006481 }
6482 }
paul718e3742002-12-13 20:15:29 +00006483 }
6484 vty_out (vty, "%s", VTY_NEWLINE);
6485}
6486
paul4dadc292005-05-06 21:37:42 +00006487static void
paul718e3742002-12-13 20:15:29 +00006488show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6489{
6490 struct route_node *rn;
6491 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006492 struct listnode *pnode;
6493 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006494 struct ospf_path *path;
6495
6496 vty_out (vty, "============ OSPF router routing table =============%s",
6497 VTY_NEWLINE);
6498 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6499 if (rn->info)
6500 {
6501 int flag = 0;
6502
6503 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6504
paul1eb8ef22005-04-07 07:30:20 +00006505 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6506 {
6507 if (flag++)
6508 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006509
paul1eb8ef22005-04-07 07:30:20 +00006510 /* Show path. */
6511 vty_out (vty, "%s [%d] area: %s",
6512 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6513 or->cost, inet_ntoa (or->u.std.area_id));
6514 /* Show flags. */
6515 vty_out (vty, "%s%s%s",
6516 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6517 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6518 VTY_NEWLINE);
6519
6520 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6521 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006522 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00006523 {
6524 if (path->nexthop.s_addr == 0)
6525 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006526 "", ifindex2ifname (path->ifindex),
6527 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006528 else
6529 vty_out (vty, "%24s via %s, %s%s", "",
6530 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006531 ifindex2ifname (path->ifindex),
6532 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006533 }
paul1eb8ef22005-04-07 07:30:20 +00006534 }
6535 }
paul718e3742002-12-13 20:15:29 +00006536 }
6537 vty_out (vty, "%s", VTY_NEWLINE);
6538}
6539
paul4dadc292005-05-06 21:37:42 +00006540static void
paul718e3742002-12-13 20:15:29 +00006541show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6542{
6543 struct route_node *rn;
6544 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006545 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006546 struct ospf_path *path;
6547
6548 vty_out (vty, "============ OSPF external routing table ===========%s",
6549 VTY_NEWLINE);
6550 for (rn = route_top (rt); rn; rn = route_next (rn))
6551 if ((er = rn->info) != NULL)
6552 {
6553 char buf1[19];
6554 snprintf (buf1, 19, "%s/%d",
6555 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6556
6557 switch (er->path_type)
6558 {
6559 case OSPF_PATH_TYPE1_EXTERNAL:
6560 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6561 er->cost, er->u.ext.tag, VTY_NEWLINE);
6562 break;
6563 case OSPF_PATH_TYPE2_EXTERNAL:
6564 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6565 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6566 break;
6567 }
6568
paul1eb8ef22005-04-07 07:30:20 +00006569 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006570 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006571 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00006572 {
6573 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006574 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006575 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006576 else
6577 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006578 inet_ntoa (path->nexthop),
6579 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00006580 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006581 }
6582 }
6583 }
6584 vty_out (vty, "%s", VTY_NEWLINE);
6585}
6586
paul718e3742002-12-13 20:15:29 +00006587DEFUN (show_ip_ospf_border_routers,
6588 show_ip_ospf_border_routers_cmd,
6589 "show ip ospf border-routers",
6590 SHOW_STR
6591 IP_STR
6592 "show all the ABR's and ASBR's\n"
6593 "for this area\n")
6594{
paul020709f2003-04-04 02:44:16 +00006595 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006596
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006597 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006598 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006599 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006600 return CMD_SUCCESS;
6601 }
6602
paul68980082003-03-25 05:07:42 +00006603 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006604 {
6605 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6606 return CMD_SUCCESS;
6607 }
6608
6609 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006610 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006611
6612 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006613 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006614
6615 return CMD_SUCCESS;
6616}
paul718e3742002-12-13 20:15:29 +00006617
6618DEFUN (show_ip_ospf_route,
6619 show_ip_ospf_route_cmd,
6620 "show ip ospf route",
6621 SHOW_STR
6622 IP_STR
6623 "OSPF information\n"
6624 "OSPF routing table\n")
6625{
paul020709f2003-04-04 02:44:16 +00006626 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006627
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006628 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006629 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006630 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006631 return CMD_SUCCESS;
6632 }
6633
paul68980082003-03-25 05:07:42 +00006634 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006635 {
6636 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6637 return CMD_SUCCESS;
6638 }
6639
6640 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006641 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006642
6643 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006644 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006645
6646 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006647 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006648
6649 return CMD_SUCCESS;
6650}
6651
David Lamparter6b0655a2014-06-04 06:53:35 +02006652
hassoeb1ce602004-10-08 08:17:22 +00006653const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006654{
6655 "unknown",
6656 "standard",
6657 "ibm",
6658 "cisco",
6659 "shortcut"
6660};
6661
hassoeb1ce602004-10-08 08:17:22 +00006662const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006663{
6664 "default",
6665 "enable",
6666 "disable"
6667};
6668
6669
paul4dadc292005-05-06 21:37:42 +00006670static void
paul718e3742002-12-13 20:15:29 +00006671area_id2str (char *buf, int length, struct ospf_area *area)
6672{
6673 memset (buf, 0, length);
6674
6675 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6676 strncpy (buf, inet_ntoa (area->area_id), length);
6677 else
6678 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6679}
6680
David Lamparter6b0655a2014-06-04 06:53:35 +02006681
hassoeb1ce602004-10-08 08:17:22 +00006682const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006683{
6684 "unknown", /* should never be used. */
6685 "point-to-point",
6686 "broadcast",
6687 "non-broadcast",
6688 "point-to-multipoint",
6689 "virtual-link", /* should never be used. */
6690 "loopback"
6691};
6692
6693/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00006694static int
paul718e3742002-12-13 20:15:29 +00006695config_write_interface (struct vty *vty)
6696{
hasso52dc7ee2004-09-23 19:18:23 +00006697 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006698 struct interface *ifp;
6699 struct crypt_key *ck;
6700 int write = 0;
6701 struct route_node *rn = NULL;
6702 struct ospf_if_params *params;
6703
paul1eb8ef22005-04-07 07:30:20 +00006704 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006705 {
paul718e3742002-12-13 20:15:29 +00006706 if (memcmp (ifp->name, "VLINK", 5) == 0)
6707 continue;
6708
6709 vty_out (vty, "!%s", VTY_NEWLINE);
6710 vty_out (vty, "interface %s%s", ifp->name,
6711 VTY_NEWLINE);
6712 if (ifp->desc)
6713 vty_out (vty, " description %s%s", ifp->desc,
6714 VTY_NEWLINE);
6715
6716 write++;
6717
6718 params = IF_DEF_PARAMS (ifp);
6719
6720 do {
6721 /* Interface Network print. */
6722 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006723 params->type != OSPF_IFTYPE_LOOPBACK)
6724 {
ajsbc18d612004-12-15 15:07:19 +00006725 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006726 {
6727 vty_out (vty, " ip ospf network %s",
6728 ospf_int_type_str[params->type]);
6729 if (params != IF_DEF_PARAMS (ifp))
6730 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6731 vty_out (vty, "%s", VTY_NEWLINE);
6732 }
paul718e3742002-12-13 20:15:29 +00006733 }
6734
6735 /* OSPF interface authentication print */
6736 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6737 params->auth_type != OSPF_AUTH_NOTSET)
6738 {
hassoeb1ce602004-10-08 08:17:22 +00006739 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006740
6741 /* Translation tables are not that much help here due to syntax
6742 of the simple option */
6743 switch (params->auth_type)
6744 {
6745
6746 case OSPF_AUTH_NULL:
6747 auth_str = " null";
6748 break;
6749
6750 case OSPF_AUTH_SIMPLE:
6751 auth_str = "";
6752 break;
6753
6754 case OSPF_AUTH_CRYPTOGRAPHIC:
6755 auth_str = " message-digest";
6756 break;
6757
6758 default:
6759 auth_str = "";
6760 break;
6761 }
6762
6763 vty_out (vty, " ip ospf authentication%s", auth_str);
6764 if (params != IF_DEF_PARAMS (ifp))
6765 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6766 vty_out (vty, "%s", VTY_NEWLINE);
6767 }
6768
6769 /* Simple Authentication Password print. */
6770 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6771 params->auth_simple[0] != '\0')
6772 {
6773 vty_out (vty, " ip ospf authentication-key %s",
6774 params->auth_simple);
6775 if (params != IF_DEF_PARAMS (ifp))
6776 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6777 vty_out (vty, "%s", VTY_NEWLINE);
6778 }
6779
6780 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00006781 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00006782 {
paul718e3742002-12-13 20:15:29 +00006783 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6784 ck->key_id, ck->auth_key);
6785 if (params != IF_DEF_PARAMS (ifp))
6786 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6787 vty_out (vty, "%s", VTY_NEWLINE);
6788 }
6789
6790 /* Interface Output Cost print. */
6791 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6792 {
6793 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6794 if (params != IF_DEF_PARAMS (ifp))
6795 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6796 vty_out (vty, "%s", VTY_NEWLINE);
6797 }
6798
6799 /* Hello Interval print. */
6800 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6801 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6802 {
6803 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6804 if (params != IF_DEF_PARAMS (ifp))
6805 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6806 vty_out (vty, "%s", VTY_NEWLINE);
6807 }
6808
6809
6810 /* Router Dead Interval print. */
6811 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6812 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6813 {
paulf9ad9372005-10-21 00:45:17 +00006814 vty_out (vty, " ip ospf dead-interval ");
6815
6816 /* fast hello ? */
6817 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
6818 vty_out (vty, "minimal hello-multiplier %d",
6819 params->fast_hello);
6820 else
6821 vty_out (vty, "%u", params->v_wait);
6822
paul718e3742002-12-13 20:15:29 +00006823 if (params != IF_DEF_PARAMS (ifp))
6824 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6825 vty_out (vty, "%s", VTY_NEWLINE);
6826 }
6827
6828 /* Router Priority print. */
6829 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6830 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6831 {
6832 vty_out (vty, " ip ospf priority %u", params->priority);
6833 if (params != IF_DEF_PARAMS (ifp))
6834 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6835 vty_out (vty, "%s", VTY_NEWLINE);
6836 }
6837
6838 /* Retransmit Interval print. */
6839 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6840 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6841 {
6842 vty_out (vty, " ip ospf retransmit-interval %u",
6843 params->retransmit_interval);
6844 if (params != IF_DEF_PARAMS (ifp))
6845 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6846 vty_out (vty, "%s", VTY_NEWLINE);
6847 }
6848
6849 /* Transmit Delay print. */
6850 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6851 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6852 {
6853 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6854 if (params != IF_DEF_PARAMS (ifp))
6855 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6856 vty_out (vty, "%s", VTY_NEWLINE);
6857 }
6858
vincentba682532005-09-29 13:52:57 +00006859 /* MTU ignore print. */
6860 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
6861 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6862 {
6863 if (params->mtu_ignore == 0)
6864 vty_out (vty, " no ip ospf mtu-ignore");
6865 else
6866 vty_out (vty, " ip ospf mtu-ignore");
6867 if (params != IF_DEF_PARAMS (ifp))
6868 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6869 vty_out (vty, "%s", VTY_NEWLINE);
6870 }
6871
6872
paul718e3742002-12-13 20:15:29 +00006873 while (1)
6874 {
6875 if (rn == NULL)
6876 rn = route_top (IF_OIFS_PARAMS (ifp));
6877 else
6878 rn = route_next (rn);
6879
6880 if (rn == NULL)
6881 break;
6882 params = rn->info;
6883 if (params != NULL)
6884 break;
6885 }
6886 } while (rn);
6887
6888#ifdef HAVE_OPAQUE_LSA
6889 ospf_opaque_config_write_if (vty, ifp);
6890#endif /* HAVE_OPAQUE_LSA */
6891 }
6892
6893 return write;
6894}
6895
paul4dadc292005-05-06 21:37:42 +00006896static int
paul68980082003-03-25 05:07:42 +00006897config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006898{
6899 struct route_node *rn;
6900 u_char buf[INET_ADDRSTRLEN];
6901
6902 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006903 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006904 if (rn->info)
6905 {
6906 struct ospf_network *n = rn->info;
6907
6908 memset (buf, 0, INET_ADDRSTRLEN);
6909
6910 /* Create Area ID string by specified Area ID format. */
6911 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006912 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006913 else
hassoc9e52be2004-09-26 16:09:34 +00006914 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006915 (unsigned long int) ntohl (n->area_id.s_addr));
6916
6917 /* Network print. */
6918 vty_out (vty, " network %s/%d area %s%s",
6919 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6920 buf, VTY_NEWLINE);
6921 }
6922
6923 return 0;
6924}
6925
paul4dadc292005-05-06 21:37:42 +00006926static int
paul68980082003-03-25 05:07:42 +00006927config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006928{
hasso52dc7ee2004-09-23 19:18:23 +00006929 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00006930 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00006931 u_char buf[INET_ADDRSTRLEN];
6932
6933 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00006934 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00006935 {
paul718e3742002-12-13 20:15:29 +00006936 struct route_node *rn1;
6937
hassoc9e52be2004-09-26 16:09:34 +00006938 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006939
6940 if (area->auth_type != OSPF_AUTH_NULL)
6941 {
6942 if (area->auth_type == OSPF_AUTH_SIMPLE)
6943 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6944 else
6945 vty_out (vty, " area %s authentication message-digest%s",
6946 buf, VTY_NEWLINE);
6947 }
6948
6949 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6950 vty_out (vty, " area %s shortcut %s%s", buf,
6951 ospf_shortcut_mode_str[area->shortcut_configured],
6952 VTY_NEWLINE);
6953
6954 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006955 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006956 )
6957 {
paulb0a053b2003-06-22 09:04:47 +00006958 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006959 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006960 else if (area->external_routing == OSPF_AREA_NSSA)
6961 {
6962 vty_out (vty, " area %s nssa", buf);
6963 switch (area->NSSATranslatorRole)
6964 {
6965 case OSPF_NSSA_ROLE_NEVER:
6966 vty_out (vty, " translate-never");
6967 break;
6968 case OSPF_NSSA_ROLE_ALWAYS:
6969 vty_out (vty, " translate-always");
6970 break;
6971 case OSPF_NSSA_ROLE_CANDIDATE:
6972 default:
6973 vty_out (vty, " translate-candidate");
6974 }
6975 }
paul718e3742002-12-13 20:15:29 +00006976
6977 if (area->no_summary)
6978 vty_out (vty, " no-summary");
6979
6980 vty_out (vty, "%s", VTY_NEWLINE);
6981
6982 if (area->default_cost != 1)
6983 vty_out (vty, " area %s default-cost %d%s", buf,
6984 area->default_cost, VTY_NEWLINE);
6985 }
6986
6987 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
6988 if (rn1->info)
6989 {
6990 struct ospf_area_range *range = rn1->info;
6991
6992 vty_out (vty, " area %s range %s/%d", buf,
6993 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
6994
paul6c835672004-10-11 11:00:30 +00006995 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00006996 vty_out (vty, " cost %d", range->cost_config);
6997
6998 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
6999 vty_out (vty, " not-advertise");
7000
7001 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7002 vty_out (vty, " substitute %s/%d",
7003 inet_ntoa (range->subst_addr), range->subst_masklen);
7004
7005 vty_out (vty, "%s", VTY_NEWLINE);
7006 }
7007
7008 if (EXPORT_NAME (area))
7009 vty_out (vty, " area %s export-list %s%s", buf,
7010 EXPORT_NAME (area), VTY_NEWLINE);
7011
7012 if (IMPORT_NAME (area))
7013 vty_out (vty, " area %s import-list %s%s", buf,
7014 IMPORT_NAME (area), VTY_NEWLINE);
7015
7016 if (PREFIX_NAME_IN (area))
7017 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7018 PREFIX_NAME_IN (area), VTY_NEWLINE);
7019
7020 if (PREFIX_NAME_OUT (area))
7021 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7022 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7023 }
7024
7025 return 0;
7026}
7027
paul4dadc292005-05-06 21:37:42 +00007028static int
paul68980082003-03-25 05:07:42 +00007029config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007030{
7031 struct ospf_nbr_nbma *nbr_nbma;
7032 struct route_node *rn;
7033
7034 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007035 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007036 if ((nbr_nbma = rn->info))
7037 {
7038 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7039
7040 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7041 vty_out (vty, " priority %d", nbr_nbma->priority);
7042
7043 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7044 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7045
7046 vty_out (vty, "%s", VTY_NEWLINE);
7047 }
7048
7049 return 0;
7050}
7051
paul4dadc292005-05-06 21:37:42 +00007052static int
paul68980082003-03-25 05:07:42 +00007053config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007054{
hasso52dc7ee2004-09-23 19:18:23 +00007055 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007056 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007057 u_char buf[INET_ADDRSTRLEN];
7058
7059 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007060 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007061 {
hasso52dc7ee2004-09-23 19:18:23 +00007062 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007063 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007064 struct ospf_interface *oi;
7065
7066 if (vl_data != NULL)
7067 {
7068 memset (buf, 0, INET_ADDRSTRLEN);
7069
7070 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007071 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007072 else
hassoc9e52be2004-09-26 16:09:34 +00007073 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007074 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7075 oi = vl_data->vl_oi;
7076
7077 /* timers */
7078 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7079 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7080 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7081 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7082 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7083 buf,
7084 inet_ntoa (vl_data->vl_peer),
7085 OSPF_IF_PARAM (oi, v_hello),
7086 OSPF_IF_PARAM (oi, retransmit_interval),
7087 OSPF_IF_PARAM (oi, transmit_delay),
7088 OSPF_IF_PARAM (oi, v_wait),
7089 VTY_NEWLINE);
7090 else
7091 vty_out (vty, " area %s virtual-link %s%s", buf,
7092 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7093 /* Auth key */
7094 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7095 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7096 buf,
7097 inet_ntoa (vl_data->vl_peer),
7098 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7099 VTY_NEWLINE);
7100 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007101 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7102 n2, ck))
7103 vty_out (vty, " area %s virtual-link %s"
7104 " message-digest-key %d md5 %s%s",
7105 buf,
7106 inet_ntoa (vl_data->vl_peer),
7107 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007108
7109 }
7110 }
7111
7112 return 0;
7113}
7114
David Lamparter6b0655a2014-06-04 06:53:35 +02007115
paul4dadc292005-05-06 21:37:42 +00007116static int
paul68980082003-03-25 05:07:42 +00007117config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007118{
7119 int type;
7120
7121 /* redistribute print. */
7122 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7123 if (type != zclient->redist_default && zclient->redist[type])
7124 {
ajsf52d13c2005-10-01 17:38:06 +00007125 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007126 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007127 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007128
paul68980082003-03-25 05:07:42 +00007129 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007130 vty_out (vty, " metric-type 1");
7131
paul020709f2003-04-04 02:44:16 +00007132 if (ROUTEMAP_NAME (ospf, type))
7133 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007134
7135 vty_out (vty, "%s", VTY_NEWLINE);
7136 }
7137
7138 return 0;
7139}
7140
paul4dadc292005-05-06 21:37:42 +00007141static int
paul68980082003-03-25 05:07:42 +00007142config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007143{
paul68980082003-03-25 05:07:42 +00007144 if (ospf->default_metric != -1)
7145 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007146 VTY_NEWLINE);
7147 return 0;
7148}
7149
paul4dadc292005-05-06 21:37:42 +00007150static int
paul68980082003-03-25 05:07:42 +00007151config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007152{
7153 int type;
7154
paul68980082003-03-25 05:07:42 +00007155 if (ospf)
paul718e3742002-12-13 20:15:29 +00007156 {
7157 /* distribute-list print. */
7158 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007159 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007160 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007161 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007162 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007163
7164 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007165 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007166 {
paulc42c1772006-01-10 20:36:49 +00007167 vty_out (vty, " default-information originate");
7168 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7169 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007170
paul68980082003-03-25 05:07:42 +00007171 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007172 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007173 ospf->dmetric[DEFAULT_ROUTE].value);
7174 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007175 vty_out (vty, " metric-type 1");
7176
paul020709f2003-04-04 02:44:16 +00007177 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7178 vty_out (vty, " route-map %s",
7179 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007180
7181 vty_out (vty, "%s", VTY_NEWLINE);
7182 }
7183
7184 }
7185
7186 return 0;
7187}
7188
paul4dadc292005-05-06 21:37:42 +00007189static int
paul68980082003-03-25 05:07:42 +00007190config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007191{
7192 struct route_node *rn;
7193 struct ospf_distance *odistance;
7194
paul68980082003-03-25 05:07:42 +00007195 if (ospf->distance_all)
7196 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007197
paul68980082003-03-25 05:07:42 +00007198 if (ospf->distance_intra
7199 || ospf->distance_inter
7200 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007201 {
7202 vty_out (vty, " distance ospf");
7203
paul68980082003-03-25 05:07:42 +00007204 if (ospf->distance_intra)
7205 vty_out (vty, " intra-area %d", ospf->distance_intra);
7206 if (ospf->distance_inter)
7207 vty_out (vty, " inter-area %d", ospf->distance_inter);
7208 if (ospf->distance_external)
7209 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007210
7211 vty_out (vty, "%s", VTY_NEWLINE);
7212 }
7213
paul68980082003-03-25 05:07:42 +00007214 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007215 if ((odistance = rn->info) != NULL)
7216 {
7217 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7218 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7219 odistance->access_list ? odistance->access_list : "",
7220 VTY_NEWLINE);
7221 }
7222 return 0;
7223}
7224
7225/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007226static int
paul718e3742002-12-13 20:15:29 +00007227ospf_config_write (struct vty *vty)
7228{
paul020709f2003-04-04 02:44:16 +00007229 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007230 struct interface *ifp;
7231 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007232 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007233 int write = 0;
7234
paul020709f2003-04-04 02:44:16 +00007235 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007236 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007237 {
7238 /* `router ospf' print. */
7239 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7240
7241 write++;
7242
paul68980082003-03-25 05:07:42 +00007243 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007244 return write;
7245
7246 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007247 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007248 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007249 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007250
7251 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007252 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007253 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007254 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007255
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007256 /* log-adjacency-changes flag print. */
7257 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7258 {
7259 vty_out(vty, " log-adjacency-changes");
7260 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7261 vty_out(vty, " detail");
7262 vty_out(vty, "%s", VTY_NEWLINE);
7263 }
7264
paul718e3742002-12-13 20:15:29 +00007265 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007266 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007267 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7268
7269 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007270 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007271 {
7272 vty_out (vty, "! Important: ensure reference bandwidth "
7273 "is consistent across all routers%s", VTY_NEWLINE);
7274 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7275 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7276 }
paul718e3742002-12-13 20:15:29 +00007277
7278 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007279 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007280 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7281 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7282 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007283 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007284 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007285
7286 /* Max-metric router-lsa print */
7287 config_write_stub_router (vty, ospf);
7288
paul718e3742002-12-13 20:15:29 +00007289 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007290 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007291 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007292 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007293
7294 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007295 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007296
7297 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007298 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
7299 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
7300
paul1eb8ef22005-04-07 07:30:20 +00007301 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007302 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
7303 && IF_DEF_PARAMS (ifp)->passive_interface !=
7304 ospf->passive_interface_default)
7305 {
7306 vty_out (vty, " %spassive-interface %s%s",
7307 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
7308 ifp->name, VTY_NEWLINE);
7309 }
paul1eb8ef22005-04-07 07:30:20 +00007310 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007311 {
7312 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
7313 continue;
7314 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
7315 passive_interface))
7316 {
7317 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
7318 continue;
7319 }
7320 else if (oi->params->passive_interface == ospf->passive_interface_default)
7321 continue;
7322
7323 vty_out (vty, " %spassive-interface %s %s%s",
7324 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00007325 oi->ifp->name,
7326 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007327 }
paul718e3742002-12-13 20:15:29 +00007328
7329 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007330 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007331
7332 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007333 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007334
7335 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007336 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007337
7338 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007339 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007340
7341 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007342 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007343
7344 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007345 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007346
7347 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007348 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007349
7350#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007351 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007352#endif /* HAVE_OPAQUE_LSA */
7353 }
7354
7355 return write;
7356}
7357
7358void
paul4dadc292005-05-06 21:37:42 +00007359ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007360{
7361 /* "show ip ospf" commands. */
7362 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7363 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7364
7365 /* "show ip ospf database" commands. */
7366 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7367 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7368 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7369 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7370 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7371 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7372 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7373 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7374 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7375 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7376 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7377 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7378 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7379 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7380
7381 /* "show ip ospf interface" commands. */
7382 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7383 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7384
7385 /* "show ip ospf neighbor" commands. */
7386 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7387 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7388 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7389 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7390 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7391 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7392 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7393 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7394 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7395 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7396 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7397 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7398 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7399 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7400
7401 /* "show ip ospf route" commands. */
7402 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7403 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007404 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7405 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007406}
7407
David Lamparter6b0655a2014-06-04 06:53:35 +02007408
paul718e3742002-12-13 20:15:29 +00007409/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007410static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00007411{
7412 INTERFACE_NODE,
7413 "%s(config-if)# ",
7414 1
7415};
7416
7417/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007418static void
7419ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007420{
7421 /* Install interface node. */
7422 install_node (&interface_node, config_write_interface);
7423
7424 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007425 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007426 install_default (INTERFACE_NODE);
7427
7428 /* "description" commands. */
7429 install_element (INTERFACE_NODE, &interface_desc_cmd);
7430 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7431
7432 /* "ip ospf authentication" commands. */
7433 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7434 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7435 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7436 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7437 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7438 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7439 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7440 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7441 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7442 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7443
7444 /* "ip ospf message-digest-key" commands. */
7445 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7446 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7447 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7448 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7449
7450 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007451 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
7452 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007453 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
7454 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007455 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007456 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7457
vincentba682532005-09-29 13:52:57 +00007458 /* "ip ospf mtu-ignore" commands. */
7459 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7460 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7461 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7462 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7463
paul718e3742002-12-13 20:15:29 +00007464 /* "ip ospf dead-interval" commands. */
7465 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7466 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007467 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7468 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007469 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7470 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007471
paul718e3742002-12-13 20:15:29 +00007472 /* "ip ospf hello-interval" commands. */
7473 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7474 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7475 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7476 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7477
7478 /* "ip ospf network" commands. */
7479 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7480 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7481
7482 /* "ip ospf priority" commands. */
7483 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7484 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7485 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7486 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7487
7488 /* "ip ospf retransmit-interval" commands. */
7489 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7490 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7491 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7492 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7493
7494 /* "ip ospf transmit-delay" commands. */
7495 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7496 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7497 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7498 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7499
7500 /* These commands are compatibitliy for previous version. */
7501 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7502 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7503 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7504 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007505 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
7506 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007507 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007508 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
7509 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007510 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007511 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7512 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7513 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7514 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7515 install_element (INTERFACE_NODE, &ospf_network_cmd);
7516 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7517 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7518 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7519 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7520 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7521 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7522 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7523}
7524
paul4dadc292005-05-06 21:37:42 +00007525static void
7526ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007527{
paul718e3742002-12-13 20:15:29 +00007528 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
paul718e3742002-12-13 20:15:29 +00007529 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7530
7531 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7532 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7533
paul718e3742002-12-13 20:15:29 +00007534 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
paul718e3742002-12-13 20:15:29 +00007535 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7536
7537 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7538 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7539 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7540
7541 install_element (OSPF_NODE, &ospf_distance_cmd);
7542 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7543 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
Christian Franke6f2a6702013-09-30 12:27:52 +00007544 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
paul718e3742002-12-13 20:15:29 +00007545#if 0
7546 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7547 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7548 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7549 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7550#endif /* 0 */
7551}
7552
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007553static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00007554{
7555 OSPF_NODE,
7556 "%s(config-router)# ",
7557 1
7558};
7559
David Lamparter6b0655a2014-06-04 06:53:35 +02007560
paul718e3742002-12-13 20:15:29 +00007561/* Install OSPF related vty commands. */
7562void
paul4dadc292005-05-06 21:37:42 +00007563ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007564{
7565 /* Install ospf top node. */
7566 install_node (&ospf_node, ospf_config_write);
7567
7568 /* "router ospf" commands. */
7569 install_element (CONFIG_NODE, &router_ospf_cmd);
7570 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7571
7572 install_default (OSPF_NODE);
7573
7574 /* "ospf router-id" commands. */
7575 install_element (OSPF_NODE, &ospf_router_id_cmd);
7576 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007577 install_element (OSPF_NODE, &router_ospf_id_cmd);
7578 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007579
7580 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007581 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7582 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007583 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00007584 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7585 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007586 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00007587
7588 /* "ospf abr-type" commands. */
7589 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7590 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7591
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007592 /* "ospf log-adjacency-changes" commands. */
7593 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
7594 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
7595 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
7596 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
7597
paul718e3742002-12-13 20:15:29 +00007598 /* "ospf rfc1583-compatible" commands. */
7599 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7600 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7601 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7602 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7603
7604 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007605 install_element (OSPF_NODE, &ospf_network_area_cmd);
7606 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007607
7608 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007609 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7610 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7611 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007612
7613 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007614 install_element (OSPF_NODE, &ospf_area_range_cmd);
7615 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7616 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7617 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7618 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7619 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7620 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7621 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7622 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7623 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7624 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007625
7626 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007627 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7628 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007629
paula2c62832003-04-23 17:01:31 +00007630 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7631 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007632
paula2c62832003-04-23 17:01:31 +00007633 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7634 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007635
paula2c62832003-04-23 17:01:31 +00007636 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7637 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007638
paula2c62832003-04-23 17:01:31 +00007639 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7640 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007641
paula2c62832003-04-23 17:01:31 +00007642 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7643 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7644 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007645
paula2c62832003-04-23 17:01:31 +00007646 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7647 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007648
paula2c62832003-04-23 17:01:31 +00007649 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7650 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007651
paula2c62832003-04-23 17:01:31 +00007652 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7653 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7654 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007655
paula2c62832003-04-23 17:01:31 +00007656 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7657 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7658 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007659
7660 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007661 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7662 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7663 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7664 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007665
paul718e3742002-12-13 20:15:29 +00007666 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007667 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7668 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7669 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7670 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7671 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7672 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007673
paula2c62832003-04-23 17:01:31 +00007674 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7675 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007676
paula2c62832003-04-23 17:01:31 +00007677 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7678 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007679
paula2c62832003-04-23 17:01:31 +00007680 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7681 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007682
paula2c62832003-04-23 17:01:31 +00007683 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7684 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007685
paula2c62832003-04-23 17:01:31 +00007686 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7687 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00007688
7689 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00007690 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7691 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00007692 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
7693 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
7694
paul88d6cf32005-10-29 12:50:09 +00007695 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00007696 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7697 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7698 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007699
paul88d6cf32005-10-29 12:50:09 +00007700 /* max-metric commands */
7701 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
7702 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
7703 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
7704 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
7705 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
7706 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
7707
7708 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00007709 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7710 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007711
7712 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007713 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7714 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7715 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7716 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7717 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7718 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7719 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7720 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007721
7722 /* Init interface related vty commands. */
7723 ospf_vty_if_init ();
7724
7725 /* Init zebra related vty commands. */
7726 ospf_vty_zebra_init ();
7727}