]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPF VTY interface. |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 Toshiaki Takada |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #include <zebra.h> | |
91756b38 | 24 | #include <lib/json.h> |
7ec4159b | 25 | #include <string.h> |
718e3744 | 26 | |
27 | #include "memory.h" | |
28 | #include "thread.h" | |
29 | #include "prefix.h" | |
30 | #include "table.h" | |
31 | #include "vty.h" | |
32 | #include "command.h" | |
33 | #include "plist.h" | |
34 | #include "log.h" | |
35 | #include "zclient.h" | |
36 | ||
37 | #include "ospfd/ospfd.h" | |
38 | #include "ospfd/ospf_asbr.h" | |
39 | #include "ospfd/ospf_lsa.h" | |
40 | #include "ospfd/ospf_lsdb.h" | |
41 | #include "ospfd/ospf_ism.h" | |
42 | #include "ospfd/ospf_interface.h" | |
43 | #include "ospfd/ospf_nsm.h" | |
44 | #include "ospfd/ospf_neighbor.h" | |
45 | #include "ospfd/ospf_flood.h" | |
46 | #include "ospfd/ospf_abr.h" | |
47 | #include "ospfd/ospf_spf.h" | |
48 | #include "ospfd/ospf_route.h" | |
49 | #include "ospfd/ospf_zebra.h" | |
50 | /*#include "ospfd/ospf_routemap.h" */ | |
51 | #include "ospfd/ospf_vty.h" | |
52 | #include "ospfd/ospf_dump.h" | |
7f342629 | 53 | #include "ospfd/ospf_bfd.h" |
718e3744 | 54 | |
30a2231a | 55 | static const char *ospf_network_type_str[] = |
718e3744 | 56 | { |
57 | "Null", | |
58 | "POINTOPOINT", | |
59 | "BROADCAST", | |
60 | "NBMA", | |
61 | "POINTOMULTIPOINT", | |
62 | "VIRTUALLINK", | |
63 | "LOOPBACK" | |
64 | }; | |
65 | ||
6b0655a2 | 66 | |
718e3744 | 67 | /* Utility functions. */ |
4dadc291 | 68 | static int |
6c835671 | 69 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
718e3744 | 70 | { |
71 | char *endptr = NULL; | |
72 | unsigned long ret; | |
73 | ||
74 | /* match "A.B.C.D". */ | |
75 | if (strchr (str, '.') != NULL) | |
76 | { | |
77 | ret = inet_aton (str, area_id); | |
78 | if (!ret) | |
79 | return -1; | |
80 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; | |
81 | } | |
82 | /* match "<0-4294967295>". */ | |
83 | else | |
84 | { | |
664711c1 UW |
85 | if (*str == '-') |
86 | return -1; | |
87 | errno = 0; | |
718e3744 | 88 | ret = strtoul (str, &endptr, 10); |
664711c1 | 89 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
718e3744 | 90 | return -1; |
91 | ||
92 | area_id->s_addr = htonl (ret); | |
93 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; | |
94 | } | |
95 | ||
96 | return 0; | |
97 | } | |
98 | ||
6b0655a2 | 99 | |
4dadc291 | 100 | static int |
6c835671 | 101 | str2metric (const char *str, int *metric) |
718e3744 | 102 | { |
103 | /* Sanity check. */ | |
104 | if (str == NULL) | |
105 | return 0; | |
106 | ||
107 | *metric = strtol (str, NULL, 10); | |
108 | if (*metric < 0 && *metric > 16777214) | |
109 | { | |
110 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
111 | return 0; | |
112 | } | |
113 | ||
114 | return 1; | |
115 | } | |
116 | ||
4dadc291 | 117 | static int |
6c835671 | 118 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 119 | { |
120 | /* Sanity check. */ | |
121 | if (str == NULL) | |
122 | return 0; | |
123 | ||
124 | if (strncmp (str, "1", 1) == 0) | |
125 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
126 | else if (strncmp (str, "2", 1) == 0) | |
127 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
128 | else | |
129 | return 0; | |
130 | ||
131 | return 1; | |
132 | } | |
133 | ||
134 | int | |
135 | ospf_oi_count (struct interface *ifp) | |
136 | { | |
137 | struct route_node *rn; | |
138 | int i = 0; | |
139 | ||
140 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
141 | if (rn->info) | |
142 | i++; | |
143 | ||
144 | return i; | |
145 | } | |
146 | ||
6b0655a2 | 147 | |
718e3744 | 148 | DEFUN (router_ospf, |
149 | router_ospf_cmd, | |
150 | "router ospf", | |
151 | "Enable a routing process\n" | |
152 | "Start OSPF configuration\n") | |
153 | { | |
7c8ff89e DS |
154 | struct ospf *ospf; |
155 | u_short instance = 0; | |
156 | ||
157 | ospf = ospf_lookup(); | |
158 | if (!ospf) | |
159 | { | |
160 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
161 | return CMD_WARNING; | |
162 | } | |
163 | ||
718e3744 | 164 | vty->node = OSPF_NODE; |
7c8ff89e DS |
165 | |
166 | if (argc) | |
167 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
168 | ||
169 | /* The following logic to set the vty->index is in place to be able | |
170 | to ignore the commands which dont belong to this instance. */ | |
171 | if (ospf->instance != instance) | |
172 | vty->index = NULL; | |
173 | else | |
0bad4851 DS |
174 | { |
175 | if (IS_DEBUG_OSPF_EVENT) | |
176 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
177 | ospf->oi_running = 1; | |
178 | vty->index = ospf; | |
179 | ospf_router_id_update (ospf); | |
180 | } | |
718e3744 | 181 | |
182 | return CMD_SUCCESS; | |
183 | } | |
184 | ||
7c8ff89e DS |
185 | ALIAS (router_ospf, |
186 | router_ospf_instance_cmd, | |
187 | "router ospf <1-65535>", | |
188 | "Enable a routing process\n" | |
189 | "Start OSPF configuration\n" | |
190 | "Instance ID\n") | |
191 | ||
718e3744 | 192 | DEFUN (no_router_ospf, |
193 | no_router_ospf_cmd, | |
194 | "no router ospf", | |
195 | NO_STR | |
196 | "Enable a routing process\n" | |
197 | "Start OSPF configuration\n") | |
198 | { | |
020709f9 | 199 | struct ospf *ospf; |
7c8ff89e | 200 | u_short instance = 0; |
020709f9 | 201 | |
7c8ff89e DS |
202 | if (argc) |
203 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
204 | ||
205 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
206 | return CMD_SUCCESS; | |
718e3744 | 207 | |
020709f9 | 208 | ospf_finish (ospf); |
718e3744 | 209 | |
210 | return CMD_SUCCESS; | |
211 | } | |
212 | ||
7c8ff89e DS |
213 | ALIAS (no_router_ospf, |
214 | no_router_ospf_instance_cmd, | |
215 | "no router ospf <1-65535>", | |
216 | NO_STR | |
217 | "Enable a routing process\n" | |
218 | "Start OSPF configuration\n" | |
219 | "Instance ID\n") | |
220 | ||
718e3744 | 221 | DEFUN (ospf_router_id, |
222 | ospf_router_id_cmd, | |
223 | "ospf router-id A.B.C.D", | |
224 | "OSPF specific commands\n" | |
225 | "router-id for the OSPF process\n" | |
226 | "OSPF router-id in IP address format\n") | |
227 | { | |
68980084 | 228 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
229 | struct listnode *node; |
230 | struct ospf_area *area; | |
718e3744 | 231 | struct in_addr router_id; |
68980084 | 232 | int ret; |
718e3744 | 233 | |
7c8ff89e DS |
234 | if (!ospf) |
235 | return CMD_SUCCESS; | |
236 | ||
718e3744 | 237 | ret = inet_aton (argv[0], &router_id); |
238 | if (!ret) | |
239 | { | |
240 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
241 | return CMD_WARNING; | |
242 | } | |
243 | ||
68980084 | 244 | ospf->router_id_static = router_id; |
2c19a6ec DS |
245 | |
246 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
247 | if (area->full_nbrs) | |
248 | { | |
249 | vty_out (vty, "For this router-id change to take effect," | |
250 | " save config and restart ospfd%s", VTY_NEWLINE); | |
251 | return CMD_SUCCESS; | |
252 | } | |
253 | ||
b29800a6 | 254 | ospf_router_id_update (ospf); |
255 | ||
718e3744 | 256 | return CMD_SUCCESS; |
257 | } | |
258 | ||
259 | ALIAS (ospf_router_id, | |
a2c62831 | 260 | router_ospf_id_cmd, |
718e3744 | 261 | "router-id A.B.C.D", |
262 | "router-id for the OSPF process\n" | |
263 | "OSPF router-id in IP address format\n") | |
264 | ||
265 | DEFUN (no_ospf_router_id, | |
266 | no_ospf_router_id_cmd, | |
267 | "no ospf router-id", | |
268 | NO_STR | |
269 | "OSPF specific commands\n" | |
270 | "router-id for the OSPF process\n") | |
271 | { | |
68980084 | 272 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
273 | struct listnode *node; |
274 | struct ospf_area *area; | |
68980084 | 275 | |
7c8ff89e DS |
276 | if (!ospf) |
277 | return CMD_SUCCESS; | |
278 | ||
68980084 | 279 | ospf->router_id_static.s_addr = 0; |
718e3744 | 280 | |
2c19a6ec DS |
281 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
282 | if (area->full_nbrs) | |
283 | { | |
284 | vty_out (vty, "For this router-id change to take effect," | |
285 | " save config and restart ospfd%s", VTY_NEWLINE); | |
286 | return CMD_SUCCESS; | |
287 | } | |
288 | ||
68980084 | 289 | ospf_router_id_update (ospf); |
718e3744 | 290 | |
291 | return CMD_SUCCESS; | |
292 | } | |
293 | ||
294 | ALIAS (no_ospf_router_id, | |
a2c62831 | 295 | no_router_ospf_id_cmd, |
718e3744 | 296 | "no router-id", |
297 | NO_STR | |
298 | "router-id for the OSPF process\n") | |
299 | ||
7ffa8fa2 | 300 | static void |
43540886 | 301 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
302 | { |
303 | struct listnode *ln; | |
304 | struct interface *ifp; | |
305 | struct ospf_interface *oi; | |
306 | ||
43540886 AS |
307 | ospf->passive_interface_default = newval; |
308 | ||
7ffa8fa2 PJ |
309 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
310 | { | |
311 | if (ifp && | |
312 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
313 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
314 | } | |
315 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
316 | { | |
317 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
318 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
319 | /* update multicast memberships */ |
320 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
321 | } |
322 | } | |
323 | ||
324 | static void | |
325 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
326 | struct in_addr addr, | |
327 | struct ospf_if_params *params, u_char value) | |
328 | { | |
329 | u_char dflt; | |
330 | ||
331 | params->passive_interface = value; | |
332 | if (params != IF_DEF_PARAMS (ifp)) | |
333 | { | |
334 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
335 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
336 | else | |
337 | dflt = ospf->passive_interface_default; | |
338 | ||
339 | if (value != dflt) | |
340 | SET_IF_PARAM (params, passive_interface); | |
341 | else | |
342 | UNSET_IF_PARAM (params, passive_interface); | |
343 | ||
344 | ospf_free_if_params (ifp, addr); | |
345 | ospf_if_update_params (ifp, addr); | |
346 | } | |
347 | else | |
348 | { | |
349 | if (value != ospf->passive_interface_default) | |
350 | SET_IF_PARAM (params, passive_interface); | |
351 | else | |
352 | UNSET_IF_PARAM (params, passive_interface); | |
353 | } | |
354 | } | |
355 | ||
a2c62831 | 356 | DEFUN (ospf_passive_interface, |
357 | ospf_passive_interface_addr_cmd, | |
718e3744 | 358 | "passive-interface IFNAME A.B.C.D", |
359 | "Suppress routing updates on an interface\n" | |
360 | "Interface's name\n") | |
361 | { | |
7ffa8fa2 PJ |
362 | struct interface *ifp; |
363 | struct in_addr addr; | |
364 | int ret; | |
365 | struct ospf_if_params *params; | |
366 | struct route_node *rn; | |
367 | struct ospf *ospf = vty->index; | |
718e3744 | 368 | |
7c8ff89e DS |
369 | if (!ospf) |
370 | return CMD_SUCCESS; | |
371 | ||
43540886 AS |
372 | if (argc == 0) |
373 | { | |
374 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
375 | return CMD_SUCCESS; | |
376 | } | |
377 | ||
7ffa8fa2 | 378 | ifp = if_get_by_name (argv[0]); |
718e3744 | 379 | |
380 | params = IF_DEF_PARAMS (ifp); | |
381 | ||
43540886 | 382 | if (argc == 2) |
718e3744 | 383 | { |
43540886 AS |
384 | ret = inet_aton(argv[1], &addr); |
385 | if (!ret) | |
386 | { | |
387 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
388 | VTY_NEWLINE); | |
389 | return CMD_WARNING; | |
390 | } | |
391 | ||
392 | params = ospf_get_if_params (ifp, addr); | |
393 | ospf_if_update_params (ifp, addr); | |
7ffa8fa2 | 394 | } |
43540886 AS |
395 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); |
396 | ||
ba6454ec | 397 | /* XXX We should call ospf_if_set_multicast on exactly those |
398 | * interfaces for which the passive property changed. It is too much | |
399 | * work to determine this set, so we do this for every interface. | |
400 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
401 | * record of joined groups to avoid systems calls if the desired | |
402 | * memberships match the current memership. | |
403 | */ | |
7ffa8fa2 | 404 | |
ba6454ec | 405 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
406 | { | |
407 | struct ospf_interface *oi = rn->info; | |
408 | ||
409 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 410 | ospf_if_set_multicast(oi); |
ba6454ec | 411 | } |
412 | /* | |
413 | * XXX It is not clear what state transitions the interface needs to | |
414 | * undergo when going from active to passive. Fixing this will | |
415 | * require precise identification of interfaces having such a | |
416 | * transition. | |
417 | */ | |
418 | ||
718e3744 | 419 | return CMD_SUCCESS; |
420 | } | |
421 | ||
a2c62831 | 422 | ALIAS (ospf_passive_interface, |
423 | ospf_passive_interface_cmd, | |
718e3744 | 424 | "passive-interface IFNAME", |
425 | "Suppress routing updates on an interface\n" | |
426 | "Interface's name\n") | |
427 | ||
7ffa8fa2 PJ |
428 | ALIAS (ospf_passive_interface, |
429 | ospf_passive_interface_default_cmd, | |
430 | "passive-interface default", | |
431 | "Suppress routing updates on an interface\n" | |
432 | "Suppress routing updates on interfaces by default\n") | |
433 | ||
a2c62831 | 434 | DEFUN (no_ospf_passive_interface, |
435 | no_ospf_passive_interface_addr_cmd, | |
718e3744 | 436 | "no passive-interface IFNAME A.B.C.D", |
437 | NO_STR | |
438 | "Allow routing updates on an interface\n" | |
439 | "Interface's name\n") | |
440 | { | |
441 | struct interface *ifp; | |
442 | struct in_addr addr; | |
443 | struct ospf_if_params *params; | |
444 | int ret; | |
ba6454ec | 445 | struct route_node *rn; |
7ffa8fa2 | 446 | struct ospf *ospf = vty->index; |
43540886 | 447 | |
7c8ff89e DS |
448 | if (!ospf) |
449 | return CMD_SUCCESS; | |
450 | ||
43540886 AS |
451 | if (argc == 0) |
452 | { | |
453 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
454 | return CMD_SUCCESS; | |
455 | } | |
718e3744 | 456 | |
6e72cb6a | 457 | ifp = if_get_by_name (argv[0]); |
718e3744 | 458 | |
459 | params = IF_DEF_PARAMS (ifp); | |
460 | ||
43540886 | 461 | if (argc == 2) |
718e3744 | 462 | { |
43540886 AS |
463 | ret = inet_aton(argv[1], &addr); |
464 | if (!ret) | |
465 | { | |
466 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
467 | VTY_NEWLINE); | |
468 | return CMD_WARNING; | |
469 | } | |
470 | ||
471 | params = ospf_lookup_if_params (ifp, addr); | |
472 | if (params == NULL) | |
473 | return CMD_SUCCESS; | |
718e3744 | 474 | } |
43540886 | 475 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); |
ba6454ec | 476 | |
477 | /* XXX We should call ospf_if_set_multicast on exactly those | |
478 | * interfaces for which the passive property changed. It is too much | |
479 | * work to determine this set, so we do this for every interface. | |
480 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
481 | * record of joined groups to avoid systems calls if the desired | |
482 | * memberships match the current memership. | |
483 | */ | |
484 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
485 | { | |
486 | struct ospf_interface *oi = rn->info; | |
487 | ||
488 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
489 | ospf_if_set_multicast(oi); | |
490 | } | |
491 | ||
718e3744 | 492 | return CMD_SUCCESS; |
493 | } | |
494 | ||
a2c62831 | 495 | ALIAS (no_ospf_passive_interface, |
496 | no_ospf_passive_interface_cmd, | |
718e3744 | 497 | "no passive-interface IFNAME", |
498 | NO_STR | |
499 | "Allow routing updates on an interface\n" | |
500 | "Interface's name\n") | |
501 | ||
7ffa8fa2 PJ |
502 | ALIAS (no_ospf_passive_interface, |
503 | no_ospf_passive_interface_default_cmd, | |
504 | "no passive-interface default", | |
505 | NO_STR | |
506 | "Allow routing updates on an interface\n" | |
507 | "Allow routing updates on interfaces by default\n") | |
508 | ||
a2c62831 | 509 | DEFUN (ospf_network_area, |
510 | ospf_network_area_cmd, | |
718e3744 | 511 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
512 | "Enable routing on an IP network\n" | |
513 | "OSPF network prefix\n" | |
514 | "Set the OSPF area ID\n" | |
515 | "OSPF area ID in IP address format\n" | |
516 | "OSPF area ID as a decimal value\n") | |
517 | { | |
518 | struct ospf *ospf= vty->index; | |
519 | struct prefix_ipv4 p; | |
520 | struct in_addr area_id; | |
521 | int ret, format; | |
522 | ||
7c8ff89e DS |
523 | if (!ospf) |
524 | return CMD_SUCCESS; | |
525 | ||
526 | if (ospf->instance) | |
527 | { | |
528 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
529 | VTY_NEWLINE); | |
530 | return CMD_WARNING; | |
531 | } | |
532 | ||
e723861d DS |
533 | if (ospf->if_ospf_cli_count > 0) |
534 | { | |
535 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
536 | VTY_NEWLINE); | |
537 | return CMD_WARNING; | |
538 | } | |
539 | ||
718e3744 | 540 | /* Get network prefix and Area ID. */ |
541 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
542 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
543 | ||
544 | ret = ospf_network_set (ospf, &p, area_id); | |
545 | if (ret == 0) | |
546 | { | |
547 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
548 | return CMD_WARNING; | |
549 | } | |
550 | ||
551 | return CMD_SUCCESS; | |
552 | } | |
553 | ||
a2c62831 | 554 | DEFUN (no_ospf_network_area, |
555 | no_ospf_network_area_cmd, | |
718e3744 | 556 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
557 | NO_STR | |
558 | "Enable routing on an IP network\n" | |
559 | "OSPF network prefix\n" | |
560 | "Set the OSPF area ID\n" | |
561 | "OSPF area ID in IP address format\n" | |
562 | "OSPF area ID as a decimal value\n") | |
563 | { | |
564 | struct ospf *ospf = (struct ospf *) vty->index; | |
565 | struct prefix_ipv4 p; | |
566 | struct in_addr area_id; | |
567 | int ret, format; | |
568 | ||
7c8ff89e DS |
569 | if (!ospf) |
570 | return CMD_SUCCESS; | |
571 | ||
572 | if (ospf->instance) | |
573 | { | |
574 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
575 | VTY_NEWLINE); | |
576 | return CMD_WARNING; | |
577 | } | |
578 | ||
718e3744 | 579 | /* Get network prefix and Area ID. */ |
580 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
581 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
582 | ||
583 | ret = ospf_network_unset (ospf, &p, area_id); | |
584 | if (ret == 0) | |
585 | { | |
586 | vty_out (vty, "Can't find specified network area configuration.%s", | |
587 | VTY_NEWLINE); | |
588 | return CMD_WARNING; | |
589 | } | |
590 | ||
591 | return CMD_SUCCESS; | |
592 | } | |
593 | ||
6b0655a2 | 594 | |
a2c62831 | 595 | DEFUN (ospf_area_range, |
596 | ospf_area_range_cmd, | |
718e3744 | 597 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
598 | "OSPF area parameters\n" | |
599 | "OSPF area ID in IP address format\n" | |
600 | "OSPF area ID as a decimal value\n" | |
601 | "Summarize routes matching address/mask (border routers only)\n" | |
602 | "Area range prefix\n") | |
603 | { | |
604 | struct ospf *ospf = vty->index; | |
605 | struct prefix_ipv4 p; | |
606 | struct in_addr area_id; | |
607 | int format; | |
608 | u_int32_t cost; | |
609 | ||
7c8ff89e DS |
610 | if (!ospf) |
611 | return CMD_SUCCESS; | |
612 | ||
718e3744 | 613 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
614 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
615 | ||
616 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
617 | if (argc > 2) | |
618 | { | |
4dadc291 | 619 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
718e3744 | 620 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
621 | } | |
622 | ||
623 | return CMD_SUCCESS; | |
624 | } | |
625 | ||
a2c62831 | 626 | ALIAS (ospf_area_range, |
627 | ospf_area_range_advertise_cmd, | |
718e3744 | 628 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
629 | "OSPF area parameters\n" | |
630 | "OSPF area ID in IP address format\n" | |
631 | "OSPF area ID as a decimal value\n" | |
632 | "OSPF area range for route advertise (default)\n" | |
633 | "Area range prefix\n" | |
634 | "Advertise this range (default)\n") | |
635 | ||
a2c62831 | 636 | ALIAS (ospf_area_range, |
637 | ospf_area_range_cost_cmd, | |
718e3744 | 638 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
639 | "OSPF area parameters\n" | |
640 | "OSPF area ID in IP address format\n" | |
641 | "OSPF area ID as a decimal value\n" | |
642 | "Summarize routes matching address/mask (border routers only)\n" | |
643 | "Area range prefix\n" | |
644 | "User specified metric for this range\n" | |
645 | "Advertised metric for this range\n") | |
646 | ||
a2c62831 | 647 | ALIAS (ospf_area_range, |
648 | ospf_area_range_advertise_cost_cmd, | |
718e3744 | 649 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
650 | "OSPF area parameters\n" | |
651 | "OSPF area ID in IP address format\n" | |
652 | "OSPF area ID as a decimal value\n" | |
653 | "Summarize routes matching address/mask (border routers only)\n" | |
654 | "Area range prefix\n" | |
655 | "Advertise this range (default)\n" | |
656 | "User specified metric for this range\n" | |
657 | "Advertised metric for this range\n") | |
658 | ||
a2c62831 | 659 | DEFUN (ospf_area_range_not_advertise, |
660 | ospf_area_range_not_advertise_cmd, | |
718e3744 | 661 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
662 | "OSPF area parameters\n" | |
663 | "OSPF area ID in IP address format\n" | |
664 | "OSPF area ID as a decimal value\n" | |
665 | "Summarize routes matching address/mask (border routers only)\n" | |
666 | "Area range prefix\n" | |
667 | "DoNotAdvertise this range\n") | |
668 | { | |
669 | struct ospf *ospf = vty->index; | |
670 | struct prefix_ipv4 p; | |
671 | struct in_addr area_id; | |
672 | int format; | |
673 | ||
7c8ff89e DS |
674 | if (!ospf) |
675 | return CMD_SUCCESS; | |
676 | ||
718e3744 | 677 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
678 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
679 | ||
680 | ospf_area_range_set (ospf, area_id, &p, 0); | |
681 | ||
682 | return CMD_SUCCESS; | |
683 | } | |
684 | ||
a2c62831 | 685 | DEFUN (no_ospf_area_range, |
686 | no_ospf_area_range_cmd, | |
718e3744 | 687 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
688 | NO_STR | |
689 | "OSPF area parameters\n" | |
690 | "OSPF area ID in IP address format\n" | |
691 | "OSPF area ID as a decimal value\n" | |
692 | "Summarize routes matching address/mask (border routers only)\n" | |
693 | "Area range prefix\n") | |
694 | { | |
695 | struct ospf *ospf = vty->index; | |
696 | struct prefix_ipv4 p; | |
697 | struct in_addr area_id; | |
698 | int format; | |
699 | ||
7c8ff89e DS |
700 | if (!ospf) |
701 | return CMD_SUCCESS; | |
702 | ||
718e3744 | 703 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
704 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
705 | ||
706 | ospf_area_range_unset (ospf, area_id, &p); | |
707 | ||
708 | return CMD_SUCCESS; | |
709 | } | |
710 | ||
a2c62831 | 711 | ALIAS (no_ospf_area_range, |
712 | no_ospf_area_range_advertise_cmd, | |
718e3744 | 713 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
714 | NO_STR | |
715 | "OSPF area parameters\n" | |
716 | "OSPF area ID in IP address format\n" | |
717 | "OSPF area ID as a decimal value\n" | |
718 | "Summarize routes matching address/mask (border routers only)\n" | |
719 | "Area range prefix\n" | |
720 | "Advertise this range (default)\n" | |
721 | "DoNotAdvertise this range\n") | |
722 | ||
a2c62831 | 723 | ALIAS (no_ospf_area_range, |
724 | no_ospf_area_range_cost_cmd, | |
718e3744 | 725 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
726 | NO_STR | |
727 | "OSPF area parameters\n" | |
728 | "OSPF area ID in IP address format\n" | |
729 | "OSPF area ID as a decimal value\n" | |
730 | "Summarize routes matching address/mask (border routers only)\n" | |
731 | "Area range prefix\n" | |
732 | "User specified metric for this range\n" | |
733 | "Advertised metric for this range\n") | |
734 | ||
a2c62831 | 735 | ALIAS (no_ospf_area_range, |
736 | no_ospf_area_range_advertise_cost_cmd, | |
718e3744 | 737 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
738 | NO_STR | |
739 | "OSPF area parameters\n" | |
740 | "OSPF area ID in IP address format\n" | |
741 | "OSPF area ID as a decimal value\n" | |
742 | "Summarize routes matching address/mask (border routers only)\n" | |
743 | "Area range prefix\n" | |
744 | "Advertise this range (default)\n" | |
745 | "User specified metric for this range\n" | |
746 | "Advertised metric for this range\n") | |
6b0655a2 | 747 | |
a2c62831 | 748 | DEFUN (ospf_area_range_substitute, |
749 | ospf_area_range_substitute_cmd, | |
718e3744 | 750 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
751 | "OSPF area parameters\n" | |
752 | "OSPF area ID in IP address format\n" | |
753 | "OSPF area ID as a decimal value\n" | |
754 | "Summarize routes matching address/mask (border routers only)\n" | |
755 | "Area range prefix\n" | |
756 | "Announce area range as another prefix\n" | |
757 | "Network prefix to be announced instead of range\n") | |
758 | { | |
759 | struct ospf *ospf = vty->index; | |
760 | struct prefix_ipv4 p, s; | |
761 | struct in_addr area_id; | |
762 | int format; | |
763 | ||
7c8ff89e DS |
764 | if (!ospf) |
765 | return CMD_SUCCESS; | |
766 | ||
718e3744 | 767 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
768 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
769 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
770 | ||
771 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
772 | ||
773 | return CMD_SUCCESS; | |
774 | } | |
775 | ||
a2c62831 | 776 | DEFUN (no_ospf_area_range_substitute, |
777 | no_ospf_area_range_substitute_cmd, | |
718e3744 | 778 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
779 | NO_STR | |
780 | "OSPF area parameters\n" | |
781 | "OSPF area ID in IP address format\n" | |
782 | "OSPF area ID as a decimal value\n" | |
783 | "Summarize routes matching address/mask (border routers only)\n" | |
784 | "Area range prefix\n" | |
785 | "Announce area range as another prefix\n" | |
786 | "Network prefix to be announced instead of range\n") | |
787 | { | |
788 | struct ospf *ospf = vty->index; | |
789 | struct prefix_ipv4 p, s; | |
790 | struct in_addr area_id; | |
791 | int format; | |
792 | ||
7c8ff89e DS |
793 | if (!ospf) |
794 | return CMD_SUCCESS; | |
795 | ||
718e3744 | 796 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
797 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
798 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
799 | ||
800 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
801 | ||
802 | return CMD_SUCCESS; | |
803 | } | |
804 | ||
6b0655a2 | 805 | |
718e3744 | 806 | /* Command Handler Logic in VLink stuff is delicate!! |
807 | ||
808 | ALTER AT YOUR OWN RISK!!!! | |
809 | ||
810 | Various dummy values are used to represent 'NoChange' state for | |
811 | VLink configuration NOT being changed by a VLink command, and | |
812 | special syntax is used within the command strings so that the | |
813 | typed in command verbs can be seen in the configuration command | |
814 | bacckend handler. This is to drastically reduce the verbeage | |
815 | required to coe up with a reasonably compatible Cisco VLink command | |
816 | ||
817 | - Matthew Grant <grantma@anathoth.gen.nz> | |
818 | Wed, 21 Feb 2001 15:13:52 +1300 | |
819 | */ | |
820 | ||
821 | ||
822 | /* Configuration data for virtual links | |
823 | */ | |
824 | struct ospf_vl_config_data { | |
825 | struct vty *vty; /* vty stuff */ | |
826 | struct in_addr area_id; /* area ID from command line */ | |
827 | int format; /* command line area ID format */ | |
828 | struct in_addr vl_peer; /* command line vl_peer */ | |
829 | int auth_type; /* Authehntication type, if given */ | |
830 | char *auth_key; /* simple password if present */ | |
831 | int crypto_key_id; /* Cryptographic key ID */ | |
832 | char *md5_key; /* MD5 authentication key */ | |
833 | int hello_interval; /* Obvious what these are... */ | |
834 | int retransmit_interval; | |
835 | int transmit_delay; | |
836 | int dead_interval; | |
837 | }; | |
838 | ||
4dadc291 | 839 | static void |
718e3744 | 840 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
841 | struct vty *vty) | |
842 | { | |
843 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
844 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
845 | vl_config->vty = vty; | |
846 | } | |
847 | ||
4dadc291 | 848 | static struct ospf_vl_data * |
68980084 | 849 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 850 | { |
851 | struct ospf_area *area; | |
852 | struct ospf_vl_data *vl_data; | |
853 | struct vty *vty; | |
854 | struct in_addr area_id; | |
855 | ||
856 | vty = vl_config->vty; | |
857 | area_id = vl_config->area_id; | |
858 | ||
859 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
860 | { | |
861 | vty_out (vty, | |
862 | "Configuring VLs over the backbone is not allowed%s", | |
863 | VTY_NEWLINE); | |
864 | return NULL; | |
865 | } | |
68980084 | 866 | area = ospf_area_get (ospf, area_id, vl_config->format); |
718e3744 | 867 | |
868 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
869 | { | |
870 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
871 | vty_out (vty, "Area %s is %s%s", | |
872 | inet_ntoa (area_id), | |
718e3744 | 873 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 874 | VTY_NEWLINE); |
875 | else | |
876 | vty_out (vty, "Area %ld is %s%s", | |
877 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 878 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 879 | VTY_NEWLINE); |
880 | return NULL; | |
881 | } | |
882 | ||
9c27ef9b | 883 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 884 | { |
885 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
886 | if (vl_data->vl_oi == NULL) | |
887 | { | |
68980084 | 888 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
889 | ospf_vl_add (ospf, vl_data); | |
890 | ospf_spf_calculate_schedule (ospf); | |
718e3744 | 891 | } |
892 | } | |
893 | return vl_data; | |
894 | } | |
895 | ||
896 | ||
4dadc291 | 897 | static int |
718e3744 | 898 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
899 | struct ospf_vl_config_data *vl_config) | |
900 | { | |
901 | struct crypt_key *ck; | |
902 | struct vty *vty; | |
903 | struct interface *ifp = vl_data->vl_oi->ifp; | |
904 | ||
905 | vty = vl_config->vty; | |
906 | ||
907 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
908 | { | |
909 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
910 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
911 | } | |
912 | ||
913 | if (vl_config->auth_key) | |
914 | { | |
915 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 916 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 917 | OSPF_AUTH_SIMPLE_SIZE); |
918 | } | |
919 | else if (vl_config->md5_key) | |
920 | { | |
921 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
922 | != NULL) | |
923 | { | |
924 | vty_out (vty, "OSPF: Key %d already exists%s", | |
925 | vl_config->crypto_key_id, VTY_NEWLINE); | |
926 | return CMD_WARNING; | |
927 | } | |
928 | ck = ospf_crypt_key_new (); | |
929 | ck->key_id = vl_config->crypto_key_id; | |
930 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 931 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 932 | |
933 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
934 | } | |
935 | else if (vl_config->crypto_key_id != 0) | |
936 | { | |
937 | /* Delete a key */ | |
938 | ||
939 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
940 | vl_config->crypto_key_id) == NULL) | |
941 | { | |
942 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
943 | vl_config->crypto_key_id, VTY_NEWLINE); | |
944 | return CMD_WARNING; | |
945 | } | |
946 | ||
947 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
948 | ||
949 | } | |
950 | ||
951 | return CMD_SUCCESS; | |
952 | } | |
953 | ||
4dadc291 | 954 | static int |
718e3744 | 955 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
956 | struct ospf_vl_config_data *vl_config) | |
957 | { | |
958 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; | |
959 | /* Virtual Link data initialised to defaults, so only set | |
960 | if a value given */ | |
961 | if (vl_config->hello_interval) | |
962 | { | |
963 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
964 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
965 | } | |
966 | ||
967 | if (vl_config->dead_interval) | |
968 | { | |
969 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
970 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
971 | } | |
972 | ||
973 | if (vl_config->retransmit_interval) | |
974 | { | |
975 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
976 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
977 | } | |
978 | ||
979 | if (vl_config->transmit_delay) | |
980 | { | |
981 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
982 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
983 | } | |
984 | ||
985 | return CMD_SUCCESS; | |
986 | } | |
987 | ||
988 | ||
989 | ||
990 | /* The business end of all of the above */ | |
4dadc291 | 991 | static int |
68980084 | 992 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 993 | { |
994 | struct ospf_vl_data *vl_data; | |
995 | int ret; | |
996 | ||
68980084 | 997 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 998 | if (!vl_data) |
999 | return CMD_WARNING; | |
1000 | ||
1001 | /* Process this one first as it can have a fatal result, which can | |
1002 | only logically occur if the virtual link exists already | |
1003 | Thus a command error does not result in a change to the | |
1004 | running configuration such as unexpectedly altered timer | |
1005 | values etc.*/ | |
1006 | ret = ospf_vl_set_security (vl_data, vl_config); | |
1007 | if (ret != CMD_SUCCESS) | |
1008 | return ret; | |
1009 | ||
1010 | /* Set any time based parameters, these area already range checked */ | |
1011 | ||
1012 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
1013 | if (ret != CMD_SUCCESS) | |
1014 | return ret; | |
1015 | ||
1016 | return CMD_SUCCESS; | |
1017 | ||
1018 | } | |
1019 | ||
1020 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1021 | */ | |
1022 | #define VLINK_HELPSTR_IPADDR \ | |
1023 | "OSPF area parameters\n" \ | |
1024 | "OSPF area ID in IP address format\n" \ | |
1025 | "OSPF area ID as a decimal value\n" \ | |
1026 | "Configure a virtual link\n" \ | |
1027 | "Router ID of the remote ABR\n" | |
1028 | ||
1029 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1030 | "Enable authentication on this virtual link\n" \ | |
1031 | "dummy string \n" | |
1032 | ||
1033 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1034 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1035 | "Use null authentication\n" \ | |
1036 | "Use message-digest authentication\n" | |
1037 | ||
1038 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1039 | "Time between HELLO packets\n" \ | |
1040 | "Time between retransmitting lost link state advertisements\n" \ | |
1041 | "Link state transmit delay\n" \ | |
1042 | "Interval after which a neighbor is declared dead\n" | |
1043 | ||
1044 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1045 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1046 | "Seconds\n" | |
1047 | ||
1048 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1049 | "Authentication password (key)\n" \ | |
1050 | "The OSPF password (key)" | |
1051 | ||
1052 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1053 | "Message digest authentication password (key)\n" \ | |
1054 | "dummy string \n" \ | |
1055 | "Key ID\n" \ | |
1056 | "Use MD5 algorithm\n" \ | |
1057 | "The OSPF password (key)" | |
1058 | ||
a2c62831 | 1059 | DEFUN (ospf_area_vlink, |
1060 | ospf_area_vlink_cmd, | |
718e3744 | 1061 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1062 | VLINK_HELPSTR_IPADDR) | |
1063 | { | |
68980084 | 1064 | struct ospf *ospf = vty->index; |
718e3744 | 1065 | struct ospf_vl_config_data vl_config; |
1066 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1067 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1068 | int i; | |
1069 | int ret; | |
1070 | ||
7c8ff89e DS |
1071 | if (!ospf) |
1072 | return CMD_SUCCESS; | |
1073 | ||
718e3744 | 1074 | ospf_vl_config_data_init(&vl_config, vty); |
1075 | ||
1076 | /* Read off first 2 parameters and check them */ | |
1077 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); | |
1078 | if (ret < 0) | |
1079 | { | |
1080 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1081 | return CMD_WARNING; | |
1082 | } | |
1083 | ||
1084 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1085 | if (! ret) | |
1086 | { | |
1087 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1088 | VTY_NEWLINE); | |
1089 | return CMD_WARNING; | |
1090 | } | |
1091 | ||
1092 | if (argc <=2) | |
1093 | { | |
1094 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1095 | ||
68980084 | 1096 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1097 | } |
1098 | ||
1099 | /* Deal with other parameters */ | |
1100 | for (i=2; i < argc; i++) | |
1101 | { | |
1102 | ||
1103 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ | |
1104 | ||
1105 | switch (argv[i][0]) | |
1106 | { | |
1107 | ||
1108 | case 'a': | |
1109 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1110 | { | |
1111 | /* authentication-key - this option can occur anywhere on | |
1112 | command line. At start of command line | |
1113 | must check for authentication option. */ | |
1114 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1115 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); | |
1116 | vl_config.auth_key = auth_key; | |
1117 | i++; | |
1118 | } | |
1119 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1120 | { | |
1121 | /* authentication - this option can only occur at start | |
1122 | of command line */ | |
1123 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1124 | if ((i+1) < argc) | |
1125 | { | |
1126 | if (strncmp (argv[i+1], "n", 1) == 0) | |
1127 | { | |
1128 | /* "authentication null" */ | |
1129 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1130 | i++; | |
1131 | } | |
1132 | else if (strncmp (argv[i+1], "m", 1) == 0 | |
1133 | && strcmp (argv[i+1], "message-digest-") != 0) | |
1134 | { | |
1135 | /* "authentication message-digest" */ | |
1136 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1137 | i++; | |
1138 | } | |
1139 | } | |
1140 | } | |
1141 | break; | |
1142 | ||
1143 | case 'm': | |
1144 | /* message-digest-key */ | |
1145 | i++; | |
1146 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1147 | if (vl_config.crypto_key_id < 0) | |
1148 | return CMD_WARNING; | |
1149 | i++; | |
1150 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1151 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); | |
1152 | vl_config.md5_key = md5_key; | |
1153 | break; | |
1154 | ||
1155 | case 'h': | |
1156 | /* Hello interval */ | |
1157 | i++; | |
1158 | vl_config.hello_interval = strtol (argv[i], NULL, 10); | |
1159 | if (vl_config.hello_interval < 0) | |
1160 | return CMD_WARNING; | |
1161 | break; | |
1162 | ||
1163 | case 'r': | |
1164 | /* Retransmit Interval */ | |
1165 | i++; | |
1166 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); | |
1167 | if (vl_config.retransmit_interval < 0) | |
1168 | return CMD_WARNING; | |
1169 | break; | |
1170 | ||
1171 | case 't': | |
1172 | /* Transmit Delay */ | |
1173 | i++; | |
1174 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); | |
1175 | if (vl_config.transmit_delay < 0) | |
1176 | return CMD_WARNING; | |
1177 | break; | |
1178 | ||
1179 | case 'd': | |
1180 | /* Dead Interval */ | |
1181 | i++; | |
1182 | vl_config.dead_interval = strtol (argv[i], NULL, 10); | |
1183 | if (vl_config.dead_interval < 0) | |
1184 | return CMD_WARNING; | |
1185 | break; | |
1186 | } | |
1187 | } | |
1188 | ||
1189 | ||
1190 | /* Action configuration */ | |
1191 | ||
68980084 | 1192 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1193 | |
1194 | } | |
1195 | ||
a2c62831 | 1196 | DEFUN (no_ospf_area_vlink, |
1197 | no_ospf_area_vlink_cmd, | |
718e3744 | 1198 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1199 | NO_STR | |
1200 | VLINK_HELPSTR_IPADDR) | |
1201 | { | |
68980084 | 1202 | struct ospf *ospf = vty->index; |
718e3744 | 1203 | struct ospf_area *area; |
1204 | struct ospf_vl_config_data vl_config; | |
1205 | struct ospf_vl_data *vl_data = NULL; | |
1206 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1207 | int i; | |
1208 | int ret, format; | |
1209 | ||
7c8ff89e DS |
1210 | if (!ospf) |
1211 | return CMD_SUCCESS; | |
1212 | ||
718e3744 | 1213 | ospf_vl_config_data_init(&vl_config, vty); |
1214 | ||
1215 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); | |
1216 | if (ret < 0) | |
1217 | { | |
1218 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1219 | return CMD_WARNING; | |
1220 | } | |
1221 | ||
68980084 | 1222 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1223 | if (!area) |
1224 | { | |
1225 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1226 | return CMD_WARNING; | |
1227 | } | |
1228 | ||
1229 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1230 | if (! ret) | |
1231 | { | |
1232 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1233 | VTY_NEWLINE); | |
1234 | return CMD_WARNING; | |
1235 | } | |
1236 | ||
1237 | if (argc <=2) | |
1238 | { | |
1239 | /* Basic VLink no command */ | |
1240 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1241 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1242 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1243 | |
68980084 | 1244 | ospf_area_check_free (ospf, vl_config.area_id); |
718e3744 | 1245 | |
1246 | return CMD_SUCCESS; | |
1247 | } | |
1248 | ||
1249 | /* If we are down here, we are reseting parameters */ | |
1250 | ||
1251 | /* Deal with other parameters */ | |
1252 | for (i=2; i < argc; i++) | |
1253 | { | |
718e3744 | 1254 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1255 | ||
1256 | switch (argv[i][0]) | |
1257 | { | |
1258 | ||
1259 | case 'a': | |
1260 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1261 | { | |
1262 | /* authentication-key - this option can occur anywhere on | |
1263 | command line. At start of command line | |
1264 | must check for authentication option. */ | |
1265 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1266 | vl_config.auth_key = auth_key; | |
1267 | } | |
1268 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1269 | { | |
1270 | /* authentication - this option can only occur at start | |
1271 | of command line */ | |
1272 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1273 | } | |
1274 | break; | |
1275 | ||
1276 | case 'm': | |
1277 | /* message-digest-key */ | |
1278 | /* Delete one key */ | |
1279 | i++; | |
1280 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1281 | if (vl_config.crypto_key_id < 0) | |
1282 | return CMD_WARNING; | |
1283 | vl_config.md5_key = NULL; | |
1284 | break; | |
1285 | ||
1286 | case 'h': | |
1287 | /* Hello interval */ | |
1288 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1289 | break; | |
1290 | ||
1291 | case 'r': | |
1292 | /* Retransmit Interval */ | |
1293 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1294 | break; | |
1295 | ||
1296 | case 't': | |
1297 | /* Transmit Delay */ | |
1298 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1299 | break; | |
1300 | ||
1301 | case 'd': | |
1302 | /* Dead Interval */ | |
1303 | i++; | |
1304 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
1305 | break; | |
1306 | } | |
1307 | } | |
1308 | ||
1309 | ||
1310 | /* Action configuration */ | |
1311 | ||
68980084 | 1312 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1313 | } |
1314 | ||
a2c62831 | 1315 | ALIAS (ospf_area_vlink, |
1316 | ospf_area_vlink_param1_cmd, | |
718e3744 | 1317 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1318 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1319 | VLINK_HELPSTR_IPADDR | |
1320 | VLINK_HELPSTR_TIME_PARAM) | |
1321 | ||
a2c62831 | 1322 | ALIAS (no_ospf_area_vlink, |
1323 | no_ospf_area_vlink_param1_cmd, | |
718e3744 | 1324 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1325 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1326 | NO_STR | |
1327 | VLINK_HELPSTR_IPADDR | |
1328 | VLINK_HELPSTR_TIME_PARAM) | |
1329 | ||
a2c62831 | 1330 | ALIAS (ospf_area_vlink, |
1331 | ospf_area_vlink_param2_cmd, | |
718e3744 | 1332 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1333 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1334 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1335 | VLINK_HELPSTR_IPADDR | |
1336 | VLINK_HELPSTR_TIME_PARAM | |
1337 | VLINK_HELPSTR_TIME_PARAM) | |
1338 | ||
a2c62831 | 1339 | ALIAS (no_ospf_area_vlink, |
1340 | no_ospf_area_vlink_param2_cmd, | |
718e3744 | 1341 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1342 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1343 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1344 | NO_STR | |
1345 | VLINK_HELPSTR_IPADDR | |
1346 | VLINK_HELPSTR_TIME_PARAM | |
1347 | VLINK_HELPSTR_TIME_PARAM) | |
1348 | ||
a2c62831 | 1349 | ALIAS (ospf_area_vlink, |
1350 | ospf_area_vlink_param3_cmd, | |
718e3744 | 1351 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1352 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1353 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1354 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1355 | VLINK_HELPSTR_IPADDR | |
1356 | VLINK_HELPSTR_TIME_PARAM | |
1357 | VLINK_HELPSTR_TIME_PARAM | |
1358 | VLINK_HELPSTR_TIME_PARAM) | |
1359 | ||
a2c62831 | 1360 | ALIAS (no_ospf_area_vlink, |
1361 | no_ospf_area_vlink_param3_cmd, | |
718e3744 | 1362 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1363 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1364 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1365 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1366 | NO_STR | |
1367 | VLINK_HELPSTR_IPADDR | |
1368 | VLINK_HELPSTR_TIME_PARAM | |
1369 | VLINK_HELPSTR_TIME_PARAM | |
1370 | VLINK_HELPSTR_TIME_PARAM) | |
1371 | ||
a2c62831 | 1372 | ALIAS (ospf_area_vlink, |
1373 | ospf_area_vlink_param4_cmd, | |
718e3744 | 1374 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1375 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1376 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1377 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1378 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1379 | VLINK_HELPSTR_IPADDR | |
1380 | VLINK_HELPSTR_TIME_PARAM | |
1381 | VLINK_HELPSTR_TIME_PARAM | |
1382 | VLINK_HELPSTR_TIME_PARAM | |
1383 | VLINK_HELPSTR_TIME_PARAM) | |
1384 | ||
a2c62831 | 1385 | ALIAS (no_ospf_area_vlink, |
1386 | no_ospf_area_vlink_param4_cmd, | |
718e3744 | 1387 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1388 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1389 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1390 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " | |
1391 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", | |
1392 | NO_STR | |
1393 | VLINK_HELPSTR_IPADDR | |
1394 | VLINK_HELPSTR_TIME_PARAM | |
1395 | VLINK_HELPSTR_TIME_PARAM | |
1396 | VLINK_HELPSTR_TIME_PARAM | |
1397 | VLINK_HELPSTR_TIME_PARAM) | |
1398 | ||
a2c62831 | 1399 | ALIAS (ospf_area_vlink, |
1400 | ospf_area_vlink_authtype_args_cmd, | |
718e3744 | 1401 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1402 | "(authentication|) (message-digest|null)", | |
1403 | VLINK_HELPSTR_IPADDR | |
1404 | VLINK_HELPSTR_AUTHTYPE_ALL) | |
1405 | ||
a2c62831 | 1406 | ALIAS (ospf_area_vlink, |
1407 | ospf_area_vlink_authtype_cmd, | |
718e3744 | 1408 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1409 | "(authentication|)", | |
1410 | VLINK_HELPSTR_IPADDR | |
1411 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1412 | ||
a2c62831 | 1413 | ALIAS (no_ospf_area_vlink, |
1414 | no_ospf_area_vlink_authtype_cmd, | |
718e3744 | 1415 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1416 | "(authentication|)", | |
1417 | NO_STR | |
1418 | VLINK_HELPSTR_IPADDR | |
1419 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1420 | ||
a2c62831 | 1421 | ALIAS (ospf_area_vlink, |
1422 | ospf_area_vlink_md5_cmd, | |
718e3744 | 1423 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1424 | "(message-digest-key|) <1-255> md5 KEY", | |
1425 | VLINK_HELPSTR_IPADDR | |
1426 | VLINK_HELPSTR_AUTH_MD5) | |
1427 | ||
a2c62831 | 1428 | ALIAS (no_ospf_area_vlink, |
1429 | no_ospf_area_vlink_md5_cmd, | |
718e3744 | 1430 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1431 | "(message-digest-key|) <1-255>", | |
1432 | NO_STR | |
1433 | VLINK_HELPSTR_IPADDR | |
1434 | VLINK_HELPSTR_AUTH_MD5) | |
1435 | ||
a2c62831 | 1436 | ALIAS (ospf_area_vlink, |
1437 | ospf_area_vlink_authkey_cmd, | |
718e3744 | 1438 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1439 | "(authentication-key|) AUTH_KEY", | |
1440 | VLINK_HELPSTR_IPADDR | |
1441 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1442 | ||
a2c62831 | 1443 | ALIAS (no_ospf_area_vlink, |
1444 | no_ospf_area_vlink_authkey_cmd, | |
718e3744 | 1445 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1446 | "(authentication-key|)", | |
1447 | NO_STR | |
1448 | VLINK_HELPSTR_IPADDR | |
1449 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1450 | ||
a2c62831 | 1451 | ALIAS (ospf_area_vlink, |
1452 | ospf_area_vlink_authtype_args_authkey_cmd, | |
718e3744 | 1453 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1454 | "(authentication|) (message-digest|null) " | |
1455 | "(authentication-key|) AUTH_KEY", | |
1456 | VLINK_HELPSTR_IPADDR | |
1457 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1458 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1459 | ||
a2c62831 | 1460 | ALIAS (ospf_area_vlink, |
1461 | ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1462 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1463 | "(authentication|) " | |
1464 | "(authentication-key|) AUTH_KEY", | |
1465 | VLINK_HELPSTR_IPADDR | |
1466 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1467 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1468 | ||
a2c62831 | 1469 | ALIAS (no_ospf_area_vlink, |
1470 | no_ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1471 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1472 | "(authentication|) " | |
1473 | "(authentication-key|)", | |
1474 | NO_STR | |
1475 | VLINK_HELPSTR_IPADDR | |
1476 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1477 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1478 | ||
a2c62831 | 1479 | ALIAS (ospf_area_vlink, |
1480 | ospf_area_vlink_authtype_args_md5_cmd, | |
718e3744 | 1481 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1482 | "(authentication|) (message-digest|null) " | |
1483 | "(message-digest-key|) <1-255> md5 KEY", | |
1484 | VLINK_HELPSTR_IPADDR | |
1485 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1486 | VLINK_HELPSTR_AUTH_MD5) | |
1487 | ||
a2c62831 | 1488 | ALIAS (ospf_area_vlink, |
1489 | ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1490 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1491 | "(authentication|) " | |
1492 | "(message-digest-key|) <1-255> md5 KEY", | |
1493 | VLINK_HELPSTR_IPADDR | |
1494 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1495 | VLINK_HELPSTR_AUTH_MD5) | |
1496 | ||
a2c62831 | 1497 | ALIAS (no_ospf_area_vlink, |
1498 | no_ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1499 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1500 | "(authentication|) " | |
1501 | "(message-digest-key|)", | |
1502 | NO_STR | |
1503 | VLINK_HELPSTR_IPADDR | |
1504 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1505 | VLINK_HELPSTR_AUTH_MD5) | |
1506 | ||
6b0655a2 | 1507 | |
a2c62831 | 1508 | DEFUN (ospf_area_shortcut, |
1509 | ospf_area_shortcut_cmd, | |
718e3744 | 1510 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
1511 | "OSPF area parameters\n" | |
1512 | "OSPF area ID in IP address format\n" | |
1513 | "OSPF area ID as a decimal value\n" | |
1514 | "Configure the area's shortcutting mode\n" | |
1515 | "Set default shortcutting behavior\n" | |
1516 | "Enable shortcutting through the area\n" | |
1517 | "Disable shortcutting through the area\n") | |
1518 | { | |
68980084 | 1519 | struct ospf *ospf = vty->index; |
718e3744 | 1520 | struct ospf_area *area; |
1521 | struct in_addr area_id; | |
1522 | int mode; | |
1523 | int format; | |
1524 | ||
7c8ff89e DS |
1525 | if (!ospf) |
1526 | return CMD_SUCCESS; | |
1527 | ||
718e3744 | 1528 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1529 | ||
68980084 | 1530 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1531 | |
1532 | if (strncmp (argv[1], "de", 2) == 0) | |
1533 | mode = OSPF_SHORTCUT_DEFAULT; | |
1534 | else if (strncmp (argv[1], "di", 2) == 0) | |
1535 | mode = OSPF_SHORTCUT_DISABLE; | |
1536 | else if (strncmp (argv[1], "e", 1) == 0) | |
1537 | mode = OSPF_SHORTCUT_ENABLE; | |
1538 | else | |
1539 | return CMD_WARNING; | |
1540 | ||
68980084 | 1541 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1542 | |
68980084 | 1543 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1544 | vty_out (vty, "Shortcut area setting will take effect " |
1545 | "only when the router is configured as Shortcut ABR%s", | |
1546 | VTY_NEWLINE); | |
1547 | ||
1548 | return CMD_SUCCESS; | |
1549 | } | |
1550 | ||
a2c62831 | 1551 | DEFUN (no_ospf_area_shortcut, |
1552 | no_ospf_area_shortcut_cmd, | |
718e3744 | 1553 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
1554 | NO_STR | |
1555 | "OSPF area parameters\n" | |
1556 | "OSPF area ID in IP address format\n" | |
1557 | "OSPF area ID as a decimal value\n" | |
1558 | "Deconfigure the area's shortcutting mode\n" | |
1559 | "Deconfigure enabled shortcutting through the area\n" | |
1560 | "Deconfigure disabled shortcutting through the area\n") | |
1561 | { | |
68980084 | 1562 | struct ospf *ospf = vty->index; |
718e3744 | 1563 | struct ospf_area *area; |
1564 | struct in_addr area_id; | |
1565 | int format; | |
1566 | ||
7c8ff89e DS |
1567 | if (!ospf) |
1568 | return CMD_SUCCESS; | |
1569 | ||
718e3744 | 1570 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1571 | ||
68980084 | 1572 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1573 | if (!area) |
1574 | return CMD_SUCCESS; | |
1575 | ||
68980084 | 1576 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1577 | |
1578 | return CMD_SUCCESS; | |
1579 | } | |
1580 | ||
6b0655a2 | 1581 | |
a2c62831 | 1582 | DEFUN (ospf_area_stub, |
1583 | ospf_area_stub_cmd, | |
718e3744 | 1584 | "area (A.B.C.D|<0-4294967295>) stub", |
1585 | "OSPF area parameters\n" | |
1586 | "OSPF area ID in IP address format\n" | |
1587 | "OSPF area ID as a decimal value\n" | |
1588 | "Configure OSPF area as stub\n") | |
1589 | { | |
1590 | struct ospf *ospf = vty->index; | |
1591 | struct in_addr area_id; | |
1592 | int ret, format; | |
1593 | ||
7c8ff89e DS |
1594 | if (!ospf) |
1595 | return CMD_SUCCESS; | |
1596 | ||
718e3744 | 1597 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1598 | ||
1599 | ret = ospf_area_stub_set (ospf, area_id); | |
1600 | if (ret == 0) | |
1601 | { | |
1602 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1603 | VTY_NEWLINE); | |
1604 | return CMD_WARNING; | |
1605 | } | |
1606 | ||
1607 | ospf_area_no_summary_unset (ospf, area_id); | |
1608 | ||
1609 | return CMD_SUCCESS; | |
1610 | } | |
1611 | ||
a2c62831 | 1612 | DEFUN (ospf_area_stub_no_summary, |
1613 | ospf_area_stub_no_summary_cmd, | |
718e3744 | 1614 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
1615 | "OSPF stub parameters\n" | |
1616 | "OSPF area ID in IP address format\n" | |
1617 | "OSPF area ID as a decimal value\n" | |
1618 | "Configure OSPF area as stub\n" | |
1619 | "Do not inject inter-area routes into stub\n") | |
1620 | { | |
1621 | struct ospf *ospf = vty->index; | |
1622 | struct in_addr area_id; | |
1623 | int ret, format; | |
1624 | ||
7c8ff89e DS |
1625 | if (!ospf) |
1626 | return CMD_SUCCESS; | |
1627 | ||
718e3744 | 1628 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1629 | ||
1630 | ret = ospf_area_stub_set (ospf, area_id); | |
1631 | if (ret == 0) | |
1632 | { | |
b0a053be | 1633 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1634 | VTY_NEWLINE); |
1635 | return CMD_WARNING; | |
1636 | } | |
1637 | ||
1638 | ospf_area_no_summary_set (ospf, area_id); | |
1639 | ||
1640 | return CMD_SUCCESS; | |
1641 | } | |
1642 | ||
a2c62831 | 1643 | DEFUN (no_ospf_area_stub, |
1644 | no_ospf_area_stub_cmd, | |
718e3744 | 1645 | "no area (A.B.C.D|<0-4294967295>) stub", |
1646 | NO_STR | |
1647 | "OSPF area parameters\n" | |
1648 | "OSPF area ID in IP address format\n" | |
1649 | "OSPF area ID as a decimal value\n" | |
1650 | "Configure OSPF area as stub\n") | |
1651 | { | |
1652 | struct ospf *ospf = vty->index; | |
1653 | struct in_addr area_id; | |
1654 | int format; | |
1655 | ||
7c8ff89e DS |
1656 | if (!ospf) |
1657 | return CMD_SUCCESS; | |
1658 | ||
718e3744 | 1659 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1660 | ||
1661 | ospf_area_stub_unset (ospf, area_id); | |
1662 | ospf_area_no_summary_unset (ospf, area_id); | |
1663 | ||
1664 | return CMD_SUCCESS; | |
1665 | } | |
1666 | ||
a2c62831 | 1667 | DEFUN (no_ospf_area_stub_no_summary, |
1668 | no_ospf_area_stub_no_summary_cmd, | |
718e3744 | 1669 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
1670 | NO_STR | |
1671 | "OSPF area parameters\n" | |
1672 | "OSPF area ID in IP address format\n" | |
1673 | "OSPF area ID as a decimal value\n" | |
1674 | "Configure OSPF area as stub\n" | |
1675 | "Do not inject inter-area routes into area\n") | |
1676 | { | |
1677 | struct ospf *ospf = vty->index; | |
1678 | struct in_addr area_id; | |
1679 | int format; | |
1680 | ||
7c8ff89e DS |
1681 | if (!ospf) |
1682 | return CMD_SUCCESS; | |
1683 | ||
718e3744 | 1684 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1685 | ospf_area_no_summary_unset (ospf, area_id); | |
1686 | ||
1687 | return CMD_SUCCESS; | |
1688 | } | |
1689 | ||
4dadc291 | 1690 | static int |
6c835671 | 1691 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
1692 | int nosum) | |
718e3744 | 1693 | { |
1694 | struct ospf *ospf = vty->index; | |
1695 | struct in_addr area_id; | |
1696 | int ret, format; | |
1697 | ||
7c8ff89e DS |
1698 | if (!ospf) |
1699 | return CMD_SUCCESS; | |
1700 | ||
718e3744 | 1701 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1702 | ||
1703 | ret = ospf_area_nssa_set (ospf, area_id); | |
1704 | if (ret == 0) | |
1705 | { | |
1706 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1707 | VTY_NEWLINE); | |
1708 | return CMD_WARNING; | |
1709 | } | |
1710 | ||
1711 | if (argc > 1) | |
1712 | { | |
1713 | if (strncmp (argv[1], "translate-c", 11) == 0) | |
b0a053be | 1714 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1715 | OSPF_NSSA_ROLE_CANDIDATE); |
1716 | else if (strncmp (argv[1], "translate-n", 11) == 0) | |
b0a053be | 1717 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1718 | OSPF_NSSA_ROLE_NEVER); |
1719 | else if (strncmp (argv[1], "translate-a", 11) == 0) | |
b0a053be | 1720 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1721 | OSPF_NSSA_ROLE_ALWAYS); |
1722 | } | |
b0a053be | 1723 | else |
1724 | { | |
1725 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1726 | OSPF_NSSA_ROLE_CANDIDATE); | |
1727 | } | |
718e3744 | 1728 | |
b0a053be | 1729 | if (nosum) |
718e3744 | 1730 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1731 | else |
1732 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1733 | |
b0a053be | 1734 | ospf_schedule_abr_task (ospf); |
1735 | ||
718e3744 | 1736 | return CMD_SUCCESS; |
1737 | } | |
1738 | ||
b0a053be | 1739 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1740 | ospf_area_nssa_translate_no_summary_cmd, |
b0a053be | 1741 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", |
718e3744 | 1742 | "OSPF area parameters\n" |
1743 | "OSPF area ID in IP address format\n" | |
1744 | "OSPF area ID as a decimal value\n" | |
1745 | "Configure OSPF area as nssa\n" | |
1746 | "Configure NSSA-ABR for translate election (default)\n" | |
1747 | "Configure NSSA-ABR to never translate\n" | |
1748 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1749 | "Do not inject inter-area routes into nssa\n") |
1750 | { | |
1751 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1752 | } | |
718e3744 | 1753 | |
b0a053be | 1754 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1755 | ospf_area_nssa_translate_cmd, |
718e3744 | 1756 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
1757 | "OSPF area parameters\n" | |
1758 | "OSPF area ID in IP address format\n" | |
1759 | "OSPF area ID as a decimal value\n" | |
1760 | "Configure OSPF area as nssa\n" | |
1761 | "Configure NSSA-ABR for translate election (default)\n" | |
1762 | "Configure NSSA-ABR to never translate\n" | |
1763 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1764 | { |
1765 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1766 | } | |
1767 | ||
1768 | DEFUN (ospf_area_nssa, | |
1769 | ospf_area_nssa_cmd, | |
1770 | "area (A.B.C.D|<0-4294967295>) nssa", | |
1771 | "OSPF area parameters\n" | |
1772 | "OSPF area ID in IP address format\n" | |
1773 | "OSPF area ID as a decimal value\n" | |
1774 | "Configure OSPF area as nssa\n") | |
1775 | { | |
1776 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1777 | } | |
718e3744 | 1778 | |
a2c62831 | 1779 | DEFUN (ospf_area_nssa_no_summary, |
1780 | ospf_area_nssa_no_summary_cmd, | |
718e3744 | 1781 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
1782 | "OSPF area parameters\n" | |
1783 | "OSPF area ID in IP address format\n" | |
1784 | "OSPF area ID as a decimal value\n" | |
1785 | "Configure OSPF area as nssa\n" | |
1786 | "Do not inject inter-area routes into nssa\n") | |
1787 | { | |
b0a053be | 1788 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1789 | } |
1790 | ||
a2c62831 | 1791 | DEFUN (no_ospf_area_nssa, |
1792 | no_ospf_area_nssa_cmd, | |
718e3744 | 1793 | "no area (A.B.C.D|<0-4294967295>) nssa", |
1794 | NO_STR | |
1795 | "OSPF area parameters\n" | |
1796 | "OSPF area ID in IP address format\n" | |
1797 | "OSPF area ID as a decimal value\n" | |
1798 | "Configure OSPF area as nssa\n") | |
1799 | { | |
1800 | struct ospf *ospf = vty->index; | |
1801 | struct in_addr area_id; | |
1802 | int format; | |
1803 | ||
7c8ff89e DS |
1804 | if (!ospf) |
1805 | return CMD_SUCCESS; | |
1806 | ||
718e3744 | 1807 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1808 | ||
1809 | ospf_area_nssa_unset (ospf, area_id); | |
1810 | ospf_area_no_summary_unset (ospf, area_id); | |
1811 | ||
b0a053be | 1812 | ospf_schedule_abr_task (ospf); |
1813 | ||
718e3744 | 1814 | return CMD_SUCCESS; |
1815 | } | |
1816 | ||
a2c62831 | 1817 | DEFUN (no_ospf_area_nssa_no_summary, |
1818 | no_ospf_area_nssa_no_summary_cmd, | |
718e3744 | 1819 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
1820 | NO_STR | |
1821 | "OSPF area parameters\n" | |
1822 | "OSPF area ID in IP address format\n" | |
1823 | "OSPF area ID as a decimal value\n" | |
1824 | "Configure OSPF area as nssa\n" | |
1825 | "Do not inject inter-area routes into nssa\n") | |
1826 | { | |
1827 | struct ospf *ospf = vty->index; | |
1828 | struct in_addr area_id; | |
1829 | int format; | |
1830 | ||
7c8ff89e DS |
1831 | if (!ospf) |
1832 | return CMD_SUCCESS; | |
1833 | ||
718e3744 | 1834 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1835 | ospf_area_no_summary_unset (ospf, area_id); | |
1836 | ||
1837 | return CMD_SUCCESS; | |
1838 | } | |
1839 | ||
a2c62831 | 1840 | DEFUN (ospf_area_default_cost, |
1841 | ospf_area_default_cost_cmd, | |
718e3744 | 1842 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1843 | "OSPF area parameters\n" | |
1844 | "OSPF area ID in IP address format\n" | |
1845 | "OSPF area ID as a decimal value\n" | |
1846 | "Set the summary-default cost of a NSSA or stub area\n" | |
1847 | "Stub's advertised default summary cost\n") | |
1848 | { | |
68980084 | 1849 | struct ospf *ospf = vty->index; |
718e3744 | 1850 | struct ospf_area *area; |
1851 | struct in_addr area_id; | |
1852 | u_int32_t cost; | |
1853 | int format; | |
ba682537 | 1854 | struct prefix_ipv4 p; |
718e3744 | 1855 | |
7c8ff89e DS |
1856 | if (!ospf) |
1857 | return CMD_SUCCESS; | |
1858 | ||
718e3744 | 1859 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
1860 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); | |
1861 | ||
68980084 | 1862 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1863 | |
1864 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1865 | { | |
1866 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1867 | return CMD_WARNING; | |
1868 | } | |
1869 | ||
1870 | area->default_cost = cost; | |
1871 | ||
ba682537 | 1872 | p.family = AF_INET; |
1873 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1874 | p.prefixlen = 0; | |
1875 | if (IS_DEBUG_OSPF_EVENT) | |
1876 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1877 | "announcing 0.0.0.0/0 to area %s", | |
1878 | inet_ntoa (area->area_id)); | |
1879 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1880 | ||
718e3744 | 1881 | return CMD_SUCCESS; |
1882 | } | |
1883 | ||
a2c62831 | 1884 | DEFUN (no_ospf_area_default_cost, |
1885 | no_ospf_area_default_cost_cmd, | |
718e3744 | 1886 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1887 | NO_STR | |
1888 | "OSPF area parameters\n" | |
1889 | "OSPF area ID in IP address format\n" | |
1890 | "OSPF area ID as a decimal value\n" | |
1891 | "Set the summary-default cost of a NSSA or stub area\n" | |
1892 | "Stub's advertised default summary cost\n") | |
1893 | { | |
68980084 | 1894 | struct ospf *ospf = vty->index; |
718e3744 | 1895 | struct ospf_area *area; |
1896 | struct in_addr area_id; | |
718e3744 | 1897 | int format; |
ba682537 | 1898 | struct prefix_ipv4 p; |
718e3744 | 1899 | |
7c8ff89e DS |
1900 | if (!ospf) |
1901 | return CMD_SUCCESS; | |
1902 | ||
718e3744 | 1903 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
0798cee3 | 1904 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
718e3744 | 1905 | |
68980084 | 1906 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1907 | if (area == NULL) |
1908 | return CMD_SUCCESS; | |
1909 | ||
1910 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1911 | { | |
1912 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1913 | return CMD_WARNING; | |
1914 | } | |
1915 | ||
1916 | area->default_cost = 1; | |
1917 | ||
ba682537 | 1918 | p.family = AF_INET; |
1919 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1920 | p.prefixlen = 0; | |
1921 | if (IS_DEBUG_OSPF_EVENT) | |
1922 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1923 | "announcing 0.0.0.0/0 to area %s", | |
1924 | inet_ntoa (area->area_id)); | |
1925 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1926 | ||
1927 | ||
68980084 | 1928 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1929 | |
1930 | return CMD_SUCCESS; | |
1931 | } | |
1932 | ||
a2c62831 | 1933 | DEFUN (ospf_area_export_list, |
1934 | ospf_area_export_list_cmd, | |
718e3744 | 1935 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
1936 | "OSPF area parameters\n" | |
1937 | "OSPF area ID in IP address format\n" | |
1938 | "OSPF area ID as a decimal value\n" | |
1939 | "Set the filter for networks announced to other areas\n" | |
1940 | "Name of the access-list\n") | |
1941 | { | |
68980084 | 1942 | struct ospf *ospf = vty->index; |
718e3744 | 1943 | struct ospf_area *area; |
1944 | struct in_addr area_id; | |
1945 | int format; | |
1946 | ||
7c8ff89e DS |
1947 | if (!ospf) |
1948 | return CMD_SUCCESS; | |
1949 | ||
52930766 | 1950 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
1951 | ||
68980084 | 1952 | area = ospf_area_get (ospf, area_id, format); |
1953 | ospf_area_export_list_set (ospf, area, argv[1]); | |
718e3744 | 1954 | |
1955 | return CMD_SUCCESS; | |
1956 | } | |
1957 | ||
a2c62831 | 1958 | DEFUN (no_ospf_area_export_list, |
1959 | no_ospf_area_export_list_cmd, | |
718e3744 | 1960 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
1961 | NO_STR | |
1962 | "OSPF area parameters\n" | |
1963 | "OSPF area ID in IP address format\n" | |
1964 | "OSPF area ID as a decimal value\n" | |
1965 | "Unset the filter for networks announced to other areas\n" | |
1966 | "Name of the access-list\n") | |
1967 | { | |
68980084 | 1968 | struct ospf *ospf = vty->index; |
718e3744 | 1969 | struct ospf_area *area; |
1970 | struct in_addr area_id; | |
1971 | int format; | |
1972 | ||
7c8ff89e DS |
1973 | if (!ospf) |
1974 | return CMD_SUCCESS; | |
1975 | ||
52930766 | 1976 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
1977 | ||
68980084 | 1978 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1979 | if (area == NULL) |
1980 | return CMD_SUCCESS; | |
1981 | ||
68980084 | 1982 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 1983 | |
1984 | return CMD_SUCCESS; | |
1985 | } | |
1986 | ||
1987 | ||
a2c62831 | 1988 | DEFUN (ospf_area_import_list, |
1989 | ospf_area_import_list_cmd, | |
718e3744 | 1990 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
1991 | "OSPF area parameters\n" | |
1992 | "OSPF area ID in IP address format\n" | |
1993 | "OSPF area ID as a decimal value\n" | |
1994 | "Set the filter for networks from other areas announced to the specified one\n" | |
1995 | "Name of the access-list\n") | |
1996 | { | |
68980084 | 1997 | struct ospf *ospf = vty->index; |
718e3744 | 1998 | struct ospf_area *area; |
1999 | struct in_addr area_id; | |
2000 | int format; | |
2001 | ||
7c8ff89e DS |
2002 | if (!ospf) |
2003 | return CMD_SUCCESS; | |
2004 | ||
52930766 | 2005 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2006 | ||
68980084 | 2007 | area = ospf_area_get (ospf, area_id, format); |
2008 | ospf_area_import_list_set (ospf, area, argv[1]); | |
718e3744 | 2009 | |
2010 | return CMD_SUCCESS; | |
2011 | } | |
2012 | ||
a2c62831 | 2013 | DEFUN (no_ospf_area_import_list, |
2014 | no_ospf_area_import_list_cmd, | |
718e3744 | 2015 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
2016 | NO_STR | |
2017 | "OSPF area parameters\n" | |
2018 | "OSPF area ID in IP address format\n" | |
2019 | "OSPF area ID as a decimal value\n" | |
2020 | "Unset the filter for networks announced to other areas\n" | |
2021 | "Name of the access-list\n") | |
2022 | { | |
68980084 | 2023 | struct ospf *ospf = vty->index; |
718e3744 | 2024 | struct ospf_area *area; |
2025 | struct in_addr area_id; | |
2026 | int format; | |
2027 | ||
7c8ff89e DS |
2028 | if (!ospf) |
2029 | return CMD_SUCCESS; | |
2030 | ||
52930766 | 2031 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2032 | ||
68980084 | 2033 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2034 | if (area == NULL) |
2035 | return CMD_SUCCESS; | |
2036 | ||
68980084 | 2037 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 2038 | |
2039 | return CMD_SUCCESS; | |
2040 | } | |
2041 | ||
a2c62831 | 2042 | DEFUN (ospf_area_filter_list, |
2043 | ospf_area_filter_list_cmd, | |
718e3744 | 2044 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2045 | "OSPF area parameters\n" | |
2046 | "OSPF area ID in IP address format\n" | |
2047 | "OSPF area ID as a decimal value\n" | |
2048 | "Filter networks between OSPF areas\n" | |
2049 | "Filter prefixes between OSPF areas\n" | |
2050 | "Name of an IP prefix-list\n" | |
2051 | "Filter networks sent to this area\n" | |
2052 | "Filter networks sent from this area\n") | |
2053 | { | |
68980084 | 2054 | struct ospf *ospf = vty->index; |
718e3744 | 2055 | struct ospf_area *area; |
2056 | struct in_addr area_id; | |
2057 | struct prefix_list *plist; | |
2058 | int format; | |
2059 | ||
7c8ff89e DS |
2060 | if (!ospf) |
2061 | return CMD_SUCCESS; | |
2062 | ||
718e3744 | 2063 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2064 | ||
68980084 | 2065 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2066 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
2067 | if (strncmp (argv[2], "in", 2) == 0) | |
2068 | { | |
2069 | PREFIX_LIST_IN (area) = plist; | |
2070 | if (PREFIX_NAME_IN (area)) | |
2071 | free (PREFIX_NAME_IN (area)); | |
2072 | ||
2073 | PREFIX_NAME_IN (area) = strdup (argv[1]); | |
68980084 | 2074 | ospf_schedule_abr_task (ospf); |
718e3744 | 2075 | } |
2076 | else | |
2077 | { | |
2078 | PREFIX_LIST_OUT (area) = plist; | |
2079 | if (PREFIX_NAME_OUT (area)) | |
2080 | free (PREFIX_NAME_OUT (area)); | |
2081 | ||
2082 | PREFIX_NAME_OUT (area) = strdup (argv[1]); | |
68980084 | 2083 | ospf_schedule_abr_task (ospf); |
718e3744 | 2084 | } |
2085 | ||
2086 | return CMD_SUCCESS; | |
2087 | } | |
2088 | ||
a2c62831 | 2089 | DEFUN (no_ospf_area_filter_list, |
2090 | no_ospf_area_filter_list_cmd, | |
718e3744 | 2091 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2092 | NO_STR | |
2093 | "OSPF area parameters\n" | |
2094 | "OSPF area ID in IP address format\n" | |
2095 | "OSPF area ID as a decimal value\n" | |
2096 | "Filter networks between OSPF areas\n" | |
2097 | "Filter prefixes between OSPF areas\n" | |
2098 | "Name of an IP prefix-list\n" | |
2099 | "Filter networks sent to this area\n" | |
2100 | "Filter networks sent from this area\n") | |
2101 | { | |
68980084 | 2102 | struct ospf *ospf = vty->index; |
718e3744 | 2103 | struct ospf_area *area; |
2104 | struct in_addr area_id; | |
718e3744 | 2105 | int format; |
2106 | ||
7c8ff89e DS |
2107 | if (!ospf) |
2108 | return CMD_SUCCESS; | |
2109 | ||
718e3744 | 2110 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2111 | ||
1a8ec2b9 PJ |
2112 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
2113 | return CMD_SUCCESS; | |
2114 | ||
718e3744 | 2115 | if (strncmp (argv[2], "in", 2) == 0) |
2116 | { | |
2117 | if (PREFIX_NAME_IN (area)) | |
2118 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) | |
2119 | return CMD_SUCCESS; | |
2120 | ||
2121 | PREFIX_LIST_IN (area) = NULL; | |
2122 | if (PREFIX_NAME_IN (area)) | |
2123 | free (PREFIX_NAME_IN (area)); | |
2124 | ||
2125 | PREFIX_NAME_IN (area) = NULL; | |
2126 | ||
68980084 | 2127 | ospf_schedule_abr_task (ospf); |
718e3744 | 2128 | } |
2129 | else | |
2130 | { | |
2131 | if (PREFIX_NAME_OUT (area)) | |
2132 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) | |
2133 | return CMD_SUCCESS; | |
2134 | ||
2135 | PREFIX_LIST_OUT (area) = NULL; | |
2136 | if (PREFIX_NAME_OUT (area)) | |
2137 | free (PREFIX_NAME_OUT (area)); | |
2138 | ||
2139 | PREFIX_NAME_OUT (area) = NULL; | |
2140 | ||
68980084 | 2141 | ospf_schedule_abr_task (ospf); |
718e3744 | 2142 | } |
2143 | ||
2144 | return CMD_SUCCESS; | |
2145 | } | |
2146 | ||
6b0655a2 | 2147 | |
a2c62831 | 2148 | DEFUN (ospf_area_authentication_message_digest, |
2149 | ospf_area_authentication_message_digest_cmd, | |
718e3744 | 2150 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
2151 | "OSPF area parameters\n" | |
2b00515a CF |
2152 | "OSPF area ID in IP address format\n" |
2153 | "OSPF area ID as a decimal value\n" | |
718e3744 | 2154 | "Enable authentication\n" |
2155 | "Use message-digest authentication\n") | |
2156 | { | |
68980084 | 2157 | struct ospf *ospf = vty->index; |
718e3744 | 2158 | struct ospf_area *area; |
2159 | struct in_addr area_id; | |
2160 | int format; | |
2161 | ||
7c8ff89e DS |
2162 | if (!ospf) |
2163 | return CMD_SUCCESS; | |
2164 | ||
718e3744 | 2165 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2166 | ||
68980084 | 2167 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2168 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
2169 | ||
2170 | return CMD_SUCCESS; | |
2171 | } | |
2172 | ||
a2c62831 | 2173 | DEFUN (ospf_area_authentication, |
2174 | ospf_area_authentication_cmd, | |
718e3744 | 2175 | "area (A.B.C.D|<0-4294967295>) authentication", |
2176 | "OSPF area parameters\n" | |
2177 | "OSPF area ID in IP address format\n" | |
2178 | "OSPF area ID as a decimal value\n" | |
2179 | "Enable authentication\n") | |
2180 | { | |
68980084 | 2181 | struct ospf *ospf = vty->index; |
718e3744 | 2182 | struct ospf_area *area; |
2183 | struct in_addr area_id; | |
2184 | int format; | |
2185 | ||
7c8ff89e DS |
2186 | if (!ospf) |
2187 | return CMD_SUCCESS; | |
2188 | ||
718e3744 | 2189 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2190 | ||
68980084 | 2191 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2192 | area->auth_type = OSPF_AUTH_SIMPLE; |
2193 | ||
2194 | return CMD_SUCCESS; | |
2195 | } | |
2196 | ||
a2c62831 | 2197 | DEFUN (no_ospf_area_authentication, |
2198 | no_ospf_area_authentication_cmd, | |
718e3744 | 2199 | "no area (A.B.C.D|<0-4294967295>) authentication", |
2200 | NO_STR | |
2201 | "OSPF area parameters\n" | |
2202 | "OSPF area ID in IP address format\n" | |
2203 | "OSPF area ID as a decimal value\n" | |
2204 | "Enable authentication\n") | |
2205 | { | |
68980084 | 2206 | struct ospf *ospf = vty->index; |
718e3744 | 2207 | struct ospf_area *area; |
2208 | struct in_addr area_id; | |
2209 | int format; | |
2210 | ||
7c8ff89e DS |
2211 | if (!ospf) |
2212 | return CMD_SUCCESS; | |
2213 | ||
718e3744 | 2214 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2215 | ||
68980084 | 2216 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2217 | if (area == NULL) |
2218 | return CMD_SUCCESS; | |
2219 | ||
2220 | area->auth_type = OSPF_AUTH_NULL; | |
2221 | ||
68980084 | 2222 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2223 | |
2224 | return CMD_SUCCESS; | |
2225 | } | |
2226 | ||
6b0655a2 | 2227 | |
718e3744 | 2228 | DEFUN (ospf_abr_type, |
2229 | ospf_abr_type_cmd, | |
2230 | "ospf abr-type (cisco|ibm|shortcut|standard)", | |
2231 | "OSPF specific commands\n" | |
2232 | "Set OSPF ABR type\n" | |
2233 | "Alternative ABR, cisco implementation\n" | |
2234 | "Alternative ABR, IBM implementation\n" | |
2235 | "Shortcut ABR\n" | |
2236 | "Standard behavior (RFC2328)\n") | |
2237 | { | |
68980084 | 2238 | struct ospf *ospf = vty->index; |
718e3744 | 2239 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2240 | ||
7c8ff89e DS |
2241 | if (!ospf) |
2242 | return CMD_SUCCESS; | |
2243 | ||
718e3744 | 2244 | if (strncmp (argv[0], "c", 1) == 0) |
2245 | abr_type = OSPF_ABR_CISCO; | |
2246 | else if (strncmp (argv[0], "i", 1) == 0) | |
2247 | abr_type = OSPF_ABR_IBM; | |
2248 | else if (strncmp (argv[0], "sh", 2) == 0) | |
2249 | abr_type = OSPF_ABR_SHORTCUT; | |
2250 | else if (strncmp (argv[0], "st", 2) == 0) | |
2251 | abr_type = OSPF_ABR_STAND; | |
2252 | else | |
2253 | return CMD_WARNING; | |
2254 | ||
2255 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2256 | if (ospf->abr_type != abr_type) |
718e3744 | 2257 | { |
68980084 | 2258 | ospf->abr_type = abr_type; |
2259 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2260 | } |
2261 | ||
2262 | return CMD_SUCCESS; | |
2263 | } | |
2264 | ||
2265 | DEFUN (no_ospf_abr_type, | |
2266 | no_ospf_abr_type_cmd, | |
d57834f6 | 2267 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
718e3744 | 2268 | NO_STR |
2269 | "OSPF specific commands\n" | |
2270 | "Set OSPF ABR type\n" | |
2271 | "Alternative ABR, cisco implementation\n" | |
2272 | "Alternative ABR, IBM implementation\n" | |
2273 | "Shortcut ABR\n") | |
2274 | { | |
68980084 | 2275 | struct ospf *ospf = vty->index; |
718e3744 | 2276 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2277 | ||
7c8ff89e DS |
2278 | if (!ospf) |
2279 | return CMD_SUCCESS; | |
2280 | ||
718e3744 | 2281 | if (strncmp (argv[0], "c", 1) == 0) |
2282 | abr_type = OSPF_ABR_CISCO; | |
2283 | else if (strncmp (argv[0], "i", 1) == 0) | |
2284 | abr_type = OSPF_ABR_IBM; | |
04d23314 | 2285 | else if (strncmp (argv[0], "sh", 2) == 0) |
718e3744 | 2286 | abr_type = OSPF_ABR_SHORTCUT; |
04d23314 FD |
2287 | else if (strncmp (argv[0], "st", 2) == 0) |
2288 | abr_type = OSPF_ABR_STAND; | |
718e3744 | 2289 | else |
2290 | return CMD_WARNING; | |
2291 | ||
2292 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2293 | if (ospf->abr_type == abr_type) |
718e3744 | 2294 | { |
d57834f6 | 2295 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2296 | ospf_schedule_abr_task (ospf); |
718e3744 | 2297 | } |
2298 | ||
2299 | return CMD_SUCCESS; | |
2300 | } | |
2301 | ||
d7e60dd7 AS |
2302 | DEFUN (ospf_log_adjacency_changes, |
2303 | ospf_log_adjacency_changes_cmd, | |
2304 | "log-adjacency-changes", | |
2305 | "Log changes in adjacency state\n") | |
2306 | { | |
2307 | struct ospf *ospf = vty->index; | |
2308 | ||
7c8ff89e DS |
2309 | if (!ospf) |
2310 | return CMD_SUCCESS; | |
2311 | ||
d7e60dd7 AS |
2312 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2313 | return CMD_SUCCESS; | |
2314 | } | |
2315 | ||
2316 | DEFUN (ospf_log_adjacency_changes_detail, | |
2317 | ospf_log_adjacency_changes_detail_cmd, | |
2318 | "log-adjacency-changes detail", | |
2319 | "Log changes in adjacency state\n" | |
2320 | "Log all state changes\n") | |
2321 | { | |
2322 | struct ospf *ospf = vty->index; | |
2323 | ||
7c8ff89e DS |
2324 | if (!ospf) |
2325 | return CMD_SUCCESS; | |
2326 | ||
d7e60dd7 AS |
2327 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2328 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2329 | return CMD_SUCCESS; | |
2330 | } | |
2331 | ||
2332 | DEFUN (no_ospf_log_adjacency_changes, | |
2333 | no_ospf_log_adjacency_changes_cmd, | |
2334 | "no log-adjacency-changes", | |
2335 | NO_STR | |
2336 | "Log changes in adjacency state\n") | |
2337 | { | |
2338 | struct ospf *ospf = vty->index; | |
2339 | ||
7c8ff89e DS |
2340 | if (!ospf) |
2341 | return CMD_SUCCESS; | |
2342 | ||
d7e60dd7 AS |
2343 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2344 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2345 | return CMD_SUCCESS; | |
2346 | } | |
2347 | ||
2348 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2349 | no_ospf_log_adjacency_changes_detail_cmd, | |
2350 | "no log-adjacency-changes detail", | |
2351 | NO_STR | |
2352 | "Log changes in adjacency state\n" | |
2353 | "Log all state changes\n") | |
2354 | { | |
2355 | struct ospf *ospf = vty->index; | |
2356 | ||
7c8ff89e DS |
2357 | if (!ospf) |
2358 | return CMD_SUCCESS; | |
2359 | ||
d7e60dd7 AS |
2360 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2361 | return CMD_SUCCESS; | |
2362 | } | |
2363 | ||
718e3744 | 2364 | DEFUN (ospf_compatible_rfc1583, |
2365 | ospf_compatible_rfc1583_cmd, | |
2366 | "compatible rfc1583", | |
2367 | "OSPF compatibility list\n" | |
2368 | "compatible with RFC 1583\n") | |
2369 | { | |
2370 | struct ospf *ospf = vty->index; | |
2371 | ||
7c8ff89e DS |
2372 | if (!ospf) |
2373 | return CMD_SUCCESS; | |
2374 | ||
718e3744 | 2375 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2376 | { | |
2377 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
68980084 | 2378 | ospf_spf_calculate_schedule (ospf); |
718e3744 | 2379 | } |
2380 | return CMD_SUCCESS; | |
2381 | } | |
2382 | ||
2383 | DEFUN (no_ospf_compatible_rfc1583, | |
2384 | no_ospf_compatible_rfc1583_cmd, | |
2385 | "no compatible rfc1583", | |
2386 | NO_STR | |
2387 | "OSPF compatibility list\n" | |
2388 | "compatible with RFC 1583\n") | |
2389 | { | |
2390 | struct ospf *ospf = vty->index; | |
2391 | ||
7c8ff89e DS |
2392 | if (!ospf) |
2393 | return CMD_SUCCESS; | |
2394 | ||
718e3744 | 2395 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2396 | { | |
2397 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
68980084 | 2398 | ospf_spf_calculate_schedule (ospf); |
718e3744 | 2399 | } |
2400 | return CMD_SUCCESS; | |
2401 | } | |
2402 | ||
2403 | ALIAS (ospf_compatible_rfc1583, | |
2404 | ospf_rfc1583_flag_cmd, | |
2405 | "ospf rfc1583compatibility", | |
2406 | "OSPF specific commands\n" | |
2407 | "Enable the RFC1583Compatibility flag\n") | |
2408 | ||
2409 | ALIAS (no_ospf_compatible_rfc1583, | |
2410 | no_ospf_rfc1583_flag_cmd, | |
2411 | "no ospf rfc1583compatibility", | |
2412 | NO_STR | |
2413 | "OSPF specific commands\n" | |
2414 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2415 | |
d24f6e2a | 2416 | static int |
2417 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2418 | unsigned int hold, | |
2419 | unsigned int max) | |
2420 | { | |
2421 | struct ospf *ospf = vty->index; | |
2422 | ||
7c8ff89e DS |
2423 | if (!ospf) |
2424 | return CMD_SUCCESS; | |
2425 | ||
d24f6e2a | 2426 | ospf->spf_delay = delay; |
2427 | ospf->spf_holdtime = hold; | |
2428 | ospf->spf_max_holdtime = max; | |
2429 | ||
2430 | return CMD_SUCCESS; | |
2431 | } | |
718e3744 | 2432 | |
ac7424f9 MR |
2433 | DEFUN (ospf_timers_min_ls_interval, |
2434 | ospf_timers_min_ls_interval_cmd, | |
2435 | "timers throttle lsa all <0-5000>", | |
2436 | "Adjust routing timers\n" | |
2437 | "Throttling adaptive timer\n" | |
2438 | "LSA delay between transmissions\n" | |
2439 | NO_STR | |
2440 | "Delay (msec) between sending LSAs\n") | |
2441 | { | |
2442 | struct ospf *ospf = vty->index; | |
2443 | unsigned int interval; | |
2444 | ||
2445 | if (argc != 1) | |
2446 | { | |
2447 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2448 | return CMD_WARNING; | |
2449 | } | |
2450 | ||
2451 | VTY_GET_INTEGER ("LSA interval", interval, argv[0]); | |
2452 | ||
2453 | ospf->min_ls_interval = interval; | |
2454 | ||
2455 | return CMD_SUCCESS; | |
2456 | } | |
2457 | ||
2458 | DEFUN (no_ospf_timers_min_ls_interval, | |
2459 | no_ospf_timers_min_ls_interval_cmd, | |
2460 | "no timers throttle lsa all", | |
2461 | NO_STR | |
2462 | "Adjust routing timers\n" | |
2463 | "Throttling adaptive timer\n" | |
2464 | "LSA delay between transmissions\n") | |
2465 | { | |
2466 | struct ospf *ospf = vty->index; | |
2467 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; | |
2468 | ||
2469 | return CMD_SUCCESS; | |
2470 | } | |
2471 | ||
2472 | DEFUN (ospf_timers_min_ls_arrival, | |
2473 | ospf_timers_min_ls_arrival_cmd, | |
2474 | "timers lsa arrival <0-1000>", | |
2475 | "Adjust routing timers\n" | |
2476 | "Throttling link state advertisement delays\n" | |
2477 | "OSPF minimum arrival interval delay\n" | |
2478 | "Delay (msec) between accepted LSAs\n") | |
2479 | { | |
2480 | struct ospf *ospf = vty->index; | |
2481 | unsigned int arrival; | |
2482 | ||
2483 | if (argc != 1) | |
2484 | { | |
2485 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2486 | return CMD_WARNING; | |
2487 | } | |
2488 | ||
2489 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); | |
2490 | ||
2491 | ospf->min_ls_arrival = arrival; | |
2492 | ||
2493 | return CMD_SUCCESS; | |
2494 | } | |
2495 | ||
2496 | DEFUN (no_ospf_timers_min_ls_arrival, | |
2497 | no_ospf_timers_min_ls_arrival_cmd, | |
2498 | "no timers lsa arrival", | |
2499 | NO_STR | |
2500 | "Adjust routing timers\n" | |
2501 | "Throttling link state advertisement delays\n" | |
2502 | "OSPF minimum arrival interval delay\n") | |
2503 | { | |
2504 | struct ospf *ospf = vty->index; | |
2505 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; | |
2506 | ||
2507 | return CMD_SUCCESS; | |
2508 | } | |
2509 | ||
d24f6e2a | 2510 | DEFUN (ospf_timers_throttle_spf, |
2511 | ospf_timers_throttle_spf_cmd, | |
2512 | "timers throttle spf <0-600000> <0-600000> <0-600000>", | |
2513 | "Adjust routing timers\n" | |
2514 | "Throttling adaptive timer\n" | |
2515 | "OSPF SPF timers\n" | |
2516 | "Delay (msec) from first change received till SPF calculation\n" | |
2517 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2518 | "Maximum hold time (msec)\n") | |
2519 | { | |
2520 | unsigned int delay, hold, max; | |
2521 | ||
2522 | if (argc != 3) | |
2523 | { | |
2524 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2525 | return CMD_WARNING; | |
2526 | } | |
2527 | ||
2528 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); | |
2529 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); | |
2530 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); | |
2531 | ||
2532 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2533 | } | |
2534 | ||
2535 | DEFUN_DEPRECATED (ospf_timers_spf, | |
a2c62831 | 2536 | ospf_timers_spf_cmd, |
718e3744 | 2537 | "timers spf <0-4294967295> <0-4294967295>", |
2538 | "Adjust routing timers\n" | |
2539 | "OSPF SPF timers\n" | |
d24f6e2a | 2540 | "Delay (s) between receiving a change to SPF calculation\n" |
2541 | "Hold time (s) between consecutive SPF calculations\n") | |
718e3744 | 2542 | { |
d24f6e2a | 2543 | unsigned int delay, hold; |
2544 | ||
2545 | if (argc != 2) | |
2546 | { | |
2547 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2548 | return CMD_WARNING; | |
2549 | } | |
2550 | ||
4dadc291 | 2551 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
2552 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); | |
d24f6e2a | 2553 | |
2554 | /* truncate down the second values if they're greater than 600000ms */ | |
2555 | if (delay > (600000 / 1000)) | |
2556 | delay = 600000; | |
2557 | else if (delay == 0) | |
2558 | /* 0s delay was probably specified because of lack of ms resolution */ | |
2559 | delay = OSPF_SPF_DELAY_DEFAULT; | |
2560 | if (hold > (600000 / 1000)) | |
2561 | hold = 600000; | |
2562 | ||
2563 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); | |
718e3744 | 2564 | } |
2565 | ||
d24f6e2a | 2566 | DEFUN (no_ospf_timers_throttle_spf, |
2567 | no_ospf_timers_throttle_spf_cmd, | |
2568 | "no timers throttle spf", | |
718e3744 | 2569 | NO_STR |
2570 | "Adjust routing timers\n" | |
d24f6e2a | 2571 | "Throttling adaptive timer\n" |
718e3744 | 2572 | "OSPF SPF timers\n") |
2573 | { | |
d24f6e2a | 2574 | return ospf_timers_spf_set (vty, |
2575 | OSPF_SPF_DELAY_DEFAULT, | |
2576 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2577 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2578 | } |
2579 | ||
b4a039bf DS |
2580 | ALIAS (no_ospf_timers_throttle_spf, |
2581 | no_ospf_timers_throttle_spf_val_cmd, | |
2582 | "no timers throttle spf <0-60000> <0-60000> <0-60000>", | |
2583 | NO_STR | |
2584 | "Adjust routing timers\n" | |
2585 | "Throttling adaptive timer\n" | |
2586 | "OSPF SPF timers\n" | |
2587 | "Delay (msec) from first change received till SPF calculation\n" | |
2588 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2589 | "Maximum hold time (msec)\n") | |
2590 | ||
d24f6e2a | 2591 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
2592 | no_ospf_timers_spf_cmd, | |
2593 | "no timers spf", | |
2594 | NO_STR | |
2595 | "Adjust routing timers\n" | |
2596 | "OSPF SPF timers\n") | |
6b0655a2 | 2597 | |
b6927875 DS |
2598 | DEFUN (ospf_timers_lsa, |
2599 | ospf_timers_lsa_cmd, | |
2600 | "timers lsa min-arrival <0-600000>", | |
2601 | "Adjust routing timers\n" | |
2602 | "OSPF LSA timers\n" | |
2603 | "Minimum delay in receiving new version of a LSA\n" | |
2604 | "Delay in milliseconds\n") | |
2605 | { | |
2606 | unsigned int minarrival; | |
2607 | struct ospf *ospf = vty->index; | |
2608 | ||
2609 | if (!ospf) | |
2610 | return CMD_SUCCESS; | |
2611 | ||
2612 | if (argc != 1) | |
2613 | { | |
2614 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2615 | return CMD_WARNING; | |
2616 | } | |
2617 | ||
2618 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2619 | ||
ac7424f9 | 2620 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2621 | |
2622 | return CMD_SUCCESS; | |
2623 | } | |
2624 | ||
2625 | DEFUN (no_ospf_timers_lsa, | |
2626 | no_ospf_timers_lsa_cmd, | |
2627 | "no timers lsa min-arrival", | |
2628 | NO_STR | |
2629 | "Adjust routing timers\n" | |
2630 | "OSPF LSA timers\n" | |
2631 | "Minimum delay in receiving new version of a LSA\n") | |
2632 | { | |
2633 | unsigned int minarrival; | |
2634 | struct ospf *ospf = vty->index; | |
2635 | ||
2636 | if (!ospf) | |
2637 | return CMD_SUCCESS; | |
2638 | ||
2639 | if (argc) | |
2640 | { | |
2641 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2642 | ||
ac7424f9 | 2643 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2644 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2645 | return CMD_SUCCESS; | |
2646 | } | |
2647 | ||
ac7424f9 | 2648 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2649 | |
2650 | return CMD_SUCCESS; | |
2651 | } | |
2652 | ||
2653 | ALIAS (no_ospf_timers_lsa, | |
2654 | no_ospf_timers_lsa_val_cmd, | |
2655 | "no timers lsa min-arrival <0-600000>", | |
2656 | NO_STR | |
2657 | "Adjust routing timers\n" | |
2658 | "OSPF LSA timers\n" | |
2659 | "Minimum delay in receiving new version of a LSA\n" | |
2660 | "Delay in milliseconds\n") | |
2661 | ||
2662 | ||
a2c62831 | 2663 | DEFUN (ospf_neighbor, |
2664 | ospf_neighbor_cmd, | |
718e3744 | 2665 | "neighbor A.B.C.D", |
2666 | NEIGHBOR_STR | |
2667 | "Neighbor IP address\n") | |
2668 | { | |
2669 | struct ospf *ospf = vty->index; | |
2670 | struct in_addr nbr_addr; | |
eb1ce605 | 2671 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2672 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2673 | |
7c8ff89e DS |
2674 | if (!ospf) |
2675 | return CMD_SUCCESS; | |
2676 | ||
718e3744 | 2677 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2678 | ||
2679 | if (argc > 1) | |
2680 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); | |
2681 | ||
2682 | if (argc > 2) | |
2683 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); | |
2684 | ||
2685 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2686 | if (argc > 1) | |
2687 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2688 | if (argc > 2) | |
1a61ad10 | 2689 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2690 | |
2691 | return CMD_SUCCESS; | |
2692 | } | |
2693 | ||
a2c62831 | 2694 | ALIAS (ospf_neighbor, |
2695 | ospf_neighbor_priority_poll_interval_cmd, | |
718e3744 | 2696 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2697 | NEIGHBOR_STR | |
2698 | "Neighbor IP address\n" | |
2699 | "Neighbor Priority\n" | |
2700 | "Priority\n" | |
2701 | "Dead Neighbor Polling interval\n" | |
2702 | "Seconds\n") | |
2703 | ||
a2c62831 | 2704 | ALIAS (ospf_neighbor, |
2705 | ospf_neighbor_priority_cmd, | |
718e3744 | 2706 | "neighbor A.B.C.D priority <0-255>", |
2707 | NEIGHBOR_STR | |
2708 | "Neighbor IP address\n" | |
2709 | "Neighbor Priority\n" | |
2710 | "Seconds\n") | |
2711 | ||
a2c62831 | 2712 | DEFUN (ospf_neighbor_poll_interval, |
2713 | ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2714 | "neighbor A.B.C.D poll-interval <1-65535>", |
2715 | NEIGHBOR_STR | |
2716 | "Neighbor IP address\n" | |
2717 | "Dead Neighbor Polling interval\n" | |
2718 | "Seconds\n") | |
2719 | { | |
2720 | struct ospf *ospf = vty->index; | |
2721 | struct in_addr nbr_addr; | |
eb1ce605 | 2722 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2723 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2724 | |
7c8ff89e DS |
2725 | if (!ospf) |
2726 | return CMD_SUCCESS; | |
2727 | ||
718e3744 | 2728 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2729 | ||
2730 | if (argc > 1) | |
2731 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); | |
2732 | ||
2733 | if (argc > 2) | |
2734 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); | |
2735 | ||
2736 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2737 | if (argc > 1) | |
2738 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); | |
2739 | if (argc > 2) | |
2740 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2741 | ||
2742 | return CMD_SUCCESS; | |
2743 | } | |
2744 | ||
a2c62831 | 2745 | ALIAS (ospf_neighbor_poll_interval, |
2746 | ospf_neighbor_poll_interval_priority_cmd, | |
718e3744 | 2747 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
2748 | NEIGHBOR_STR | |
2749 | "Neighbor address\n" | |
2750 | "OSPF dead-router polling interval\n" | |
2751 | "Seconds\n" | |
2752 | "OSPF priority of non-broadcast neighbor\n" | |
2753 | "Priority\n") | |
2754 | ||
a2c62831 | 2755 | DEFUN (no_ospf_neighbor, |
2756 | no_ospf_neighbor_cmd, | |
718e3744 | 2757 | "no neighbor A.B.C.D", |
2758 | NO_STR | |
2759 | NEIGHBOR_STR | |
2760 | "Neighbor IP address\n") | |
2761 | { | |
2762 | struct ospf *ospf = vty->index; | |
2763 | struct in_addr nbr_addr; | |
718e3744 | 2764 | |
7c8ff89e DS |
2765 | if (!ospf) |
2766 | return CMD_SUCCESS; | |
2767 | ||
718e3744 | 2768 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2769 | ||
0798cee3 | 2770 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2771 | |
2772 | return CMD_SUCCESS; | |
2773 | } | |
2774 | ||
a2c62831 | 2775 | ALIAS (no_ospf_neighbor, |
2776 | no_ospf_neighbor_priority_cmd, | |
718e3744 | 2777 | "no neighbor A.B.C.D priority <0-255>", |
2778 | NO_STR | |
2779 | NEIGHBOR_STR | |
2780 | "Neighbor IP address\n" | |
2781 | "Neighbor Priority\n" | |
2782 | "Priority\n") | |
2783 | ||
a2c62831 | 2784 | ALIAS (no_ospf_neighbor, |
2785 | no_ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2786 | "no neighbor A.B.C.D poll-interval <1-65535>", |
2787 | NO_STR | |
2788 | NEIGHBOR_STR | |
2789 | "Neighbor IP address\n" | |
2790 | "Dead Neighbor Polling interval\n" | |
2791 | "Seconds\n") | |
2792 | ||
a2c62831 | 2793 | ALIAS (no_ospf_neighbor, |
2794 | no_ospf_neighbor_priority_pollinterval_cmd, | |
718e3744 | 2795 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2796 | NO_STR | |
2797 | NEIGHBOR_STR | |
2798 | "Neighbor IP address\n" | |
2799 | "Neighbor Priority\n" | |
2800 | "Priority\n" | |
2801 | "Dead Neighbor Polling interval\n" | |
2802 | "Seconds\n") | |
2803 | ||
6b0655a2 | 2804 | |
a2c62831 | 2805 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
718e3744 | 2806 | "refresh timer <10-1800>", |
2807 | "Adjust refresh parameters\n" | |
2808 | "Set refresh timer\n" | |
2809 | "Timer value in seconds\n") | |
2810 | { | |
2811 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2812 | unsigned int interval; |
718e3744 | 2813 | |
7c8ff89e DS |
2814 | if (!ospf) |
2815 | return CMD_SUCCESS; | |
2816 | ||
718e3744 | 2817 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
2818 | interval = (interval / 10) * 10; | |
2819 | ||
2820 | ospf_timers_refresh_set (ospf, interval); | |
2821 | ||
2822 | return CMD_SUCCESS; | |
2823 | } | |
2824 | ||
a2c62831 | 2825 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
718e3744 | 2826 | "no refresh timer <10-1800>", |
2827 | "Adjust refresh parameters\n" | |
2828 | "Unset refresh timer\n" | |
2829 | "Timer value in seconds\n") | |
2830 | { | |
2831 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2832 | unsigned int interval; |
718e3744 | 2833 | |
7c8ff89e DS |
2834 | if (!ospf) |
2835 | return CMD_SUCCESS; | |
2836 | ||
718e3744 | 2837 | if (argc == 1) |
2838 | { | |
2839 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); | |
2840 | ||
2841 | if (ospf->lsa_refresh_interval != interval || | |
2842 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2843 | return CMD_SUCCESS; | |
2844 | } | |
2845 | ||
2846 | ospf_timers_refresh_unset (ospf); | |
2847 | ||
2848 | return CMD_SUCCESS; | |
2849 | } | |
2850 | ||
a2c62831 | 2851 | ALIAS (no_ospf_refresh_timer, |
2852 | no_ospf_refresh_timer_cmd, | |
718e3744 | 2853 | "no refresh timer", |
2854 | "Adjust refresh parameters\n" | |
2855 | "Unset refresh timer\n") | |
2856 | ||
a2c62831 | 2857 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2858 | ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2859 | "auto-cost reference-bandwidth <1-4294967>", |
2860 | "Calculate OSPF interface cost according to bandwidth\n" | |
2861 | "Use reference bandwidth method to assign OSPF cost\n" | |
2862 | "The reference bandwidth in terms of Mbits per second\n") | |
2863 | { | |
68980084 | 2864 | struct ospf *ospf = vty->index; |
718e3744 | 2865 | u_int32_t refbw; |
52dc7ee6 | 2866 | struct listnode *node; |
1eb8ef25 | 2867 | struct interface *ifp; |
718e3744 | 2868 | |
7c8ff89e DS |
2869 | if (!ospf) |
2870 | return CMD_SUCCESS; | |
2871 | ||
718e3744 | 2872 | refbw = strtol (argv[0], NULL, 10); |
2873 | if (refbw < 1 || refbw > 4294967) | |
2874 | { | |
2875 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2876 | return CMD_WARNING; | |
2877 | } | |
2878 | ||
2879 | /* If reference bandwidth is changed. */ | |
68980084 | 2880 | if ((refbw * 1000) == ospf->ref_bandwidth) |
718e3744 | 2881 | return CMD_SUCCESS; |
2882 | ||
68980084 | 2883 | ospf->ref_bandwidth = refbw * 1000; |
1eb8ef25 | 2884 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2885 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2886 | |
2887 | return CMD_SUCCESS; | |
2888 | } | |
2889 | ||
a2c62831 | 2890 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2891 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2892 | "no auto-cost reference-bandwidth", |
2893 | NO_STR | |
2894 | "Calculate OSPF interface cost according to bandwidth\n" | |
2895 | "Use reference bandwidth method to assign OSPF cost\n") | |
2896 | { | |
68980084 | 2897 | struct ospf *ospf = vty->index; |
1eb8ef25 | 2898 | struct listnode *node, *nnode; |
2899 | struct interface *ifp; | |
718e3744 | 2900 | |
7c8ff89e DS |
2901 | if (!ospf) |
2902 | return CMD_SUCCESS; | |
2903 | ||
68980084 | 2904 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2905 | return CMD_SUCCESS; |
2906 | ||
68980084 | 2907 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2908 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2909 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2910 | ||
1eb8ef25 | 2911 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2912 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2913 | |
2914 | return CMD_SUCCESS; | |
2915 | } | |
2916 | ||
2f8f370e DS |
2917 | DEFUN (ospf_write_multiplier, |
2918 | ospf_write_multiplier_cmd, | |
e8f45e82 DS |
2919 | "ospf write-multiplier <1-100>", |
2920 | "OSPF specific commands\n" | |
2921 | "Write multiplier\n" | |
2922 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2923 | { |
2924 | struct ospf *ospf = vty->index; | |
e8f45e82 | 2925 | u_int32_t write_oi_count; |
2f8f370e | 2926 | |
7c8ff89e DS |
2927 | if (!ospf) |
2928 | return CMD_SUCCESS; | |
2929 | ||
e8f45e82 DS |
2930 | write_oi_count = strtol (argv[0], NULL, 10); |
2931 | if (write_oi_count < 1 || write_oi_count > 100) | |
2f8f370e DS |
2932 | { |
2933 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2934 | return CMD_WARNING; | |
2935 | } | |
2936 | ||
e8f45e82 | 2937 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2938 | return CMD_SUCCESS; |
2939 | } | |
2940 | ||
e8f45e82 DS |
2941 | ALIAS (ospf_write_multiplier, |
2942 | write_multiplier_cmd, | |
2943 | "write-multiplier <1-100>", | |
2944 | "Write multiplier\n" | |
2945 | "Maximum number of interface serviced per write\n") | |
2946 | ||
2f8f370e DS |
2947 | DEFUN (no_ospf_write_multiplier, |
2948 | no_ospf_write_multiplier_cmd, | |
e8f45e82 | 2949 | "no ospf write-multiplier", |
2f8f370e | 2950 | NO_STR |
e8f45e82 DS |
2951 | "OSPF specific commands\n" |
2952 | "Write multiplier\n") | |
2f8f370e DS |
2953 | { |
2954 | struct ospf *ospf = vty->index; | |
2955 | ||
7c8ff89e DS |
2956 | if (!ospf) |
2957 | return CMD_SUCCESS; | |
2958 | ||
e8f45e82 | 2959 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
2960 | return CMD_SUCCESS; |
2961 | } | |
2962 | ||
e8f45e82 DS |
2963 | ALIAS (no_ospf_write_multiplier, |
2964 | no_write_multiplier_cmd, | |
2965 | "no write-multiplier", | |
2966 | NO_STR | |
2967 | "Write multiplier\n") | |
2968 | ||
eb1ce605 | 2969 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 2970 | { |
2971 | "Unknown", | |
2972 | "Standard (RFC2328)", | |
2973 | "Alternative IBM", | |
2974 | "Alternative Cisco", | |
2975 | "Alternative Shortcut" | |
2976 | }; | |
2977 | ||
eb1ce605 | 2978 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 2979 | { |
2980 | "Default", | |
2981 | "Enabled", | |
2982 | "Disabled" | |
2983 | }; | |
2984 | ||
4dadc291 | 2985 | static void |
ca08c43d | 2986 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 2987 | { |
ca08c43d DS |
2988 | json_object *json_area = NULL; |
2989 | ||
2990 | if (use_json) | |
2991 | json_area = json_object_new_object(); | |
2992 | ||
718e3744 | 2993 | /* Show Area ID. */ |
ca08c43d DS |
2994 | if (!use_json) |
2995 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 2996 | |
2997 | /* Show Area type/mode. */ | |
2998 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
2999 | { |
3000 | if (use_json) | |
3001 | json_object_boolean_true_add(json_area, "backbone"); | |
3002 | else | |
3003 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
3004 | } | |
718e3744 | 3005 | else |
3006 | { | |
ca08c43d DS |
3007 | if (use_json) |
3008 | { | |
3009 | if (area->external_routing == OSPF_AREA_STUB) | |
3010 | { | |
3011 | if (area->no_summary) | |
3012 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
3013 | if (area->shortcut_configured) | |
3014 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
3015 | } | |
3016 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3017 | { | |
3018 | if (area->no_summary) | |
3019 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
3020 | if (area->shortcut_configured) | |
3021 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
3022 | } | |
3023 | ||
3024 | json_object_string_add(json_area,"shortcuttingMode", | |
3025 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3026 | if (area->shortcut_capability) | |
3027 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
3028 | } | |
3029 | else | |
3030 | { | |
3031 | if (area->external_routing == OSPF_AREA_STUB) | |
3032 | vty_out (vty, " (Stub%s%s)", | |
3033 | area->no_summary ? ", no summary" : "", | |
3034 | area->shortcut_configured ? "; " : ""); | |
3035 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3036 | vty_out (vty, " (NSSA%s%s)", | |
3037 | area->no_summary ? ", no summary" : "", | |
3038 | area->shortcut_configured ? "; " : ""); | |
3039 | ||
3040 | vty_out (vty, "%s", VTY_NEWLINE); | |
3041 | vty_out (vty, " Shortcutting mode: %s", | |
3042 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3043 | vty_out (vty, ", S-bit consensus: %s%s", | |
3044 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); | |
3045 | } | |
3046 | } | |
3047 | ||
3048 | /* Show number of interfaces */ | |
3049 | if (use_json) | |
3050 | { | |
3ac237f8 MS |
3051 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
3052 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 3053 | } |
ca08c43d DS |
3054 | else |
3055 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
3056 | "Active: %d%s", listcount (area->oiflist), | |
3057 | area->act_ints, VTY_NEWLINE); | |
718e3744 | 3058 | |
718e3744 | 3059 | if (area->external_routing == OSPF_AREA_NSSA) |
3060 | { | |
ca08c43d DS |
3061 | if (use_json) |
3062 | { | |
3063 | json_object_boolean_true_add(json_area, "nssa"); | |
3064 | if (! IS_OSPF_ABR (area->ospf)) | |
3065 | json_object_boolean_false_add(json_area, "abr"); | |
3066 | else if (area->NSSATranslatorState) | |
3067 | { | |
3068 | json_object_boolean_true_add(json_area, "abr"); | |
3069 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3070 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
3071 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3072 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
3073 | } | |
3074 | else | |
3075 | { | |
3076 | json_object_boolean_true_add(json_area, "abr"); | |
3077 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3078 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
3079 | else | |
3080 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
3081 | } | |
3082 | } | |
718e3744 | 3083 | else |
ca08c43d DS |
3084 | { |
3085 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
3086 | if (! IS_OSPF_ABR (area->ospf)) | |
3087 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
3088 | VTY_NEWLINE); | |
3089 | else if (area->NSSATranslatorState) | |
3090 | { | |
3091 | vty_out (vty, " We are an ABR and "); | |
3092 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3093 | vty_out (vty, "the NSSA Elected Translator. %s", | |
3094 | VTY_NEWLINE); | |
3095 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3096 | vty_out (vty, "always an NSSA Translator. %s", | |
3097 | VTY_NEWLINE); | |
3098 | } | |
3099 | else | |
3100 | { | |
3101 | vty_out (vty, " We are an ABR, but "); | |
3102 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3103 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
3104 | VTY_NEWLINE); | |
3105 | else | |
3106 | vty_out (vty, "never an NSSA Translator. %s", | |
3107 | VTY_NEWLINE); | |
3108 | } | |
3109 | } | |
718e3744 | 3110 | } |
ca08c43d | 3111 | |
88d6cf37 | 3112 | /* Stub-router state for this area */ |
3113 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
3114 | { | |
649654ab | 3115 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3116 | |
3117 | if (use_json) | |
3118 | { | |
3119 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
3120 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3121 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
3122 | if (area->t_stub_router) | |
3123 | { | |
3124 | struct timeval result; | |
3125 | unsigned long time_store = 0; | |
3126 | result = tv_sub (area->t_stub_router->u.sands, recent_relative_time()); | |
3127 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3128 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); | |
3129 | } | |
3130 | } | |
3131 | else | |
3132 | { | |
3133 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
3134 | VTY_NEWLINE); | |
3135 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3136 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
3137 | VTY_NEWLINE); | |
3138 | if (area->t_stub_router) | |
3139 | vty_out (vty, " Active from startup, %s remaining%s", | |
3140 | ospf_timer_dump (area->t_stub_router, timebuf, | |
3141 | sizeof(timebuf)), VTY_NEWLINE); | |
3142 | } | |
3143 | } | |
3144 | ||
3145 | if (use_json) | |
3146 | { | |
3147 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 3148 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
3149 | |
3150 | /* Show authentication type. */ | |
3151 | if (area->auth_type == OSPF_AUTH_NULL) | |
3152 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
3153 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3154 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
3155 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3156 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
3157 | ||
3158 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 3159 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
3160 | |
3161 | /* Show SPF calculation times. */ | |
3ac237f8 | 3162 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
3163 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
3164 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
3165 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
3166 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
3167 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
3168 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
3169 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
3170 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3171 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3172 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
3173 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 3174 | } |
ca08c43d DS |
3175 | else |
3176 | { | |
3177 | /* Show number of fully adjacent neighbors. */ | |
3178 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
3179 | " %d%s", area->full_nbrs, VTY_NEWLINE); | |
3180 | ||
3181 | /* Show authentication type. */ | |
3182 | vty_out (vty, " Area has "); | |
3183 | if (area->auth_type == OSPF_AUTH_NULL) | |
3184 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
3185 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3186 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
3187 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3188 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
3189 | ||
3190 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3191 | vty_out (vty, " Number of full virtual adjacencies going through" | |
3192 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
3193 | ||
3194 | /* Show SPF calculation times. */ | |
3195 | vty_out (vty, " SPF algorithm executed %d times%s", | |
3196 | area->spf_calculation, VTY_NEWLINE); | |
3197 | ||
3198 | /* Show number of LSA. */ | |
3199 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
3200 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", | |
3201 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
3202 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
3203 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
3204 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
3205 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
3206 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
3207 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
3208 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
3209 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
3210 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
3211 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
3212 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
3213 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
3214 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
3215 | } | |
3216 | ||
fe71a97d | 3217 | #ifdef HAVE_OPAQUE_LSA |
ca08c43d DS |
3218 | if (use_json) |
3219 | { | |
3220 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3221 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3222 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3223 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3224 | } | |
3225 | else | |
3226 | { | |
3227 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
3228 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
3229 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
3230 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
3231 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
3232 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
3233 | } | |
fe71a97d | 3234 | #endif /* HAVE_OPAQUE_LSA */ |
ca08c43d DS |
3235 | |
3236 | if (use_json) | |
3237 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
3238 | else | |
3239 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 3240 | } |
3241 | ||
7c8ff89e | 3242 | static int |
ca08c43d | 3243 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3244 | { |
1eb8ef25 | 3245 | struct listnode *node, *nnode; |
718e3744 | 3246 | struct ospf_area * area; |
d24f6e2a | 3247 | struct timeval result; |
649654ab | 3248 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3249 | json_object *json = NULL; |
3250 | json_object *json_areas = NULL; | |
3251 | ||
3252 | if (use_json) | |
3253 | json = json_object_new_object(); | |
3254 | json_areas = json_object_new_object(); | |
718e3744 | 3255 | |
7c8ff89e | 3256 | if (ospf->instance) |
ca08c43d DS |
3257 | { |
3258 | if (use_json) | |
3259 | { | |
3260 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3261 | } | |
3262 | else | |
3263 | { | |
3264 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3265 | VTY_NEWLINE, VTY_NEWLINE); | |
3266 | } | |
3267 | } | |
718e3744 | 3268 | |
3269 | /* Show Router ID. */ | |
ca08c43d DS |
3270 | if (use_json) |
3271 | { | |
3272 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
3273 | } | |
3274 | else | |
3275 | { | |
3276 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
3277 | inet_ntoa (ospf->router_id), | |
3278 | VTY_NEWLINE); | |
3279 | } | |
7c8ff89e | 3280 | |
88d6cf37 | 3281 | /* Graceful shutdown */ |
c9c93d50 | 3282 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
3283 | { |
3284 | if (use_json) | |
3285 | { | |
3286 | unsigned long time_store = 0; | |
3287 | result = tv_sub (ospf->t_deferred_shutdown->u.sands, recent_relative_time()); | |
3288 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3289 | json_object_int_add(json, "deferredShutdownMsecs", time_store); | |
3290 | } | |
3291 | else | |
3292 | { | |
3293 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
3294 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
3295 | timebuf, sizeof (timebuf)), VTY_NEWLINE); | |
3296 | } | |
3297 | } | |
3298 | ||
718e3744 | 3299 | /* Show capability. */ |
ca08c43d DS |
3300 | if (use_json) |
3301 | { | |
3302 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
3303 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
3304 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
3305 | { | |
3306 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
3307 | } | |
3308 | } | |
3309 | else | |
3310 | { | |
3311 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
3312 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
3313 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
3314 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
3315 | "enabled" : "disabled", VTY_NEWLINE); | |
3316 | } | |
3317 | ||
718e3744 | 3318 | #ifdef HAVE_OPAQUE_LSA |
ca08c43d DS |
3319 | if (use_json) |
3320 | { | |
3321 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
3322 | { | |
3323 | json_object_boolean_true_add(json, "opaqueCapable"); | |
3324 | } | |
3325 | if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque)) | |
3326 | { | |
3327 | json_object_boolean_true_add(json, "lsaOpaqueOriginationBlocked"); | |
3328 | } | |
3329 | } | |
3330 | else | |
3331 | { | |
3332 | vty_out (vty, " OpaqueCapability flag is %s%s%s", | |
3333 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", | |
3334 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? " (origination blocked)" : "", | |
3335 | VTY_NEWLINE); | |
3336 | } | |
718e3744 | 3337 | #endif /* HAVE_OPAQUE_LSA */ |
ca08c43d | 3338 | |
88d6cf37 | 3339 | /* Show stub-router configuration */ |
3340 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3341 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3342 | { | |
ca08c43d DS |
3343 | if (use_json) |
3344 | { | |
3345 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3346 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3347 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3348 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3349 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3350 | } | |
3351 | else | |
3352 | { | |
3353 | vty_out (vty, " Stub router advertisement is configured%s", | |
3354 | VTY_NEWLINE); | |
3355 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3356 | vty_out (vty, " Enabled for %us after start-up%s", | |
3357 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3358 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3359 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3360 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3361 | } | |
88d6cf37 | 3362 | } |
ca08c43d | 3363 | |
718e3744 | 3364 | /* Show SPF timers. */ |
ca08c43d DS |
3365 | if (use_json) |
3366 | { | |
3367 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3368 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3369 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3370 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3371 | } |
3372 | else | |
ca08c43d DS |
3373 | { |
3374 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3375 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3376 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3377 | " Hold time multiplier is currently %d%s", | |
3378 | ospf->spf_delay, VTY_NEWLINE, | |
3379 | ospf->spf_holdtime, VTY_NEWLINE, | |
3380 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3381 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
3382 | } | |
b6927875 | 3383 | |
ca08c43d DS |
3384 | if (use_json) |
3385 | { | |
3386 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3387 | { | |
3388 | unsigned long time_store = 0; | |
3389 | ||
3390 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3391 | result = tv_sub (result, recent_relative_time()); | |
3392 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3393 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); | |
3394 | ||
3395 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3396 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3397 | } | |
3398 | else | |
3399 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3400 | } | |
3401 | else | |
3402 | { | |
3403 | vty_out (vty, " SPF algorithm "); | |
3404 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3405 | { | |
3406 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3407 | vty_out (vty, "last executed %s ago%s", | |
3408 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3409 | VTY_NEWLINE); | |
3410 | vty_out (vty, " Last SPF duration %s%s", | |
3411 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3412 | VTY_NEWLINE); | |
3413 | } | |
3414 | else | |
3415 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
3416 | } | |
3417 | ||
3418 | if (use_json) | |
3419 | { | |
3420 | struct timeval temp_time; | |
3421 | unsigned long time_store = 0; | |
3422 | ||
3423 | if (ospf->t_spf_calc) | |
3424 | { | |
3425 | temp_time = tv_sub (ospf->t_spf_calc->u.sands, recent_relative_time()); | |
3426 | time_store = (1000 * temp_time.tv_sec) + (temp_time.tv_usec / 1000); | |
3427 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); | |
3428 | } | |
3429 | ||
ac7424f9 MR |
3430 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3431 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3432 | /* Show write multiplier values */ |
3433 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3434 | /* Show refresh parameters. */ | |
3435 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval / 1000); | |
3436 | } | |
3437 | else | |
3438 | { | |
3439 | vty_out (vty, " SPF timer %s%s%s", | |
3440 | (ospf->t_spf_calc ? "due in " : "is "), | |
3441 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3442 | VTY_NEWLINE); | |
3443 | ||
ac7424f9 MR |
3444 | vty_out (vty, " LSA minimum interval %d msecs%s", |
3445 | ospf->min_ls_interval, VTY_NEWLINE); | |
ca08c43d | 3446 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
ac7424f9 | 3447 | ospf->min_ls_arrival, VTY_NEWLINE); |
ca08c43d DS |
3448 | |
3449 | /* Show write multiplier values */ | |
3450 | vty_out (vty, " Write Multiplier set to %d %s", | |
3451 | ospf->write_oi_count, VTY_NEWLINE); | |
3452 | ||
3453 | /* Show refresh parameters. */ | |
3454 | vty_out (vty, " Refresh timer %d secs%s", | |
3455 | ospf->lsa_refresh_interval, VTY_NEWLINE); | |
3456 | } | |
2f8f370e | 3457 | |
718e3744 | 3458 | /* Show ABR/ASBR flags. */ |
68980084 | 3459 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3460 | { |
3461 | if (use_json) | |
3462 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3463 | else | |
3464 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
3465 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); | |
3466 | } | |
68980084 | 3467 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3468 | { |
3469 | if (use_json) | |
3470 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3471 | else | |
3472 | vty_out (vty, " This router is an ASBR " | |
3473 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3474 | } | |
718e3744 | 3475 | |
3476 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3477 | if (use_json) |
3478 | { | |
3ac237f8 | 3479 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3480 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3481 | json_object_int_add(json, "lsaExternalChecksum", | |
3482 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3483 | } | |
3484 | else | |
3485 | { | |
3486 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3487 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3488 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3489 | } | |
3490 | ||
fe71a97d | 3491 | #ifdef HAVE_OPAQUE_LSA |
ca08c43d DS |
3492 | if (use_json) |
3493 | { | |
3ac237f8 | 3494 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3495 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3496 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3497 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3498 | } | |
3499 | else | |
3500 | { | |
3501 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3502 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3503 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3504 | } | |
fe71a97d | 3505 | #endif /* HAVE_OPAQUE_LSA */ |
ca08c43d | 3506 | |
718e3744 | 3507 | /* Show number of areas attached. */ |
ca08c43d | 3508 | if (use_json) |
3ac237f8 | 3509 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3510 | else |
3511 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
3512 | listcount (ospf->areas), VTY_NEWLINE); | |
d7e60dd7 AS |
3513 | |
3514 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3515 | { | |
3516 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3517 | { |
3518 | if (use_json) | |
3519 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3520 | else | |
3521 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3522 | } | |
d7e60dd7 | 3523 | else |
ca08c43d DS |
3524 | { |
3525 | if (use_json) | |
3526 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3527 | else | |
3528 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3529 | } | |
d7e60dd7 | 3530 | } |
718e3744 | 3531 | /* Show each area status. */ |
1eb8ef25 | 3532 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3533 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3534 | ||
3535 | if (use_json) | |
3536 | { | |
3537 | json_object_object_add(json, "areas", json_areas); | |
3538 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
3539 | json_object_free(json); | |
3540 | } | |
3541 | else | |
3542 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3543 | |
3544 | return CMD_SUCCESS; | |
3545 | } | |
3546 | ||
7c8ff89e DS |
3547 | DEFUN (show_ip_ospf, |
3548 | show_ip_ospf_cmd, | |
ca08c43d | 3549 | "show ip ospf {json}", |
7c8ff89e DS |
3550 | SHOW_STR |
3551 | IP_STR | |
ca08c43d DS |
3552 | "OSPF information\n" |
3553 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3554 | { |
3555 | struct ospf *ospf; | |
ca08c43d | 3556 | u_char use_json = (argv[0] != NULL); |
7c8ff89e | 3557 | |
0bad4851 | 3558 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3559 | return CMD_SUCCESS; |
3560 | ||
ca08c43d | 3561 | return (show_ip_ospf_common(vty, ospf, use_json)); |
7c8ff89e DS |
3562 | } |
3563 | ||
3564 | DEFUN (show_ip_ospf_instance, | |
3565 | show_ip_ospf_instance_cmd, | |
ca08c43d | 3566 | "show ip ospf <1-65535> {json}", |
7c8ff89e DS |
3567 | SHOW_STR |
3568 | IP_STR | |
3569 | "OSPF information\n" | |
ca08c43d DS |
3570 | "Instance ID\n" |
3571 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3572 | { |
3573 | struct ospf *ospf; | |
3574 | u_short instance = 0; | |
ca08c43d | 3575 | u_char use_json = (argv[1] != NULL); |
7c8ff89e DS |
3576 | |
3577 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3578 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3579 | return CMD_SUCCESS; |
3580 | ||
ca08c43d | 3581 | return (show_ip_ospf_common(vty, ospf, use_json)); |
7c8ff89e DS |
3582 | } |
3583 | ||
fd651fa6 | 3584 | static void |
7ec4159b DS |
3585 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3586 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3587 | { |
fd651fa6 | 3588 | int is_up; |
718e3744 | 3589 | struct ospf_neighbor *nbr; |
718e3744 | 3590 | struct route_node *rn; |
718e3744 | 3591 | |
718e3744 | 3592 | /* Is interface up? */ |
7ec4159b DS |
3593 | if (use_json) |
3594 | { | |
3595 | is_up = if_is_operative(ifp); | |
3596 | if (is_up) | |
3597 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3598 | else | |
3599 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3600 | ||
3601 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3602 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
3603 | json_object_int_add(json_interface_sub, "bandwidthKbit", ifp->bandwidth); | |
3604 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); | |
3605 | } | |
3606 | else | |
3607 | { | |
3608 | vty_out (vty, "%s is %s%s", ifp->name, | |
3609 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
3610 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", | |
3611 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), | |
3612 | VTY_NEWLINE); | |
3613 | } | |
718e3744 | 3614 | |
3615 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3616 | if (use_json) |
718e3744 | 3617 | { |
7ec4159b DS |
3618 | if (ospf_oi_count(ifp) == 0) |
3619 | { | |
3620 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3621 | return; | |
3622 | } | |
3623 | else if (!is_up) | |
3624 | { | |
3625 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3626 | return; | |
3627 | } | |
3628 | else | |
3629 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3630 | } |
7ec4159b | 3631 | else |
fd651fa6 | 3632 | { |
7ec4159b DS |
3633 | if (ospf_oi_count(ifp) == 0) |
3634 | { | |
3635 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3636 | return; | |
3637 | } | |
3638 | else if (!is_up) | |
3639 | { | |
3640 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3641 | VTY_NEWLINE); | |
3642 | return; | |
3643 | } | |
fd651fa6 | 3644 | } |
3645 | ||
718e3744 | 3646 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3647 | { | |
3648 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3649 | |
718e3744 | 3650 | if (oi == NULL) |
7ec4159b DS |
3651 | continue; |
3652 | ||
525c1839 DS |
3653 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3654 | { | |
7ec4159b DS |
3655 | if (use_json) |
3656 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3657 | else | |
3658 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3659 | } |
3660 | else | |
9c27ef9b | 3661 | { |
525c1839 | 3662 | /* Show OSPF interface information. */ |
7ec4159b DS |
3663 | if (use_json) |
3664 | { | |
3665 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3666 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3667 | } | |
3668 | else | |
3669 | vty_out (vty, " Internet Address %s/%d,", | |
3670 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3671 | |
3672 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3673 | { | |
3674 | struct in_addr *dest; | |
3675 | const char *dstr; | |
3676 | ||
3677 | if (CONNECTED_PEER(oi->connected) | |
3678 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3679 | dstr = "Peer"; | |
3680 | else | |
3681 | dstr = "Broadcast"; | |
3682 | ||
3683 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3684 | * * * * * informative than the local interface that is being used |
3685 | * * * * */ | |
525c1839 DS |
3686 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3687 | dest = &oi->vl_data->peer_addr; | |
3688 | else | |
3689 | dest = &oi->connected->destination->u.prefix4; | |
3690 | ||
7ec4159b DS |
3691 | if (use_json) |
3692 | { | |
3693 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3694 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3695 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3696 | else | |
3697 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3698 | } | |
3699 | else | |
3700 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3701 | } |
9c27ef9b | 3702 | } |
7ec4159b DS |
3703 | if (use_json) |
3704 | { | |
3705 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3706 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3707 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3708 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3709 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3710 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3711 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
3712 | json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state)); | |
3713 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); | |
3714 | } | |
3715 | else | |
3716 | { | |
3717 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), | |
3718 | VTY_NEWLINE); | |
3fb9cd6e | 3719 | |
7ec4159b DS |
3720 | vty_out (vty, " MTU mismatch detection:%s%s", |
3721 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
ba682537 | 3722 | |
7ec4159b DS |
3723 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
3724 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3725 | oi->output_cost, VTY_NEWLINE); | |
718e3744 | 3726 | |
7ec4159b DS |
3727 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
3728 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3729 | PRIORITY (oi), VTY_NEWLINE); | |
3730 | } | |
718e3744 | 3731 | |
3732 | /* Show DR information. */ | |
3733 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3734 | { |
3735 | if (!use_json) | |
3736 | vty_out (vty, " No backup designated router on this network%s", | |
3737 | VTY_NEWLINE); | |
3738 | } | |
718e3744 | 3739 | else |
7ec4159b DS |
3740 | { |
3741 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3742 | if (nbr == NULL) | |
3743 | { | |
3744 | if (!use_json) | |
3745 | vty_out (vty, " No backup designated router on this network%s", | |
3746 | VTY_NEWLINE); | |
3747 | } | |
3748 | else | |
3749 | { | |
3750 | if (use_json) | |
3751 | { | |
3752 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3753 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3754 | } | |
3755 | else | |
3756 | { | |
3757 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3758 | inet_ntoa (nbr->router_id)); | |
3759 | vty_out (vty, " Interface Address %s%s", | |
3760 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3761 | } | |
3762 | } | |
3763 | } | |
525c1839 | 3764 | |
7eb5b47e | 3765 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3766 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3767 | { |
7ec4159b DS |
3768 | if (use_json) |
3769 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3770 | else | |
3771 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3772 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3773 | } | |
3774 | ||
3775 | if (use_json) | |
3776 | { | |
3777 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3778 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3779 | { | |
3780 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3781 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3782 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3783 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3784 | } | |
429ac78c PJ |
3785 | } |
3786 | else | |
7ec4159b DS |
3787 | { |
3788 | vty_out (vty, " Multicast group memberships:"); | |
3789 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3790 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3791 | { | |
3792 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3793 | vty_out (vty, " OSPFAllRouters"); | |
3794 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3795 | vty_out (vty, " OSPFDesignatedRouters"); | |
3796 | } | |
3797 | else | |
3798 | vty_out (vty, " <None>"); | |
3799 | vty_out (vty, "%s", VTY_NEWLINE); | |
3800 | } | |
ba6454ec | 3801 | |
7ec4159b DS |
3802 | if (use_json) |
3803 | { | |
3804 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3805 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3806 | else | |
3807 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3808 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3809 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3810 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3811 | } | |
f9ad937f | 3812 | else |
7ec4159b DS |
3813 | { |
3814 | vty_out (vty, " Timer intervals configured,"); | |
3815 | vty_out (vty, " Hello "); | |
3816 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3817 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3818 | else | |
3819 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3820 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3821 | OSPF_IF_PARAM (oi, v_wait), | |
3822 | OSPF_IF_PARAM (oi, v_wait), | |
3823 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3824 | VTY_NEWLINE); | |
3825 | } | |
3826 | ||
7ffa8fa2 | 3827 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3828 | { |
7ec4159b DS |
3829 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3830 | if (use_json) | |
3831 | { | |
3832 | struct timeval result; | |
3833 | unsigned long time_store = 0; | |
3834 | result = tv_sub (oi->t_hello->u.sands, recent_relative_time()); | |
3835 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3836 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); | |
3837 | } | |
3838 | else | |
3839 | vty_out (vty, " Hello due in %s%s", | |
3840 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
3841 | VTY_NEWLINE); | |
f9ad937f | 3842 | } |
7ffa8fa2 | 3843 | else /* passive-interface is set */ |
7ec4159b DS |
3844 | { |
3845 | if (use_json) | |
3846 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3847 | else | |
3848 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); | |
3849 | } | |
3850 | ||
3851 | if (use_json) | |
3852 | { | |
3853 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3854 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3855 | } | |
3856 | else | |
3857 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3858 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
3859 | VTY_NEWLINE); | |
68fe91d6 | 3860 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3861 | } |
3862 | } | |
3863 | ||
7c8ff89e | 3864 | static int |
7ec4159b DS |
3865 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
3866 | const char **argv, int iface_argv, u_char use_json) | |
718e3744 | 3867 | { |
3868 | struct interface *ifp; | |
52dc7ee6 | 3869 | struct listnode *node; |
7ec4159b DS |
3870 | json_object *json = NULL; |
3871 | json_object *json_interface_sub = NULL; | |
3872 | ||
3873 | if (use_json) | |
3874 | { | |
3875 | json = json_object_new_object(); | |
3876 | json_interface_sub = json_object_new_object(); | |
3877 | } | |
718e3744 | 3878 | |
7c8ff89e | 3879 | if (ospf->instance) |
7ec4159b DS |
3880 | { |
3881 | if (use_json) | |
3882 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3883 | else | |
3884 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3885 | VTY_NEWLINE, VTY_NEWLINE); | |
3886 | } | |
7c8ff89e | 3887 | |
7ec4159b DS |
3888 | if (argc == (iface_argv + 1)) |
3889 | { | |
3890 | /* Show All Interfaces.*/ | |
3891 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) | |
3892 | { | |
3893 | if (ospf_oi_count(ifp)) | |
3894 | { | |
3895 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3896 | } | |
3897 | } | |
3898 | } | |
3899 | else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0) | |
cac3b5c4 | 3900 | { |
7c8ff89e DS |
3901 | /* Show All Interfaces. */ |
3902 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) | |
7ec4159b DS |
3903 | { |
3904 | if (ospf_oi_count(ifp)) | |
3905 | { | |
3906 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3907 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3908 | } | |
3909 | } | |
cac3b5c4 | 3910 | } |
718e3744 | 3911 | else |
3912 | { | |
7c8ff89e | 3913 | /* Interface name is specified. */ |
7ec4159b DS |
3914 | if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL) |
3915 | { | |
3916 | if (use_json) | |
3917 | json_object_boolean_true_add(json, "noSuchIface"); | |
3918 | else | |
3919 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
3920 | } | |
718e3744 | 3921 | else |
7ec4159b DS |
3922 | { |
3923 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3924 | if (use_json) | |
3925 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3926 | } | |
718e3744 | 3927 | } |
3928 | ||
7ec4159b DS |
3929 | if (use_json) |
3930 | { | |
3931 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
3932 | json_object_free(json); | |
3933 | } | |
3934 | else | |
3935 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3936 | |
718e3744 | 3937 | return CMD_SUCCESS; |
3938 | } | |
3939 | ||
7c8ff89e DS |
3940 | DEFUN (show_ip_ospf_interface, |
3941 | show_ip_ospf_interface_cmd, | |
7ec4159b | 3942 | "show ip ospf interface [INTERFACE] {json}", |
7c8ff89e DS |
3943 | SHOW_STR |
3944 | IP_STR | |
3945 | "OSPF information\n" | |
3946 | "Interface information\n" | |
7ec4159b DS |
3947 | "Interface name\n" |
3948 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3949 | { |
3950 | struct ospf *ospf; | |
7ec4159b DS |
3951 | u_char use_json; |
3952 | ||
3ac237f8 MS |
3953 | if ((argv[0] && strcmp(argv[0], "json") == 0) || |
3954 | (argv[1] && strcmp(argv[1], "json") == 0)) | |
7ec4159b DS |
3955 | use_json = 1; |
3956 | else | |
3957 | use_json = 0; | |
7c8ff89e | 3958 | |
0bad4851 | 3959 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3960 | return CMD_SUCCESS; |
3961 | ||
7ec4159b | 3962 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, use_json); |
7c8ff89e DS |
3963 | } |
3964 | ||
3965 | DEFUN (show_ip_ospf_instance_interface, | |
3966 | show_ip_ospf_instance_interface_cmd, | |
7ec4159b | 3967 | "show ip ospf <1-65535> interface [INTERFACE] {json}", |
7c8ff89e DS |
3968 | SHOW_STR |
3969 | IP_STR | |
3970 | "OSPF information\n" | |
3971 | "Instance ID\n" | |
3972 | "Interface information\n" | |
7ec4159b DS |
3973 | "Interface name\n" |
3974 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3975 | { |
3976 | struct ospf *ospf; | |
3977 | u_short instance = 0; | |
7ec4159b DS |
3978 | u_char use_json; |
3979 | ||
3ac237f8 MS |
3980 | if ((argv[1] && strcmp(argv[1], "json") == 0) || |
3981 | (argv[2] && strcmp(argv[2], "json") == 0)) | |
7ec4159b DS |
3982 | use_json = 1; |
3983 | else | |
3984 | use_json = 0; | |
7c8ff89e DS |
3985 | |
3986 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3987 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3988 | return CMD_SUCCESS; |
3989 | ||
7ec4159b | 3990 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, use_json); |
7c8ff89e DS |
3991 | } |
3992 | ||
d24f6e2a | 3993 | static void |
3994 | show_ip_ospf_neighbour_header (struct vty *vty) | |
3995 | { | |
490578f3 | 3996 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 3997 | VTY_NEWLINE, |
3998 | "Neighbor ID", "Pri", "State", "Dead Time", | |
3999 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
4000 | VTY_NEWLINE); | |
4001 | } | |
4002 | ||
4dadc291 | 4003 | static void |
91756b38 | 4004 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 4005 | { |
4006 | struct route_node *rn; | |
4007 | struct ospf_neighbor *nbr; | |
4008 | char msgbuf[16]; | |
649654ab | 4009 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 4010 | json_object *json_neighbor = NULL; |
718e3744 | 4011 | |
4012 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
4013 | { |
4014 | if ((nbr = rn->info)) | |
4015 | { | |
4016 | /* Do not show myself. */ | |
4017 | if (nbr != oi->nbr_self) | |
4018 | { | |
4019 | /* Down state is not shown. */ | |
4020 | if (nbr->state != NSM_Down) | |
4021 | { | |
4022 | if (use_json) | |
4023 | { | |
4024 | json_neighbor = json_object_new_object(); | |
4025 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4026 | ||
4027 | struct timeval result; | |
4028 | unsigned long time_store = 0; | |
4029 | ||
4030 | result = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time()); | |
4031 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
4032 | ||
4033 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
4034 | json_object_string_add (json_neighbor, "state", msgbuf); | |
4035 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
4036 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
4037 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4038 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
4039 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
4040 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
4041 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
4042 | json_object_object_add(json, "neighbor", json_neighbor); | |
4043 | else | |
4044 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
4045 | } | |
4046 | else | |
4047 | { | |
4048 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4049 | ||
4050 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4051 | vty_out (vty, "%-15s %3d %-15s ", | |
4052 | "-", nbr->priority, | |
4053 | msgbuf); | |
4054 | else | |
4055 | vty_out (vty, "%-15s %3d %-15s ", | |
4056 | inet_ntoa (nbr->router_id), nbr->priority, | |
4057 | msgbuf); | |
4058 | ||
4059 | vty_out (vty, "%9s ", | |
4060 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
4061 | sizeof(timebuf))); | |
4062 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
4063 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
4064 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
4065 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
4066 | VTY_NEWLINE); | |
4067 | } | |
4068 | } | |
4069 | } | |
4070 | } | |
4071 | } | |
718e3744 | 4072 | } |
4073 | ||
7c8ff89e | 4074 | static int |
91756b38 | 4075 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 4076 | { |
1eb8ef25 | 4077 | struct ospf_interface *oi; |
52dc7ee6 | 4078 | struct listnode *node; |
91756b38 | 4079 | json_object *json = NULL; |
718e3744 | 4080 | |
91756b38 DS |
4081 | if (use_json) |
4082 | json = json_object_new_object(); | |
4083 | else | |
4084 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 4085 | |
91756b38 DS |
4086 | if (ospf->instance) |
4087 | { | |
4088 | if (use_json) | |
4089 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4090 | else | |
4091 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4092 | VTY_NEWLINE, VTY_NEWLINE); | |
4093 | } | |
718e3744 | 4094 | |
1eb8ef25 | 4095 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 4096 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4097 | |
91756b38 DS |
4098 | if (use_json) |
4099 | { | |
4100 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4101 | json_object_free(json); | |
4102 | } | |
4103 | else | |
4104 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4105 | |
718e3744 | 4106 | return CMD_SUCCESS; |
4107 | } | |
4108 | ||
7c8ff89e DS |
4109 | DEFUN (show_ip_ospf_neighbor, |
4110 | show_ip_ospf_neighbor_cmd, | |
91756b38 | 4111 | "show ip ospf neighbor {json}", |
718e3744 | 4112 | SHOW_STR |
4113 | IP_STR | |
4114 | "OSPF information\n" | |
91756b38 DS |
4115 | "Neighbor list\n" |
4116 | "JavaScript Object Notation\n") | |
718e3744 | 4117 | { |
7c8ff89e | 4118 | struct ospf *ospf; |
91756b38 | 4119 | u_char use_json = (argv[0] != NULL); |
718e3744 | 4120 | |
0bad4851 | 4121 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4122 | return CMD_SUCCESS; |
4123 | ||
91756b38 | 4124 | return show_ip_ospf_neighbor_common(vty, ospf, use_json); |
7c8ff89e DS |
4125 | } |
4126 | ||
4127 | ||
4128 | DEFUN (show_ip_ospf_instance_neighbor, | |
4129 | show_ip_ospf_instance_neighbor_cmd, | |
91756b38 | 4130 | "show ip ospf <1-65535> neighbor {json}", |
7c8ff89e DS |
4131 | SHOW_STR |
4132 | IP_STR | |
4133 | "OSPF information\n" | |
4134 | "Instance ID\n" | |
91756b38 DS |
4135 | "Neighbor list\n" |
4136 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4137 | { |
4138 | struct ospf *ospf; | |
4139 | u_short instance = 0; | |
91756b38 | 4140 | u_char use_json = (argv[1] != NULL); |
7c8ff89e DS |
4141 | |
4142 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4143 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4144 | return CMD_SUCCESS; |
4145 | ||
91756b38 | 4146 | return show_ip_ospf_neighbor_common(vty, ospf, use_json); |
7c8ff89e DS |
4147 | } |
4148 | ||
4149 | static int | |
91756b38 | 4150 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
4151 | { |
4152 | struct listnode *node; | |
4153 | struct ospf_interface *oi; | |
91756b38 DS |
4154 | json_object *json = NULL; |
4155 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 4156 | |
91756b38 DS |
4157 | if (use_json) |
4158 | { | |
4159 | json = json_object_new_object(); | |
4160 | json_neighbor_sub = json_object_new_object(); | |
4161 | } | |
4162 | else | |
4163 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 4164 | |
91756b38 DS |
4165 | if (ospf->instance) |
4166 | { | |
4167 | if (use_json) | |
4168 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4169 | else | |
4170 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4171 | VTY_NEWLINE, VTY_NEWLINE); | |
4172 | } | |
7c8ff89e DS |
4173 | |
4174 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
4175 | { | |
52dc7ee6 | 4176 | struct listnode *nbr_node; |
1eb8ef25 | 4177 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4178 | |
91756b38 | 4179 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4180 | |
91756b38 DS |
4181 | /* print Down neighbor status */ |
4182 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
4183 | { | |
4184 | if (nbr_nbma->nbr == NULL | |
4185 | || nbr_nbma->nbr->state == NSM_Down) | |
4186 | { | |
4187 | if (use_json) | |
4188 | { | |
4189 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
4190 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
4191 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4192 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
4193 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
4194 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
4195 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
4196 | } | |
4197 | else | |
4198 | { | |
4199 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
4200 | "-", nbr_nbma->priority, "Down", "-"); | |
4201 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
4202 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
4203 | 0, 0, 0, VTY_NEWLINE); | |
4204 | } | |
4205 | } | |
4206 | } | |
718e3744 | 4207 | } |
4208 | ||
91756b38 DS |
4209 | if (use_json) |
4210 | { | |
4211 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4212 | json_object_free(json); | |
4213 | } | |
4214 | else | |
4215 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4216 | |
718e3744 | 4217 | return CMD_SUCCESS; |
4218 | } | |
4219 | ||
7c8ff89e DS |
4220 | DEFUN (show_ip_ospf_neighbor_all, |
4221 | show_ip_ospf_neighbor_all_cmd, | |
91756b38 | 4222 | "show ip ospf neighbor all {json}", |
718e3744 | 4223 | SHOW_STR |
4224 | IP_STR | |
4225 | "OSPF information\n" | |
4226 | "Neighbor list\n" | |
91756b38 DS |
4227 | "include down status neighbor\n" |
4228 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4229 | { |
4230 | struct ospf *ospf; | |
91756b38 | 4231 | u_char use_json = (argv[0] != NULL); |
7c8ff89e | 4232 | |
0bad4851 | 4233 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4234 | return CMD_SUCCESS; |
4235 | ||
91756b38 | 4236 | return show_ip_ospf_neighbor_all_common(vty, ospf, use_json); |
7c8ff89e DS |
4237 | } |
4238 | ||
4239 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
4240 | show_ip_ospf_instance_neighbor_all_cmd, | |
91756b38 | 4241 | "show ip ospf <1-65535> neighbor all {json}", |
7c8ff89e DS |
4242 | SHOW_STR |
4243 | IP_STR | |
4244 | "OSPF information\n" | |
4245 | "Instance ID\n" | |
4246 | "Neighbor list\n" | |
91756b38 DS |
4247 | "include down status neighbor\n" |
4248 | "JavaScript Object Notation\n") | |
718e3744 | 4249 | { |
020709f9 | 4250 | struct ospf *ospf; |
7c8ff89e | 4251 | u_short instance = 0; |
91756b38 | 4252 | u_char use_json = (argv[1] != NULL); |
7c8ff89e DS |
4253 | |
4254 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4255 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4256 | return CMD_SUCCESS; |
4257 | ||
91756b38 | 4258 | return show_ip_ospf_neighbor_all_common(vty, ospf, use_json); |
7c8ff89e DS |
4259 | } |
4260 | ||
4261 | static int | |
4262 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
91756b38 | 4263 | const char **argv, u_char use_json) |
7c8ff89e | 4264 | { |
bb5b7552 | 4265 | struct interface *ifp; |
4266 | struct route_node *rn; | |
91756b38 DS |
4267 | json_object *json = NULL; |
4268 | ||
4269 | if (use_json) | |
4270 | json = json_object_new_object(); | |
4271 | else | |
4272 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
4273 | |
4274 | if (ospf->instance) | |
91756b38 DS |
4275 | { |
4276 | if (use_json) | |
4277 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4278 | else | |
4279 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4280 | VTY_NEWLINE, VTY_NEWLINE); | |
4281 | } | |
7c8ff89e | 4282 | |
91756b38 | 4283 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4284 | if (!ifp) |
718e3744 | 4285 | { |
91756b38 DS |
4286 | if (use_json) |
4287 | json_object_boolean_true_add(json, "noSuchIface"); | |
4288 | else | |
4289 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4290 | return CMD_WARNING; |
4291 | } | |
d24f6e2a | 4292 | |
bb5b7552 | 4293 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 4294 | { |
bb5b7552 | 4295 | struct ospf_interface *oi = rn->info; |
4296 | ||
4297 | if (oi == NULL) | |
91756b38 | 4298 | continue; |
bb5b7552 | 4299 | |
91756b38 | 4300 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4301 | } |
4302 | ||
91756b38 DS |
4303 | if (use_json) |
4304 | { | |
4305 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4306 | json_object_free(json); | |
4307 | } | |
4308 | else | |
4309 | vty_out (vty, "%s", VTY_NEWLINE); | |
4310 | ||
718e3744 | 4311 | return CMD_SUCCESS; |
4312 | } | |
4313 | ||
7c8ff89e DS |
4314 | DEFUN (show_ip_ospf_neighbor_int, |
4315 | show_ip_ospf_neighbor_int_cmd, | |
91756b38 | 4316 | "show ip ospf neighbor IFNAME {json}", |
7c8ff89e DS |
4317 | SHOW_STR |
4318 | IP_STR | |
4319 | "OSPF information\n" | |
4320 | "Neighbor list\n" | |
91756b38 DS |
4321 | "Interface name\n" |
4322 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4323 | { |
4324 | struct ospf *ospf; | |
3ac237f8 | 4325 | u_char use_json = (argv[1] != NULL); |
7c8ff89e | 4326 | |
0bad4851 | 4327 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4328 | return CMD_SUCCESS; |
4329 | ||
91756b38 | 4330 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, use_json); |
7c8ff89e DS |
4331 | } |
4332 | ||
4333 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
4334 | show_ip_ospf_instance_neighbor_int_cmd, | |
91756b38 | 4335 | "show ip ospf <1-65535> neighbor IFNAME {json}", |
7c8ff89e DS |
4336 | SHOW_STR |
4337 | IP_STR | |
4338 | "OSPF information\n" | |
4339 | "Instance ID\n" | |
4340 | "Neighbor list\n" | |
91756b38 DS |
4341 | "Interface name\n" |
4342 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4343 | { |
4344 | struct ospf *ospf; | |
4345 | u_short instance = 0; | |
3ac237f8 | 4346 | u_char use_json = (argv[2] != NULL); |
7c8ff89e DS |
4347 | |
4348 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4349 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4350 | return CMD_SUCCESS; |
4351 | ||
91756b38 | 4352 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, use_json); |
7c8ff89e DS |
4353 | } |
4354 | ||
4dadc291 | 4355 | static void |
3ac237f8 MS |
4356 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4357 | u_char use_json, json_object *json) | |
718e3744 | 4358 | { |
649654ab | 4359 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4360 | json_object *json_sub = NULL; |
718e3744 | 4361 | |
3ac237f8 MS |
4362 | if (use_json) |
4363 | json_sub = json_object_new_object(); | |
4364 | else /* Show neighbor ID. */ | |
4365 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4366 | |
4367 | /* Show interface address. */ | |
3ac237f8 MS |
4368 | if (use_json) |
4369 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4370 | else | |
4371 | vty_out (vty, " interface address %s%s", | |
4372 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
4373 | ||
718e3744 | 4374 | /* Show Area ID. */ |
3ac237f8 MS |
4375 | if (use_json) |
4376 | { | |
4377 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4378 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4379 | } | |
4380 | else | |
4381 | vty_out (vty, " In the area %s via interface %s%s", | |
4382 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
4383 | ||
718e3744 | 4384 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4385 | if (use_json) |
4386 | { | |
4387 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4388 | json_object_string_add(json_sub, "nbrState", "down"); | |
4389 | } | |
4390 | else | |
4391 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4392 | nbr_nbma->priority, "Down"); | |
4393 | ||
718e3744 | 4394 | /* Show state changes. */ |
3ac237f8 MS |
4395 | if (use_json) |
4396 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4397 | else | |
4398 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
718e3744 | 4399 | |
4400 | /* Show PollInterval */ | |
3ac237f8 MS |
4401 | if (use_json) |
4402 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4403 | else | |
4404 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
718e3744 | 4405 | |
4406 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4407 | if (use_json) |
4408 | { | |
4409 | struct timeval res = tv_sub (nbr_nbma->t_poll->u.sands, recent_relative_time ()); | |
4410 | unsigned long time_store = 0; | |
4411 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4412 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); | |
4413 | } | |
4414 | else | |
4415 | vty_out (vty, " Poll timer due in %s%s", | |
4416 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
4417 | VTY_NEWLINE); | |
718e3744 | 4418 | |
4419 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4420 | if (use_json) |
4421 | { | |
4422 | if (nbr_nbma->t_poll != NULL) | |
4423 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4424 | } | |
4425 | else | |
4426 | vty_out (vty, " Thread Poll Timer %s%s", | |
4427 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
4428 | ||
4429 | if (use_json) | |
4430 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4431 | } |
4432 | ||
4dadc291 | 4433 | static void |
718e3744 | 4434 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4435 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4436 | { |
649654ab | 4437 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4438 | json_object *json_sub = NULL; |
718e3744 | 4439 | |
3ac237f8 MS |
4440 | if (use_json) |
4441 | json_sub = json_object_new_object(); | |
718e3744 | 4442 | else |
3ac237f8 MS |
4443 | { |
4444 | /* Show neighbor ID. */ | |
4445 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4446 | vty_out (vty, " Neighbor %s,", "-"); | |
4447 | else | |
4448 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4449 | } | |
718e3744 | 4450 | |
4451 | /* Show interface address. */ | |
3ac237f8 MS |
4452 | if (use_json) |
4453 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4454 | else | |
4455 | vty_out (vty, " interface address %s%s", | |
4456 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
4457 | ||
718e3744 | 4458 | /* Show Area ID. */ |
3ac237f8 MS |
4459 | if (use_json) |
4460 | { | |
4461 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4462 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4463 | } | |
4464 | else | |
4465 | vty_out (vty, " In the area %s via interface %s%s", | |
4466 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
4467 | ||
718e3744 | 4468 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4469 | if (use_json) |
4470 | { | |
4471 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4472 | json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4473 | } | |
4474 | else | |
4475 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4476 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4477 | ||
718e3744 | 4478 | /* Show state changes. */ |
3ac237f8 MS |
4479 | if (use_json) |
4480 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4481 | else | |
4482 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
4483 | ||
3fed4160 | 4484 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4485 | { |
3ac237f8 MS |
4486 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
4487 | if (use_json) | |
4488 | { | |
4489 | unsigned long time_store = 0; | |
4490 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4491 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store); | |
4492 | } | |
4493 | else | |
4494 | { | |
4495 | vty_out (vty, " Most recent state change statistics:%s", | |
4496 | VTY_NEWLINE); | |
4497 | vty_out (vty, " Progressive change %s ago%s", | |
4498 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4499 | VTY_NEWLINE); | |
4500 | } | |
3fed4160 | 4501 | } |
3ac237f8 | 4502 | |
3fed4160 PJ |
4503 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4504 | { | |
3ac237f8 MS |
4505 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
4506 | if (use_json) | |
4507 | { | |
4508 | unsigned long time_store = 0; | |
4509 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4510 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); | |
4511 | if (nbr->last_regress_str) | |
4512 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4513 | } | |
4514 | else | |
4515 | { | |
4516 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4517 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4518 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
4519 | VTY_NEWLINE); | |
4520 | } | |
90c33177 | 4521 | } |
3ac237f8 | 4522 | |
718e3744 | 4523 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4524 | if (use_json) |
4525 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4526 | else | |
4527 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4528 | ||
718e3744 | 4529 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4530 | if (use_json) |
4531 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4532 | else | |
4533 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
4534 | ||
718e3744 | 4535 | /* Show options. */ |
3ac237f8 MS |
4536 | if (use_json) |
4537 | { | |
4538 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4539 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4540 | } | |
4541 | else | |
4542 | vty_out (vty, " Options %d %s%s", nbr->options, | |
4543 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
4544 | ||
718e3744 | 4545 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4546 | if (use_json) |
4547 | { | |
4548 | struct timeval res = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time ()); | |
4549 | unsigned long time_store = 0; | |
4550 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4551 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); | |
4552 | } | |
4553 | else | |
4554 | vty_out (vty, " Dead timer due in %s%s", | |
4555 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
4556 | VTY_NEWLINE); | |
4557 | ||
718e3744 | 4558 | /* Show Database Summary list. */ |
3ac237f8 MS |
4559 | if (use_json) |
4560 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4561 | else | |
4562 | vty_out (vty, " Database Summary List %d%s", | |
4563 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
4564 | ||
718e3744 | 4565 | /* Show Link State Request list. */ |
3ac237f8 MS |
4566 | if (use_json) |
4567 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4568 | else | |
4569 | vty_out (vty, " Link State Request List %ld%s", | |
4570 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
4571 | ||
718e3744 | 4572 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4573 | if (use_json) |
4574 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4575 | else | |
4576 | vty_out (vty, " Link State Retransmission List %ld%s", | |
4577 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
4578 | ||
718e3744 | 4579 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4580 | if (use_json) |
4581 | { | |
4582 | if (nbr->t_inactivity != NULL) | |
4583 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4584 | } | |
4585 | else | |
4586 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
4587 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
4588 | ||
718e3744 | 4589 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4590 | if (use_json) |
4591 | { | |
4592 | if (nbr->t_db_desc != NULL) | |
4593 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4594 | } | |
4595 | else | |
4596 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
4597 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
4598 | ||
718e3744 | 4599 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4600 | if (use_json) |
4601 | { | |
4602 | if (nbr->t_ls_req != NULL) | |
4603 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4604 | } | |
4605 | else | |
4606 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
4607 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
4608 | ||
718e3744 | 4609 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4610 | if (use_json) |
4611 | { | |
4612 | if (nbr->t_ls_upd != NULL) | |
4613 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4614 | } | |
4615 | else | |
4616 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
4617 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
4618 | ||
4619 | if (use_json) | |
4620 | { | |
4621 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4622 | json_object_object_add(json, "noNbrId", json_sub); | |
4623 | else | |
4624 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4625 | } | |
68fe91d6 | 4626 | |
4627 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4628 | } |
4629 | ||
7c8ff89e DS |
4630 | static int |
4631 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4632 | int arg_base, const char **argv, u_char use_json) |
718e3744 | 4633 | { |
52dc7ee6 | 4634 | struct listnode *node; |
718e3744 | 4635 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4636 | struct ospf_interface *oi; |
718e3744 | 4637 | struct in_addr router_id; |
4638 | int ret; | |
3ac237f8 MS |
4639 | json_object *json = NULL; |
4640 | ||
4641 | if (use_json) | |
4642 | json = json_object_new_object(); | |
718e3744 | 4643 | |
7c8ff89e | 4644 | if (ospf->instance) |
3ac237f8 MS |
4645 | { |
4646 | if (use_json) | |
4647 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4648 | else | |
4649 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4650 | VTY_NEWLINE, VTY_NEWLINE); | |
4651 | } | |
7c8ff89e | 4652 | |
3ac237f8 | 4653 | ret = inet_aton (argv[arg_base], &router_id); |
718e3744 | 4654 | if (!ret) |
4655 | { | |
3ac237f8 MS |
4656 | if (!use_json) |
4657 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
718e3744 | 4658 | return CMD_WARNING; |
4659 | } | |
4660 | ||
1eb8ef25 | 4661 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4662 | { |
4663 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4664 | { | |
4665 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4666 | } | |
4667 | } | |
4668 | ||
4669 | if (use_json) | |
4670 | { | |
4671 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4672 | json_object_free(json); | |
4673 | } | |
4674 | else | |
4675 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4676 | |
718e3744 | 4677 | return CMD_SUCCESS; |
4678 | } | |
4679 | ||
7c8ff89e DS |
4680 | DEFUN (show_ip_ospf_neighbor_id, |
4681 | show_ip_ospf_neighbor_id_cmd, | |
3ac237f8 | 4682 | "show ip ospf neighbor A.B.C.D {json}", |
718e3744 | 4683 | SHOW_STR |
4684 | IP_STR | |
4685 | "OSPF information\n" | |
4686 | "Neighbor list\n" | |
3ac237f8 MS |
4687 | "Neighbor ID\n" |
4688 | "JavaScript Object Notation\n") | |
718e3744 | 4689 | { |
020709f9 | 4690 | struct ospf *ospf; |
3ac237f8 | 4691 | u_char use_json = (argv[1] != NULL); |
7c8ff89e | 4692 | |
0bad4851 | 4693 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4694 | return CMD_SUCCESS; |
4695 | ||
3ac237f8 | 4696 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, use_json); |
7c8ff89e DS |
4697 | } |
4698 | ||
4699 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4700 | show_ip_ospf_instance_neighbor_id_cmd, | |
3ac237f8 | 4701 | "show ip ospf <1-65535> neighbor A.B.C.D {json}", |
7c8ff89e DS |
4702 | SHOW_STR |
4703 | IP_STR | |
4704 | "OSPF information\n" | |
4705 | "Instance ID\n" | |
4706 | "Neighbor list\n" | |
3ac237f8 MS |
4707 | "Neighbor ID\n" |
4708 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4709 | { |
4710 | struct ospf *ospf; | |
4711 | u_short instance = 0; | |
3ac237f8 | 4712 | u_char use_json = (argv[2] != NULL); |
7c8ff89e DS |
4713 | |
4714 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4715 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4716 | return CMD_SUCCESS; |
4717 | ||
3ac237f8 | 4718 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, use_json); |
7c8ff89e DS |
4719 | } |
4720 | ||
4721 | static int | |
3ac237f8 | 4722 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4723 | { |
1eb8ef25 | 4724 | struct ospf_interface *oi; |
52dc7ee6 | 4725 | struct listnode *node; |
3ac237f8 MS |
4726 | json_object *json = NULL; |
4727 | ||
4728 | if (use_json) | |
4729 | json = json_object_new_object(); | |
718e3744 | 4730 | |
7c8ff89e | 4731 | if (ospf->instance) |
3ac237f8 MS |
4732 | { |
4733 | if (use_json) | |
4734 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4735 | else | |
4736 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4737 | VTY_NEWLINE, VTY_NEWLINE); | |
4738 | } | |
718e3744 | 4739 | |
1eb8ef25 | 4740 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4741 | { |
718e3744 | 4742 | struct route_node *rn; |
4743 | struct ospf_neighbor *nbr; | |
4744 | ||
4745 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4746 | { |
4747 | if ((nbr = rn->info)) | |
4748 | { | |
4749 | if (nbr != oi->nbr_self) | |
4750 | { | |
4751 | if (nbr->state != NSM_Down) | |
4752 | { | |
4753 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4754 | } | |
4755 | } | |
4756 | } | |
4757 | } | |
718e3744 | 4758 | } |
4759 | ||
3ac237f8 MS |
4760 | if (use_json) |
4761 | { | |
4762 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4763 | json_object_free(json); | |
4764 | } | |
4765 | else | |
4766 | vty_out (vty, "%s", VTY_NEWLINE); | |
4767 | ||
718e3744 | 4768 | return CMD_SUCCESS; |
4769 | } | |
4770 | ||
7c8ff89e DS |
4771 | DEFUN (show_ip_ospf_neighbor_detail, |
4772 | show_ip_ospf_neighbor_detail_cmd, | |
3ac237f8 | 4773 | "show ip ospf neighbor detail {json}", |
718e3744 | 4774 | SHOW_STR |
4775 | IP_STR | |
4776 | "OSPF information\n" | |
4777 | "Neighbor list\n" | |
3ac237f8 MS |
4778 | "detail of all neighbors\n" |
4779 | "JavaScript Object Notation\n") | |
718e3744 | 4780 | { |
020709f9 | 4781 | struct ospf *ospf; |
3ac237f8 | 4782 | u_char use_json = (argv[0] != NULL); |
7c8ff89e | 4783 | |
0bad4851 | 4784 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4785 | return CMD_SUCCESS; |
4786 | ||
3ac237f8 | 4787 | return show_ip_ospf_neighbor_detail_common(vty, ospf, use_json); |
7c8ff89e DS |
4788 | } |
4789 | ||
4790 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4791 | show_ip_ospf_instance_neighbor_detail_cmd, | |
3ac237f8 | 4792 | "show ip ospf <1-65535> neighbor detail {json}", |
7c8ff89e DS |
4793 | SHOW_STR |
4794 | IP_STR | |
4795 | "OSPF information\n" | |
4796 | "Instance ID\n" | |
4797 | "Neighbor list\n" | |
3ac237f8 MS |
4798 | "detail of all neighbors\n" |
4799 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4800 | { |
4801 | struct ospf *ospf; | |
4802 | u_short instance = 0; | |
3ac237f8 | 4803 | u_char use_json = (argv[1] != NULL); |
7c8ff89e DS |
4804 | |
4805 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4806 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4807 | return CMD_SUCCESS; |
4808 | ||
3ac237f8 | 4809 | return show_ip_ospf_neighbor_detail_common(vty, ospf, use_json); |
7c8ff89e DS |
4810 | } |
4811 | ||
4812 | static int | |
3ac237f8 | 4813 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4814 | { |
52dc7ee6 | 4815 | struct listnode *node; |
1eb8ef25 | 4816 | struct ospf_interface *oi; |
3ac237f8 MS |
4817 | json_object *json = NULL; |
4818 | ||
4819 | if (use_json) | |
4820 | json = json_object_new_object(); | |
718e3744 | 4821 | |
7c8ff89e | 4822 | if (ospf->instance) |
3ac237f8 MS |
4823 | { |
4824 | if (use_json) | |
4825 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4826 | else | |
4827 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4828 | VTY_NEWLINE, VTY_NEWLINE); | |
4829 | } | |
718e3744 | 4830 | |
1eb8ef25 | 4831 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4832 | { |
718e3744 | 4833 | struct route_node *rn; |
4834 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4835 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4836 | |
4837 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4838 | if ((nbr = rn->info)) | |
4839 | if (nbr != oi->nbr_self) | |
4840 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) | |
3ac237f8 | 4841 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4842 | |
4843 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4844 | { |
4845 | struct listnode *nd; | |
718e3744 | 4846 | |
3ac237f8 MS |
4847 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4848 | { | |
4849 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4850 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4851 | } | |
4852 | } | |
4853 | } | |
4854 | ||
4855 | if (use_json) | |
4856 | { | |
4857 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4858 | json_object_free(json); | |
4859 | } | |
4860 | else | |
4861 | { | |
4862 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4863 | } |
4864 | ||
4865 | return CMD_SUCCESS; | |
4866 | } | |
4867 | ||
7c8ff89e DS |
4868 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4869 | show_ip_ospf_neighbor_detail_all_cmd, | |
3ac237f8 | 4870 | "show ip ospf neighbor detail all {json}", |
718e3744 | 4871 | SHOW_STR |
4872 | IP_STR | |
4873 | "OSPF information\n" | |
4874 | "Neighbor list\n" | |
7c8ff89e | 4875 | "detail of all neighbors\n" |
3ac237f8 MS |
4876 | "include down status neighbor\n" |
4877 | "JavaScript Object Notation\n") | |
718e3744 | 4878 | { |
020709f9 | 4879 | struct ospf *ospf; |
3ac237f8 | 4880 | u_char use_json = (argv[0] != NULL);; |
7c8ff89e | 4881 | |
0bad4851 | 4882 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4883 | return CMD_SUCCESS; |
4884 | ||
3ac237f8 | 4885 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, use_json); |
7c8ff89e DS |
4886 | } |
4887 | ||
4888 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4889 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
3ac237f8 | 4890 | "show ip ospf <1-65535> neighbor detail all {json}", |
7c8ff89e DS |
4891 | SHOW_STR |
4892 | IP_STR | |
4893 | "OSPF information\n" | |
4894 | "Instance ID\n" | |
4895 | "Neighbor list\n" | |
4896 | "detail of all neighbors\n" | |
3ac237f8 MS |
4897 | "include down status neighbor\n" |
4898 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4899 | { |
4900 | struct ospf *ospf; | |
4901 | u_short instance = 0; | |
3ac237f8 | 4902 | u_char use_json = (argv[1] != NULL); |
7c8ff89e DS |
4903 | |
4904 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4905 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4906 | return CMD_SUCCESS; |
4907 | ||
3ac237f8 | 4908 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, use_json); |
7c8ff89e DS |
4909 | } |
4910 | ||
4911 | static int | |
4912 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4913 | int arg_base, const char **argv, u_char use_json) |
7c8ff89e | 4914 | { |
718e3744 | 4915 | struct ospf_interface *oi; |
bb5b7552 | 4916 | struct interface *ifp; |
4917 | struct route_node *rn, *nrn; | |
4918 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4919 | json_object *json = NULL; |
4920 | ||
4921 | if (use_json) | |
4922 | json = json_object_new_object(); | |
bb5b7552 | 4923 | |
7c8ff89e | 4924 | if (ospf->instance) |
3ac237f8 MS |
4925 | { |
4926 | if (use_json) | |
4927 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4928 | else | |
4929 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4930 | VTY_NEWLINE, VTY_NEWLINE); | |
4931 | } | |
7c8ff89e | 4932 | |
3ac237f8 | 4933 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4934 | if (!ifp) |
718e3744 | 4935 | { |
3ac237f8 MS |
4936 | if (!use_json) |
4937 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4938 | return CMD_WARNING; |
4939 | } | |
4940 | ||
bb5b7552 | 4941 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
4942 | { |
4943 | if ((oi = rn->info)) | |
4944 | { | |
4945 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
4946 | { | |
4947 | if ((nbr = nrn->info)) | |
4948 | { | |
4949 | if (nbr != oi->nbr_self) | |
4950 | { | |
4951 | if (nbr->state != NSM_Down) | |
4952 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4953 | } | |
4954 | } | |
4955 | } | |
4956 | } | |
4957 | } | |
4958 | ||
4959 | if (use_json) | |
4960 | { | |
4961 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4962 | json_object_free(json); | |
4963 | } | |
4964 | else | |
4965 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4966 | |
4967 | return CMD_SUCCESS; | |
4968 | } | |
4969 | ||
7c8ff89e DS |
4970 | DEFUN (show_ip_ospf_neighbor_int_detail, |
4971 | show_ip_ospf_neighbor_int_detail_cmd, | |
3ac237f8 | 4972 | "show ip ospf neighbor IFNAME detail {json}", |
7c8ff89e DS |
4973 | SHOW_STR |
4974 | IP_STR | |
4975 | "OSPF information\n" | |
4976 | "Neighbor list\n" | |
4977 | "Interface name\n" | |
3ac237f8 MS |
4978 | "detail of all neighbors\n" |
4979 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4980 | { |
4981 | struct ospf *ospf; | |
3ac237f8 | 4982 | u_char use_json = (argv[1] != NULL); |
7c8ff89e | 4983 | |
0bad4851 | 4984 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4985 | return CMD_SUCCESS; |
4986 | ||
3ac237f8 | 4987 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, use_json); |
7c8ff89e DS |
4988 | } |
4989 | ||
4990 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
4991 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
3ac237f8 | 4992 | "show ip ospf <1-65535> neighbor IFNAME detail {json}", |
7c8ff89e DS |
4993 | SHOW_STR |
4994 | IP_STR | |
4995 | "OSPF information\n" | |
4996 | "Instance ID\n" | |
4997 | "Neighbor list\n" | |
4998 | "Interface name\n" | |
3ac237f8 MS |
4999 | "detail of all neighbors\n" |
5000 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5001 | { |
5002 | struct ospf *ospf; | |
5003 | u_short instance = 0; | |
3ac237f8 | 5004 | u_char use_json = (argv[2] != NULL); |
7c8ff89e DS |
5005 | |
5006 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 5007 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5008 | return CMD_SUCCESS; |
5009 | ||
3ac237f8 | 5010 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, use_json); |
7c8ff89e | 5011 | } |
6b0655a2 | 5012 | |
718e3744 | 5013 | /* Show functions */ |
4dadc291 | 5014 | static int |
020709f9 | 5015 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 5016 | { |
718e3744 | 5017 | struct router_lsa *rl; |
5018 | struct summary_lsa *sl; | |
5019 | struct as_external_lsa *asel; | |
5020 | struct prefix_ipv4 p; | |
5021 | ||
5022 | if (lsa != NULL) | |
5023 | /* If self option is set, check LSA self flag. */ | |
5024 | if (self == 0 || IS_LSA_SELF (lsa)) | |
5025 | { | |
5026 | /* LSA common part show. */ | |
5027 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
5028 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
5029 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
5030 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
5031 | /* LSA specific part show. */ | |
5032 | switch (lsa->data->type) | |
5033 | { | |
5034 | case OSPF_ROUTER_LSA: | |
5035 | rl = (struct router_lsa *) lsa->data; | |
5036 | vty_out (vty, " %-d", ntohs (rl->links)); | |
5037 | break; | |
5038 | case OSPF_SUMMARY_LSA: | |
5039 | sl = (struct summary_lsa *) lsa->data; | |
5040 | ||
5041 | p.family = AF_INET; | |
5042 | p.prefix = sl->header.id; | |
5043 | p.prefixlen = ip_masklen (sl->mask); | |
5044 | apply_mask_ipv4 (&p); | |
5045 | ||
5046 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
5047 | break; | |
5048 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 5049 | case OSPF_AS_NSSA_LSA: |
718e3744 | 5050 | asel = (struct as_external_lsa *) lsa->data; |
5051 | ||
5052 | p.family = AF_INET; | |
5053 | p.prefix = asel->header.id; | |
5054 | p.prefixlen = ip_masklen (asel->mask); | |
5055 | apply_mask_ipv4 (&p); | |
5056 | ||
5057 | vty_out (vty, " %s %s/%d [0x%lx]", | |
5058 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
5059 | inet_ntoa (p.prefix), p.prefixlen, | |
5060 | (u_long)ntohl (asel->e[0].route_tag)); | |
5061 | break; | |
5062 | case OSPF_NETWORK_LSA: | |
5063 | case OSPF_ASBR_SUMMARY_LSA: | |
5064 | #ifdef HAVE_OPAQUE_LSA | |
5065 | case OSPF_OPAQUE_LINK_LSA: | |
5066 | case OSPF_OPAQUE_AREA_LSA: | |
5067 | case OSPF_OPAQUE_AS_LSA: | |
5068 | #endif /* HAVE_OPAQUE_LSA */ | |
5069 | default: | |
5070 | break; | |
5071 | } | |
5072 | vty_out (vty, VTY_NEWLINE); | |
5073 | } | |
5074 | ||
5075 | return 0; | |
5076 | } | |
5077 | ||
8b6a15b2 | 5078 | static const char *show_database_desc[] = |
718e3744 | 5079 | { |
5080 | "unknown", | |
5081 | "Router Link States", | |
5082 | "Net Link States", | |
5083 | "Summary Link States", | |
5084 | "ASBR-Summary Link States", | |
5085 | "AS External Link States", | |
718e3744 | 5086 | "Group Membership LSA", |
5087 | "NSSA-external Link States", | |
718e3744 | 5088 | #ifdef HAVE_OPAQUE_LSA |
5089 | "Type-8 LSA", | |
5090 | "Link-Local Opaque-LSA", | |
5091 | "Area-Local Opaque-LSA", | |
5092 | "AS-external Opaque-LSA", | |
5093 | #endif /* HAVE_OPAQUE_LSA */ | |
5094 | }; | |
5095 | ||
8b6a15b2 | 5096 | static const char *show_database_header[] = |
718e3744 | 5097 | { |
5098 | "", | |
5099 | "Link ID ADV Router Age Seq# CkSum Link count", | |
5100 | "Link ID ADV Router Age Seq# CkSum", | |
5101 | "Link ID ADV Router Age Seq# CkSum Route", | |
5102 | "Link ID ADV Router Age Seq# CkSum", | |
5103 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5104 | " --- header for Group Member ----", |
5105 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5106 | #ifdef HAVE_OPAQUE_LSA |
718e3744 | 5107 | " --- type-8 ---", |
5108 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5109 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5110 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5111 | #endif /* HAVE_OPAQUE_LSA */ | |
5112 | }; | |
5113 | ||
4dadc291 | 5114 | static void |
718e3744 | 5115 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
5116 | { | |
5117 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 5118 | |
718e3744 | 5119 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 5120 | vty_out (vty, " Options: 0x%-2x : %s%s", |
5121 | lsa->data->options, | |
5122 | ospf_options_dump(lsa->data->options), | |
5123 | VTY_NEWLINE); | |
5124 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 5125 | lsa->flags, |
4957f494 | 5126 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
5127 | VTY_NEWLINE); | |
718e3744 | 5128 | |
5129 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
5130 | { | |
5131 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
5132 | ||
5133 | if (rlsa->flags) | |
5134 | vty_out (vty, " :%s%s%s%s", | |
5135 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
5136 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
5137 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
5138 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
5139 | ||
5140 | vty_out (vty, "%s", VTY_NEWLINE); | |
5141 | } | |
5142 | vty_out (vty, " LS Type: %s%s", | |
5143 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
5144 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
5145 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
5146 | vty_out (vty, " Advertising Router: %s%s", | |
5147 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5148 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
5149 | VTY_NEWLINE); | |
5150 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
5151 | VTY_NEWLINE); | |
5152 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
5153 | } | |
5154 | ||
eb1ce605 | 5155 | const char *link_type_desc[] = |
718e3744 | 5156 | { |
5157 | "(null)", | |
5158 | "another Router (point-to-point)", | |
5159 | "a Transit Network", | |
5160 | "Stub Network", | |
5161 | "a Virtual Link", | |
5162 | }; | |
5163 | ||
eb1ce605 | 5164 | const char *link_id_desc[] = |
718e3744 | 5165 | { |
5166 | "(null)", | |
5167 | "Neighboring Router ID", | |
5168 | "Designated Router address", | |
68980084 | 5169 | "Net", |
718e3744 | 5170 | "Neighboring Router ID", |
5171 | }; | |
5172 | ||
eb1ce605 | 5173 | const char *link_data_desc[] = |
718e3744 | 5174 | { |
5175 | "(null)", | |
5176 | "Router Interface address", | |
5177 | "Router Interface address", | |
5178 | "Network Mask", | |
5179 | "Router Interface address", | |
5180 | }; | |
5181 | ||
5182 | /* Show router-LSA each Link information. */ | |
4dadc291 | 5183 | static void |
718e3744 | 5184 | show_ip_ospf_database_router_links (struct vty *vty, |
5185 | struct router_lsa *rl) | |
5186 | { | |
b07c4cb3 DS |
5187 | int len, type; |
5188 | unsigned int i; | |
718e3744 | 5189 | |
5190 | len = ntohs (rl->header.length) - 4; | |
5191 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
5192 | { | |
5193 | type = rl->link[i].type; | |
5194 | ||
5195 | vty_out (vty, " Link connected to: %s%s", | |
5196 | link_type_desc[type], VTY_NEWLINE); | |
5197 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
5198 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
5199 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
5200 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
5201 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
5202 | vty_out (vty, " TOS 0 Metric: %d%s", | |
5203 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
5204 | vty_out (vty, "%s", VTY_NEWLINE); | |
5205 | } | |
5206 | } | |
5207 | ||
5208 | /* Show router-LSA detail information. */ | |
4dadc291 | 5209 | static int |
718e3744 | 5210 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5211 | { | |
5212 | if (lsa != NULL) | |
5213 | { | |
5214 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
5215 | ||
5216 | show_ip_ospf_database_header (vty, lsa); | |
5217 | ||
5218 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
5219 | VTY_NEWLINE, VTY_NEWLINE); | |
5220 | ||
5221 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 5222 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5223 | } |
5224 | ||
5225 | return 0; | |
5226 | } | |
5227 | ||
5228 | /* Show network-LSA detail information. */ | |
4dadc291 | 5229 | static int |
718e3744 | 5230 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5231 | { | |
5232 | int length, i; | |
5233 | ||
5234 | if (lsa != NULL) | |
5235 | { | |
5236 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
5237 | ||
5238 | show_ip_ospf_database_header (vty, lsa); | |
5239 | ||
5240 | vty_out (vty, " Network Mask: /%d%s", | |
5241 | ip_masklen (nl->mask), VTY_NEWLINE); | |
5242 | ||
5243 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
5244 | ||
5245 | for (i = 0; length > 0; i++, length -= 4) | |
5246 | vty_out (vty, " Attached Router: %s%s", | |
5247 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
5248 | ||
5249 | vty_out (vty, "%s", VTY_NEWLINE); | |
5250 | } | |
5251 | ||
5252 | return 0; | |
5253 | } | |
5254 | ||
5255 | /* Show summary-LSA detail information. */ | |
4dadc291 | 5256 | static int |
718e3744 | 5257 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5258 | { | |
5259 | if (lsa != NULL) | |
5260 | { | |
5261 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5262 | ||
5263 | show_ip_ospf_database_header (vty, lsa); | |
5264 | ||
5265 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
5266 | VTY_NEWLINE); | |
5267 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5268 | VTY_NEWLINE); | |
b0a053be | 5269 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5270 | } |
5271 | ||
5272 | return 0; | |
5273 | } | |
5274 | ||
5275 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 5276 | static int |
718e3744 | 5277 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5278 | { | |
5279 | if (lsa != NULL) | |
5280 | { | |
5281 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5282 | ||
5283 | show_ip_ospf_database_header (vty, lsa); | |
5284 | ||
5285 | vty_out (vty, " Network Mask: /%d%s", | |
5286 | ip_masklen (sl->mask), VTY_NEWLINE); | |
5287 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5288 | VTY_NEWLINE); | |
b0a053be | 5289 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5290 | } |
5291 | ||
5292 | return 0; | |
5293 | } | |
5294 | ||
5295 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 5296 | static int |
718e3744 | 5297 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5298 | { | |
5299 | if (lsa != NULL) | |
5300 | { | |
5301 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5302 | ||
5303 | show_ip_ospf_database_header (vty, lsa); | |
5304 | ||
5305 | vty_out (vty, " Network Mask: /%d%s", | |
5306 | ip_masklen (al->mask), VTY_NEWLINE); | |
5307 | vty_out (vty, " Metric Type: %s%s", | |
5308 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5309 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5310 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5311 | vty_out (vty, " Metric: %d%s", | |
5312 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5313 | vty_out (vty, " Forward Address: %s%s", | |
5314 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5315 | ||
5316 | vty_out (vty, " External Route Tag: %lu%s%s", | |
5317 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
5318 | } | |
5319 | ||
5320 | return 0; | |
5321 | } | |
5322 | ||
075e12f5 | 5323 | #if 0 |
4dadc291 | 5324 | static int |
718e3744 | 5325 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
5326 | { | |
5327 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5328 | ||
5329 | /* show_ip_ospf_database_header (vty, lsa); */ | |
5330 | ||
2a42e285 | 5331 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 5332 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5333 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5334 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5335 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5336 | zlog_debug( " TOS: 0%s", "\n"); |
5337 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5338 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5339 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5340 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5341 | ||
2a42e285 | 5342 | zlog_debug( " External Route Tag: %u%s%s", |
718e3744 | 5343 | ntohl (al->e[0].route_tag), "\n", "\n"); |
5344 | ||
5345 | return 0; | |
5346 | } | |
075e12f5 | 5347 | #endif |
718e3744 | 5348 | |
5349 | /* Show AS-NSSA-LSA detail information. */ | |
4dadc291 | 5350 | static int |
718e3744 | 5351 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5352 | { | |
5353 | if (lsa != NULL) | |
5354 | { | |
5355 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5356 | ||
5357 | show_ip_ospf_database_header (vty, lsa); | |
5358 | ||
5359 | vty_out (vty, " Network Mask: /%d%s", | |
5360 | ip_masklen (al->mask), VTY_NEWLINE); | |
5361 | vty_out (vty, " Metric Type: %s%s", | |
5362 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5363 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5364 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5365 | vty_out (vty, " Metric: %d%s", | |
5366 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5367 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
5368 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5369 | ||
5370 | vty_out (vty, " External Route Tag: %u%s%s", | |
5371 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
5372 | } | |
5373 | ||
5374 | return 0; | |
5375 | } | |
5376 | ||
4dadc291 | 5377 | static int |
718e3744 | 5378 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5379 | { | |
5380 | return 0; | |
5381 | } | |
5382 | ||
5383 | #ifdef HAVE_OPAQUE_LSA | |
4dadc291 | 5384 | static int |
718e3744 | 5385 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5386 | { | |
5387 | if (lsa != NULL) | |
5388 | { | |
5389 | show_ip_ospf_database_header (vty, lsa); | |
5390 | show_opaque_info_detail (vty, lsa); | |
5391 | ||
5392 | vty_out (vty, "%s", VTY_NEWLINE); | |
5393 | } | |
5394 | return 0; | |
5395 | } | |
5396 | #endif /* HAVE_OPAQUE_LSA */ | |
5397 | ||
5398 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5399 | { | |
5400 | NULL, | |
5401 | show_router_lsa_detail, | |
5402 | show_network_lsa_detail, | |
5403 | show_summary_lsa_detail, | |
5404 | show_summary_asbr_lsa_detail, | |
5405 | show_as_external_lsa_detail, | |
718e3744 | 5406 | show_func_dummy, |
5407 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5408 | #ifdef HAVE_OPAQUE_LSA |
718e3744 | 5409 | NULL, /* type-8 */ |
5410 | show_opaque_lsa_detail, | |
5411 | show_opaque_lsa_detail, | |
5412 | show_opaque_lsa_detail, | |
5413 | #endif /* HAVE_OPAQUE_LSA */ | |
5414 | }; | |
5415 | ||
4dadc291 | 5416 | static void |
718e3744 | 5417 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5418 | struct in_addr *adv_router) | |
5419 | { | |
5420 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5421 | lp->family = 0; | |
5422 | if (id == NULL) | |
5423 | lp->prefixlen = 0; | |
5424 | else if (adv_router == NULL) | |
5425 | { | |
5426 | lp->prefixlen = 32; | |
5427 | lp->id = *id; | |
5428 | } | |
5429 | else | |
5430 | { | |
5431 | lp->prefixlen = 64; | |
5432 | lp->id = *id; | |
5433 | lp->adv_router = *adv_router; | |
5434 | } | |
5435 | } | |
5436 | ||
4dadc291 | 5437 | static void |
718e3744 | 5438 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5439 | struct in_addr *id, struct in_addr *adv_router) | |
5440 | { | |
5441 | struct prefix_ls lp; | |
5442 | struct route_node *rn, *start; | |
5443 | struct ospf_lsa *lsa; | |
5444 | ||
5445 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5446 | start = route_node_get (rt, (struct prefix *) &lp); | |
5447 | if (start) | |
5448 | { | |
5449 | route_lock_node (start); | |
5450 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5451 | if ((lsa = rn->info)) | |
5452 | { | |
718e3744 | 5453 | if (show_function[lsa->data->type] != NULL) |
5454 | show_function[lsa->data->type] (vty, lsa); | |
5455 | } | |
5456 | route_unlock_node (start); | |
5457 | } | |
5458 | } | |
5459 | ||
5460 | /* Show detail LSA information | |
5461 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5462 | static void |
020709f9 | 5463 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5464 | struct in_addr *id, struct in_addr *adv_router) |
5465 | { | |
52dc7ee6 | 5466 | struct listnode *node; |
1eb8ef25 | 5467 | struct ospf_area *area; |
5468 | ||
718e3744 | 5469 | switch (type) |
5470 | { | |
5471 | case OSPF_AS_EXTERNAL_LSA: | |
5472 | #ifdef HAVE_OPAQUE_LSA | |
5473 | case OSPF_OPAQUE_AS_LSA: | |
5474 | #endif /* HAVE_OPAQUE_LSA */ | |
5475 | vty_out (vty, " %s %s%s", | |
5476 | show_database_desc[type], | |
5477 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5478 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5479 | break; |
5480 | default: | |
1eb8ef25 | 5481 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5482 | { |
718e3744 | 5483 | vty_out (vty, "%s %s (Area %s)%s%s", |
5484 | VTY_NEWLINE, show_database_desc[type], | |
5485 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5486 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
5487 | } | |
5488 | break; | |
5489 | } | |
5490 | } | |
5491 | ||
4dadc291 | 5492 | static void |
718e3744 | 5493 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5494 | struct in_addr *adv_router) | |
5495 | { | |
5496 | struct route_node *rn; | |
5497 | struct ospf_lsa *lsa; | |
5498 | ||
5499 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5500 | if ((lsa = rn->info)) | |
5501 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5502 | { | |
718e3744 | 5503 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5504 | continue; | |
718e3744 | 5505 | if (show_function[lsa->data->type] != NULL) |
5506 | show_function[lsa->data->type] (vty, lsa); | |
5507 | } | |
5508 | } | |
5509 | ||
5510 | /* Show detail LSA information. */ | |
4dadc291 | 5511 | static void |
020709f9 | 5512 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5513 | struct in_addr *adv_router) |
5514 | { | |
52dc7ee6 | 5515 | struct listnode *node; |
1eb8ef25 | 5516 | struct ospf_area *area; |
718e3744 | 5517 | |
5518 | switch (type) | |
5519 | { | |
5520 | case OSPF_AS_EXTERNAL_LSA: | |
5521 | #ifdef HAVE_OPAQUE_LSA | |
5522 | case OSPF_OPAQUE_AS_LSA: | |
5523 | #endif /* HAVE_OPAQUE_LSA */ | |
5524 | vty_out (vty, " %s %s%s", | |
5525 | show_database_desc[type], | |
5526 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5527 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5528 | adv_router); |
5529 | break; | |
5530 | default: | |
1eb8ef25 | 5531 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5532 | { |
718e3744 | 5533 | vty_out (vty, "%s %s (Area %s)%s%s", |
5534 | VTY_NEWLINE, show_database_desc[type], | |
5535 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5536 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
5537 | adv_router); | |
5538 | } | |
5539 | break; | |
5540 | } | |
5541 | } | |
5542 | ||
4dadc291 | 5543 | static void |
020709f9 | 5544 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5545 | { |
020709f9 | 5546 | struct ospf_lsa *lsa; |
5547 | struct route_node *rn; | |
1eb8ef25 | 5548 | struct ospf_area *area; |
52dc7ee6 | 5549 | struct listnode *node; |
718e3744 | 5550 | int type; |
5551 | ||
1eb8ef25 | 5552 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5553 | { |
718e3744 | 5554 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5555 | { | |
5556 | switch (type) | |
5557 | { | |
5558 | case OSPF_AS_EXTERNAL_LSA: | |
5559 | #ifdef HAVE_OPAQUE_LSA | |
5560 | case OSPF_OPAQUE_AS_LSA: | |
5561 | #endif /* HAVE_OPAQUE_LSA */ | |
5562 | continue; | |
5563 | default: | |
5564 | break; | |
5565 | } | |
5566 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5567 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5568 | { | |
5569 | vty_out (vty, " %s (Area %s)%s%s", | |
5570 | show_database_desc[type], | |
5571 | ospf_area_desc_string (area), | |
5572 | VTY_NEWLINE, VTY_NEWLINE); | |
5573 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
5574 | ||
020709f9 | 5575 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5576 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5577 | |
5578 | vty_out (vty, "%s", VTY_NEWLINE); | |
5579 | } | |
5580 | } | |
5581 | } | |
5582 | ||
5583 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5584 | { | |
5585 | switch (type) | |
5586 | { | |
5587 | case OSPF_AS_EXTERNAL_LSA: | |
5588 | #ifdef HAVE_OPAQUE_LSA | |
5589 | case OSPF_OPAQUE_AS_LSA: | |
5590 | #endif /* HAVE_OPAQUE_LSA */ | |
e8e1946e | 5591 | break; |
718e3744 | 5592 | default: |
5593 | continue; | |
5594 | } | |
68980084 | 5595 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5596 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5597 | { |
5598 | vty_out (vty, " %s%s%s", | |
5599 | show_database_desc[type], | |
5600 | VTY_NEWLINE, VTY_NEWLINE); | |
5601 | vty_out (vty, "%s%s", show_database_header[type], | |
5602 | VTY_NEWLINE); | |
020709f9 | 5603 | |
5604 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5605 | show_lsa_summary (vty, lsa, self); | |
5606 | ||
718e3744 | 5607 | vty_out (vty, "%s", VTY_NEWLINE); |
5608 | } | |
5609 | } | |
5610 | ||
5611 | vty_out (vty, "%s", VTY_NEWLINE); | |
5612 | } | |
5613 | ||
4dadc291 | 5614 | static void |
020709f9 | 5615 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5616 | { |
91e6a0e5 | 5617 | struct route_node *rn; |
718e3744 | 5618 | |
5619 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
5620 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
5621 | ||
91e6a0e5 | 5622 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5623 | { |
91e6a0e5 DD |
5624 | struct ospf_lsa *lsa; |
5625 | ||
5626 | if ((lsa = rn->info) != NULL) | |
5627 | { | |
5628 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
5629 | vty_out (vty, "Link State ID: %s%s", | |
5630 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
5631 | vty_out (vty, "Advertising Router: %s%s", | |
5632 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5633 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
5634 | vty_out (vty, "%s", VTY_NEWLINE); | |
5635 | } | |
1eb8ef25 | 5636 | } |
718e3744 | 5637 | } |
5638 | ||
718e3744 | 5639 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5640 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5641 | |
5642 | #ifdef HAVE_OPAQUE_LSA | |
5643 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" | |
5644 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
5645 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
5646 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
5647 | #else /* HAVE_OPAQUE_LSA */ | |
5648 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" | |
5649 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" | |
5650 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" | |
5651 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" | |
5652 | #endif /* HAVE_OPAQUE_LSA */ | |
5653 | ||
5654 | #define OSPF_LSA_TYPES_CMD_STR \ | |
5655 | "asbr-summary|external|network|router|summary" \ | |
5656 | OSPF_LSA_TYPE_NSSA_CMD_STR \ | |
5657 | OSPF_LSA_TYPE_OPAQUE_CMD_STR | |
5658 | ||
5659 | #define OSPF_LSA_TYPES_DESC \ | |
5660 | "ASBR summary link states\n" \ | |
5661 | "External link states\n" \ | |
5662 | "Network link states\n" \ | |
5663 | "Router link states\n" \ | |
5664 | "Network summary link states\n" \ | |
5665 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5666 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5667 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5668 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5669 | ||
7c8ff89e DS |
5670 | static int |
5671 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
5672 | int arg_base, int argc, const char **argv) | |
718e3744 | 5673 | { |
5674 | int type, ret; | |
5675 | struct in_addr id, adv_router; | |
5676 | ||
7c8ff89e DS |
5677 | if (ospf->instance) |
5678 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5679 | VTY_NEWLINE); | |
718e3744 | 5680 | |
5681 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5682 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5683 | |
5684 | /* Show all LSA. */ | |
7c8ff89e | 5685 | if (argc == arg_base + 0) |
718e3744 | 5686 | { |
020709f9 | 5687 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5688 | return CMD_SUCCESS; |
5689 | } | |
5690 | ||
5691 | /* Set database type to show. */ | |
7c8ff89e | 5692 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5693 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5694 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5695 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5696 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5697 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5698 | else if (strncmp (argv[arg_base + 0], "su", 2) == 0) |
718e3744 | 5699 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5700 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5701 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5702 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5703 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 5704 | else if (strncmp (argv[arg_base + 0], "se", 2) == 0) |
718e3744 | 5705 | { |
020709f9 | 5706 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5707 | return CMD_SUCCESS; |
5708 | } | |
7c8ff89e | 5709 | else if (strncmp (argv[arg_base + 0], "m", 1) == 0) |
718e3744 | 5710 | { |
020709f9 | 5711 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5712 | return CMD_SUCCESS; |
5713 | } | |
5714 | #ifdef HAVE_OPAQUE_LSA | |
7c8ff89e | 5715 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5716 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5717 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5718 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5719 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5720 | type = OSPF_OPAQUE_AS_LSA; |
5721 | #endif /* HAVE_OPAQUE_LSA */ | |
5722 | else | |
5723 | return CMD_WARNING; | |
5724 | ||
5725 | /* `show ip ospf database LSA'. */ | |
7c8ff89e | 5726 | if (argc == arg_base + 1) |
020709f9 | 5727 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7c8ff89e | 5728 | else if (argc >= arg_base + 2) |
718e3744 | 5729 | { |
7c8ff89e | 5730 | ret = inet_aton (argv[arg_base + 1], &id); |
718e3744 | 5731 | if (!ret) |
5732 | return CMD_WARNING; | |
5733 | ||
5734 | /* `show ip ospf database LSA ID'. */ | |
7c8ff89e | 5735 | if (argc == arg_base + 2) |
020709f9 | 5736 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5737 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7c8ff89e | 5738 | else if (argc == arg_base + 3) |
718e3744 | 5739 | { |
7c8ff89e | 5740 | if (strncmp (argv[arg_base + 2], "s", 1) == 0) |
68980084 | 5741 | adv_router = ospf->router_id; |
718e3744 | 5742 | else |
5743 | { | |
7c8ff89e | 5744 | ret = inet_aton (argv[arg_base + 2], &adv_router); |
718e3744 | 5745 | if (!ret) |
5746 | return CMD_WARNING; | |
5747 | } | |
020709f9 | 5748 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5749 | } |
5750 | } | |
5751 | ||
5752 | return CMD_SUCCESS; | |
5753 | } | |
5754 | ||
7c8ff89e DS |
5755 | DEFUN (show_ip_ospf_database, |
5756 | show_ip_ospf_database_cmd, | |
5757 | "show ip ospf database", | |
5758 | SHOW_STR | |
5759 | IP_STR | |
5760 | "OSPF information\n" | |
5761 | "Database summary\n") | |
5762 | { | |
5763 | struct ospf *ospf; | |
5764 | ||
0bad4851 | 5765 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5766 | return CMD_SUCCESS; |
5767 | ||
5768 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); | |
5769 | } | |
5770 | ||
718e3744 | 5771 | ALIAS (show_ip_ospf_database, |
5772 | show_ip_ospf_database_type_cmd, | |
5773 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5774 | SHOW_STR | |
5775 | IP_STR | |
5776 | "OSPF information\n" | |
5777 | "Database summary\n" | |
5778 | OSPF_LSA_TYPES_DESC | |
5779 | "LSAs in MaxAge list\n" | |
5780 | "Self-originated link states\n") | |
5781 | ||
5782 | ALIAS (show_ip_ospf_database, | |
5783 | show_ip_ospf_database_type_id_cmd, | |
5784 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5785 | SHOW_STR | |
5786 | IP_STR | |
5787 | "OSPF information\n" | |
5788 | "Database summary\n" | |
5789 | OSPF_LSA_TYPES_DESC | |
5790 | "Link State ID (as an IP address)\n") | |
5791 | ||
5792 | ALIAS (show_ip_ospf_database, | |
5793 | show_ip_ospf_database_type_id_adv_router_cmd, | |
5794 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5795 | SHOW_STR | |
5796 | IP_STR | |
5797 | "OSPF information\n" | |
5798 | "Database summary\n" | |
5799 | OSPF_LSA_TYPES_DESC | |
5800 | "Link State ID (as an IP address)\n" | |
5801 | "Advertising Router link states\n" | |
5802 | "Advertising Router (as an IP address)\n") | |
5803 | ||
5804 | ALIAS (show_ip_ospf_database, | |
5805 | show_ip_ospf_database_type_id_self_cmd, | |
5806 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5807 | SHOW_STR | |
5808 | IP_STR | |
5809 | "OSPF information\n" | |
5810 | "Database summary\n" | |
5811 | OSPF_LSA_TYPES_DESC | |
5812 | "Link State ID (as an IP address)\n" | |
5813 | "Self-originated link states\n" | |
5814 | "\n") | |
5815 | ||
7c8ff89e DS |
5816 | DEFUN (show_ip_ospf_instance_database, |
5817 | show_ip_ospf_instance_database_cmd, | |
5818 | "show ip ospf <1-65535> database", | |
718e3744 | 5819 | SHOW_STR |
5820 | IP_STR | |
5821 | "OSPF information\n" | |
7c8ff89e DS |
5822 | "Instance ID\n" |
5823 | "Database summary\n") | |
5824 | { | |
5825 | struct ospf *ospf; | |
5826 | u_short instance = 0; | |
5827 | ||
5828 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
5829 | ||
0bad4851 | 5830 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5831 | return CMD_SUCCESS; |
5832 | ||
5833 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); | |
5834 | } | |
5835 | ||
5836 | ALIAS (show_ip_ospf_instance_database, | |
5837 | show_ip_ospf_instance_database_type_cmd, | |
5838 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5839 | SHOW_STR | |
5840 | IP_STR | |
5841 | "OSPF information\n" | |
5842 | "Instance ID\n" | |
5843 | "Database summary\n" | |
5844 | OSPF_LSA_TYPES_DESC | |
5845 | "LSAs in MaxAge list\n" | |
5846 | "Self-originated link states\n") | |
5847 | ||
5848 | ALIAS (show_ip_ospf_instance_database, | |
5849 | show_ip_ospf_instance_database_type_id_cmd, | |
5850 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5851 | SHOW_STR | |
5852 | IP_STR | |
5853 | "OSPF information\n" | |
5854 | "Instance ID\n" | |
5855 | "Database summary\n" | |
5856 | OSPF_LSA_TYPES_DESC | |
5857 | "Link State ID (as an IP address)\n") | |
5858 | ||
5859 | ALIAS (show_ip_ospf_instance_database, | |
5860 | show_ip_ospf_instance_database_type_id_adv_router_cmd, | |
5861 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5862 | SHOW_STR | |
5863 | IP_STR | |
5864 | "OSPF information\n" | |
5865 | "Instance ID\n" | |
718e3744 | 5866 | "Database summary\n" |
5867 | OSPF_LSA_TYPES_DESC | |
7c8ff89e | 5868 | "Link State ID (as an IP address)\n" |
718e3744 | 5869 | "Advertising Router link states\n" |
5870 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
5871 | |
5872 | ALIAS (show_ip_ospf_instance_database, | |
5873 | show_ip_ospf_instance_database_type_id_self_cmd, | |
5874 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5875 | SHOW_STR | |
5876 | IP_STR | |
5877 | "OSPF information\n" | |
5878 | "Instance ID\n" | |
5879 | "Database summary\n" | |
5880 | OSPF_LSA_TYPES_DESC | |
5881 | "Link State ID (as an IP address)\n" | |
5882 | "Self-originated link states\n" | |
5883 | "\n") | |
5884 | ||
5885 | ||
5886 | static int | |
5887 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
5888 | int arg_base, int argc, const char **argv) | |
718e3744 | 5889 | { |
5890 | int type, ret; | |
5891 | struct in_addr adv_router; | |
5892 | ||
7c8ff89e DS |
5893 | if (ospf->instance) |
5894 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5895 | VTY_NEWLINE); | |
718e3744 | 5896 | |
5897 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5898 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5899 | |
7c8ff89e | 5900 | if (argc != arg_base + 2) |
718e3744 | 5901 | return CMD_WARNING; |
5902 | ||
5903 | /* Set database type to show. */ | |
7c8ff89e | 5904 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5905 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5906 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5907 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5908 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5909 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5910 | else if (strncmp (argv[arg_base + 0], "s", 1) == 0) |
718e3744 | 5911 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5912 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5913 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5914 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5915 | type = OSPF_AS_EXTERNAL_LSA; |
5916 | #ifdef HAVE_OPAQUE_LSA | |
7c8ff89e | 5917 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5918 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5919 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5920 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5921 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5922 | type = OSPF_OPAQUE_AS_LSA; |
5923 | #endif /* HAVE_OPAQUE_LSA */ | |
5924 | else | |
5925 | return CMD_WARNING; | |
5926 | ||
7c8ff89e DS |
5927 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
5928 | if (strncmp (argv[arg_base + 1], "s", 1) == 0) | |
5929 | adv_router = ospf->router_id; | |
5930 | else | |
5931 | { | |
5932 | ret = inet_aton (argv[arg_base + 1], &adv_router); | |
5933 | if (!ret) | |
5934 | return CMD_WARNING; | |
5935 | } | |
5936 | ||
5937 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5938 | ||
5939 | return CMD_SUCCESS; | |
5940 | } | |
5941 | ||
5942 | DEFUN (show_ip_ospf_database_type_adv_router, | |
5943 | show_ip_ospf_database_type_adv_router_cmd, | |
5944 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
5945 | SHOW_STR | |
5946 | IP_STR | |
5947 | "OSPF information\n" | |
5948 | "Database summary\n" | |
5949 | OSPF_LSA_TYPES_DESC | |
5950 | "Advertising Router link states\n" | |
5951 | "Advertising Router (as an IP address)\n") | |
5952 | { | |
5953 | struct ospf *ospf; | |
5954 | ||
0bad4851 | 5955 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5956 | return CMD_SUCCESS; |
5957 | ||
5958 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
5959 | } | |
5960 | ||
5961 | ALIAS (show_ip_ospf_database_type_adv_router, | |
5962 | show_ip_ospf_database_type_self_cmd, | |
5963 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
5964 | SHOW_STR | |
5965 | IP_STR | |
5966 | "OSPF information\n" | |
5967 | "Database summary\n" | |
5968 | OSPF_LSA_TYPES_DESC | |
5969 | "Self-originated link states\n") | |
5970 | ||
5971 | DEFUN (show_ip_ospf_instance_database_type_adv_router, | |
5972 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
5973 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
5974 | SHOW_STR | |
5975 | IP_STR | |
5976 | "OSPF information\n" | |
5977 | "Instance ID\n" | |
5978 | "Database summary\n" | |
5979 | OSPF_LSA_TYPES_DESC | |
5980 | "Advertising Router link states\n" | |
5981 | "Advertising Router (as an IP address)\n") | |
5982 | { | |
5983 | struct ospf *ospf; | |
5984 | u_short instance = 0; | |
5985 | ||
5986 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
718e3744 | 5987 | |
0bad4851 | 5988 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 5989 | return CMD_SUCCESS; |
718e3744 | 5990 | |
7c8ff89e | 5991 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 5992 | } |
5993 | ||
7c8ff89e DS |
5994 | ALIAS (show_ip_ospf_instance_database_type_adv_router, |
5995 | show_ip_ospf_instance_database_type_self_cmd, | |
5996 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
718e3744 | 5997 | SHOW_STR |
5998 | IP_STR | |
5999 | "OSPF information\n" | |
7c8ff89e | 6000 | "Instance ID\n" |
718e3744 | 6001 | "Database summary\n" |
6002 | OSPF_LSA_TYPES_DESC | |
6003 | "Self-originated link states\n") | |
6004 | ||
718e3744 | 6005 | DEFUN (ip_ospf_authentication_args, |
6006 | ip_ospf_authentication_args_addr_cmd, | |
6007 | "ip ospf authentication (null|message-digest) A.B.C.D", | |
6008 | "IP Information\n" | |
6009 | "OSPF interface commands\n" | |
6010 | "Enable authentication on this interface\n" | |
6011 | "Use null authentication\n" | |
6012 | "Use message-digest authentication\n" | |
6013 | "Address of interface") | |
6014 | { | |
6015 | struct interface *ifp; | |
6016 | struct in_addr addr; | |
6017 | int ret; | |
6018 | struct ospf_if_params *params; | |
6019 | ||
6020 | ifp = vty->index; | |
6021 | params = IF_DEF_PARAMS (ifp); | |
6022 | ||
6023 | if (argc == 2) | |
6024 | { | |
6025 | ret = inet_aton(argv[1], &addr); | |
6026 | if (!ret) | |
6027 | { | |
6028 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6029 | VTY_NEWLINE); | |
6030 | return CMD_WARNING; | |
6031 | } | |
6032 | ||
6033 | params = ospf_get_if_params (ifp, addr); | |
6034 | ospf_if_update_params (ifp, addr); | |
6035 | } | |
6036 | ||
6037 | /* Handle null authentication */ | |
6038 | if ( argv[0][0] == 'n' ) | |
6039 | { | |
6040 | SET_IF_PARAM (params, auth_type); | |
6041 | params->auth_type = OSPF_AUTH_NULL; | |
6042 | return CMD_SUCCESS; | |
6043 | } | |
6044 | ||
6045 | /* Handle message-digest authentication */ | |
6046 | if ( argv[0][0] == 'm' ) | |
6047 | { | |
6048 | SET_IF_PARAM (params, auth_type); | |
6049 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6050 | return CMD_SUCCESS; | |
6051 | } | |
6052 | ||
6053 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
6054 | return CMD_WARNING; | |
6055 | } | |
6056 | ||
6057 | ALIAS (ip_ospf_authentication_args, | |
6058 | ip_ospf_authentication_args_cmd, | |
6059 | "ip ospf authentication (null|message-digest)", | |
6060 | "IP Information\n" | |
6061 | "OSPF interface commands\n" | |
6062 | "Enable authentication on this interface\n" | |
6063 | "Use null authentication\n" | |
6064 | "Use message-digest authentication\n") | |
6065 | ||
6066 | DEFUN (ip_ospf_authentication, | |
6067 | ip_ospf_authentication_addr_cmd, | |
6068 | "ip ospf authentication A.B.C.D", | |
6069 | "IP Information\n" | |
6070 | "OSPF interface commands\n" | |
6071 | "Enable authentication on this interface\n" | |
6072 | "Address of interface") | |
6073 | { | |
6074 | struct interface *ifp; | |
6075 | struct in_addr addr; | |
6076 | int ret; | |
6077 | struct ospf_if_params *params; | |
6078 | ||
6079 | ifp = vty->index; | |
6080 | params = IF_DEF_PARAMS (ifp); | |
6081 | ||
6082 | if (argc == 1) | |
6083 | { | |
5dcf71df | 6084 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6085 | if (!ret) |
6086 | { | |
6087 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6088 | VTY_NEWLINE); | |
6089 | return CMD_WARNING; | |
6090 | } | |
6091 | ||
6092 | params = ospf_get_if_params (ifp, addr); | |
6093 | ospf_if_update_params (ifp, addr); | |
6094 | } | |
6095 | ||
6096 | SET_IF_PARAM (params, auth_type); | |
6097 | params->auth_type = OSPF_AUTH_SIMPLE; | |
6098 | ||
6099 | return CMD_SUCCESS; | |
6100 | } | |
6101 | ||
6102 | ALIAS (ip_ospf_authentication, | |
6103 | ip_ospf_authentication_cmd, | |
6104 | "ip ospf authentication", | |
6105 | "IP Information\n" | |
6106 | "OSPF interface commands\n" | |
6107 | "Enable authentication on this interface\n") | |
6108 | ||
b4a039bf DS |
6109 | DEFUN (no_ip_ospf_authentication_args, |
6110 | no_ip_ospf_authentication_args_addr_cmd, | |
6111 | "no ip ospf authentication (null|message-digest) A.B.C.D", | |
6112 | NO_STR | |
6113 | "IP Information\n" | |
6114 | "OSPF interface commands\n" | |
6115 | "Enable authentication on this interface\n" | |
6116 | "Use null authentication\n" | |
6117 | "Use message-digest authentication\n" | |
6118 | "Address of interface") | |
6119 | { | |
6120 | struct interface *ifp; | |
6121 | struct in_addr addr; | |
6122 | int ret; | |
6123 | struct ospf_if_params *params; | |
6124 | struct route_node *rn; | |
6125 | int auth_type; | |
6126 | ||
6127 | ifp = vty->index; | |
6128 | params = IF_DEF_PARAMS (ifp); | |
6129 | ||
6130 | if (argc == 2) | |
6131 | { | |
6132 | ret = inet_aton(argv[1], &addr); | |
6133 | if (!ret) | |
6134 | { | |
6135 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6136 | VTY_NEWLINE); | |
6137 | return CMD_WARNING; | |
6138 | } | |
6139 | ||
6140 | params = ospf_lookup_if_params (ifp, addr); | |
6141 | if (params == NULL) | |
6142 | { | |
6143 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6144 | return CMD_WARNING; | |
6145 | } | |
6146 | params->auth_type = OSPF_AUTH_NOTSET; | |
6147 | UNSET_IF_PARAM (params, auth_type); | |
6148 | if (params != IF_DEF_PARAMS (ifp)) | |
6149 | { | |
6150 | ospf_free_if_params (ifp, addr); | |
6151 | ospf_if_update_params (ifp, addr); | |
6152 | } | |
6153 | } | |
6154 | else | |
6155 | { | |
6156 | if ( argv[0][0] == 'n' ) | |
6157 | { | |
6158 | auth_type = OSPF_AUTH_NULL; | |
6159 | } | |
6160 | else if ( argv[0][0] == 'm' ) | |
6161 | { | |
6162 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6163 | } | |
6164 | else | |
6165 | { | |
6166 | vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE); | |
6167 | return CMD_WARNING; | |
6168 | } | |
6169 | /* | |
6170 | * Here we have a case where the user has entered | |
6171 | * 'no ip ospf authentication (null | message_digest )' | |
6172 | * we need to find if we have any ip addresses underneath it that | |
6173 | * correspond to the associated type. | |
6174 | */ | |
6175 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) | |
6176 | { | |
6177 | if ((params = rn->info)) | |
6178 | { | |
6179 | if (params->auth_type == auth_type) | |
6180 | { | |
6181 | params->auth_type = OSPF_AUTH_NOTSET; | |
6182 | UNSET_IF_PARAM (params, auth_type); | |
6183 | if (params != IF_DEF_PARAMS (ifp)) | |
6184 | { | |
6185 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6186 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6187 | } | |
6188 | } | |
6189 | } | |
6190 | } | |
6191 | } | |
6192 | ||
6193 | return CMD_SUCCESS; | |
6194 | } | |
6195 | ||
6196 | ALIAS (no_ip_ospf_authentication_args, | |
6197 | no_ip_ospf_authentication_args_cmd, | |
6198 | "no ip ospf authentication (null|message-digest)", | |
6199 | NO_STR | |
6200 | "IP Information\n" | |
6201 | "OSPF interface commands\n" | |
6202 | "Enable authentication on this interface\n" | |
6203 | "Use null authentication\n" | |
6204 | "Use message-digest authentication\n") | |
6205 | ||
718e3744 | 6206 | DEFUN (no_ip_ospf_authentication, |
6207 | no_ip_ospf_authentication_addr_cmd, | |
6208 | "no ip ospf authentication A.B.C.D", | |
6209 | NO_STR | |
6210 | "IP Information\n" | |
6211 | "OSPF interface commands\n" | |
6212 | "Enable authentication on this interface\n" | |
6213 | "Address of interface") | |
6214 | { | |
6215 | struct interface *ifp; | |
6216 | struct in_addr addr; | |
6217 | int ret; | |
6218 | struct ospf_if_params *params; | |
b4a039bf DS |
6219 | struct route_node *rn; |
6220 | ||
718e3744 | 6221 | ifp = vty->index; |
6222 | params = IF_DEF_PARAMS (ifp); | |
6223 | ||
6224 | if (argc == 1) | |
6225 | { | |
5dcf71df | 6226 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6227 | if (!ret) |
6228 | { | |
6229 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6230 | VTY_NEWLINE); | |
6231 | return CMD_WARNING; | |
6232 | } | |
6233 | ||
6234 | params = ospf_lookup_if_params (ifp, addr); | |
6235 | if (params == NULL) | |
b4a039bf DS |
6236 | { |
6237 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6238 | return CMD_WARNING; | |
6239 | } | |
718e3744 | 6240 | |
b4a039bf DS |
6241 | params->auth_type = OSPF_AUTH_NOTSET; |
6242 | UNSET_IF_PARAM (params, auth_type); | |
6243 | if (params != IF_DEF_PARAMS (ifp)) | |
6244 | { | |
6245 | ospf_free_if_params (ifp, addr); | |
6246 | ospf_if_update_params (ifp, addr); | |
6247 | } | |
6248 | } | |
6249 | else | |
718e3744 | 6250 | { |
b4a039bf DS |
6251 | /* |
6252 | * When a user enters 'no ip ospf authentication' | |
6253 | * We should remove all authentication types from | |
6254 | * the interface. | |
6255 | */ | |
6256 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) | |
6257 | { | |
6258 | if ((params = rn->info)) | |
6259 | { | |
6260 | if ((params->auth_type == OSPF_AUTH_NULL) || | |
6261 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6262 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6263 | { | |
6264 | params->auth_type = OSPF_AUTH_NOTSET; | |
6265 | UNSET_IF_PARAM (params, auth_type); | |
6266 | if (params != IF_DEF_PARAMS (ifp)) | |
6267 | { | |
6268 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6269 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6270 | } | |
6271 | } | |
6272 | } | |
6273 | } | |
718e3744 | 6274 | } |
6275 | ||
6276 | return CMD_SUCCESS; | |
6277 | } | |
6278 | ||
6279 | ALIAS (no_ip_ospf_authentication, | |
6280 | no_ip_ospf_authentication_cmd, | |
6281 | "no ip ospf authentication", | |
6282 | NO_STR | |
6283 | "IP Information\n" | |
6284 | "OSPF interface commands\n" | |
6285 | "Enable authentication on this interface\n") | |
6286 | ||
6287 | DEFUN (ip_ospf_authentication_key, | |
6288 | ip_ospf_authentication_key_addr_cmd, | |
6289 | "ip ospf authentication-key AUTH_KEY A.B.C.D", | |
6290 | "IP Information\n" | |
6291 | "OSPF interface commands\n" | |
6292 | "Authentication password (key)\n" | |
6293 | "The OSPF password (key)\n" | |
6294 | "Address of interface") | |
6295 | { | |
6296 | struct interface *ifp; | |
6297 | struct in_addr addr; | |
6298 | int ret; | |
6299 | struct ospf_if_params *params; | |
6300 | ||
6301 | ifp = vty->index; | |
6302 | params = IF_DEF_PARAMS (ifp); | |
6303 | ||
6304 | if (argc == 2) | |
6305 | { | |
6306 | ret = inet_aton(argv[1], &addr); | |
6307 | if (!ret) | |
6308 | { | |
6309 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6310 | VTY_NEWLINE); | |
6311 | return CMD_WARNING; | |
6312 | } | |
6313 | ||
6314 | params = ospf_get_if_params (ifp, addr); | |
6315 | ospf_if_update_params (ifp, addr); | |
6316 | } | |
6317 | ||
6318 | ||
6319 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
c9e52be3 | 6320 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 6321 | SET_IF_PARAM (params, auth_simple); |
6322 | ||
6323 | return CMD_SUCCESS; | |
6324 | } | |
6325 | ||
6326 | ALIAS (ip_ospf_authentication_key, | |
6327 | ip_ospf_authentication_key_cmd, | |
6328 | "ip ospf authentication-key AUTH_KEY", | |
6329 | "IP Information\n" | |
6330 | "OSPF interface commands\n" | |
6331 | "Authentication password (key)\n" | |
6332 | "The OSPF password (key)") | |
6333 | ||
6334 | ALIAS (ip_ospf_authentication_key, | |
6335 | ospf_authentication_key_cmd, | |
6336 | "ospf authentication-key AUTH_KEY", | |
6337 | "OSPF interface commands\n" | |
6338 | "Authentication password (key)\n" | |
6339 | "The OSPF password (key)") | |
6340 | ||
6341 | DEFUN (no_ip_ospf_authentication_key, | |
6342 | no_ip_ospf_authentication_key_addr_cmd, | |
6343 | "no ip ospf authentication-key A.B.C.D", | |
6344 | NO_STR | |
6345 | "IP Information\n" | |
6346 | "OSPF interface commands\n" | |
6347 | "Authentication password (key)\n" | |
6348 | "Address of interface") | |
6349 | { | |
6350 | struct interface *ifp; | |
6351 | struct in_addr addr; | |
6352 | int ret; | |
6353 | struct ospf_if_params *params; | |
6354 | ||
6355 | ifp = vty->index; | |
6356 | params = IF_DEF_PARAMS (ifp); | |
6357 | ||
5dcf71df | 6358 | if (argc == 1) |
718e3744 | 6359 | { |
5dcf71df | 6360 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6361 | if (!ret) |
6362 | { | |
6363 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6364 | VTY_NEWLINE); | |
6365 | return CMD_WARNING; | |
6366 | } | |
6367 | ||
6368 | params = ospf_lookup_if_params (ifp, addr); | |
6369 | if (params == NULL) | |
6370 | return CMD_SUCCESS; | |
6371 | } | |
6372 | ||
6373 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); | |
6374 | UNSET_IF_PARAM (params, auth_simple); | |
6375 | ||
6376 | if (params != IF_DEF_PARAMS (ifp)) | |
6377 | { | |
6378 | ospf_free_if_params (ifp, addr); | |
6379 | ospf_if_update_params (ifp, addr); | |
6380 | } | |
6381 | ||
6382 | return CMD_SUCCESS; | |
6383 | } | |
6384 | ||
6385 | ALIAS (no_ip_ospf_authentication_key, | |
6386 | no_ip_ospf_authentication_key_cmd, | |
6387 | "no ip ospf authentication-key", | |
6388 | NO_STR | |
6389 | "IP Information\n" | |
6390 | "OSPF interface commands\n" | |
6391 | "Authentication password (key)\n") | |
6392 | ||
6393 | ALIAS (no_ip_ospf_authentication_key, | |
6394 | no_ospf_authentication_key_cmd, | |
6395 | "no ospf authentication-key", | |
6396 | NO_STR | |
6397 | "OSPF interface commands\n" | |
6398 | "Authentication password (key)\n") | |
6399 | ||
6400 | DEFUN (ip_ospf_message_digest_key, | |
6401 | ip_ospf_message_digest_key_addr_cmd, | |
6402 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", | |
6403 | "IP Information\n" | |
6404 | "OSPF interface commands\n" | |
6405 | "Message digest authentication password (key)\n" | |
6406 | "Key ID\n" | |
6407 | "Use MD5 algorithm\n" | |
6408 | "The OSPF password (key)" | |
6409 | "Address of interface") | |
6410 | { | |
6411 | struct interface *ifp; | |
6412 | struct crypt_key *ck; | |
6413 | u_char key_id; | |
6414 | struct in_addr addr; | |
6415 | int ret; | |
6416 | struct ospf_if_params *params; | |
6417 | ||
6418 | ifp = vty->index; | |
6419 | params = IF_DEF_PARAMS (ifp); | |
6420 | ||
6421 | if (argc == 3) | |
6422 | { | |
6423 | ret = inet_aton(argv[2], &addr); | |
6424 | if (!ret) | |
6425 | { | |
6426 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6427 | VTY_NEWLINE); | |
6428 | return CMD_WARNING; | |
6429 | } | |
6430 | ||
6431 | params = ospf_get_if_params (ifp, addr); | |
6432 | ospf_if_update_params (ifp, addr); | |
6433 | } | |
6434 | ||
6435 | key_id = strtol (argv[0], NULL, 10); | |
6436 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) | |
6437 | { | |
6438 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
6439 | return CMD_WARNING; | |
6440 | } | |
6441 | ||
6442 | ck = ospf_crypt_key_new (); | |
6443 | ck->key_id = (u_char) key_id; | |
6444 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 6445 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
718e3744 | 6446 | |
6447 | ospf_crypt_key_add (params->auth_crypt, ck); | |
6448 | SET_IF_PARAM (params, auth_crypt); | |
6449 | ||
6450 | return CMD_SUCCESS; | |
6451 | } | |
6452 | ||
6453 | ALIAS (ip_ospf_message_digest_key, | |
6454 | ip_ospf_message_digest_key_cmd, | |
6455 | "ip ospf message-digest-key <1-255> md5 KEY", | |
6456 | "IP Information\n" | |
6457 | "OSPF interface commands\n" | |
6458 | "Message digest authentication password (key)\n" | |
6459 | "Key ID\n" | |
6460 | "Use MD5 algorithm\n" | |
6461 | "The OSPF password (key)") | |
6462 | ||
6463 | ALIAS (ip_ospf_message_digest_key, | |
6464 | ospf_message_digest_key_cmd, | |
6465 | "ospf message-digest-key <1-255> md5 KEY", | |
6466 | "OSPF interface commands\n" | |
6467 | "Message digest authentication password (key)\n" | |
6468 | "Key ID\n" | |
6469 | "Use MD5 algorithm\n" | |
6470 | "The OSPF password (key)") | |
6471 | ||
6472 | DEFUN (no_ip_ospf_message_digest_key, | |
6473 | no_ip_ospf_message_digest_key_addr_cmd, | |
6474 | "no ip ospf message-digest-key <1-255> A.B.C.D", | |
6475 | NO_STR | |
6476 | "IP Information\n" | |
6477 | "OSPF interface commands\n" | |
6478 | "Message digest authentication password (key)\n" | |
6479 | "Key ID\n" | |
6480 | "Address of interface") | |
6481 | { | |
6482 | struct interface *ifp; | |
6483 | struct crypt_key *ck; | |
6484 | int key_id; | |
6485 | struct in_addr addr; | |
6486 | int ret; | |
6487 | struct ospf_if_params *params; | |
6488 | ||
6489 | ifp = vty->index; | |
6490 | params = IF_DEF_PARAMS (ifp); | |
6491 | ||
6492 | if (argc == 2) | |
6493 | { | |
6494 | ret = inet_aton(argv[1], &addr); | |
6495 | if (!ret) | |
6496 | { | |
6497 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6498 | VTY_NEWLINE); | |
6499 | return CMD_WARNING; | |
6500 | } | |
6501 | ||
6502 | params = ospf_lookup_if_params (ifp, addr); | |
6503 | if (params == NULL) | |
6504 | return CMD_SUCCESS; | |
6505 | } | |
6506 | ||
6507 | key_id = strtol (argv[0], NULL, 10); | |
6508 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); | |
6509 | if (ck == NULL) | |
6510 | { | |
6511 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6512 | return CMD_WARNING; | |
6513 | } | |
6514 | ||
6515 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6516 | ||
6517 | if (params != IF_DEF_PARAMS (ifp)) | |
6518 | { | |
6519 | ospf_free_if_params (ifp, addr); | |
6520 | ospf_if_update_params (ifp, addr); | |
6521 | } | |
6522 | ||
6523 | return CMD_SUCCESS; | |
6524 | } | |
6525 | ||
6526 | ALIAS (no_ip_ospf_message_digest_key, | |
6527 | no_ip_ospf_message_digest_key_cmd, | |
6528 | "no ip ospf message-digest-key <1-255>", | |
6529 | NO_STR | |
6530 | "IP Information\n" | |
6531 | "OSPF interface commands\n" | |
6532 | "Message digest authentication password (key)\n" | |
6533 | "Key ID\n") | |
6534 | ||
6535 | ALIAS (no_ip_ospf_message_digest_key, | |
6536 | no_ospf_message_digest_key_cmd, | |
6537 | "no ospf message-digest-key <1-255>", | |
6538 | NO_STR | |
6539 | "OSPF interface commands\n" | |
6540 | "Message digest authentication password (key)\n" | |
6541 | "Key ID\n") | |
6542 | ||
6543 | DEFUN (ip_ospf_cost, | |
9eff36b3 | 6544 | ip_ospf_cost_u32_inet4_cmd, |
718e3744 | 6545 | "ip ospf cost <1-65535> A.B.C.D", |
6546 | "IP Information\n" | |
6547 | "OSPF interface commands\n" | |
6548 | "Interface cost\n" | |
6549 | "Cost\n" | |
6550 | "Address of interface") | |
6551 | { | |
6552 | struct interface *ifp = vty->index; | |
6553 | u_int32_t cost; | |
6554 | struct in_addr addr; | |
6555 | int ret; | |
6556 | struct ospf_if_params *params; | |
6557 | ||
6558 | params = IF_DEF_PARAMS (ifp); | |
6559 | ||
6560 | cost = strtol (argv[0], NULL, 10); | |
6561 | ||
6562 | /* cost range is <1-65535>. */ | |
6563 | if (cost < 1 || cost > 65535) | |
6564 | { | |
6565 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6566 | return CMD_WARNING; | |
6567 | } | |
6568 | ||
6569 | if (argc == 2) | |
6570 | { | |
6571 | ret = inet_aton(argv[1], &addr); | |
6572 | if (!ret) | |
6573 | { | |
6574 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6575 | VTY_NEWLINE); | |
6576 | return CMD_WARNING; | |
6577 | } | |
6578 | ||
6579 | params = ospf_get_if_params (ifp, addr); | |
6580 | ospf_if_update_params (ifp, addr); | |
6581 | } | |
6582 | ||
6583 | SET_IF_PARAM (params, output_cost_cmd); | |
6584 | params->output_cost_cmd = cost; | |
6585 | ||
6586 | ospf_if_recalculate_output_cost (ifp); | |
6587 | ||
6588 | return CMD_SUCCESS; | |
6589 | } | |
6590 | ||
6591 | ALIAS (ip_ospf_cost, | |
9eff36b3 | 6592 | ip_ospf_cost_u32_cmd, |
718e3744 | 6593 | "ip ospf cost <1-65535>", |
6594 | "IP Information\n" | |
6595 | "OSPF interface commands\n" | |
6596 | "Interface cost\n" | |
6597 | "Cost") | |
6598 | ||
6599 | ALIAS (ip_ospf_cost, | |
9eff36b3 | 6600 | ospf_cost_u32_cmd, |
718e3744 | 6601 | "ospf cost <1-65535>", |
6602 | "OSPF interface commands\n" | |
6603 | "Interface cost\n" | |
6604 | "Cost") | |
6605 | ||
9eff36b3 DO |
6606 | ALIAS (ip_ospf_cost, |
6607 | ospf_cost_u32_inet4_cmd, | |
6608 | "ospf cost <1-65535> A.B.C.D", | |
6609 | "OSPF interface commands\n" | |
6610 | "Interface cost\n" | |
6611 | "Cost\n" | |
6612 | "Address of interface") | |
6613 | ||
718e3744 | 6614 | DEFUN (no_ip_ospf_cost, |
9eff36b3 | 6615 | no_ip_ospf_cost_inet4_cmd, |
718e3744 | 6616 | "no ip ospf cost A.B.C.D", |
6617 | NO_STR | |
6618 | "IP Information\n" | |
6619 | "OSPF interface commands\n" | |
6620 | "Interface cost\n" | |
6621 | "Address of interface") | |
6622 | { | |
6623 | struct interface *ifp = vty->index; | |
6624 | struct in_addr addr; | |
6625 | int ret; | |
6626 | struct ospf_if_params *params; | |
6627 | ||
6628 | ifp = vty->index; | |
6629 | params = IF_DEF_PARAMS (ifp); | |
6630 | ||
6631 | if (argc == 1) | |
6632 | { | |
6633 | ret = inet_aton(argv[0], &addr); | |
6634 | if (!ret) | |
6635 | { | |
6636 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6637 | VTY_NEWLINE); | |
6638 | return CMD_WARNING; | |
6639 | } | |
6640 | ||
6641 | params = ospf_lookup_if_params (ifp, addr); | |
6642 | if (params == NULL) | |
6643 | return CMD_SUCCESS; | |
6644 | } | |
6645 | ||
6646 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6647 | ||
6648 | if (params != IF_DEF_PARAMS (ifp)) | |
6649 | { | |
6650 | ospf_free_if_params (ifp, addr); | |
6651 | ospf_if_update_params (ifp, addr); | |
6652 | } | |
6653 | ||
6654 | ospf_if_recalculate_output_cost (ifp); | |
6655 | ||
6656 | return CMD_SUCCESS; | |
6657 | } | |
6658 | ||
6659 | ALIAS (no_ip_ospf_cost, | |
6660 | no_ip_ospf_cost_cmd, | |
6661 | "no ip ospf cost", | |
6662 | NO_STR | |
6663 | "IP Information\n" | |
6664 | "OSPF interface commands\n" | |
6665 | "Interface cost\n") | |
6666 | ||
6667 | ALIAS (no_ip_ospf_cost, | |
6668 | no_ospf_cost_cmd, | |
6669 | "no ospf cost", | |
6670 | NO_STR | |
6671 | "OSPF interface commands\n" | |
6672 | "Interface cost\n") | |
6673 | ||
9eff36b3 DO |
6674 | ALIAS (no_ip_ospf_cost, |
6675 | no_ospf_cost_inet4_cmd, | |
6676 | "no ospf cost A.B.C.D", | |
6677 | NO_STR | |
6678 | "OSPF interface commands\n" | |
6679 | "Interface cost\n" | |
6680 | "Address of interface") | |
6681 | ||
827341b7 DO |
6682 | DEFUN (no_ip_ospf_cost2, |
6683 | no_ip_ospf_cost_u32_cmd, | |
6684 | "no ip ospf cost <1-65535>", | |
6685 | NO_STR | |
6686 | "IP Information\n" | |
6687 | "OSPF interface commands\n" | |
6688 | "Interface cost\n" | |
6689 | "Cost") | |
6690 | { | |
6691 | struct interface *ifp = vty->index; | |
6692 | struct in_addr addr; | |
6693 | u_int32_t cost; | |
6694 | int ret; | |
6695 | struct ospf_if_params *params; | |
6696 | ||
6697 | ifp = vty->index; | |
6698 | params = IF_DEF_PARAMS (ifp); | |
6699 | ||
6700 | /* According to the semantics we are mimicking "no ip ospf cost N" is | |
6701 | * always treated as "no ip ospf cost" regardless of the actual value | |
6702 | * of N already configured for the interface. Thus the first argument | |
6703 | * is always checked to be a number, but is ignored after that. | |
6704 | */ | |
6705 | cost = strtol (argv[0], NULL, 10); | |
6706 | if (cost < 1 || cost > 65535) | |
6707 | { | |
6708 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6709 | return CMD_WARNING; | |
6710 | } | |
6711 | ||
6712 | if (argc == 2) | |
6713 | { | |
6714 | ret = inet_aton(argv[1], &addr); | |
6715 | if (!ret) | |
6716 | { | |
6717 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6718 | VTY_NEWLINE); | |
6719 | return CMD_WARNING; | |
6720 | } | |
6721 | ||
6722 | params = ospf_lookup_if_params (ifp, addr); | |
6723 | if (params == NULL) | |
6724 | return CMD_SUCCESS; | |
6725 | } | |
6726 | ||
6727 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6728 | ||
6729 | if (params != IF_DEF_PARAMS (ifp)) | |
6730 | { | |
6731 | ospf_free_if_params (ifp, addr); | |
6732 | ospf_if_update_params (ifp, addr); | |
6733 | } | |
6734 | ||
6735 | ospf_if_recalculate_output_cost (ifp); | |
6736 | ||
6737 | return CMD_SUCCESS; | |
6738 | } | |
6739 | ||
6740 | ALIAS (no_ip_ospf_cost2, | |
6741 | no_ospf_cost_u32_cmd, | |
6742 | "no ospf cost <1-65535>", | |
6743 | NO_STR | |
6744 | "OSPF interface commands\n" | |
6745 | "Interface cost\n" | |
6746 | "Cost") | |
6747 | ||
6748 | ALIAS (no_ip_ospf_cost2, | |
6749 | no_ip_ospf_cost_u32_inet4_cmd, | |
6750 | "no ip ospf cost <1-65535> A.B.C.D", | |
6751 | NO_STR | |
6752 | "IP Information\n" | |
6753 | "OSPF interface commands\n" | |
6754 | "Interface cost\n" | |
6755 | "Cost\n" | |
6756 | "Address of interface") | |
6757 | ||
6758 | ALIAS (no_ip_ospf_cost2, | |
6759 | no_ospf_cost_u32_inet4_cmd, | |
6760 | "no ospf cost <1-65535> A.B.C.D", | |
6761 | NO_STR | |
6762 | "OSPF interface commands\n" | |
6763 | "Interface cost\n" | |
6764 | "Cost\n" | |
6765 | "Address of interface") | |
9eff36b3 | 6766 | |
4dadc291 | 6767 | static void |
718e3744 | 6768 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6769 | { | |
6770 | struct route_node *rn; | |
6771 | struct ospf_neighbor *nbr; | |
6772 | ||
6773 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6774 | if ((nbr = rn->info)) | |
6775 | { | |
6776 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6777 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6778 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6779 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6780 | } | |
6781 | } | |
6782 | ||
f9ad937f | 6783 | static int |
6784 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6785 | const char *nbr_str, | |
6786 | const char *fast_hello_str) | |
718e3744 | 6787 | { |
6788 | struct interface *ifp = vty->index; | |
6789 | u_int32_t seconds; | |
f9ad937f | 6790 | u_char hellomult; |
718e3744 | 6791 | struct in_addr addr; |
6792 | int ret; | |
6793 | struct ospf_if_params *params; | |
6794 | struct ospf_interface *oi; | |
6795 | struct route_node *rn; | |
6796 | ||
6797 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6798 | |
6799 | if (nbr_str) | |
718e3744 | 6800 | { |
f9ad937f | 6801 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6802 | if (!ret) |
6803 | { | |
6804 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6805 | VTY_NEWLINE); | |
6806 | return CMD_WARNING; | |
6807 | } | |
6808 | ||
6809 | params = ospf_get_if_params (ifp, addr); | |
6810 | ospf_if_update_params (ifp, addr); | |
6811 | } | |
6812 | ||
f9ad937f | 6813 | if (interval_str) |
6814 | { | |
6815 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
6816 | 1, 65535); | |
6817 | ||
6818 | /* reset fast_hello too, just to be sure */ | |
6819 | UNSET_IF_PARAM (params, fast_hello); | |
6820 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6821 | } | |
6822 | else if (fast_hello_str) | |
6823 | { | |
6824 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
6825 | 1, 10); | |
6826 | /* 1s dead-interval with sub-second hellos desired */ | |
6827 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6828 | SET_IF_PARAM (params, fast_hello); | |
6829 | params->fast_hello = hellomult; | |
6830 | } | |
6831 | else | |
6832 | { | |
6833 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
6834 | VTY_NEWLINE); | |
6835 | return CMD_WARNING; | |
6836 | } | |
6837 | ||
718e3744 | 6838 | SET_IF_PARAM (params, v_wait); |
6839 | params->v_wait = seconds; | |
6840 | ||
6841 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6842 | if (nbr_str) |
718e3744 | 6843 | { |
cac3b5c4 PJ |
6844 | struct ospf *ospf; |
6845 | if ((ospf = ospf_lookup())) | |
68980084 | 6846 | { |
6847 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6848 | if (oi) | |
6849 | ospf_nbr_timer_update (oi); | |
6850 | } | |
718e3744 | 6851 | } |
6852 | else | |
6853 | { | |
6854 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6855 | if ((oi = rn->info)) | |
6856 | ospf_nbr_timer_update (oi); | |
6857 | } | |
6858 | ||
6859 | return CMD_SUCCESS; | |
6860 | } | |
6861 | ||
f9ad937f | 6862 | |
6863 | DEFUN (ip_ospf_dead_interval, | |
6864 | ip_ospf_dead_interval_addr_cmd, | |
6865 | "ip ospf dead-interval <1-65535> A.B.C.D", | |
6866 | "IP Information\n" | |
6867 | "OSPF interface commands\n" | |
6868 | "Interval after which a neighbor is declared dead\n" | |
6869 | "Seconds\n" | |
6870 | "Address of interface\n") | |
6871 | { | |
6872 | if (argc == 2) | |
6873 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); | |
6874 | else | |
6875 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); | |
6876 | } | |
6877 | ||
718e3744 | 6878 | ALIAS (ip_ospf_dead_interval, |
6879 | ip_ospf_dead_interval_cmd, | |
6880 | "ip ospf dead-interval <1-65535>", | |
6881 | "IP Information\n" | |
6882 | "OSPF interface commands\n" | |
6883 | "Interval after which a neighbor is declared dead\n" | |
6884 | "Seconds\n") | |
6885 | ||
6886 | ALIAS (ip_ospf_dead_interval, | |
6887 | ospf_dead_interval_cmd, | |
6888 | "ospf dead-interval <1-65535>", | |
6889 | "OSPF interface commands\n" | |
6890 | "Interval after which a neighbor is declared dead\n" | |
6891 | "Seconds\n") | |
6892 | ||
f9ad937f | 6893 | DEFUN (ip_ospf_dead_interval_minimal, |
6894 | ip_ospf_dead_interval_minimal_addr_cmd, | |
6895 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
6896 | "IP Information\n" | |
6897 | "OSPF interface commands\n" | |
6898 | "Interval after which a neighbor is declared dead\n" | |
6899 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
6900 | "Hello multiplier factor\n" | |
6901 | "Number of Hellos to send each second\n" | |
6902 | "Address of interface\n") | |
6903 | { | |
6904 | if (argc == 2) | |
6905 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); | |
6906 | else | |
6907 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); | |
6908 | } | |
6909 | ||
6910 | ALIAS (ip_ospf_dead_interval_minimal, | |
6911 | ip_ospf_dead_interval_minimal_cmd, | |
6912 | "ip ospf dead-interval minimal hello-multiplier <1-10>", | |
6913 | "IP Information\n" | |
6914 | "OSPF interface commands\n" | |
6915 | "Interval after which a neighbor is declared dead\n" | |
6916 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
6917 | "Hello multiplier factor\n" | |
6918 | "Number of Hellos to send each second\n") | |
6919 | ||
718e3744 | 6920 | DEFUN (no_ip_ospf_dead_interval, |
6921 | no_ip_ospf_dead_interval_addr_cmd, | |
f9dfba8d | 6922 | "no ip ospf dead-interval <1-65535> A.B.C.D", |
718e3744 | 6923 | NO_STR |
6924 | "IP Information\n" | |
6925 | "OSPF interface commands\n" | |
6926 | "Interval after which a neighbor is declared dead\n" | |
f9dfba8d | 6927 | "Seconds\n" |
718e3744 | 6928 | "Address of interface") |
6929 | { | |
6930 | struct interface *ifp = vty->index; | |
6931 | struct in_addr addr; | |
6932 | int ret; | |
6933 | struct ospf_if_params *params; | |
6934 | struct ospf_interface *oi; | |
6935 | struct route_node *rn; | |
020709f9 | 6936 | |
718e3744 | 6937 | ifp = vty->index; |
6938 | params = IF_DEF_PARAMS (ifp); | |
6939 | ||
f9dfba8d | 6940 | if (argc == 2) |
718e3744 | 6941 | { |
f9dfba8d | 6942 | ret = inet_aton(argv[1], &addr); |
718e3744 | 6943 | if (!ret) |
6944 | { | |
6945 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6946 | VTY_NEWLINE); | |
6947 | return CMD_WARNING; | |
6948 | } | |
6949 | ||
6950 | params = ospf_lookup_if_params (ifp, addr); | |
6951 | if (params == NULL) | |
6952 | return CMD_SUCCESS; | |
6953 | } | |
6954 | ||
6955 | UNSET_IF_PARAM (params, v_wait); | |
6956 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 6957 | |
6958 | UNSET_IF_PARAM (params, fast_hello); | |
6959 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6960 | ||
718e3744 | 6961 | if (params != IF_DEF_PARAMS (ifp)) |
6962 | { | |
6963 | ospf_free_if_params (ifp, addr); | |
6964 | ospf_if_update_params (ifp, addr); | |
6965 | } | |
6966 | ||
6967 | /* Update timer values in neighbor structure. */ | |
6968 | if (argc == 1) | |
6969 | { | |
cac3b5c4 PJ |
6970 | struct ospf *ospf; |
6971 | ||
6972 | if ((ospf = ospf_lookup())) | |
68980084 | 6973 | { |
6974 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6975 | if (oi) | |
6976 | ospf_nbr_timer_update (oi); | |
6977 | } | |
718e3744 | 6978 | } |
6979 | else | |
6980 | { | |
6981 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6982 | if ((oi = rn->info)) | |
6983 | ospf_nbr_timer_update (oi); | |
6984 | } | |
6985 | ||
6986 | return CMD_SUCCESS; | |
6987 | } | |
6988 | ||
f9dfba8d DS |
6989 | ALIAS (no_ip_ospf_dead_interval, |
6990 | no_ip_ospf_dead_interval_seconds_cmd, | |
6991 | "no ip ospf dead-interval <1-65535>", | |
6992 | NO_STR | |
6993 | "IP Information\n" | |
6994 | "OSPF interface commands\n" | |
6995 | "Interval after which a neighbor is declared dead\n" | |
6996 | "Seconds\n") | |
6997 | ||
718e3744 | 6998 | ALIAS (no_ip_ospf_dead_interval, |
6999 | no_ip_ospf_dead_interval_cmd, | |
7000 | "no ip ospf dead-interval", | |
7001 | NO_STR | |
7002 | "IP Information\n" | |
7003 | "OSPF interface commands\n" | |
7004 | "Interval after which a neighbor is declared dead\n") | |
7005 | ||
7006 | ALIAS (no_ip_ospf_dead_interval, | |
7007 | no_ospf_dead_interval_cmd, | |
7008 | "no ospf dead-interval", | |
7009 | NO_STR | |
7010 | "OSPF interface commands\n" | |
7011 | "Interval after which a neighbor is declared dead\n") | |
7012 | ||
7013 | DEFUN (ip_ospf_hello_interval, | |
7014 | ip_ospf_hello_interval_addr_cmd, | |
7015 | "ip ospf hello-interval <1-65535> A.B.C.D", | |
7016 | "IP Information\n" | |
7017 | "OSPF interface commands\n" | |
7018 | "Time between HELLO packets\n" | |
7019 | "Seconds\n" | |
7020 | "Address of interface") | |
7021 | { | |
7022 | struct interface *ifp = vty->index; | |
7023 | u_int32_t seconds; | |
7024 | struct in_addr addr; | |
7025 | int ret; | |
7026 | struct ospf_if_params *params; | |
7027 | ||
7028 | params = IF_DEF_PARAMS (ifp); | |
7029 | ||
7030 | seconds = strtol (argv[0], NULL, 10); | |
7031 | ||
7032 | /* HelloInterval range is <1-65535>. */ | |
7033 | if (seconds < 1 || seconds > 65535) | |
7034 | { | |
7035 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); | |
7036 | return CMD_WARNING; | |
7037 | } | |
7038 | ||
7039 | if (argc == 2) | |
7040 | { | |
7041 | ret = inet_aton(argv[1], &addr); | |
7042 | if (!ret) | |
7043 | { | |
7044 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7045 | VTY_NEWLINE); | |
7046 | return CMD_WARNING; | |
7047 | } | |
7048 | ||
7049 | params = ospf_get_if_params (ifp, addr); | |
7050 | ospf_if_update_params (ifp, addr); | |
7051 | } | |
7052 | ||
f9ad937f | 7053 | SET_IF_PARAM (params, v_hello); |
718e3744 | 7054 | params->v_hello = seconds; |
7055 | ||
7056 | return CMD_SUCCESS; | |
7057 | } | |
7058 | ||
7059 | ALIAS (ip_ospf_hello_interval, | |
7060 | ip_ospf_hello_interval_cmd, | |
7061 | "ip ospf hello-interval <1-65535>", | |
7062 | "IP Information\n" | |
7063 | "OSPF interface commands\n" | |
7064 | "Time between HELLO packets\n" | |
7065 | "Seconds\n") | |
7066 | ||
7067 | ALIAS (ip_ospf_hello_interval, | |
7068 | ospf_hello_interval_cmd, | |
7069 | "ospf hello-interval <1-65535>", | |
7070 | "OSPF interface commands\n" | |
7071 | "Time between HELLO packets\n" | |
7072 | "Seconds\n") | |
7073 | ||
7074 | DEFUN (no_ip_ospf_hello_interval, | |
7075 | no_ip_ospf_hello_interval_addr_cmd, | |
f9dfba8d | 7076 | "no ip ospf hello-interval <1-65535> A.B.C.D", |
718e3744 | 7077 | NO_STR |
7078 | "IP Information\n" | |
7079 | "OSPF interface commands\n" | |
7080 | "Time between HELLO packets\n" | |
f9dfba8d | 7081 | "Seconds\n" |
718e3744 | 7082 | "Address of interface") |
7083 | { | |
7084 | struct interface *ifp = vty->index; | |
7085 | struct in_addr addr; | |
7086 | int ret; | |
7087 | struct ospf_if_params *params; | |
7088 | ||
7089 | ifp = vty->index; | |
7090 | params = IF_DEF_PARAMS (ifp); | |
7091 | ||
f9dfba8d | 7092 | if (argc == 2) |
718e3744 | 7093 | { |
f9dfba8d | 7094 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7095 | if (!ret) |
7096 | { | |
7097 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7098 | VTY_NEWLINE); | |
7099 | return CMD_WARNING; | |
7100 | } | |
7101 | ||
7102 | params = ospf_lookup_if_params (ifp, addr); | |
7103 | if (params == NULL) | |
7104 | return CMD_SUCCESS; | |
7105 | } | |
7106 | ||
7107 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 7108 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 7109 | |
7110 | if (params != IF_DEF_PARAMS (ifp)) | |
7111 | { | |
7112 | ospf_free_if_params (ifp, addr); | |
7113 | ospf_if_update_params (ifp, addr); | |
7114 | } | |
7115 | ||
7116 | return CMD_SUCCESS; | |
7117 | } | |
7118 | ||
f9dfba8d DS |
7119 | ALIAS (no_ip_ospf_hello_interval, |
7120 | no_ip_ospf_hello_interval_seconds_cmd, | |
7121 | "no ip ospf hello-interval <1-65535>", | |
7122 | NO_STR | |
7123 | "IP Information\n" | |
7124 | "OSPF interface commands\n" | |
7125 | "Time between HELLO packets\n" | |
7126 | "Seconds\n") | |
7127 | ||
718e3744 | 7128 | ALIAS (no_ip_ospf_hello_interval, |
7129 | no_ip_ospf_hello_interval_cmd, | |
7130 | "no ip ospf hello-interval", | |
7131 | NO_STR | |
7132 | "IP Information\n" | |
7133 | "OSPF interface commands\n" | |
7134 | "Time between HELLO packets\n") | |
7135 | ||
7136 | ALIAS (no_ip_ospf_hello_interval, | |
7137 | no_ospf_hello_interval_cmd, | |
7138 | "no ospf hello-interval", | |
7139 | NO_STR | |
7140 | "OSPF interface commands\n" | |
7141 | "Time between HELLO packets\n") | |
7142 | ||
7143 | DEFUN (ip_ospf_network, | |
7144 | ip_ospf_network_cmd, | |
7145 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7146 | "IP Information\n" | |
7147 | "OSPF interface commands\n" | |
7148 | "Network type\n" | |
7149 | "Specify OSPF broadcast multi-access network\n" | |
7150 | "Specify OSPF NBMA network\n" | |
7151 | "Specify OSPF point-to-multipoint network\n" | |
7152 | "Specify OSPF point-to-point network\n") | |
7153 | { | |
7154 | struct interface *ifp = vty->index; | |
7155 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7156 | struct route_node *rn; | |
4b4bda9b CF |
7157 | |
7158 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
7159 | { | |
7160 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
7161 | return CMD_WARNING; | |
7162 | } | |
7163 | ||
718e3744 | 7164 | if (strncmp (argv[0], "b", 1) == 0) |
7165 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; | |
7166 | else if (strncmp (argv[0], "n", 1) == 0) | |
7167 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; | |
7168 | else if (strncmp (argv[0], "point-to-m", 10) == 0) | |
7169 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; | |
7170 | else if (strncmp (argv[0], "point-to-p", 10) == 0) | |
7171 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; | |
7172 | ||
7173 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7174 | return CMD_SUCCESS; | |
7175 | ||
7176 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
7177 | ||
7178 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7179 | { | |
7180 | struct ospf_interface *oi = rn->info; | |
7181 | ||
7182 | if (!oi) | |
7183 | continue; | |
7184 | ||
7185 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7186 | ||
7187 | if (oi->state > ISM_Down) | |
7188 | { | |
7189 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7190 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7191 | } | |
7192 | } | |
7193 | ||
7194 | return CMD_SUCCESS; | |
7195 | } | |
7196 | ||
7197 | ALIAS (ip_ospf_network, | |
7198 | ospf_network_cmd, | |
7199 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7200 | "OSPF interface commands\n" | |
7201 | "Network type\n" | |
7202 | "Specify OSPF broadcast multi-access network\n" | |
7203 | "Specify OSPF NBMA network\n" | |
7204 | "Specify OSPF point-to-multipoint network\n" | |
7205 | "Specify OSPF point-to-point network\n") | |
7206 | ||
7207 | DEFUN (no_ip_ospf_network, | |
7208 | no_ip_ospf_network_cmd, | |
7209 | "no ip ospf network", | |
7210 | NO_STR | |
7211 | "IP Information\n" | |
7212 | "OSPF interface commands\n" | |
7213 | "Network type\n") | |
7214 | { | |
7215 | struct interface *ifp = vty->index; | |
7216 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7217 | struct route_node *rn; | |
7218 | ||
bc18d616 | 7219 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
718e3744 | 7220 | |
7221 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7222 | return CMD_SUCCESS; | |
7223 | ||
7224 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7225 | { | |
7226 | struct ospf_interface *oi = rn->info; | |
7227 | ||
7228 | if (!oi) | |
7229 | continue; | |
7230 | ||
7231 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7232 | ||
7233 | if (oi->state > ISM_Down) | |
7234 | { | |
7235 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7236 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7237 | } | |
7238 | } | |
7239 | ||
7240 | return CMD_SUCCESS; | |
7241 | } | |
7242 | ||
7243 | ALIAS (no_ip_ospf_network, | |
7244 | no_ospf_network_cmd, | |
7245 | "no ospf network", | |
7246 | NO_STR | |
7247 | "OSPF interface commands\n" | |
7248 | "Network type\n") | |
7249 | ||
7250 | DEFUN (ip_ospf_priority, | |
7251 | ip_ospf_priority_addr_cmd, | |
7252 | "ip ospf priority <0-255> A.B.C.D", | |
7253 | "IP Information\n" | |
7254 | "OSPF interface commands\n" | |
7255 | "Router priority\n" | |
7256 | "Priority\n" | |
7257 | "Address of interface") | |
7258 | { | |
7259 | struct interface *ifp = vty->index; | |
0798cee3 | 7260 | long priority; |
718e3744 | 7261 | struct route_node *rn; |
7262 | struct in_addr addr; | |
7263 | int ret; | |
7264 | struct ospf_if_params *params; | |
7265 | ||
7266 | params = IF_DEF_PARAMS (ifp); | |
7267 | ||
7268 | priority = strtol (argv[0], NULL, 10); | |
7269 | ||
7270 | /* Router Priority range is <0-255>. */ | |
7271 | if (priority < 0 || priority > 255) | |
7272 | { | |
7273 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); | |
7274 | return CMD_WARNING; | |
7275 | } | |
7276 | ||
7277 | if (argc == 2) | |
7278 | { | |
7279 | ret = inet_aton(argv[1], &addr); | |
7280 | if (!ret) | |
7281 | { | |
7282 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7283 | VTY_NEWLINE); | |
7284 | return CMD_WARNING; | |
7285 | } | |
7286 | ||
7287 | params = ospf_get_if_params (ifp, addr); | |
7288 | ospf_if_update_params (ifp, addr); | |
7289 | } | |
7290 | ||
7291 | SET_IF_PARAM (params, priority); | |
7292 | params->priority = priority; | |
7293 | ||
7294 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7295 | { | |
7296 | struct ospf_interface *oi = rn->info; | |
7297 | ||
7298 | if (!oi) | |
7299 | continue; | |
7300 | ||
7301 | ||
7302 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7303 | { | |
7304 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7305 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7306 | } | |
7307 | } | |
7308 | ||
7309 | return CMD_SUCCESS; | |
7310 | } | |
7311 | ||
7312 | ALIAS (ip_ospf_priority, | |
7313 | ip_ospf_priority_cmd, | |
7314 | "ip ospf priority <0-255>", | |
7315 | "IP Information\n" | |
7316 | "OSPF interface commands\n" | |
7317 | "Router priority\n" | |
7318 | "Priority\n") | |
7319 | ||
7320 | ALIAS (ip_ospf_priority, | |
7321 | ospf_priority_cmd, | |
7322 | "ospf priority <0-255>", | |
7323 | "OSPF interface commands\n" | |
7324 | "Router priority\n" | |
7325 | "Priority\n") | |
7326 | ||
7327 | DEFUN (no_ip_ospf_priority, | |
7328 | no_ip_ospf_priority_addr_cmd, | |
7329 | "no ip ospf priority A.B.C.D", | |
7330 | NO_STR | |
7331 | "IP Information\n" | |
7332 | "OSPF interface commands\n" | |
7333 | "Router priority\n" | |
7334 | "Address of interface") | |
7335 | { | |
7336 | struct interface *ifp = vty->index; | |
7337 | struct route_node *rn; | |
7338 | struct in_addr addr; | |
7339 | int ret; | |
7340 | struct ospf_if_params *params; | |
7341 | ||
7342 | ifp = vty->index; | |
7343 | params = IF_DEF_PARAMS (ifp); | |
7344 | ||
7345 | if (argc == 1) | |
7346 | { | |
7347 | ret = inet_aton(argv[0], &addr); | |
7348 | if (!ret) | |
7349 | { | |
7350 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7351 | VTY_NEWLINE); | |
7352 | return CMD_WARNING; | |
7353 | } | |
7354 | ||
7355 | params = ospf_lookup_if_params (ifp, addr); | |
7356 | if (params == NULL) | |
7357 | return CMD_SUCCESS; | |
7358 | } | |
7359 | ||
7360 | UNSET_IF_PARAM (params, priority); | |
7361 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
7362 | ||
7363 | if (params != IF_DEF_PARAMS (ifp)) | |
7364 | { | |
7365 | ospf_free_if_params (ifp, addr); | |
7366 | ospf_if_update_params (ifp, addr); | |
7367 | } | |
7368 | ||
7369 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7370 | { | |
7371 | struct ospf_interface *oi = rn->info; | |
7372 | ||
7373 | if (!oi) | |
7374 | continue; | |
7375 | ||
7376 | ||
7377 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7378 | { | |
7379 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7380 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7381 | } | |
7382 | } | |
7383 | ||
7384 | return CMD_SUCCESS; | |
7385 | } | |
7386 | ||
7387 | ALIAS (no_ip_ospf_priority, | |
7388 | no_ip_ospf_priority_cmd, | |
7389 | "no ip ospf priority", | |
7390 | NO_STR | |
7391 | "IP Information\n" | |
7392 | "OSPF interface commands\n" | |
7393 | "Router priority\n") | |
7394 | ||
7395 | ALIAS (no_ip_ospf_priority, | |
7396 | no_ospf_priority_cmd, | |
7397 | "no ospf priority", | |
7398 | NO_STR | |
7399 | "OSPF interface commands\n" | |
7400 | "Router priority\n") | |
7401 | ||
d5a5c8f0 | 7402 | |
718e3744 | 7403 | DEFUN (ip_ospf_retransmit_interval, |
7404 | ip_ospf_retransmit_interval_addr_cmd, | |
7405 | "ip ospf retransmit-interval <3-65535> A.B.C.D", | |
7406 | "IP Information\n" | |
7407 | "OSPF interface commands\n" | |
7408 | "Time between retransmitting lost link state advertisements\n" | |
7409 | "Seconds\n" | |
7410 | "Address of interface") | |
7411 | { | |
7412 | struct interface *ifp = vty->index; | |
7413 | u_int32_t seconds; | |
7414 | struct in_addr addr; | |
7415 | int ret; | |
7416 | struct ospf_if_params *params; | |
7417 | ||
7418 | params = IF_DEF_PARAMS (ifp); | |
7419 | seconds = strtol (argv[0], NULL, 10); | |
7420 | ||
7421 | /* Retransmit Interval range is <3-65535>. */ | |
7422 | if (seconds < 3 || seconds > 65535) | |
7423 | { | |
7424 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); | |
7425 | return CMD_WARNING; | |
7426 | } | |
7427 | ||
7428 | ||
7429 | if (argc == 2) | |
7430 | { | |
7431 | ret = inet_aton(argv[1], &addr); | |
7432 | if (!ret) | |
7433 | { | |
7434 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7435 | VTY_NEWLINE); | |
7436 | return CMD_WARNING; | |
7437 | } | |
7438 | ||
7439 | params = ospf_get_if_params (ifp, addr); | |
7440 | ospf_if_update_params (ifp, addr); | |
7441 | } | |
7442 | ||
7443 | SET_IF_PARAM (params, retransmit_interval); | |
7444 | params->retransmit_interval = seconds; | |
7445 | ||
7446 | return CMD_SUCCESS; | |
7447 | } | |
7448 | ||
7449 | ALIAS (ip_ospf_retransmit_interval, | |
7450 | ip_ospf_retransmit_interval_cmd, | |
7451 | "ip ospf retransmit-interval <3-65535>", | |
7452 | "IP Information\n" | |
7453 | "OSPF interface commands\n" | |
7454 | "Time between retransmitting lost link state advertisements\n" | |
7455 | "Seconds\n") | |
7456 | ||
7457 | ALIAS (ip_ospf_retransmit_interval, | |
7458 | ospf_retransmit_interval_cmd, | |
7459 | "ospf retransmit-interval <3-65535>", | |
7460 | "OSPF interface commands\n" | |
7461 | "Time between retransmitting lost link state advertisements\n" | |
7462 | "Seconds\n") | |
7463 | ||
7464 | DEFUN (no_ip_ospf_retransmit_interval, | |
7465 | no_ip_ospf_retransmit_interval_addr_cmd, | |
7466 | "no ip ospf retransmit-interval A.B.C.D", | |
7467 | NO_STR | |
7468 | "IP Information\n" | |
7469 | "OSPF interface commands\n" | |
7470 | "Time between retransmitting lost link state advertisements\n" | |
7471 | "Address of interface") | |
7472 | { | |
7473 | struct interface *ifp = vty->index; | |
7474 | struct in_addr addr; | |
7475 | int ret; | |
7476 | struct ospf_if_params *params; | |
7477 | ||
7478 | ifp = vty->index; | |
7479 | params = IF_DEF_PARAMS (ifp); | |
7480 | ||
7481 | if (argc == 1) | |
7482 | { | |
7483 | ret = inet_aton(argv[0], &addr); | |
7484 | if (!ret) | |
7485 | { | |
7486 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7487 | VTY_NEWLINE); | |
7488 | return CMD_WARNING; | |
7489 | } | |
7490 | ||
7491 | params = ospf_lookup_if_params (ifp, addr); | |
7492 | if (params == NULL) | |
7493 | return CMD_SUCCESS; | |
7494 | } | |
7495 | ||
7496 | UNSET_IF_PARAM (params, retransmit_interval); | |
7497 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7498 | ||
7499 | if (params != IF_DEF_PARAMS (ifp)) | |
7500 | { | |
7501 | ospf_free_if_params (ifp, addr); | |
7502 | ospf_if_update_params (ifp, addr); | |
7503 | } | |
7504 | ||
7505 | return CMD_SUCCESS; | |
7506 | } | |
7507 | ||
7508 | ALIAS (no_ip_ospf_retransmit_interval, | |
7509 | no_ip_ospf_retransmit_interval_cmd, | |
7510 | "no ip ospf retransmit-interval", | |
7511 | NO_STR | |
7512 | "IP Information\n" | |
7513 | "OSPF interface commands\n" | |
7514 | "Time between retransmitting lost link state advertisements\n") | |
7515 | ||
7516 | ALIAS (no_ip_ospf_retransmit_interval, | |
7517 | no_ospf_retransmit_interval_cmd, | |
7518 | "no ospf retransmit-interval", | |
7519 | NO_STR | |
7520 | "OSPF interface commands\n" | |
7521 | "Time between retransmitting lost link state advertisements\n") | |
7522 | ||
7523 | DEFUN (ip_ospf_transmit_delay, | |
7524 | ip_ospf_transmit_delay_addr_cmd, | |
7525 | "ip ospf transmit-delay <1-65535> A.B.C.D", | |
7526 | "IP Information\n" | |
7527 | "OSPF interface commands\n" | |
7528 | "Link state transmit delay\n" | |
7529 | "Seconds\n" | |
7530 | "Address of interface") | |
7531 | { | |
7532 | struct interface *ifp = vty->index; | |
7533 | u_int32_t seconds; | |
7534 | struct in_addr addr; | |
7535 | int ret; | |
7536 | struct ospf_if_params *params; | |
7537 | ||
7538 | params = IF_DEF_PARAMS (ifp); | |
7539 | seconds = strtol (argv[0], NULL, 10); | |
7540 | ||
7541 | /* Transmit Delay range is <1-65535>. */ | |
7542 | if (seconds < 1 || seconds > 65535) | |
7543 | { | |
7544 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); | |
7545 | return CMD_WARNING; | |
7546 | } | |
7547 | ||
7548 | if (argc == 2) | |
7549 | { | |
7550 | ret = inet_aton(argv[1], &addr); | |
7551 | if (!ret) | |
7552 | { | |
7553 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7554 | VTY_NEWLINE); | |
7555 | return CMD_WARNING; | |
7556 | } | |
7557 | ||
7558 | params = ospf_get_if_params (ifp, addr); | |
7559 | ospf_if_update_params (ifp, addr); | |
7560 | } | |
7561 | ||
7562 | SET_IF_PARAM (params, transmit_delay); | |
7563 | params->transmit_delay = seconds; | |
7564 | ||
7565 | return CMD_SUCCESS; | |
7566 | } | |
7567 | ||
7568 | ALIAS (ip_ospf_transmit_delay, | |
7569 | ip_ospf_transmit_delay_cmd, | |
7570 | "ip ospf transmit-delay <1-65535>", | |
7571 | "IP Information\n" | |
7572 | "OSPF interface commands\n" | |
7573 | "Link state transmit delay\n" | |
7574 | "Seconds\n") | |
7575 | ||
7576 | ALIAS (ip_ospf_transmit_delay, | |
7577 | ospf_transmit_delay_cmd, | |
7578 | "ospf transmit-delay <1-65535>", | |
7579 | "OSPF interface commands\n" | |
7580 | "Link state transmit delay\n" | |
7581 | "Seconds\n") | |
7582 | ||
7583 | DEFUN (no_ip_ospf_transmit_delay, | |
7584 | no_ip_ospf_transmit_delay_addr_cmd, | |
7585 | "no ip ospf transmit-delay A.B.C.D", | |
7586 | NO_STR | |
7587 | "IP Information\n" | |
7588 | "OSPF interface commands\n" | |
7589 | "Link state transmit delay\n" | |
7590 | "Address of interface") | |
7591 | { | |
7592 | struct interface *ifp = vty->index; | |
7593 | struct in_addr addr; | |
7594 | int ret; | |
7595 | struct ospf_if_params *params; | |
7596 | ||
7597 | ifp = vty->index; | |
7598 | params = IF_DEF_PARAMS (ifp); | |
7599 | ||
7600 | if (argc == 1) | |
7601 | { | |
7602 | ret = inet_aton(argv[0], &addr); | |
7603 | if (!ret) | |
7604 | { | |
7605 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7606 | VTY_NEWLINE); | |
7607 | return CMD_WARNING; | |
7608 | } | |
7609 | ||
7610 | params = ospf_lookup_if_params (ifp, addr); | |
7611 | if (params == NULL) | |
7612 | return CMD_SUCCESS; | |
7613 | } | |
7614 | ||
7615 | UNSET_IF_PARAM (params, transmit_delay); | |
7616 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7617 | ||
7618 | if (params != IF_DEF_PARAMS (ifp)) | |
7619 | { | |
7620 | ospf_free_if_params (ifp, addr); | |
7621 | ospf_if_update_params (ifp, addr); | |
7622 | } | |
7623 | ||
7624 | return CMD_SUCCESS; | |
7625 | } | |
7626 | ||
7627 | ALIAS (no_ip_ospf_transmit_delay, | |
7628 | no_ip_ospf_transmit_delay_cmd, | |
7629 | "no ip ospf transmit-delay", | |
7630 | NO_STR | |
7631 | "IP Information\n" | |
7632 | "OSPF interface commands\n" | |
7633 | "Link state transmit delay\n") | |
7634 | ||
7635 | ALIAS (no_ip_ospf_transmit_delay, | |
7636 | no_ospf_transmit_delay_cmd, | |
7637 | "no ospf transmit-delay", | |
7638 | NO_STR | |
7639 | "OSPF interface commands\n" | |
7640 | "Link state transmit delay\n") | |
7641 | ||
e723861d DS |
7642 | DEFUN (ip_ospf_area, |
7643 | ip_ospf_area_cmd, | |
7644 | "ip ospf area (A.B.C.D|<0-4294967295>)", | |
7645 | "IP Information\n" | |
7646 | "OSPF interface commands\n" | |
7647 | "Enable OSPF on this interface\n" | |
7648 | "OSPF area ID in IP address format\n" | |
7649 | "OSPF area ID as a decimal value\n") | |
7650 | { | |
7651 | struct interface *ifp = vty->index; | |
7652 | int format, ret; | |
7653 | struct in_addr area_id; | |
7654 | struct ospf *ospf; | |
7655 | struct ospf_if_params *params; | |
7656 | struct route_node *rn; | |
7c8ff89e | 7657 | u_short instance = 0; |
e723861d | 7658 | |
7c8ff89e DS |
7659 | if (argc == 2) |
7660 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
7661 | ||
7662 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
7663 | if (ospf == NULL) |
7664 | { | |
7c8ff89e DS |
7665 | params = IF_DEF_PARAMS (ifp); |
7666 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7667 | { | |
7668 | ospf_interface_unset (ifp); | |
7669 | ospf = ospf_lookup(); | |
7670 | ospf->if_ospf_cli_count--; | |
7671 | } | |
e723861d DS |
7672 | return CMD_SUCCESS; |
7673 | } | |
7674 | ||
7c8ff89e | 7675 | ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); |
e723861d DS |
7676 | if (ret < 0) |
7677 | { | |
7678 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
7679 | VTY_NEWLINE); | |
7680 | return CMD_WARNING; | |
7681 | } | |
7682 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
7683 | { | |
7684 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
7685 | return CMD_WARNING; | |
7686 | } | |
7687 | ||
7688 | params = IF_DEF_PARAMS (ifp); | |
7689 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7690 | { | |
7691 | return CMD_WARNING; | |
7692 | } | |
7693 | ||
7694 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
7695 | { | |
7696 | if (rn->info != NULL) | |
7697 | { | |
7698 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
7699 | return CMD_WARNING; | |
7700 | } | |
7701 | } | |
7702 | ||
7703 | /* enable ospf on this interface with area_id */ | |
7704 | ospf_interface_set (ifp, area_id); | |
7705 | ospf->if_ospf_cli_count++; | |
7706 | ||
7707 | return CMD_SUCCESS; | |
7708 | } | |
7709 | ||
7c8ff89e DS |
7710 | ALIAS (ip_ospf_area, |
7711 | ip_ospf_instance_area_cmd, | |
7712 | "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
7713 | "IP Information\n" | |
7714 | "OSPF interface commands\n" | |
7715 | "Instance ID\n" | |
7716 | "Enable OSPF on this interface\n" | |
7717 | "OSPF area ID in IP address format\n" | |
7718 | "OSPF area ID as a decimal value\n") | |
7719 | ||
e723861d DS |
7720 | DEFUN (no_ip_ospf_area, |
7721 | no_ip_ospf_area_cmd, | |
7722 | "no ip ospf area", | |
7723 | NO_STR | |
7724 | "IP Information\n" | |
7725 | "OSPF interface commands\n" | |
7726 | "Disable OSPF on this interface\n") | |
7727 | { | |
7728 | struct interface *ifp = vty->index; | |
7729 | struct ospf *ospf; | |
7730 | struct ospf_if_params *params; | |
7c8ff89e | 7731 | u_short instance = 0; |
e723861d | 7732 | |
7c8ff89e DS |
7733 | if (argc) |
7734 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
7735 | ||
7736 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
7737 | return CMD_SUCCESS; | |
e723861d DS |
7738 | |
7739 | params = IF_DEF_PARAMS (ifp); | |
7740 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7741 | { | |
7742 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
7743 | return CMD_WARNING; | |
7744 | } | |
7745 | ||
7746 | ospf_interface_unset (ifp); | |
7747 | ospf->if_ospf_cli_count--; | |
7748 | return CMD_SUCCESS; | |
7749 | } | |
7750 | ||
7c8ff89e DS |
7751 | ALIAS (no_ip_ospf_area, |
7752 | no_ip_ospf_instance_area_cmd, | |
7753 | "no ip ospf <1-65535> area", | |
7754 | NO_STR | |
7755 | "IP Information\n" | |
7756 | "OSPF interface commands\n" | |
7757 | "Instance ID\n" | |
7758 | "Disable OSPF on this interface\n") | |
7759 | ||
6f2a6703 CF |
7760 | DEFUN (ospf_redistribute_source, |
7761 | ospf_redistribute_source_cmd, | |
7762 | "redistribute " QUAGGA_REDIST_STR_OSPFD | |
7763 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
d1c65c21 PJ |
7764 | REDIST_STR |
7765 | QUAGGA_REDIST_HELP_STR_OSPFD | |
718e3744 | 7766 | "Metric for redistributed routes\n" |
7767 | "OSPF default metric\n" | |
7768 | "OSPF exterior metric type for redistributed routes\n" | |
7769 | "Set OSPF External Type 1 metrics\n" | |
7770 | "Set OSPF External Type 2 metrics\n" | |
7771 | "Route map reference\n" | |
7772 | "Pointer to route-map entries\n") | |
7773 | { | |
020709f9 | 7774 | struct ospf *ospf = vty->index; |
718e3744 | 7775 | int source; |
7776 | int type = -1; | |
7777 | int metric = -1; | |
7c8ff89e | 7778 | struct ospf_redist *red; |
718e3744 | 7779 | |
6f2a6703 CF |
7780 | if (argc < 4) |
7781 | return CMD_WARNING; /* should not happen */ | |
7782 | ||
7c8ff89e DS |
7783 | if (!ospf) |
7784 | return CMD_SUCCESS; | |
7785 | ||
718e3744 | 7786 | /* Get distribute source. */ |
e0ca5fde DL |
7787 | source = proto_redistnum(AFI_IP, argv[0]); |
7788 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 7789 | return CMD_WARNING; |
7790 | ||
7791 | /* Get metric value. */ | |
6f2a6703 | 7792 | if (argv[1] != NULL) |
718e3744 | 7793 | if (!str2metric (argv[1], &metric)) |
7794 | return CMD_WARNING; | |
7795 | ||
7796 | /* Get metric type. */ | |
6f2a6703 | 7797 | if (argv[2] != NULL) |
718e3744 | 7798 | if (!str2metric_type (argv[2], &type)) |
7799 | return CMD_WARNING; | |
7800 | ||
7c8ff89e DS |
7801 | red = ospf_redist_add(ospf, source, 0); |
7802 | ||
6f2a6703 | 7803 | if (argv[3] != NULL) |
7c8ff89e | 7804 | ospf_routemap_set (red, argv[3]); |
718e3744 | 7805 | else |
7c8ff89e | 7806 | ospf_routemap_unset (red); |
718e3744 | 7807 | |
7c8ff89e | 7808 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 7809 | } |
7810 | ||
718e3744 | 7811 | DEFUN (no_ospf_redistribute_source, |
7812 | no_ospf_redistribute_source_cmd, | |
d1c65c21 | 7813 | "no redistribute " QUAGGA_REDIST_STR_OSPFD, |
718e3744 | 7814 | NO_STR |
d1c65c21 PJ |
7815 | REDIST_STR |
7816 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 7817 | { |
020709f9 | 7818 | struct ospf *ospf = vty->index; |
718e3744 | 7819 | int source; |
7c8ff89e DS |
7820 | struct ospf_redist *red; |
7821 | if (!ospf) | |
7822 | return CMD_SUCCESS; | |
718e3744 | 7823 | |
e0ca5fde DL |
7824 | source = proto_redistnum(AFI_IP, argv[0]); |
7825 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 7826 | return CMD_WARNING; |
7827 | ||
7c8ff89e DS |
7828 | red = ospf_redist_lookup(ospf, source, 0); |
7829 | if (!red) | |
7830 | return CMD_SUCCESS; | |
7831 | ||
7832 | ospf_routemap_unset (red); | |
7833 | return ospf_redistribute_unset (ospf, source, 0); | |
7834 | } | |
7835 | ||
7836 | DEFUN (ospf_redistribute_instance_source, | |
7837 | ospf_redistribute_instance_source_cmd, | |
2d627ff5 | 7838 | "redistribute (ospf|table) <1-65535>" |
7c8ff89e DS |
7839 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
7840 | REDIST_STR | |
7841 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7842 | "Non-main Kernel Routing Table\n" |
7843 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
7844 | "Metric for redistributed routes\n" |
7845 | "OSPF default metric\n" | |
7846 | "OSPF exterior metric type for redistributed routes\n" | |
7847 | "Set OSPF External Type 1 metrics\n" | |
7848 | "Set OSPF External Type 2 metrics\n" | |
7849 | "Route map reference\n" | |
7850 | "Pointer to route-map entries\n") | |
7851 | { | |
7852 | struct ospf *ospf = vty->index; | |
7853 | int source; | |
7854 | int type = -1; | |
7855 | int metric = -1; | |
7856 | u_short instance; | |
7857 | struct ospf_redist *red; | |
7858 | ||
2d627ff5 DS |
7859 | if (strncmp(argv[0], "o", 1) == 0) |
7860 | source = ZEBRA_ROUTE_OSPF; | |
7861 | else | |
7862 | source = ZEBRA_ROUTE_TABLE; | |
7863 | ||
7864 | VTY_GET_INTEGER ("Instance ID", instance, argv[1]); | |
7c8ff89e DS |
7865 | |
7866 | if (!ospf) | |
7867 | return CMD_SUCCESS; | |
7868 | ||
2d627ff5 | 7869 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7870 | { |
7871 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
7872 | VTY_NEWLINE); | |
7873 | return CMD_WARNING; | |
7874 | } | |
7875 | ||
2d627ff5 | 7876 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7877 | { |
7878 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
7879 | VTY_NEWLINE); | |
7880 | return CMD_WARNING; | |
7881 | } | |
7882 | ||
7c8ff89e | 7883 | /* Get metric value. */ |
2d627ff5 DS |
7884 | if (argv[2] != NULL) |
7885 | if (!str2metric (argv[2], &metric)) | |
7c8ff89e DS |
7886 | return CMD_WARNING; |
7887 | ||
7888 | /* Get metric type. */ | |
2d627ff5 DS |
7889 | if (argv[3] != NULL) |
7890 | if (!str2metric_type (argv[3], &type)) | |
7c8ff89e DS |
7891 | return CMD_WARNING; |
7892 | ||
7893 | red = ospf_redist_add(ospf, source, instance); | |
2d627ff5 DS |
7894 | if (argv[4] != NULL) |
7895 | ospf_routemap_set (red, argv[4]); | |
7c8ff89e DS |
7896 | else |
7897 | ospf_routemap_unset (red); | |
7898 | ||
7899 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
7900 | } | |
7901 | ||
7902 | DEFUN (no_ospf_redistribute_instance_source, | |
7903 | no_ospf_redistribute_instance_source_cmd, | |
2d627ff5 | 7904 | "no redistribute (ospf|table) <1-65535>" |
7c8ff89e DS |
7905 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
7906 | NO_STR | |
7907 | REDIST_STR | |
7908 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7909 | "Non-main Kernel Routing Table\n" |
7910 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
7911 | "Metric for redistributed routes\n" |
7912 | "OSPF default metric\n" | |
7913 | "OSPF exterior metric type for redistributed routes\n" | |
7914 | "Set OSPF External Type 1 metrics\n" | |
7915 | "Set OSPF External Type 2 metrics\n" | |
7916 | "Route map reference\n" | |
7917 | "Pointer to route-map entries\n") | |
7918 | { | |
7919 | struct ospf *ospf = vty->index; | |
7920 | u_int instance; | |
7921 | struct ospf_redist *red; | |
7922 | int source; | |
7923 | ||
7924 | if (!ospf) | |
7925 | return CMD_SUCCESS; | |
7926 | ||
2d627ff5 DS |
7927 | if (strncmp(argv[0], "o", 1) == 0) |
7928 | source = ZEBRA_ROUTE_OSPF; | |
7929 | else | |
7930 | source = ZEBRA_ROUTE_TABLE; | |
7931 | ||
7932 | VTY_GET_INTEGER ("Instance ID", instance, argv[1]); | |
7c8ff89e | 7933 | |
2d627ff5 | 7934 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7935 | { |
7936 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
7937 | VTY_NEWLINE); | |
7938 | return CMD_WARNING; | |
7939 | } | |
7940 | ||
2d627ff5 | 7941 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7942 | { |
7943 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
7944 | VTY_NEWLINE); | |
7945 | return CMD_WARNING; | |
7946 | } | |
7947 | ||
7c8ff89e DS |
7948 | red = ospf_redist_lookup(ospf, source, instance); |
7949 | if (!red) | |
7950 | return CMD_SUCCESS; | |
7951 | ||
7952 | ospf_routemap_unset (red); | |
7953 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 7954 | } |
7955 | ||
7956 | DEFUN (ospf_distribute_list_out, | |
7957 | ospf_distribute_list_out_cmd, | |
d1c65c21 | 7958 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
718e3744 | 7959 | "Filter networks in routing updates\n" |
6f2a6703 CF |
7960 | "Access-list name\n" |
7961 | OUT_STR | |
7962 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 7963 | { |
020709f9 | 7964 | struct ospf *ospf = vty->index; |
6f2a6703 | 7965 | int source; |
718e3744 | 7966 | |
7c8ff89e DS |
7967 | if (!ospf) |
7968 | return CMD_SUCCESS; | |
7969 | ||
6f2a6703 CF |
7970 | /* Get distribute source. */ |
7971 | source = proto_redistnum(AFI_IP, argv[1]); | |
7972 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
7973 | return CMD_WARNING; | |
718e3744 | 7974 | |
6f2a6703 | 7975 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
718e3744 | 7976 | } |
7977 | ||
6f2a6703 CF |
7978 | DEFUN (no_ospf_distribute_list_out, |
7979 | no_ospf_distribute_list_out_cmd, | |
7980 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, | |
7981 | NO_STR | |
7982 | "Filter networks in routing updates\n" | |
7983 | "Access-list name\n" | |
7984 | OUT_STR | |
7985 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 7986 | { |
020709f9 | 7987 | struct ospf *ospf = vty->index; |
6f2a6703 | 7988 | int source; |
020709f9 | 7989 | |
7c8ff89e DS |
7990 | if (!ospf) |
7991 | return CMD_SUCCESS; | |
7992 | ||
6f2a6703 CF |
7993 | source = proto_redistnum(AFI_IP, argv[1]); |
7994 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
7995 | return CMD_WARNING; | |
718e3744 | 7996 | |
6f2a6703 | 7997 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
718e3744 | 7998 | } |
7999 | ||
6f2a6703 CF |
8000 | /* Default information originate. */ |
8001 | DEFUN (ospf_default_information_originate, | |
8002 | ospf_default_information_originate_cmd, | |
8003 | "default-information originate " | |
8004 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 8005 | "Control distribution of default information\n" |
8006 | "Distribute a default route\n" | |
8007 | "Always advertise default route\n" | |
6f2a6703 CF |
8008 | "OSPF default metric\n" |
8009 | "OSPF metric\n" | |
718e3744 | 8010 | "OSPF metric type for default routes\n" |
8011 | "Set OSPF External Type 1 metrics\n" | |
8012 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 8013 | "Route map reference\n" |
8014 | "Pointer to route-map entries\n") | |
8015 | { | |
020709f9 | 8016 | struct ospf *ospf = vty->index; |
6f2a6703 | 8017 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 8018 | int type = -1; |
8019 | int metric = -1; | |
7c8ff89e DS |
8020 | struct ospf_redist *red; |
8021 | ||
8022 | if (!ospf) | |
8023 | return CMD_SUCCESS; | |
718e3744 | 8024 | |
6f2a6703 CF |
8025 | if (argc < 4) |
8026 | return CMD_WARNING; /* this should not happen */ | |
8027 | ||
8028 | /* Check whether "always" was specified */ | |
8029 | if (argv[0] != NULL) | |
8030 | default_originate = DEFAULT_ORIGINATE_ALWAYS; | |
718e3744 | 8031 | |
7c8ff89e DS |
8032 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
8033 | ||
718e3744 | 8034 | /* Get metric value. */ |
6f2a6703 | 8035 | if (argv[1] != NULL) |
718e3744 | 8036 | if (!str2metric (argv[1], &metric)) |
8037 | return CMD_WARNING; | |
8038 | ||
718e3744 | 8039 | /* Get metric type. */ |
6f2a6703 CF |
8040 | if (argv[2] != NULL) |
8041 | if (!str2metric_type (argv[2], &type)) | |
718e3744 | 8042 | return CMD_WARNING; |
8043 | ||
6f2a6703 | 8044 | if (argv[3] != NULL) |
7c8ff89e | 8045 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8046 | else |
7c8ff89e | 8047 | ospf_routemap_unset (red); |
718e3744 | 8048 | |
6f2a6703 CF |
8049 | return ospf_redistribute_default_set (ospf, default_originate, |
8050 | type, metric); | |
718e3744 | 8051 | } |
8052 | ||
8053 | DEFUN (no_ospf_default_information_originate, | |
8054 | no_ospf_default_information_originate_cmd, | |
8055 | "no default-information originate", | |
8056 | NO_STR | |
8057 | "Control distribution of default information\n" | |
8058 | "Distribute a default route\n") | |
8059 | { | |
68980084 | 8060 | struct ospf *ospf = vty->index; |
718e3744 | 8061 | struct prefix_ipv4 p; |
7c8ff89e DS |
8062 | struct ospf_external *ext; |
8063 | struct ospf_redist *red; | |
718e3744 | 8064 | |
7c8ff89e DS |
8065 | if (!ospf) |
8066 | return CMD_SUCCESS; | |
8067 | ||
718e3744 | 8068 | p.family = AF_INET; |
8069 | p.prefix.s_addr = 0; | |
8070 | p.prefixlen = 0; | |
8071 | ||
5339cfdb | 8072 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 8073 | |
7c8ff89e DS |
8074 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
8075 | EXTERNAL_INFO (ext)) { | |
8076 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
8077 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 8078 | } |
8079 | ||
7c8ff89e DS |
8080 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8081 | if (!red) | |
8082 | return CMD_SUCCESS; | |
8083 | ||
8084 | ospf_routemap_unset (red); | |
020709f9 | 8085 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 8086 | } |
8087 | ||
8088 | DEFUN (ospf_default_metric, | |
8089 | ospf_default_metric_cmd, | |
8090 | "default-metric <0-16777214>", | |
8091 | "Set metric of redistributed routes\n" | |
8092 | "Default metric\n") | |
8093 | { | |
68980084 | 8094 | struct ospf *ospf = vty->index; |
718e3744 | 8095 | int metric = -1; |
8096 | ||
7c8ff89e DS |
8097 | if (!ospf) |
8098 | return CMD_SUCCESS; | |
8099 | ||
718e3744 | 8100 | if (!str2metric (argv[0], &metric)) |
8101 | return CMD_WARNING; | |
8102 | ||
68980084 | 8103 | ospf->default_metric = metric; |
718e3744 | 8104 | |
8105 | return CMD_SUCCESS; | |
8106 | } | |
8107 | ||
8108 | DEFUN (no_ospf_default_metric, | |
8109 | no_ospf_default_metric_cmd, | |
8110 | "no default-metric", | |
8111 | NO_STR | |
8112 | "Set metric of redistributed routes\n") | |
8113 | { | |
68980084 | 8114 | struct ospf *ospf = vty->index; |
8115 | ||
7c8ff89e DS |
8116 | if (!ospf) |
8117 | return CMD_SUCCESS; | |
8118 | ||
68980084 | 8119 | ospf->default_metric = -1; |
8120 | ||
718e3744 | 8121 | return CMD_SUCCESS; |
8122 | } | |
8123 | ||
8124 | ALIAS (no_ospf_default_metric, | |
8125 | no_ospf_default_metric_val_cmd, | |
8126 | "no default-metric <0-16777214>", | |
8127 | NO_STR | |
8128 | "Set metric of redistributed routes\n" | |
8129 | "Default metric\n") | |
8130 | ||
8131 | DEFUN (ospf_distance, | |
8132 | ospf_distance_cmd, | |
8133 | "distance <1-255>", | |
8134 | "Define an administrative distance\n" | |
8135 | "OSPF Administrative distance\n") | |
8136 | { | |
68980084 | 8137 | struct ospf *ospf = vty->index; |
8138 | ||
7c8ff89e DS |
8139 | if (!ospf) |
8140 | return CMD_SUCCESS; | |
8141 | ||
68980084 | 8142 | ospf->distance_all = atoi (argv[0]); |
8143 | ||
718e3744 | 8144 | return CMD_SUCCESS; |
8145 | } | |
8146 | ||
8147 | DEFUN (no_ospf_distance, | |
8148 | no_ospf_distance_cmd, | |
8149 | "no distance <1-255>", | |
8150 | NO_STR | |
8151 | "Define an administrative distance\n" | |
8152 | "OSPF Administrative distance\n") | |
8153 | { | |
68980084 | 8154 | struct ospf *ospf = vty->index; |
8155 | ||
7c8ff89e DS |
8156 | if (!ospf) |
8157 | return CMD_SUCCESS; | |
8158 | ||
68980084 | 8159 | ospf->distance_all = 0; |
8160 | ||
718e3744 | 8161 | return CMD_SUCCESS; |
8162 | } | |
8163 | ||
8164 | DEFUN (no_ospf_distance_ospf, | |
8165 | no_ospf_distance_ospf_cmd, | |
6f2a6703 | 8166 | "no distance ospf {intra-area|inter-area|external}", |
718e3744 | 8167 | NO_STR |
8168 | "Define an administrative distance\n" | |
8169 | "OSPF Administrative distance\n" | |
6f2a6703 | 8170 | "OSPF Distance\n" |
718e3744 | 8171 | "Intra-area routes\n" |
718e3744 | 8172 | "Inter-area routes\n" |
6f2a6703 | 8173 | "External routes\n") |
718e3744 | 8174 | { |
68980084 | 8175 | struct ospf *ospf = vty->index; |
8176 | ||
6f2a6703 CF |
8177 | if (argc < 3) |
8178 | return CMD_WARNING; | |
718e3744 | 8179 | |
7c8ff89e DS |
8180 | if (!ospf) |
8181 | return CMD_SUCCESS; | |
8182 | ||
6f2a6703 CF |
8183 | if (argv[0] != NULL) |
8184 | ospf->distance_intra = 0; | |
68980084 | 8185 | |
6f2a6703 CF |
8186 | if (argv[1] != NULL) |
8187 | ospf->distance_inter = 0; | |
68980084 | 8188 | |
6f2a6703 CF |
8189 | if (argv[2] != NULL) |
8190 | ospf->distance_external = 0; | |
718e3744 | 8191 | |
6f2a6703 CF |
8192 | if (argv[0] || argv[1] || argv[2]) |
8193 | return CMD_SUCCESS; | |
68980084 | 8194 | |
6f2a6703 CF |
8195 | /* If no arguments are given, clear all distance information */ |
8196 | ospf->distance_intra = 0; | |
8197 | ospf->distance_inter = 0; | |
8198 | ospf->distance_external = 0; | |
68980084 | 8199 | |
718e3744 | 8200 | return CMD_SUCCESS; |
8201 | } | |
8202 | ||
6f2a6703 CF |
8203 | DEFUN (ospf_distance_ospf, |
8204 | ospf_distance_ospf_cmd, | |
8205 | "distance ospf " | |
8206 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", | |
718e3744 | 8207 | "Define an administrative distance\n" |
8208 | "OSPF Administrative distance\n" | |
718e3744 | 8209 | "Intra-area routes\n" |
8210 | "Distance for intra-area routes\n" | |
718e3744 | 8211 | "Inter-area routes\n" |
8212 | "Distance for inter-area routes\n" | |
8213 | "External routes\n" | |
718e3744 | 8214 | "Distance for external routes\n") |
8215 | { | |
68980084 | 8216 | struct ospf *ospf = vty->index; |
8217 | ||
6f2a6703 CF |
8218 | if (argc < 3) /* should not happen */ |
8219 | return CMD_WARNING; | |
68980084 | 8220 | |
6f2a6703 CF |
8221 | if (!argv[0] && !argv[1] && !argv[2]) |
8222 | { | |
8223 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", | |
8224 | VTY_NEWLINE); | |
8225 | return CMD_WARNING; | |
8226 | } | |
68980084 | 8227 | |
6f2a6703 CF |
8228 | if (argv[0] != NULL) |
8229 | ospf->distance_intra = atoi(argv[0]); | |
718e3744 | 8230 | |
6f2a6703 CF |
8231 | if (argv[1] != NULL) |
8232 | ospf->distance_inter = atoi(argv[1]); | |
68980084 | 8233 | |
6f2a6703 CF |
8234 | if (argv[2] != NULL) |
8235 | ospf->distance_external = atoi(argv[2]); | |
68980084 | 8236 | |
718e3744 | 8237 | return CMD_SUCCESS; |
8238 | } | |
8239 | ||
8240 | DEFUN (ospf_distance_source, | |
8241 | ospf_distance_source_cmd, | |
8242 | "distance <1-255> A.B.C.D/M", | |
8243 | "Administrative distance\n" | |
8244 | "Distance value\n" | |
8245 | "IP source prefix\n") | |
8246 | { | |
020709f9 | 8247 | struct ospf *ospf = vty->index; |
8248 | ||
7c8ff89e DS |
8249 | if (!ospf) |
8250 | return CMD_SUCCESS; | |
8251 | ||
020709f9 | 8252 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
68980084 | 8253 | |
718e3744 | 8254 | return CMD_SUCCESS; |
8255 | } | |
8256 | ||
8257 | DEFUN (no_ospf_distance_source, | |
8258 | no_ospf_distance_source_cmd, | |
8259 | "no distance <1-255> A.B.C.D/M", | |
8260 | NO_STR | |
8261 | "Administrative distance\n" | |
8262 | "Distance value\n" | |
8263 | "IP source prefix\n") | |
8264 | { | |
020709f9 | 8265 | struct ospf *ospf = vty->index; |
8266 | ||
7c8ff89e DS |
8267 | if (!ospf) |
8268 | return CMD_SUCCESS; | |
8269 | ||
020709f9 | 8270 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
8271 | ||
718e3744 | 8272 | return CMD_SUCCESS; |
8273 | } | |
8274 | ||
8275 | DEFUN (ospf_distance_source_access_list, | |
8276 | ospf_distance_source_access_list_cmd, | |
8277 | "distance <1-255> A.B.C.D/M WORD", | |
8278 | "Administrative distance\n" | |
8279 | "Distance value\n" | |
8280 | "IP source prefix\n" | |
8281 | "Access list name\n") | |
8282 | { | |
020709f9 | 8283 | struct ospf *ospf = vty->index; |
8284 | ||
7c8ff89e DS |
8285 | if (!ospf) |
8286 | return CMD_SUCCESS; | |
8287 | ||
020709f9 | 8288 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
8289 | ||
718e3744 | 8290 | return CMD_SUCCESS; |
8291 | } | |
8292 | ||
8293 | DEFUN (no_ospf_distance_source_access_list, | |
8294 | no_ospf_distance_source_access_list_cmd, | |
8295 | "no distance <1-255> A.B.C.D/M WORD", | |
8296 | NO_STR | |
8297 | "Administrative distance\n" | |
8298 | "Distance value\n" | |
8299 | "IP source prefix\n" | |
8300 | "Access list name\n") | |
8301 | { | |
020709f9 | 8302 | struct ospf *ospf = vty->index; |
8303 | ||
7c8ff89e DS |
8304 | if (!ospf) |
8305 | return CMD_SUCCESS; | |
8306 | ||
020709f9 | 8307 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
8308 | ||
718e3744 | 8309 | return CMD_SUCCESS; |
8310 | } | |
8311 | ||
ba682537 | 8312 | DEFUN (ip_ospf_mtu_ignore, |
8313 | ip_ospf_mtu_ignore_addr_cmd, | |
8314 | "ip ospf mtu-ignore A.B.C.D", | |
8315 | "IP Information\n" | |
8316 | "OSPF interface commands\n" | |
8317 | "Disable mtu mismatch detection\n" | |
8318 | "Address of interface") | |
8319 | { | |
8320 | struct interface *ifp = vty->index; | |
8321 | struct in_addr addr; | |
8322 | int ret; | |
8323 | ||
8324 | struct ospf_if_params *params; | |
8325 | params = IF_DEF_PARAMS (ifp); | |
8326 | ||
8327 | if (argc == 1) | |
8328 | { | |
8329 | ret = inet_aton(argv[0], &addr); | |
8330 | if (!ret) | |
8331 | { | |
8332 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8333 | VTY_NEWLINE); | |
8334 | return CMD_WARNING; | |
8335 | } | |
8336 | params = ospf_get_if_params (ifp, addr); | |
8337 | ospf_if_update_params (ifp, addr); | |
8338 | } | |
8339 | params->mtu_ignore = 1; | |
8340 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8341 | SET_IF_PARAM (params, mtu_ignore); | |
8342 | else | |
8343 | { | |
8344 | UNSET_IF_PARAM (params, mtu_ignore); | |
8345 | if (params != IF_DEF_PARAMS (ifp)) | |
8346 | { | |
8347 | ospf_free_if_params (ifp, addr); | |
8348 | ospf_if_update_params (ifp, addr); | |
8349 | } | |
8350 | } | |
8351 | return CMD_SUCCESS; | |
8352 | } | |
8353 | ||
8354 | ALIAS (ip_ospf_mtu_ignore, | |
8355 | ip_ospf_mtu_ignore_cmd, | |
8356 | "ip ospf mtu-ignore", | |
8357 | "IP Information\n" | |
8358 | "OSPF interface commands\n" | |
8359 | "Disable mtu mismatch detection\n") | |
8360 | ||
8361 | ||
8362 | DEFUN (no_ip_ospf_mtu_ignore, | |
8363 | no_ip_ospf_mtu_ignore_addr_cmd, | |
8364 | "no ip ospf mtu-ignore A.B.C.D", | |
8365 | "IP Information\n" | |
8366 | "OSPF interface commands\n" | |
8367 | "Disable mtu mismatch detection\n" | |
8368 | "Address of interface") | |
8369 | { | |
8370 | struct interface *ifp = vty->index; | |
8371 | struct in_addr addr; | |
8372 | int ret; | |
8373 | ||
8374 | struct ospf_if_params *params; | |
8375 | params = IF_DEF_PARAMS (ifp); | |
8376 | ||
8377 | if (argc == 1) | |
8378 | { | |
8379 | ret = inet_aton(argv[0], &addr); | |
8380 | if (!ret) | |
8381 | { | |
8382 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8383 | VTY_NEWLINE); | |
8384 | return CMD_WARNING; | |
8385 | } | |
8386 | params = ospf_get_if_params (ifp, addr); | |
8387 | ospf_if_update_params (ifp, addr); | |
8388 | } | |
8389 | params->mtu_ignore = 0; | |
8390 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8391 | SET_IF_PARAM (params, mtu_ignore); | |
8392 | else | |
8393 | { | |
8394 | UNSET_IF_PARAM (params, mtu_ignore); | |
8395 | if (params != IF_DEF_PARAMS (ifp)) | |
8396 | { | |
8397 | ospf_free_if_params (ifp, addr); | |
8398 | ospf_if_update_params (ifp, addr); | |
8399 | } | |
8400 | } | |
8401 | return CMD_SUCCESS; | |
8402 | } | |
8403 | ||
8404 | ALIAS (no_ip_ospf_mtu_ignore, | |
8405 | no_ip_ospf_mtu_ignore_cmd, | |
8406 | "no ip ospf mtu-ignore", | |
8407 | "IP Information\n" | |
8408 | "OSPF interface commands\n" | |
8409 | "Disable mtu mismatch detection\n") | |
6b0655a2 | 8410 | |
88d6cf37 | 8411 | DEFUN (ospf_max_metric_router_lsa_admin, |
8412 | ospf_max_metric_router_lsa_admin_cmd, | |
8413 | "max-metric router-lsa administrative", | |
8414 | "OSPF maximum / infinite-distance metric\n" | |
8415 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8416 | "Administratively applied, for an indefinite period\n") | |
8417 | { | |
8418 | struct listnode *ln; | |
8419 | struct ospf_area *area; | |
8420 | struct ospf *ospf = vty->index; | |
ba682537 | 8421 | |
7c8ff89e DS |
8422 | if (!ospf) |
8423 | return CMD_SUCCESS; | |
8424 | ||
88d6cf37 | 8425 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8426 | { | |
8427 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8428 | ||
8429 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 8430 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8431 | } |
4ba4fc85 AB |
8432 | |
8433 | /* Allows for areas configured later to get the property */ | |
8434 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
8435 | ||
88d6cf37 | 8436 | return CMD_SUCCESS; |
8437 | } | |
8438 | ||
8439 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
8440 | no_ospf_max_metric_router_lsa_admin_cmd, | |
8441 | "no max-metric router-lsa administrative", | |
8442 | NO_STR | |
8443 | "OSPF maximum / infinite-distance metric\n" | |
8444 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8445 | "Administratively applied, for an indefinite period\n") | |
8446 | { | |
8447 | struct listnode *ln; | |
8448 | struct ospf_area *area; | |
8449 | struct ospf *ospf = vty->index; | |
8450 | ||
7c8ff89e DS |
8451 | if (!ospf) |
8452 | return CMD_SUCCESS; | |
8453 | ||
88d6cf37 | 8454 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8455 | { | |
8456 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8457 | ||
8458 | /* Don't trample on the start-up stub timer */ | |
8459 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
8460 | && !area->t_stub_router) | |
8461 | { | |
8462 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8463 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8464 | } |
8465 | } | |
4ba4fc85 | 8466 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 8467 | return CMD_SUCCESS; |
8468 | } | |
8469 | ||
8470 | DEFUN (ospf_max_metric_router_lsa_startup, | |
8471 | ospf_max_metric_router_lsa_startup_cmd, | |
8472 | "max-metric router-lsa on-startup <5-86400>", | |
8473 | "OSPF maximum / infinite-distance metric\n" | |
8474 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8475 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8476 | "Time (seconds) to advertise self as stub-router\n") | |
8477 | { | |
8478 | unsigned int seconds; | |
8479 | struct ospf *ospf = vty->index; | |
8480 | ||
7c8ff89e DS |
8481 | if (!ospf) |
8482 | return CMD_SUCCESS; | |
8483 | ||
88d6cf37 | 8484 | if (argc != 1) |
8485 | { | |
8486 | vty_out (vty, "%% Must supply stub-router period"); | |
8487 | return CMD_WARNING; | |
8488 | } | |
8489 | ||
8490 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); | |
8491 | ||
8492 | ospf->stub_router_startup_time = seconds; | |
8493 | ||
8494 | return CMD_SUCCESS; | |
8495 | } | |
8496 | ||
8497 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
8498 | no_ospf_max_metric_router_lsa_startup_cmd, | |
8499 | "no max-metric router-lsa on-startup", | |
8500 | NO_STR | |
8501 | "OSPF maximum / infinite-distance metric\n" | |
8502 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8503 | "Automatically advertise stub Router-LSA on startup of OSPF\n") | |
8504 | { | |
8505 | struct listnode *ln; | |
8506 | struct ospf_area *area; | |
8507 | struct ospf *ospf = vty->index; | |
8508 | ||
7c8ff89e DS |
8509 | if (!ospf) |
8510 | return CMD_SUCCESS; | |
8511 | ||
88d6cf37 | 8512 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8513 | ||
8514 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8515 | { | |
8516 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
8517 | OSPF_TIMER_OFF (area->t_stub_router); | |
8518 | ||
8519 | /* Don't trample on admin stub routed */ | |
8520 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8521 | { | |
8522 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8523 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8524 | } |
8525 | } | |
8526 | return CMD_SUCCESS; | |
8527 | } | |
8528 | ||
8529 | DEFUN (ospf_max_metric_router_lsa_shutdown, | |
8530 | ospf_max_metric_router_lsa_shutdown_cmd, | |
804fb5c1 | 8531 | "max-metric router-lsa on-shutdown <5-100>", |
88d6cf37 | 8532 | "OSPF maximum / infinite-distance metric\n" |
8533 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8534 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
8535 | "Time (seconds) to wait till full shutdown\n") | |
8536 | { | |
8537 | unsigned int seconds; | |
8538 | struct ospf *ospf = vty->index; | |
8539 | ||
7c8ff89e DS |
8540 | if (!ospf) |
8541 | return CMD_SUCCESS; | |
8542 | ||
88d6cf37 | 8543 | if (argc != 1) |
8544 | { | |
8545 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
8546 | return CMD_WARNING; | |
8547 | } | |
8548 | ||
8549 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); | |
8550 | ||
8551 | ospf->stub_router_shutdown_time = seconds; | |
8552 | ||
8553 | return CMD_SUCCESS; | |
8554 | } | |
8555 | ||
8556 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
8557 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
8558 | "no max-metric router-lsa on-shutdown", | |
8559 | NO_STR | |
8560 | "OSPF maximum / infinite-distance metric\n" | |
8561 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8562 | "Advertise stub-router prior to full shutdown of OSPF\n") | |
8563 | { | |
8564 | struct ospf *ospf = vty->index; | |
8565 | ||
7c8ff89e DS |
8566 | if (!ospf) |
8567 | return CMD_SUCCESS; | |
8568 | ||
88d6cf37 | 8569 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8570 | ||
8571 | return CMD_SUCCESS; | |
8572 | } | |
8573 | ||
8574 | static void | |
8575 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
8576 | { | |
8577 | struct listnode *ln; | |
8578 | struct ospf_area *area; | |
8579 | ||
8580 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8581 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
8582 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
8583 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8584 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
8585 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
8586 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8587 | { | |
8588 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8589 | { | |
8590 | vty_out (vty, " max-metric router-lsa administrative%s", | |
8591 | VTY_NEWLINE); | |
8592 | break; | |
8593 | } | |
8594 | } | |
8595 | return; | |
8596 | } | |
6b0655a2 | 8597 | |
4dadc291 | 8598 | static void |
718e3744 | 8599 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
8600 | { | |
8601 | struct route_node *rn; | |
8602 | struct ospf_route *or; | |
1eb8ef25 | 8603 | struct listnode *pnode, *pnnode; |
718e3744 | 8604 | struct ospf_path *path; |
8605 | ||
8606 | vty_out (vty, "============ OSPF network routing table ============%s", | |
8607 | VTY_NEWLINE); | |
8608 | ||
8609 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8610 | if ((or = rn->info) != NULL) | |
8611 | { | |
8612 | char buf1[19]; | |
8613 | snprintf (buf1, 19, "%s/%d", | |
8614 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8615 | ||
8616 | switch (or->path_type) | |
8617 | { | |
8618 | case OSPF_PATH_INTER_AREA: | |
8619 | if (or->type == OSPF_DESTINATION_NETWORK) | |
8620 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
8621 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8622 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
8623 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
8624 | break; | |
8625 | case OSPF_PATH_INTRA_AREA: | |
8626 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
8627 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8628 | break; | |
8629 | default: | |
8630 | break; | |
8631 | } | |
8632 | ||
8633 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 8634 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 8635 | { |
a8ba847f | 8636 | if (if_lookup_by_index(path->ifindex)) |
96735eea | 8637 | { |
8638 | if (path->nexthop.s_addr == 0) | |
8639 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f | 8640 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 8641 | else |
8642 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
8643 | inet_ntoa (path->nexthop), |
8644 | ifindex2ifname (path->ifindex), VTY_NEWLINE); | |
96735eea | 8645 | } |
8646 | } | |
718e3744 | 8647 | } |
8648 | vty_out (vty, "%s", VTY_NEWLINE); | |
8649 | } | |
8650 | ||
4dadc291 | 8651 | static void |
718e3744 | 8652 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
8653 | { | |
8654 | struct route_node *rn; | |
8655 | struct ospf_route *or; | |
1eb8ef25 | 8656 | struct listnode *pnode; |
8657 | struct listnode *node; | |
718e3744 | 8658 | struct ospf_path *path; |
8659 | ||
8660 | vty_out (vty, "============ OSPF router routing table =============%s", | |
8661 | VTY_NEWLINE); | |
8662 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
8663 | if (rn->info) | |
8664 | { | |
8665 | int flag = 0; | |
8666 | ||
8667 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
8668 | ||
1eb8ef25 | 8669 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
8670 | { | |
8671 | if (flag++) | |
8672 | vty_out (vty, "%24s", ""); | |
8673 | ||
8674 | /* Show path. */ | |
8675 | vty_out (vty, "%s [%d] area: %s", | |
8676 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
8677 | or->cost, inet_ntoa (or->u.std.area_id)); | |
8678 | /* Show flags. */ | |
8679 | vty_out (vty, "%s%s%s", | |
8680 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
8681 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
8682 | VTY_NEWLINE); | |
8683 | ||
8684 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
8685 | { | |
a8ba847f | 8686 | if (if_lookup_by_index(path->ifindex)) |
54bedb55 | 8687 | { |
8688 | if (path->nexthop.s_addr == 0) | |
8689 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f JT |
8690 | "", ifindex2ifname (path->ifindex), |
8691 | VTY_NEWLINE); | |
54bedb55 | 8692 | else |
8693 | vty_out (vty, "%24s via %s, %s%s", "", | |
8694 | inet_ntoa (path->nexthop), | |
a8ba847f JT |
8695 | ifindex2ifname (path->ifindex), |
8696 | VTY_NEWLINE); | |
54bedb55 | 8697 | } |
1eb8ef25 | 8698 | } |
8699 | } | |
718e3744 | 8700 | } |
8701 | vty_out (vty, "%s", VTY_NEWLINE); | |
8702 | } | |
8703 | ||
4dadc291 | 8704 | static void |
718e3744 | 8705 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
8706 | { | |
8707 | struct route_node *rn; | |
8708 | struct ospf_route *er; | |
1eb8ef25 | 8709 | struct listnode *pnode, *pnnode; |
718e3744 | 8710 | struct ospf_path *path; |
8711 | ||
8712 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
8713 | VTY_NEWLINE); | |
8714 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8715 | if ((er = rn->info) != NULL) | |
8716 | { | |
8717 | char buf1[19]; | |
8718 | snprintf (buf1, 19, "%s/%d", | |
8719 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8720 | ||
8721 | switch (er->path_type) | |
8722 | { | |
8723 | case OSPF_PATH_TYPE1_EXTERNAL: | |
8724 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, | |
8725 | er->cost, er->u.ext.tag, VTY_NEWLINE); | |
8726 | break; | |
8727 | case OSPF_PATH_TYPE2_EXTERNAL: | |
8728 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, | |
8729 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); | |
8730 | break; | |
8731 | } | |
8732 | ||
1eb8ef25 | 8733 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 8734 | { |
a8ba847f | 8735 | if (if_lookup_by_index(path->ifindex)) |
718e3744 | 8736 | { |
8737 | if (path->nexthop.s_addr == 0) | |
96735eea | 8738 | vty_out (vty, "%24s directly attached to %s%s", |
a8ba847f | 8739 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 8740 | else |
8741 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
8742 | inet_ntoa (path->nexthop), |
8743 | ifindex2ifname (path->ifindex), | |
96735eea | 8744 | VTY_NEWLINE); |
718e3744 | 8745 | } |
8746 | } | |
8747 | } | |
8748 | vty_out (vty, "%s", VTY_NEWLINE); | |
8749 | } | |
8750 | ||
7c8ff89e DS |
8751 | static int |
8752 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 8753 | { |
7c8ff89e DS |
8754 | if (ospf->instance) |
8755 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
8756 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 8757 | |
68980084 | 8758 | if (ospf->new_table == NULL) |
718e3744 | 8759 | { |
8760 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
8761 | return CMD_SUCCESS; | |
8762 | } | |
8763 | ||
8764 | /* Show Network routes. | |
020709f9 | 8765 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 8766 | |
8767 | /* Show Router routes. */ | |
68980084 | 8768 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8769 | |
7c8ff89e DS |
8770 | vty_out (vty, "%s", VTY_NEWLINE); |
8771 | ||
718e3744 | 8772 | return CMD_SUCCESS; |
8773 | } | |
718e3744 | 8774 | |
7c8ff89e DS |
8775 | DEFUN (show_ip_ospf_border_routers, |
8776 | show_ip_ospf_border_routers_cmd, | |
8777 | "show ip ospf border-routers", | |
718e3744 | 8778 | SHOW_STR |
8779 | IP_STR | |
8780 | "OSPF information\n" | |
7c8ff89e | 8781 | "Show all the ABR's and ASBR's\n") |
718e3744 | 8782 | { |
020709f9 | 8783 | struct ospf *ospf; |
68980084 | 8784 | |
0bad4851 | 8785 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8786 | return CMD_SUCCESS; |
8787 | ||
8788 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8789 | } | |
8790 | ||
8791 | DEFUN (show_ip_ospf_instance_border_routers, | |
8792 | show_ip_ospf_instance_border_routers_cmd, | |
8793 | "show ip ospf <1-65535> border-routers", | |
8794 | SHOW_STR | |
8795 | IP_STR | |
8796 | "OSPF information\n" | |
8797 | "Instance ID\n" | |
8798 | "Show all the ABR's and ASBR's\n") | |
8799 | { | |
8800 | struct ospf *ospf; | |
8801 | u_short instance = 0; | |
8802 | ||
8803 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 8804 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8805 | return CMD_SUCCESS; |
8806 | ||
8807 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8808 | } | |
8809 | ||
8810 | static int | |
8811 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
8812 | { | |
8813 | if (ospf->instance) | |
8814 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
8815 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 8816 | |
68980084 | 8817 | if (ospf->new_table == NULL) |
718e3744 | 8818 | { |
8819 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
8820 | return CMD_SUCCESS; | |
8821 | } | |
8822 | ||
8823 | /* Show Network routes. */ | |
68980084 | 8824 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 8825 | |
8826 | /* Show Router routes. */ | |
68980084 | 8827 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8828 | |
8829 | /* Show AS External routes. */ | |
68980084 | 8830 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 8831 | |
7c8ff89e DS |
8832 | vty_out (vty, "%s", VTY_NEWLINE); |
8833 | ||
718e3744 | 8834 | return CMD_SUCCESS; |
8835 | } | |
8836 | ||
7c8ff89e DS |
8837 | DEFUN (show_ip_ospf_route, |
8838 | show_ip_ospf_route_cmd, | |
8839 | "show ip ospf route", | |
8840 | SHOW_STR | |
8841 | IP_STR | |
8842 | "OSPF information\n" | |
8843 | "OSPF routing table\n") | |
8844 | { | |
8845 | struct ospf *ospf; | |
8846 | ||
0bad4851 | 8847 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8848 | return CMD_SUCCESS; |
8849 | ||
8850 | return show_ip_ospf_route_common(vty, ospf); | |
8851 | } | |
8852 | ||
8853 | DEFUN (show_ip_ospf_instance_route, | |
8854 | show_ip_ospf_instance_route_cmd, | |
8855 | "show ip ospf <1-65535> route", | |
8856 | SHOW_STR | |
8857 | IP_STR | |
8858 | "OSPF information\n" | |
8859 | "Instance ID\n" | |
8860 | "OSPF routing table\n") | |
8861 | { | |
8862 | struct ospf *ospf; | |
8863 | u_short instance = 0; | |
8864 | ||
8865 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 8866 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8867 | return CMD_SUCCESS; |
8868 | ||
8869 | return show_ip_ospf_route_common(vty, ospf); | |
8870 | } | |
6b0655a2 | 8871 | |
eb1ce605 | 8872 | const char *ospf_abr_type_str[] = |
718e3744 | 8873 | { |
8874 | "unknown", | |
8875 | "standard", | |
8876 | "ibm", | |
8877 | "cisco", | |
8878 | "shortcut" | |
8879 | }; | |
8880 | ||
eb1ce605 | 8881 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 8882 | { |
8883 | "default", | |
8884 | "enable", | |
8885 | "disable" | |
8886 | }; | |
8887 | ||
8888 | ||
4dadc291 | 8889 | static void |
718e3744 | 8890 | area_id2str (char *buf, int length, struct ospf_area *area) |
8891 | { | |
8892 | memset (buf, 0, length); | |
8893 | ||
8894 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
8895 | strncpy (buf, inet_ntoa (area->area_id), length); | |
8896 | else | |
8897 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); | |
8898 | } | |
8899 | ||
6b0655a2 | 8900 | |
eb1ce605 | 8901 | const char *ospf_int_type_str[] = |
718e3744 | 8902 | { |
8903 | "unknown", /* should never be used. */ | |
8904 | "point-to-point", | |
8905 | "broadcast", | |
8906 | "non-broadcast", | |
8907 | "point-to-multipoint", | |
8908 | "virtual-link", /* should never be used. */ | |
8909 | "loopback" | |
8910 | }; | |
8911 | ||
8912 | /* Configuration write function for ospfd. */ | |
4dadc291 | 8913 | static int |
718e3744 | 8914 | config_write_interface (struct vty *vty) |
8915 | { | |
52dc7ee6 | 8916 | struct listnode *n1, *n2; |
718e3744 | 8917 | struct interface *ifp; |
8918 | struct crypt_key *ck; | |
8919 | int write = 0; | |
8920 | struct route_node *rn = NULL; | |
8921 | struct ospf_if_params *params; | |
7c8ff89e | 8922 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 8923 | |
1eb8ef25 | 8924 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
718e3744 | 8925 | { |
718e3744 | 8926 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
8927 | continue; | |
8928 | ||
8929 | vty_out (vty, "!%s", VTY_NEWLINE); | |
8930 | vty_out (vty, "interface %s%s", ifp->name, | |
8931 | VTY_NEWLINE); | |
8932 | if (ifp->desc) | |
8933 | vty_out (vty, " description %s%s", ifp->desc, | |
8934 | VTY_NEWLINE); | |
8935 | ||
8936 | write++; | |
8937 | ||
8938 | params = IF_DEF_PARAMS (ifp); | |
8939 | ||
8940 | do { | |
8941 | /* Interface Network print. */ | |
8942 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 8943 | params->type != OSPF_IFTYPE_LOOPBACK) |
8944 | { | |
bc18d616 | 8945 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 8946 | { |
8947 | vty_out (vty, " ip ospf network %s", | |
8948 | ospf_int_type_str[params->type]); | |
8949 | if (params != IF_DEF_PARAMS (ifp)) | |
8950 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8951 | vty_out (vty, "%s", VTY_NEWLINE); | |
8952 | } | |
718e3744 | 8953 | } |
8954 | ||
8955 | /* OSPF interface authentication print */ | |
8956 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
8957 | params->auth_type != OSPF_AUTH_NOTSET) | |
8958 | { | |
eb1ce605 | 8959 | const char *auth_str; |
718e3744 | 8960 | |
8961 | /* Translation tables are not that much help here due to syntax | |
8962 | of the simple option */ | |
8963 | switch (params->auth_type) | |
8964 | { | |
8965 | ||
8966 | case OSPF_AUTH_NULL: | |
8967 | auth_str = " null"; | |
8968 | break; | |
8969 | ||
8970 | case OSPF_AUTH_SIMPLE: | |
8971 | auth_str = ""; | |
8972 | break; | |
8973 | ||
8974 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
8975 | auth_str = " message-digest"; | |
8976 | break; | |
8977 | ||
8978 | default: | |
8979 | auth_str = ""; | |
8980 | break; | |
8981 | } | |
8982 | ||
8983 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
8984 | if (params != IF_DEF_PARAMS (ifp)) | |
8985 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8986 | vty_out (vty, "%s", VTY_NEWLINE); | |
8987 | } | |
8988 | ||
8989 | /* Simple Authentication Password print. */ | |
8990 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
8991 | params->auth_simple[0] != '\0') | |
8992 | { | |
8993 | vty_out (vty, " ip ospf authentication-key %s", | |
8994 | params->auth_simple); | |
8995 | if (params != IF_DEF_PARAMS (ifp)) | |
8996 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8997 | vty_out (vty, "%s", VTY_NEWLINE); | |
8998 | } | |
8999 | ||
9000 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 9001 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 9002 | { |
718e3744 | 9003 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 9004 | ck->key_id, ck->auth_key); |
718e3744 | 9005 | if (params != IF_DEF_PARAMS (ifp)) |
9006 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9007 | vty_out (vty, "%s", VTY_NEWLINE); | |
9008 | } | |
9009 | ||
9010 | /* Interface Output Cost print. */ | |
9011 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
9012 | { | |
9013 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
9014 | if (params != IF_DEF_PARAMS (ifp)) | |
9015 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9016 | vty_out (vty, "%s", VTY_NEWLINE); | |
9017 | } | |
9018 | ||
9019 | /* Hello Interval print. */ | |
9020 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
9021 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
9022 | { | |
9023 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
9024 | if (params != IF_DEF_PARAMS (ifp)) | |
9025 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9026 | vty_out (vty, "%s", VTY_NEWLINE); | |
9027 | } | |
9028 | ||
9029 | ||
9030 | /* Router Dead Interval print. */ | |
9031 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
9032 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
9033 | { | |
f9ad937f | 9034 | vty_out (vty, " ip ospf dead-interval "); |
9035 | ||
9036 | /* fast hello ? */ | |
9037 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
9038 | vty_out (vty, "minimal hello-multiplier %d", | |
9039 | params->fast_hello); | |
9040 | else | |
9041 | vty_out (vty, "%u", params->v_wait); | |
9042 | ||
718e3744 | 9043 | if (params != IF_DEF_PARAMS (ifp)) |
9044 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9045 | vty_out (vty, "%s", VTY_NEWLINE); | |
9046 | } | |
9047 | ||
9048 | /* Router Priority print. */ | |
9049 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
9050 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
9051 | { | |
9052 | vty_out (vty, " ip ospf priority %u", params->priority); | |
9053 | if (params != IF_DEF_PARAMS (ifp)) | |
9054 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9055 | vty_out (vty, "%s", VTY_NEWLINE); | |
9056 | } | |
9057 | ||
9058 | /* Retransmit Interval print. */ | |
9059 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
9060 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
9061 | { | |
9062 | vty_out (vty, " ip ospf retransmit-interval %u", | |
9063 | params->retransmit_interval); | |
9064 | if (params != IF_DEF_PARAMS (ifp)) | |
9065 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9066 | vty_out (vty, "%s", VTY_NEWLINE); | |
9067 | } | |
9068 | ||
9069 | /* Transmit Delay print. */ | |
9070 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
9071 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9072 | { | |
9073 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
9074 | if (params != IF_DEF_PARAMS (ifp)) | |
9075 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9076 | vty_out (vty, "%s", VTY_NEWLINE); | |
9077 | } | |
9078 | ||
e723861d DS |
9079 | /* Area print. */ |
9080 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
9081 | { | |
7c8ff89e DS |
9082 | if (ospf->instance) |
9083 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
9084 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
9085 | else | |
9086 | vty_out (vty, " ip ospf area %s%s", | |
9087 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
e723861d DS |
9088 | |
9089 | } | |
9090 | ||
d5a5c8f0 | 9091 | /* bfd print. */ |
7f342629 | 9092 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 9093 | |
ba682537 | 9094 | /* MTU ignore print. */ |
9095 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
9096 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
9097 | { | |
9098 | if (params->mtu_ignore == 0) | |
9099 | vty_out (vty, " no ip ospf mtu-ignore"); | |
9100 | else | |
9101 | vty_out (vty, " ip ospf mtu-ignore"); | |
9102 | if (params != IF_DEF_PARAMS (ifp)) | |
9103 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9104 | vty_out (vty, "%s", VTY_NEWLINE); | |
9105 | } | |
9106 | ||
9107 | ||
718e3744 | 9108 | while (1) |
9109 | { | |
9110 | if (rn == NULL) | |
9111 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
9112 | else | |
9113 | rn = route_next (rn); | |
9114 | ||
9115 | if (rn == NULL) | |
9116 | break; | |
9117 | params = rn->info; | |
9118 | if (params != NULL) | |
9119 | break; | |
9120 | } | |
9121 | } while (rn); | |
9122 | ||
9123 | #ifdef HAVE_OPAQUE_LSA | |
9124 | ospf_opaque_config_write_if (vty, ifp); | |
9125 | #endif /* HAVE_OPAQUE_LSA */ | |
9126 | } | |
9127 | ||
9128 | return write; | |
9129 | } | |
9130 | ||
4dadc291 | 9131 | static int |
68980084 | 9132 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9133 | { |
9134 | struct route_node *rn; | |
9135 | u_char buf[INET_ADDRSTRLEN]; | |
9136 | ||
9137 | /* `network area' print. */ | |
68980084 | 9138 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 9139 | if (rn->info) |
9140 | { | |
9141 | struct ospf_network *n = rn->info; | |
9142 | ||
9143 | memset (buf, 0, INET_ADDRSTRLEN); | |
9144 | ||
9145 | /* Create Area ID string by specified Area ID format. */ | |
9146 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9147 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 9148 | else |
c9e52be3 | 9149 | sprintf ((char *) buf, "%lu", |
718e3744 | 9150 | (unsigned long int) ntohl (n->area_id.s_addr)); |
9151 | ||
9152 | /* Network print. */ | |
9153 | vty_out (vty, " network %s/%d area %s%s", | |
9154 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9155 | buf, VTY_NEWLINE); | |
9156 | } | |
9157 | ||
9158 | return 0; | |
9159 | } | |
9160 | ||
4dadc291 | 9161 | static int |
68980084 | 9162 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9163 | { |
52dc7ee6 | 9164 | struct listnode *node; |
1eb8ef25 | 9165 | struct ospf_area *area; |
718e3744 | 9166 | u_char buf[INET_ADDRSTRLEN]; |
9167 | ||
9168 | /* Area configuration print. */ | |
1eb8ef25 | 9169 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 9170 | { |
718e3744 | 9171 | struct route_node *rn1; |
9172 | ||
c9e52be3 | 9173 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
718e3744 | 9174 | |
9175 | if (area->auth_type != OSPF_AUTH_NULL) | |
9176 | { | |
9177 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
9178 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
9179 | else | |
9180 | vty_out (vty, " area %s authentication message-digest%s", | |
9181 | buf, VTY_NEWLINE); | |
9182 | } | |
9183 | ||
9184 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
9185 | vty_out (vty, " area %s shortcut %s%s", buf, | |
9186 | ospf_shortcut_mode_str[area->shortcut_configured], | |
9187 | VTY_NEWLINE); | |
9188 | ||
9189 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 9190 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 9191 | ) |
9192 | { | |
b0a053be | 9193 | if (area->external_routing == OSPF_AREA_STUB) |
9194 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 9195 | else if (area->external_routing == OSPF_AREA_NSSA) |
9196 | { | |
9197 | vty_out (vty, " area %s nssa", buf); | |
9198 | switch (area->NSSATranslatorRole) | |
9199 | { | |
9200 | case OSPF_NSSA_ROLE_NEVER: | |
9201 | vty_out (vty, " translate-never"); | |
9202 | break; | |
9203 | case OSPF_NSSA_ROLE_ALWAYS: | |
9204 | vty_out (vty, " translate-always"); | |
9205 | break; | |
9206 | case OSPF_NSSA_ROLE_CANDIDATE: | |
9207 | default: | |
9208 | vty_out (vty, " translate-candidate"); | |
9209 | } | |
9210 | } | |
718e3744 | 9211 | |
9212 | if (area->no_summary) | |
9213 | vty_out (vty, " no-summary"); | |
9214 | ||
9215 | vty_out (vty, "%s", VTY_NEWLINE); | |
9216 | ||
9217 | if (area->default_cost != 1) | |
9218 | vty_out (vty, " area %s default-cost %d%s", buf, | |
9219 | area->default_cost, VTY_NEWLINE); | |
9220 | } | |
9221 | ||
9222 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
9223 | if (rn1->info) | |
9224 | { | |
9225 | struct ospf_area_range *range = rn1->info; | |
9226 | ||
9227 | vty_out (vty, " area %s range %s/%d", buf, | |
9228 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
9229 | ||
6c835671 | 9230 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 9231 | vty_out (vty, " cost %d", range->cost_config); |
9232 | ||
9233 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
9234 | vty_out (vty, " not-advertise"); | |
9235 | ||
9236 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
9237 | vty_out (vty, " substitute %s/%d", | |
9238 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
9239 | ||
9240 | vty_out (vty, "%s", VTY_NEWLINE); | |
9241 | } | |
9242 | ||
9243 | if (EXPORT_NAME (area)) | |
9244 | vty_out (vty, " area %s export-list %s%s", buf, | |
9245 | EXPORT_NAME (area), VTY_NEWLINE); | |
9246 | ||
9247 | if (IMPORT_NAME (area)) | |
9248 | vty_out (vty, " area %s import-list %s%s", buf, | |
9249 | IMPORT_NAME (area), VTY_NEWLINE); | |
9250 | ||
9251 | if (PREFIX_NAME_IN (area)) | |
9252 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
9253 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
9254 | ||
9255 | if (PREFIX_NAME_OUT (area)) | |
9256 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
9257 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
9258 | } | |
9259 | ||
9260 | return 0; | |
9261 | } | |
9262 | ||
4dadc291 | 9263 | static int |
68980084 | 9264 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 9265 | { |
9266 | struct ospf_nbr_nbma *nbr_nbma; | |
9267 | struct route_node *rn; | |
9268 | ||
9269 | /* Static Neighbor configuration print. */ | |
68980084 | 9270 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 9271 | if ((nbr_nbma = rn->info)) |
9272 | { | |
9273 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
9274 | ||
9275 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
9276 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
9277 | ||
9278 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
9279 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
9280 | ||
9281 | vty_out (vty, "%s", VTY_NEWLINE); | |
9282 | } | |
9283 | ||
9284 | return 0; | |
9285 | } | |
9286 | ||
4dadc291 | 9287 | static int |
68980084 | 9288 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 9289 | { |
52dc7ee6 | 9290 | struct listnode *node; |
1eb8ef25 | 9291 | struct ospf_vl_data *vl_data; |
718e3744 | 9292 | u_char buf[INET_ADDRSTRLEN]; |
9293 | ||
9294 | /* Virtual-Link print */ | |
1eb8ef25 | 9295 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 9296 | { |
52dc7ee6 | 9297 | struct listnode *n2; |
718e3744 | 9298 | struct crypt_key *ck; |
718e3744 | 9299 | struct ospf_interface *oi; |
9300 | ||
9301 | if (vl_data != NULL) | |
9302 | { | |
9303 | memset (buf, 0, INET_ADDRSTRLEN); | |
9304 | ||
9305 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9306 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
718e3744 | 9307 | else |
c9e52be3 | 9308 | sprintf ((char *) buf, "%lu", |
718e3744 | 9309 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
9310 | oi = vl_data->vl_oi; | |
9311 | ||
9312 | /* timers */ | |
9313 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
9314 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
9315 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
9316 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9317 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
9318 | buf, | |
9319 | inet_ntoa (vl_data->vl_peer), | |
9320 | OSPF_IF_PARAM (oi, v_hello), | |
9321 | OSPF_IF_PARAM (oi, retransmit_interval), | |
9322 | OSPF_IF_PARAM (oi, transmit_delay), | |
9323 | OSPF_IF_PARAM (oi, v_wait), | |
9324 | VTY_NEWLINE); | |
9325 | else | |
9326 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
9327 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
9328 | /* Auth key */ | |
9329 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
9330 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
9331 | buf, | |
9332 | inet_ntoa (vl_data->vl_peer), | |
9333 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
9334 | VTY_NEWLINE); | |
9335 | /* md5 keys */ | |
1eb8ef25 | 9336 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
9337 | n2, ck)) | |
9338 | vty_out (vty, " area %s virtual-link %s" | |
9339 | " message-digest-key %d md5 %s%s", | |
9340 | buf, | |
9341 | inet_ntoa (vl_data->vl_peer), | |
9342 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 9343 | |
9344 | } | |
9345 | } | |
9346 | ||
9347 | return 0; | |
9348 | } | |
9349 | ||
6b0655a2 | 9350 | |
4dadc291 | 9351 | static int |
68980084 | 9352 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9353 | { |
9354 | int type; | |
9355 | ||
9356 | /* redistribute print. */ | |
9357 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
9358 | { |
9359 | struct list *red_list; | |
9360 | struct listnode *node; | |
9361 | struct ospf_redist *red; | |
718e3744 | 9362 | |
7c8ff89e DS |
9363 | red_list = ospf->redist[type]; |
9364 | if (!red_list) | |
9365 | continue; | |
9366 | ||
9367 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
9368 | { | |
9369 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
9370 | if (red->instance) | |
9371 | vty_out (vty, " %d", red->instance); | |
9372 | ||
9373 | if (red->dmetric.value >= 0) | |
9374 | vty_out (vty, " metric %d", red->dmetric.value); | |
9375 | ||
9376 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9377 | vty_out (vty, " metric-type 1"); | |
9378 | ||
9379 | if (ROUTEMAP_NAME (red)) | |
9380 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
9381 | ||
9382 | vty_out (vty, "%s", VTY_NEWLINE); | |
9383 | } | |
9384 | } | |
718e3744 | 9385 | |
9386 | return 0; | |
9387 | } | |
9388 | ||
4dadc291 | 9389 | static int |
68980084 | 9390 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 9391 | { |
68980084 | 9392 | if (ospf->default_metric != -1) |
9393 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 9394 | VTY_NEWLINE); |
9395 | return 0; | |
9396 | } | |
9397 | ||
4dadc291 | 9398 | static int |
68980084 | 9399 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9400 | { |
9401 | int type; | |
7c8ff89e | 9402 | struct ospf_redist *red; |
718e3744 | 9403 | |
68980084 | 9404 | if (ospf) |
718e3744 | 9405 | { |
9406 | /* distribute-list print. */ | |
9407 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 9408 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 9409 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 9410 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 9411 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 9412 | |
9413 | /* default-information print. */ | |
68980084 | 9414 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 9415 | { |
c42c177d | 9416 | vty_out (vty, " default-information originate"); |
9417 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
9418 | vty_out (vty, " always"); | |
718e3744 | 9419 | |
7c8ff89e DS |
9420 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
9421 | if (red) | |
9422 | { | |
9423 | if (red->dmetric.value >= 0) | |
9424 | vty_out (vty, " metric %d", | |
9425 | red->dmetric.value); | |
9426 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9427 | vty_out (vty, " metric-type 1"); | |
9428 | ||
9429 | if (ROUTEMAP_NAME (red)) | |
9430 | vty_out (vty, " route-map %s", | |
9431 | ROUTEMAP_NAME (red)); | |
9432 | } | |
718e3744 | 9433 | |
9434 | vty_out (vty, "%s", VTY_NEWLINE); | |
9435 | } | |
9436 | ||
9437 | } | |
9438 | ||
9439 | return 0; | |
9440 | } | |
9441 | ||
4dadc291 | 9442 | static int |
68980084 | 9443 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 9444 | { |
9445 | struct route_node *rn; | |
9446 | struct ospf_distance *odistance; | |
9447 | ||
68980084 | 9448 | if (ospf->distance_all) |
9449 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 9450 | |
68980084 | 9451 | if (ospf->distance_intra |
9452 | || ospf->distance_inter | |
9453 | || ospf->distance_external) | |
718e3744 | 9454 | { |
9455 | vty_out (vty, " distance ospf"); | |
9456 | ||
68980084 | 9457 | if (ospf->distance_intra) |
9458 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
9459 | if (ospf->distance_inter) | |
9460 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
9461 | if (ospf->distance_external) | |
9462 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 9463 | |
9464 | vty_out (vty, "%s", VTY_NEWLINE); | |
9465 | } | |
9466 | ||
68980084 | 9467 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 9468 | if ((odistance = rn->info) != NULL) |
9469 | { | |
9470 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
9471 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9472 | odistance->access_list ? odistance->access_list : "", | |
9473 | VTY_NEWLINE); | |
9474 | } | |
9475 | return 0; | |
9476 | } | |
9477 | ||
9478 | /* OSPF configuration write function. */ | |
4dadc291 | 9479 | static int |
718e3744 | 9480 | ospf_config_write (struct vty *vty) |
9481 | { | |
020709f9 | 9482 | struct ospf *ospf; |
1eb8ef25 | 9483 | struct interface *ifp; |
9484 | struct ospf_interface *oi; | |
52dc7ee6 | 9485 | struct listnode *node; |
718e3744 | 9486 | int write = 0; |
9487 | ||
020709f9 | 9488 | ospf = ospf_lookup (); |
0bad4851 | 9489 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 9490 | { |
9491 | /* `router ospf' print. */ | |
7c8ff89e DS |
9492 | if (ospf->instance) |
9493 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
9494 | else | |
9495 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 9496 | |
9497 | write++; | |
9498 | ||
68980084 | 9499 | if (!ospf->networks) |
718e3744 | 9500 | return write; |
9501 | ||
9502 | /* Router ID print. */ | |
68980084 | 9503 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 9504 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 9505 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 9506 | |
9507 | /* ABR type print. */ | |
d57834f6 | 9508 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 9509 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 9510 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 9511 | |
d7e60dd7 AS |
9512 | /* log-adjacency-changes flag print. */ |
9513 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
9514 | { | |
9515 | vty_out(vty, " log-adjacency-changes"); | |
9516 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
9517 | vty_out(vty, " detail"); | |
9518 | vty_out(vty, "%s", VTY_NEWLINE); | |
9519 | } | |
9520 | ||
718e3744 | 9521 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 9522 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 9523 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
9524 | ||
9525 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 9526 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 9527 | { |
9528 | vty_out (vty, "! Important: ensure reference bandwidth " | |
9529 | "is consistent across all routers%s", VTY_NEWLINE); | |
9530 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
9531 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); | |
9532 | } | |
718e3744 | 9533 | |
9534 | /* SPF timers print. */ | |
68980084 | 9535 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 9536 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
9537 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
9538 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 9539 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 9540 | ospf->spf_max_holdtime, VTY_NEWLINE); |
b6927875 DS |
9541 | |
9542 | /* LSA timers print. */ | |
ac7424f9 MR |
9543 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
9544 | vty_out (vty, " timers throttle lsa all %d%s", | |
9545 | ospf->min_ls_interval, VTY_NEWLINE); | |
9546 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
b6927875 | 9547 | vty_out (vty, " timers lsa min-arrival %d%s", |
ac7424f9 | 9548 | ospf->min_ls_arrival, VTY_NEWLINE); |
b6927875 | 9549 | |
2f8f370e | 9550 | /* Write multiplier print. */ |
e8f45e82 | 9551 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 9552 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 9553 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 9554 | |
88d6cf37 | 9555 | /* Max-metric router-lsa print */ |
9556 | config_write_stub_router (vty, ospf); | |
9557 | ||
718e3744 | 9558 | /* SPF refresh parameters print. */ |
68980084 | 9559 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 9560 | vty_out (vty, " refresh timer %d%s", |
68980084 | 9561 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 9562 | |
9563 | /* Redistribute information print. */ | |
68980084 | 9564 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 9565 | |
9566 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
9567 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
9568 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
9569 | ||
1eb8ef25 | 9570 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
9571 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
9572 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
9573 | ospf->passive_interface_default) | |
9574 | { | |
9575 | vty_out (vty, " %spassive-interface %s%s", | |
9576 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
9577 | ifp->name, VTY_NEWLINE); | |
9578 | } | |
1eb8ef25 | 9579 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
9580 | { |
9581 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
9582 | continue; | |
9583 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
9584 | passive_interface)) | |
9585 | { | |
9586 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
9587 | continue; | |
9588 | } | |
9589 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
9590 | continue; | |
9591 | ||
9592 | vty_out (vty, " %spassive-interface %s %s%s", | |
9593 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 9594 | oi->ifp->name, |
9595 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 9596 | } |
718e3744 | 9597 | |
9598 | /* Network area print. */ | |
68980084 | 9599 | config_write_network_area (vty, ospf); |
718e3744 | 9600 | |
9601 | /* Area config print. */ | |
68980084 | 9602 | config_write_ospf_area (vty, ospf); |
718e3744 | 9603 | |
9604 | /* static neighbor print. */ | |
68980084 | 9605 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 9606 | |
9607 | /* Virtual-Link print. */ | |
68980084 | 9608 | config_write_virtual_link (vty, ospf); |
718e3744 | 9609 | |
9610 | /* Default metric configuration. */ | |
68980084 | 9611 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 9612 | |
9613 | /* Distribute-list and default-information print. */ | |
68980084 | 9614 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 9615 | |
9616 | /* Distance configuration. */ | |
68980084 | 9617 | config_write_ospf_distance (vty, ospf); |
718e3744 | 9618 | |
9619 | #ifdef HAVE_OPAQUE_LSA | |
68980084 | 9620 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 9621 | #endif /* HAVE_OPAQUE_LSA */ |
9622 | } | |
9623 | ||
9624 | return write; | |
9625 | } | |
9626 | ||
9627 | void | |
4dadc291 | 9628 | ospf_vty_show_init (void) |
718e3744 | 9629 | { |
9630 | /* "show ip ospf" commands. */ | |
9631 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
9632 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); | |
9633 | ||
7c8ff89e DS |
9634 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
9635 | install_element (ENABLE_NODE, &show_ip_ospf_instance_cmd); | |
9636 | ||
718e3744 | 9637 | /* "show ip ospf database" commands. */ |
9638 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); | |
9639 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); | |
9640 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
9641 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
9642 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
9643 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); | |
9644 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); | |
9645 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); | |
9646 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); | |
9647 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
9648 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
9649 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
9650 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); | |
9651 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); | |
9652 | ||
7c8ff89e DS |
9653 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd); |
9654 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
9655 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
9656 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
9657 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
9658 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
9659 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); | |
9660 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_cmd); | |
9661 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
9662 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
9663 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
9664 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
9665 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
9666 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_cmd); | |
9667 | ||
718e3744 | 9668 | /* "show ip ospf interface" commands. */ |
9669 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
9670 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); | |
9671 | ||
7c8ff89e DS |
9672 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
9673 | install_element (ENABLE_NODE, &show_ip_ospf_instance_interface_cmd); | |
9674 | ||
718e3744 | 9675 | /* "show ip ospf neighbor" commands. */ |
9676 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
9677 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
9678 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
9679 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
9680 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
9681 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
9682 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
9683 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
9684 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); | |
9685 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); | |
9686 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
9687 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
9688 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); | |
9689 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); | |
9690 | ||
7c8ff89e DS |
9691 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
9692 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
9693 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
9694 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
9695 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
9696 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
9697 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
9698 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); | |
9699 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
9700 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
9701 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
9702 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
9703 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
9704 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
9705 | ||
718e3744 | 9706 | /* "show ip ospf route" commands. */ |
9707 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
9708 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 9709 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
9710 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); | |
7c8ff89e DS |
9711 | |
9712 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
9713 | install_element (ENABLE_NODE, &show_ip_ospf_instance_route_cmd); | |
9714 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
9715 | install_element (ENABLE_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
718e3744 | 9716 | } |
9717 | ||
6b0655a2 | 9718 | |
718e3744 | 9719 | /* ospfd's interface node. */ |
7fc626de | 9720 | static struct cmd_node interface_node = |
718e3744 | 9721 | { |
9722 | INTERFACE_NODE, | |
9723 | "%s(config-if)# ", | |
9724 | 1 | |
9725 | }; | |
9726 | ||
9727 | /* Initialization of OSPF interface. */ | |
4dadc291 | 9728 | static void |
9729 | ospf_vty_if_init (void) | |
718e3744 | 9730 | { |
9731 | /* Install interface node. */ | |
9732 | install_node (&interface_node, config_write_interface); | |
9733 | ||
9734 | install_element (CONFIG_NODE, &interface_cmd); | |
32d2463c | 9735 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 9736 | install_default (INTERFACE_NODE); |
9737 | ||
9738 | /* "description" commands. */ | |
9739 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
9740 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
9741 | ||
9742 | /* "ip ospf authentication" commands. */ | |
9743 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
9744 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); | |
9745 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); | |
9746 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); | |
b4a039bf DS |
9747 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
9748 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_cmd); | |
718e3744 | 9749 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
9750 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); | |
9751 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); | |
9752 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); | |
9753 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); | |
9754 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); | |
9755 | ||
9756 | /* "ip ospf message-digest-key" commands. */ | |
9757 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); | |
9758 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); | |
9759 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); | |
9760 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
9761 | ||
9762 | /* "ip ospf cost" commands. */ | |
9eff36b3 DO |
9763 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
9764 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); | |
827341b7 DO |
9765 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
9766 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 9767 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
718e3744 | 9768 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
9769 | ||
ba682537 | 9770 | /* "ip ospf mtu-ignore" commands. */ |
9771 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
9772 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); | |
9773 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); | |
9774 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); | |
9775 | ||
718e3744 | 9776 | /* "ip ospf dead-interval" commands. */ |
9777 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); | |
9778 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); | |
f9ad937f | 9779 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
9780 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); | |
718e3744 | 9781 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
9782 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); | |
f9dfba8d | 9783 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd); |
f9ad937f | 9784 | |
718e3744 | 9785 | /* "ip ospf hello-interval" commands. */ |
9786 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); | |
9787 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); | |
9788 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); | |
9789 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
f9dfba8d | 9790 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd); |
718e3744 | 9791 | |
9792 | /* "ip ospf network" commands. */ | |
9793 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
9794 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
9795 | ||
9796 | /* "ip ospf priority" commands. */ | |
9797 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); | |
9798 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); | |
9799 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); | |
9800 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); | |
9801 | ||
9802 | /* "ip ospf retransmit-interval" commands. */ | |
9803 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
9804 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); | |
9805 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); | |
9806 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); | |
9807 | ||
9808 | /* "ip ospf transmit-delay" commands. */ | |
9809 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
9810 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); | |
9811 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); | |
9812 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); | |
9813 | ||
e723861d DS |
9814 | /* "ip ospf area" commands. */ |
9815 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
9816 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
7c8ff89e DS |
9817 | install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd); |
9818 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd); | |
e723861d | 9819 | |
718e3744 | 9820 | /* These commands are compatibitliy for previous version. */ |
9821 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
9822 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); | |
9823 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); | |
9824 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); | |
9eff36b3 DO |
9825 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
9826 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); | |
718e3744 | 9827 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
827341b7 DO |
9828 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
9829 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 9830 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
718e3744 | 9831 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
9832 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); | |
9833 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); | |
9834 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); | |
9835 | install_element (INTERFACE_NODE, &ospf_network_cmd); | |
9836 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); | |
9837 | install_element (INTERFACE_NODE, &ospf_priority_cmd); | |
9838 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); | |
9839 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); | |
9840 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); | |
9841 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); | |
9842 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); | |
9843 | } | |
9844 | ||
4dadc291 | 9845 | static void |
9846 | ospf_vty_zebra_init (void) | |
718e3744 | 9847 | { |
718e3744 | 9848 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 9849 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
9850 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
9851 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 9852 | |
9853 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
9854 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
9855 | ||
718e3744 | 9856 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 9857 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
9858 | ||
9859 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
9860 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
9861 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); | |
9862 | ||
9863 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
9864 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
9865 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 9866 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 9867 | #if 0 |
9868 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
9869 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
9870 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
9871 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
9872 | #endif /* 0 */ | |
9873 | } | |
9874 | ||
7fc626de | 9875 | static struct cmd_node ospf_node = |
718e3744 | 9876 | { |
9877 | OSPF_NODE, | |
9878 | "%s(config-router)# ", | |
9879 | 1 | |
9880 | }; | |
9881 | ||
09f35f8c DS |
9882 | static void |
9883 | ospf_interface_clear (struct interface *ifp) | |
9884 | { | |
9885 | if (!if_is_operative (ifp)) return; | |
9886 | ||
9887 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
9888 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); | |
9889 | ||
9890 | ospf_if_reset(ifp); | |
9891 | } | |
9892 | ||
9893 | DEFUN (clear_ip_ospf_interface, | |
9894 | clear_ip_ospf_interface_cmd, | |
9895 | "clear ip ospf interface [IFNAME]", | |
9896 | CLEAR_STR | |
9897 | IP_STR | |
9898 | "OSPF information\n" | |
9899 | "Interface information\n" | |
9900 | "Interface name\n") | |
9901 | { | |
9902 | struct interface *ifp; | |
9903 | struct listnode *node; | |
9904 | ||
9905 | if (argc == 0) /* Clear all the ospfv2 interfaces. */ | |
9906 | { | |
9907 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) | |
9908 | ospf_interface_clear(ifp); | |
9909 | } | |
9910 | else /* Interface name is specified. */ | |
9911 | { | |
9912 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) | |
9913 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
9914 | else | |
9915 | ospf_interface_clear(ifp); | |
9916 | } | |
9917 | ||
9918 | return CMD_SUCCESS; | |
9919 | } | |
9920 | ||
9921 | void | |
9922 | ospf_vty_clear_init (void) | |
9923 | { | |
9924 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
9925 | } | |
9926 | ||
6b0655a2 | 9927 | |
718e3744 | 9928 | /* Install OSPF related vty commands. */ |
9929 | void | |
4dadc291 | 9930 | ospf_vty_init (void) |
718e3744 | 9931 | { |
9932 | /* Install ospf top node. */ | |
9933 | install_node (&ospf_node, ospf_config_write); | |
9934 | ||
9935 | /* "router ospf" commands. */ | |
9936 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
9937 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
9938 | ||
7c8ff89e DS |
9939 | install_element (CONFIG_NODE, &router_ospf_instance_cmd); |
9940 | install_element (CONFIG_NODE, &no_router_ospf_instance_cmd); | |
9941 | ||
718e3744 | 9942 | install_default (OSPF_NODE); |
9943 | ||
9944 | /* "ospf router-id" commands. */ | |
9945 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
9946 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); | |
a2c62831 | 9947 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
9948 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); | |
718e3744 | 9949 | |
9950 | /* "passive-interface" commands. */ | |
a2c62831 | 9951 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
9952 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); | |
7ffa8fa2 | 9953 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
a2c62831 | 9954 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
9955 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); | |
7ffa8fa2 | 9956 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
718e3744 | 9957 | |
9958 | /* "ospf abr-type" commands. */ | |
9959 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
9960 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
9961 | ||
d7e60dd7 AS |
9962 | /* "ospf log-adjacency-changes" commands. */ |
9963 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
9964 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
9965 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
9966 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
9967 | ||
718e3744 | 9968 | /* "ospf rfc1583-compatible" commands. */ |
9969 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); | |
9970 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
9971 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); | |
9972 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
9973 | ||
9974 | /* "network area" commands. */ | |
a2c62831 | 9975 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
9976 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 9977 | |
9978 | /* "area authentication" commands. */ | |
a2c62831 | 9979 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
9980 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
9981 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 9982 | |
9983 | /* "area range" commands. */ | |
a2c62831 | 9984 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
9985 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); | |
9986 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); | |
9987 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); | |
9988 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); | |
9989 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
9990 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); | |
9991 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); | |
9992 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); | |
9993 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); | |
9994 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 9995 | |
9996 | /* "area virtual-link" commands. */ | |
a2c62831 | 9997 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
9998 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); | |
718e3744 | 9999 | |
a2c62831 | 10000 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
10001 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); | |
718e3744 | 10002 | |
a2c62831 | 10003 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
10004 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); | |
718e3744 | 10005 | |
a2c62831 | 10006 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
10007 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); | |
718e3744 | 10008 | |
a2c62831 | 10009 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
10010 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); | |
718e3744 | 10011 | |
a2c62831 | 10012 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
10013 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); | |
10014 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); | |
718e3744 | 10015 | |
a2c62831 | 10016 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
10017 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); | |
718e3744 | 10018 | |
a2c62831 | 10019 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
10020 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); | |
718e3744 | 10021 | |
a2c62831 | 10022 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
10023 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); | |
10024 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); | |
718e3744 | 10025 | |
a2c62831 | 10026 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
10027 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); | |
10028 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); | |
718e3744 | 10029 | |
10030 | /* "area stub" commands. */ | |
a2c62831 | 10031 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
10032 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
10033 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
10034 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 10035 | |
718e3744 | 10036 | /* "area nssa" commands. */ |
a2c62831 | 10037 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
10038 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
10039 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
10040 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
10041 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
10042 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); | |
718e3744 | 10043 | |
a2c62831 | 10044 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
10045 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 10046 | |
a2c62831 | 10047 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
10048 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 10049 | |
a2c62831 | 10050 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
10051 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 10052 | |
a2c62831 | 10053 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
10054 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 10055 | |
a2c62831 | 10056 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
10057 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 10058 | |
10059 | /* SPF timer commands */ | |
a2c62831 | 10060 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
10061 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); | |
d24f6e2a | 10062 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
10063 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
b4a039bf | 10064 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_val_cmd); |
d24f6e2a | 10065 | |
b6927875 | 10066 | /* LSA timers commands */ |
ac7424f9 MR |
10067 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
10068 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
10069 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); | |
10070 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
b6927875 DS |
10071 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
10072 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
10073 | install_element (OSPF_NODE, &no_ospf_timers_lsa_val_cmd); | |
10074 | ||
88d6cf37 | 10075 | /* refresh timer commands */ |
a2c62831 | 10076 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
10077 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
10078 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); | |
718e3744 | 10079 | |
88d6cf37 | 10080 | /* max-metric commands */ |
10081 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
10082 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
10083 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
10084 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
10085 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
10086 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
10087 | ||
10088 | /* reference bandwidth commands */ | |
a2c62831 | 10089 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
10090 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
718e3744 | 10091 | |
10092 | /* "neighbor" commands. */ | |
a2c62831 | 10093 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
10094 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); | |
10095 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); | |
10096 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); | |
10097 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); | |
10098 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); | |
10099 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); | |
10100 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); | |
718e3744 | 10101 | |
2f8f370e DS |
10102 | /* write multiplier commands */ |
10103 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
10104 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); | |
e8f45e82 DS |
10105 | install_element (OSPF_NODE, &write_multiplier_cmd); |
10106 | install_element (OSPF_NODE, &no_write_multiplier_cmd); | |
2f8f370e | 10107 | |
718e3744 | 10108 | /* Init interface related vty commands. */ |
10109 | ospf_vty_if_init (); | |
10110 | ||
10111 | /* Init zebra related vty commands. */ | |
10112 | ospf_vty_zebra_init (); | |
10113 | } |