]>
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> | |
7ec4159b | 24 | #include <string.h> |
718e3744 | 25 | |
26 | #include "memory.h" | |
27 | #include "thread.h" | |
28 | #include "prefix.h" | |
29 | #include "table.h" | |
30 | #include "vty.h" | |
31 | #include "command.h" | |
32 | #include "plist.h" | |
33 | #include "log.h" | |
34 | #include "zclient.h" | |
bf2bfafd | 35 | #include <lib/json.h> |
718e3744 | 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 | ||
718e3744 | 66 | /* Utility functions. */ |
16f1b9ee | 67 | int |
6c835671 | 68 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
718e3744 | 69 | { |
70 | char *endptr = NULL; | |
71 | unsigned long ret; | |
72 | ||
73 | /* match "A.B.C.D". */ | |
74 | if (strchr (str, '.') != NULL) | |
75 | { | |
76 | ret = inet_aton (str, area_id); | |
77 | if (!ret) | |
78 | return -1; | |
79 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; | |
80 | } | |
81 | /* match "<0-4294967295>". */ | |
82 | else | |
83 | { | |
664711c1 UW |
84 | if (*str == '-') |
85 | return -1; | |
86 | errno = 0; | |
718e3744 | 87 | ret = strtoul (str, &endptr, 10); |
664711c1 | 88 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
718e3744 | 89 | return -1; |
90 | ||
91 | area_id->s_addr = htonl (ret); | |
92 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; | |
93 | } | |
94 | ||
95 | return 0; | |
96 | } | |
97 | ||
6b0655a2 | 98 | |
4dadc291 | 99 | static int |
6c835671 | 100 | str2metric (const char *str, int *metric) |
718e3744 | 101 | { |
102 | /* Sanity check. */ | |
103 | if (str == NULL) | |
104 | return 0; | |
105 | ||
106 | *metric = strtol (str, NULL, 10); | |
107 | if (*metric < 0 && *metric > 16777214) | |
108 | { | |
109 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
110 | return 0; | |
111 | } | |
112 | ||
113 | return 1; | |
114 | } | |
115 | ||
4dadc291 | 116 | static int |
6c835671 | 117 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 118 | { |
119 | /* Sanity check. */ | |
120 | if (str == NULL) | |
121 | return 0; | |
122 | ||
123 | if (strncmp (str, "1", 1) == 0) | |
124 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
125 | else if (strncmp (str, "2", 1) == 0) | |
126 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
127 | else | |
128 | return 0; | |
129 | ||
130 | return 1; | |
131 | } | |
132 | ||
133 | int | |
134 | ospf_oi_count (struct interface *ifp) | |
135 | { | |
136 | struct route_node *rn; | |
137 | int i = 0; | |
138 | ||
139 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
140 | if (rn->info) | |
141 | i++; | |
142 | ||
143 | return i; | |
144 | } | |
145 | ||
718e3744 | 146 | DEFUN (router_ospf, |
147 | router_ospf_cmd, | |
7a7be519 | 148 | "router ospf [(1-65535)]", |
718e3744 | 149 | "Enable a routing process\n" |
7a7be519 | 150 | "Start OSPF configuration\n" |
151 | "Instance ID\n") | |
718e3744 | 152 | { |
7c8ff89e DS |
153 | struct ospf *ospf; |
154 | u_short instance = 0; | |
155 | ||
156 | ospf = ospf_lookup(); | |
157 | if (!ospf) | |
158 | { | |
159 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
160 | return CMD_WARNING; | |
161 | } | |
162 | ||
718e3744 | 163 | vty->node = OSPF_NODE; |
7c8ff89e | 164 | |
7a7be519 | 165 | if (argc > 2) |
166 | VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); | |
7c8ff89e DS |
167 | |
168 | /* The following logic to set the vty->index is in place to be able | |
169 | to ignore the commands which dont belong to this instance. */ | |
170 | if (ospf->instance != instance) | |
171 | vty->index = NULL; | |
172 | else | |
0bad4851 DS |
173 | { |
174 | if (IS_DEBUG_OSPF_EVENT) | |
175 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
176 | ospf->oi_running = 1; | |
177 | vty->index = ospf; | |
178 | ospf_router_id_update (ospf); | |
179 | } | |
718e3744 | 180 | |
181 | return CMD_SUCCESS; | |
182 | } | |
183 | ||
184 | DEFUN (no_router_ospf, | |
185 | no_router_ospf_cmd, | |
7a7be519 | 186 | "no router ospf [(1-65535)]", |
718e3744 | 187 | NO_STR |
188 | "Enable a routing process\n" | |
7a7be519 | 189 | "Start OSPF configuration\n" |
190 | "Instance ID\n") | |
718e3744 | 191 | { |
020709f9 | 192 | struct ospf *ospf; |
7c8ff89e | 193 | u_short instance = 0; |
020709f9 | 194 | |
7a7be519 | 195 | if (argc > 3) |
bf2bfafd | 196 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
7c8ff89e DS |
197 | |
198 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
199 | return CMD_SUCCESS; | |
718e3744 | 200 | |
020709f9 | 201 | ospf_finish (ospf); |
718e3744 | 202 | |
203 | return CMD_SUCCESS; | |
204 | } | |
205 | ||
7c8ff89e | 206 | |
718e3744 | 207 | DEFUN (ospf_router_id, |
208 | ospf_router_id_cmd, | |
209 | "ospf router-id A.B.C.D", | |
210 | "OSPF specific commands\n" | |
211 | "router-id for the OSPF process\n" | |
212 | "OSPF router-id in IP address format\n") | |
213 | { | |
8d769265 | 214 | int idx_ipv4 = 2; |
68980084 | 215 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
216 | struct listnode *node; |
217 | struct ospf_area *area; | |
718e3744 | 218 | struct in_addr router_id; |
68980084 | 219 | int ret; |
718e3744 | 220 | |
7c8ff89e DS |
221 | if (!ospf) |
222 | return CMD_SUCCESS; | |
223 | ||
8d769265 | 224 | ret = inet_aton (argv[idx_ipv4]->arg, &router_id); |
718e3744 | 225 | if (!ret) |
226 | { | |
227 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
228 | return CMD_WARNING; | |
229 | } | |
230 | ||
68980084 | 231 | ospf->router_id_static = router_id; |
2c19a6ec DS |
232 | |
233 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
234 | if (area->full_nbrs) | |
235 | { | |
236 | vty_out (vty, "For this router-id change to take effect," | |
237 | " save config and restart ospfd%s", VTY_NEWLINE); | |
238 | return CMD_SUCCESS; | |
239 | } | |
240 | ||
b29800a6 | 241 | ospf_router_id_update (ospf); |
242 | ||
718e3744 | 243 | return CMD_SUCCESS; |
244 | } | |
245 | ||
7a7be519 | 246 | DEFUN_HIDDEN (ospf_router_id_old, |
747e489c DW |
247 | ospf_router_id_old_cmd, |
248 | "router-id A.B.C.D", | |
249 | "router-id for the OSPF process\n" | |
250 | "OSPF router-id in IP address format\n") | |
7a7be519 | 251 | { |
252 | int idx_ipv4 = 1; | |
253 | struct ospf *ospf = vty->index; | |
254 | struct listnode *node; | |
255 | struct ospf_area *area; | |
256 | struct in_addr router_id; | |
257 | int ret; | |
258 | ||
259 | if (!ospf) | |
260 | return CMD_SUCCESS; | |
261 | ||
262 | ret = inet_aton (argv[idx_ipv4]->arg, &router_id); | |
263 | if (!ret) | |
264 | { | |
265 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
266 | return CMD_WARNING; | |
267 | } | |
268 | ||
269 | ospf->router_id_static = router_id; | |
270 | ||
271 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
272 | if (area->full_nbrs) | |
273 | { | |
274 | vty_out (vty, "For this router-id change to take effect," | |
275 | " save config and restart ospfd%s", VTY_NEWLINE); | |
276 | return CMD_SUCCESS; | |
277 | } | |
278 | ||
279 | ospf_router_id_update (ospf); | |
280 | ||
281 | return CMD_SUCCESS; | |
282 | } | |
747e489c | 283 | |
718e3744 | 284 | DEFUN (no_ospf_router_id, |
285 | no_ospf_router_id_cmd, | |
7a7be519 | 286 | "no ospf router-id [A.B.C.D]", |
718e3744 | 287 | NO_STR |
288 | "OSPF specific commands\n" | |
7a7be519 | 289 | "router-id for the OSPF process\n" |
290 | "OSPF router-id in IP address format\n") | |
718e3744 | 291 | { |
68980084 | 292 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
293 | struct listnode *node; |
294 | struct ospf_area *area; | |
68980084 | 295 | |
7c8ff89e DS |
296 | if (!ospf) |
297 | return CMD_SUCCESS; | |
298 | ||
68980084 | 299 | ospf->router_id_static.s_addr = 0; |
718e3744 | 300 | |
2c19a6ec DS |
301 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
302 | if (area->full_nbrs) | |
303 | { | |
304 | vty_out (vty, "For this router-id change to take effect," | |
305 | " save config and restart ospfd%s", VTY_NEWLINE); | |
306 | return CMD_SUCCESS; | |
307 | } | |
308 | ||
68980084 | 309 | ospf_router_id_update (ospf); |
718e3744 | 310 | |
311 | return CMD_SUCCESS; | |
312 | } | |
313 | ||
718e3744 | 314 | |
7ffa8fa2 | 315 | static void |
43540886 | 316 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
317 | { |
318 | struct listnode *ln; | |
319 | struct interface *ifp; | |
320 | struct ospf_interface *oi; | |
321 | ||
43540886 AS |
322 | ospf->passive_interface_default = newval; |
323 | ||
7ffa8fa2 PJ |
324 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
325 | { | |
326 | if (ifp && | |
327 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
328 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
329 | } | |
330 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
331 | { | |
332 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
333 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
334 | /* update multicast memberships */ |
335 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
336 | } |
337 | } | |
338 | ||
339 | static void | |
f842f166 PJ |
340 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
341 | struct ospf_if_params *params, u_char value, | |
342 | struct in_addr addr) | |
7ffa8fa2 PJ |
343 | { |
344 | u_char dflt; | |
345 | ||
346 | params->passive_interface = value; | |
347 | if (params != IF_DEF_PARAMS (ifp)) | |
348 | { | |
349 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
350 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
351 | else | |
352 | dflt = ospf->passive_interface_default; | |
353 | ||
354 | if (value != dflt) | |
355 | SET_IF_PARAM (params, passive_interface); | |
356 | else | |
357 | UNSET_IF_PARAM (params, passive_interface); | |
358 | ||
359 | ospf_free_if_params (ifp, addr); | |
360 | ospf_if_update_params (ifp, addr); | |
361 | } | |
f842f166 PJ |
362 | } |
363 | ||
364 | static void | |
365 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
366 | struct ospf_if_params *params, u_char value) | |
367 | { | |
368 | params->passive_interface = value; | |
369 | if (params == IF_DEF_PARAMS (ifp)) | |
7ffa8fa2 PJ |
370 | { |
371 | if (value != ospf->passive_interface_default) | |
372 | SET_IF_PARAM (params, passive_interface); | |
373 | else | |
374 | UNSET_IF_PARAM (params, passive_interface); | |
375 | } | |
376 | } | |
377 | ||
a2c62831 | 378 | DEFUN (ospf_passive_interface, |
379 | ospf_passive_interface_addr_cmd, | |
7a7be519 | 380 | "passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 381 | "Suppress routing updates on an interface\n" |
7a7be519 | 382 | "Interface's name\n" |
383 | "Suppress routing updates on interfaces by default\n") | |
718e3744 | 384 | { |
8d769265 | 385 | int idx_ipv4 = 2; |
7ffa8fa2 | 386 | struct interface *ifp; |
cb2af5d0 | 387 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
7ffa8fa2 PJ |
388 | int ret; |
389 | struct ospf_if_params *params; | |
390 | struct route_node *rn; | |
391 | struct ospf *ospf = vty->index; | |
718e3744 | 392 | |
7c8ff89e DS |
393 | if (!ospf) |
394 | return CMD_SUCCESS; | |
395 | ||
7a7be519 | 396 | if (strcmp (argv[1]->text, "default") == 0) |
43540886 AS |
397 | { |
398 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
399 | return CMD_SUCCESS; | |
400 | } | |
401 | ||
7a7be519 | 402 | ifp = if_get_by_name (argv[1]->arg); |
718e3744 | 403 | |
404 | params = IF_DEF_PARAMS (ifp); | |
405 | ||
7a7be519 | 406 | if (argc == 3) |
718e3744 | 407 | { |
7a7be519 | 408 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
43540886 AS |
409 | if (!ret) |
410 | { | |
411 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
412 | VTY_NEWLINE); | |
413 | return CMD_WARNING; | |
414 | } | |
415 | ||
416 | params = ospf_get_if_params (ifp, addr); | |
417 | ospf_if_update_params (ifp, addr); | |
f842f166 PJ |
418 | ospf_passive_interface_update_addr (ospf, ifp, params, |
419 | OSPF_IF_PASSIVE, addr); | |
7ffa8fa2 | 420 | } |
f842f166 PJ |
421 | |
422 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); | |
43540886 | 423 | |
ba6454ec | 424 | /* XXX We should call ospf_if_set_multicast on exactly those |
425 | * interfaces for which the passive property changed. It is too much | |
426 | * work to determine this set, so we do this for every interface. | |
427 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
428 | * record of joined groups to avoid systems calls if the desired | |
429 | * memberships match the current memership. | |
430 | */ | |
7ffa8fa2 | 431 | |
ba6454ec | 432 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
433 | { | |
434 | struct ospf_interface *oi = rn->info; | |
435 | ||
436 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 437 | ospf_if_set_multicast(oi); |
ba6454ec | 438 | } |
439 | /* | |
440 | * XXX It is not clear what state transitions the interface needs to | |
441 | * undergo when going from active to passive. Fixing this will | |
442 | * require precise identification of interfaces having such a | |
443 | * transition. | |
444 | */ | |
445 | ||
718e3744 | 446 | return CMD_SUCCESS; |
447 | } | |
448 | ||
a2c62831 | 449 | DEFUN (no_ospf_passive_interface, |
450 | no_ospf_passive_interface_addr_cmd, | |
7a7be519 | 451 | "no passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 452 | NO_STR |
453 | "Allow routing updates on an interface\n" | |
7a7be519 | 454 | "Interface's name\n" |
455 | "Allow routing updates on interfaces by default\n") | |
718e3744 | 456 | { |
8d769265 | 457 | int idx_ipv4 = 3; |
718e3744 | 458 | struct interface *ifp; |
cb2af5d0 | 459 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
718e3744 | 460 | struct ospf_if_params *params; |
461 | int ret; | |
ba6454ec | 462 | struct route_node *rn; |
7ffa8fa2 | 463 | struct ospf *ospf = vty->index; |
43540886 | 464 | |
7c8ff89e DS |
465 | if (!ospf) |
466 | return CMD_SUCCESS; | |
467 | ||
7a7be519 | 468 | if (strcmp (argv[2]->text, "default") == 0) |
43540886 AS |
469 | { |
470 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
471 | return CMD_SUCCESS; | |
472 | } | |
718e3744 | 473 | |
7a7be519 | 474 | ifp = if_get_by_name (argv[2]->arg); |
718e3744 | 475 | |
476 | params = IF_DEF_PARAMS (ifp); | |
477 | ||
7a7be519 | 478 | if (argc == 4) |
718e3744 | 479 | { |
7a7be519 | 480 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
43540886 AS |
481 | if (!ret) |
482 | { | |
483 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
484 | VTY_NEWLINE); | |
485 | return CMD_WARNING; | |
486 | } | |
487 | ||
488 | params = ospf_lookup_if_params (ifp, addr); | |
489 | if (params == NULL) | |
490 | return CMD_SUCCESS; | |
f842f166 PJ |
491 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
492 | addr); | |
718e3744 | 493 | } |
f842f166 PJ |
494 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
495 | ||
ba6454ec | 496 | /* XXX We should call ospf_if_set_multicast on exactly those |
497 | * interfaces for which the passive property changed. It is too much | |
498 | * work to determine this set, so we do this for every interface. | |
499 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
500 | * record of joined groups to avoid systems calls if the desired | |
501 | * memberships match the current memership. | |
502 | */ | |
503 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
504 | { | |
505 | struct ospf_interface *oi = rn->info; | |
506 | ||
507 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
508 | ospf_if_set_multicast(oi); | |
509 | } | |
510 | ||
718e3744 | 511 | return CMD_SUCCESS; |
512 | } | |
513 | ||
718e3744 | 514 | |
7ffa8fa2 | 515 | |
a2c62831 | 516 | DEFUN (ospf_network_area, |
517 | ospf_network_area_cmd, | |
6147e2c6 | 518 | "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 519 | "Enable routing on an IP network\n" |
520 | "OSPF network prefix\n" | |
521 | "Set the OSPF area ID\n" | |
522 | "OSPF area ID in IP address format\n" | |
523 | "OSPF area ID as a decimal value\n") | |
524 | { | |
8d769265 DW |
525 | int idx_ipv4_prefixlen = 1; |
526 | int idx_ipv4_number = 3; | |
718e3744 | 527 | struct ospf *ospf= vty->index; |
528 | struct prefix_ipv4 p; | |
529 | struct in_addr area_id; | |
530 | int ret, format; | |
531 | ||
7c8ff89e DS |
532 | if (!ospf) |
533 | return CMD_SUCCESS; | |
534 | ||
535 | if (ospf->instance) | |
536 | { | |
537 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
538 | VTY_NEWLINE); | |
539 | return CMD_WARNING; | |
540 | } | |
541 | ||
953cde65 JT |
542 | if (ospf->if_ospf_cli_count > 0) |
543 | { | |
544 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
545 | VTY_NEWLINE); | |
546 | return CMD_WARNING; | |
547 | } | |
548 | ||
718e3744 | 549 | /* Get network prefix and Area ID. */ |
8d769265 DW |
550 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); |
551 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); | |
718e3744 | 552 | |
553 | ret = ospf_network_set (ospf, &p, area_id); | |
554 | if (ret == 0) | |
555 | { | |
556 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
557 | return CMD_WARNING; | |
558 | } | |
559 | ||
560 | return CMD_SUCCESS; | |
561 | } | |
562 | ||
a2c62831 | 563 | DEFUN (no_ospf_network_area, |
564 | no_ospf_network_area_cmd, | |
6147e2c6 | 565 | "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 566 | NO_STR |
567 | "Enable routing on an IP network\n" | |
568 | "OSPF network prefix\n" | |
569 | "Set the OSPF area ID\n" | |
570 | "OSPF area ID in IP address format\n" | |
571 | "OSPF area ID as a decimal value\n") | |
572 | { | |
8d769265 DW |
573 | int idx_ipv4_prefixlen = 2; |
574 | int idx_ipv4_number = 4; | |
718e3744 | 575 | struct ospf *ospf = (struct ospf *) vty->index; |
576 | struct prefix_ipv4 p; | |
577 | struct in_addr area_id; | |
578 | int ret, format; | |
579 | ||
7c8ff89e DS |
580 | if (!ospf) |
581 | return CMD_SUCCESS; | |
582 | ||
583 | if (ospf->instance) | |
584 | { | |
585 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
586 | VTY_NEWLINE); | |
587 | return CMD_WARNING; | |
588 | } | |
589 | ||
718e3744 | 590 | /* Get network prefix and Area ID. */ |
8d769265 DW |
591 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); |
592 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); | |
718e3744 | 593 | |
594 | ret = ospf_network_unset (ospf, &p, area_id); | |
595 | if (ret == 0) | |
596 | { | |
597 | vty_out (vty, "Can't find specified network area configuration.%s", | |
598 | VTY_NEWLINE); | |
599 | return CMD_WARNING; | |
600 | } | |
601 | ||
602 | return CMD_SUCCESS; | |
603 | } | |
604 | ||
a2c62831 | 605 | DEFUN (ospf_area_range, |
606 | ospf_area_range_cmd, | |
7a7be519 | 607 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]", |
718e3744 | 608 | "OSPF area parameters\n" |
609 | "OSPF area ID in IP address format\n" | |
610 | "OSPF area ID as a decimal value\n" | |
611 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 612 | "Area range prefix\n" |
613 | "Advertise this range (default)\n" | |
614 | "User specified metric for this range\n" | |
615 | "Advertised metric for this range\n") | |
718e3744 | 616 | { |
8d769265 DW |
617 | int idx_ipv4_number = 1; |
618 | int idx_ipv4_prefixlen = 3; | |
7a7be519 | 619 | int idx_cost = 6; |
718e3744 | 620 | struct ospf *ospf = vty->index; |
621 | struct prefix_ipv4 p; | |
622 | struct in_addr area_id; | |
623 | int format; | |
624 | u_int32_t cost; | |
625 | ||
7c8ff89e DS |
626 | if (!ospf) |
627 | return CMD_SUCCESS; | |
628 | ||
8d769265 DW |
629 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
630 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
718e3744 | 631 | |
632 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
7a7be519 | 633 | if (argc > 5) |
718e3744 | 634 | { |
7a7be519 | 635 | VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); |
718e3744 | 636 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
637 | } | |
638 | ||
639 | return CMD_SUCCESS; | |
640 | } | |
641 | ||
7a7be519 | 642 | DEFUN (ospf_area_range_cost, |
643 | ospf_area_range_cost_cmd, | |
644 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)", | |
645 | "OSPF area parameters\n" | |
646 | "OSPF area ID in IP address format\n" | |
647 | "OSPF area ID as a decimal value\n" | |
648 | "Summarize routes matching address/mask (border routers only)\n" | |
649 | "Area range prefix\n" | |
650 | "User specified metric for this range\n" | |
651 | "Advertised metric for this range\n") | |
652 | { | |
653 | int idx_ipv4_number = 1; | |
654 | int idx_ipv4_prefixlen = 3; | |
655 | int idx_cost = 5; | |
656 | struct ospf *ospf = vty->index; | |
657 | struct prefix_ipv4 p; | |
658 | struct in_addr area_id; | |
659 | int format; | |
660 | u_int32_t cost; | |
661 | ||
662 | if (!ospf) | |
663 | return CMD_SUCCESS; | |
664 | ||
665 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); | |
666 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
667 | ||
668 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
718e3744 | 669 | |
7a7be519 | 670 | VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); |
671 | ospf_area_range_cost_set (ospf, area_id, &p, cost); | |
718e3744 | 672 | |
7a7be519 | 673 | return CMD_SUCCESS; |
674 | } | |
718e3744 | 675 | |
a2c62831 | 676 | DEFUN (ospf_area_range_not_advertise, |
677 | ospf_area_range_not_advertise_cmd, | |
6147e2c6 | 678 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise", |
718e3744 | 679 | "OSPF area parameters\n" |
680 | "OSPF area ID in IP address format\n" | |
681 | "OSPF area ID as a decimal value\n" | |
682 | "Summarize routes matching address/mask (border routers only)\n" | |
683 | "Area range prefix\n" | |
684 | "DoNotAdvertise this range\n") | |
685 | { | |
8d769265 DW |
686 | int idx_ipv4_number = 1; |
687 | int idx_ipv4_prefixlen = 3; | |
718e3744 | 688 | struct ospf *ospf = vty->index; |
689 | struct prefix_ipv4 p; | |
690 | struct in_addr area_id; | |
691 | int format; | |
692 | ||
7c8ff89e DS |
693 | if (!ospf) |
694 | return CMD_SUCCESS; | |
695 | ||
8d769265 DW |
696 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
697 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
718e3744 | 698 | |
699 | ospf_area_range_set (ospf, area_id, &p, 0); | |
700 | ||
701 | return CMD_SUCCESS; | |
702 | } | |
703 | ||
a2c62831 | 704 | DEFUN (no_ospf_area_range, |
705 | no_ospf_area_range_cmd, | |
7a7be519 | 706 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)] | not-advertise>]", |
718e3744 | 707 | NO_STR |
708 | "OSPF area parameters\n" | |
709 | "OSPF area ID in IP address format\n" | |
710 | "OSPF area ID as a decimal value\n" | |
711 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 712 | "Area range prefix\n" |
713 | "Advertise this range (default)\n" | |
714 | "DoNotAdvertise this range\n") | |
718e3744 | 715 | { |
8d769265 DW |
716 | int idx_ipv4_number = 2; |
717 | int idx_ipv4_prefixlen = 4; | |
718e3744 | 718 | struct ospf *ospf = vty->index; |
719 | struct prefix_ipv4 p; | |
720 | struct in_addr area_id; | |
721 | int format; | |
722 | ||
7c8ff89e DS |
723 | if (!ospf) |
724 | return CMD_SUCCESS; | |
725 | ||
8d769265 DW |
726 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
727 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
718e3744 | 728 | |
729 | ospf_area_range_unset (ospf, area_id, &p); | |
730 | ||
731 | return CMD_SUCCESS; | |
732 | } | |
733 | ||
a2c62831 | 734 | DEFUN (ospf_area_range_substitute, |
735 | ospf_area_range_substitute_cmd, | |
6147e2c6 | 736 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 737 | "OSPF area parameters\n" |
738 | "OSPF area ID in IP address format\n" | |
739 | "OSPF area ID as a decimal value\n" | |
740 | "Summarize routes matching address/mask (border routers only)\n" | |
741 | "Area range prefix\n" | |
742 | "Announce area range as another prefix\n" | |
743 | "Network prefix to be announced instead of range\n") | |
744 | { | |
8d769265 DW |
745 | int idx_ipv4_number = 1; |
746 | int idx_ipv4_prefixlen = 3; | |
747 | int idx_ipv4_prefixlen_2 = 5; | |
718e3744 | 748 | struct ospf *ospf = vty->index; |
749 | struct prefix_ipv4 p, s; | |
750 | struct in_addr area_id; | |
751 | int format; | |
752 | ||
7c8ff89e DS |
753 | if (!ospf) |
754 | return CMD_SUCCESS; | |
755 | ||
8d769265 DW |
756 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
757 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
758 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); | |
718e3744 | 759 | |
760 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
761 | ||
762 | return CMD_SUCCESS; | |
763 | } | |
764 | ||
a2c62831 | 765 | DEFUN (no_ospf_area_range_substitute, |
766 | no_ospf_area_range_substitute_cmd, | |
6147e2c6 | 767 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 768 | NO_STR |
769 | "OSPF area parameters\n" | |
770 | "OSPF area ID in IP address format\n" | |
771 | "OSPF area ID as a decimal value\n" | |
772 | "Summarize routes matching address/mask (border routers only)\n" | |
773 | "Area range prefix\n" | |
774 | "Announce area range as another prefix\n" | |
775 | "Network prefix to be announced instead of range\n") | |
776 | { | |
8d769265 DW |
777 | int idx_ipv4_number = 2; |
778 | int idx_ipv4_prefixlen = 4; | |
779 | int idx_ipv4_prefixlen_2 = 6; | |
718e3744 | 780 | struct ospf *ospf = vty->index; |
781 | struct prefix_ipv4 p, s; | |
782 | struct in_addr area_id; | |
783 | int format; | |
784 | ||
7c8ff89e DS |
785 | if (!ospf) |
786 | return CMD_SUCCESS; | |
787 | ||
8d769265 DW |
788 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
789 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
790 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); | |
718e3744 | 791 | |
792 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
793 | ||
794 | return CMD_SUCCESS; | |
795 | } | |
796 | ||
6b0655a2 | 797 | |
718e3744 | 798 | /* Command Handler Logic in VLink stuff is delicate!! |
799 | ||
800 | ALTER AT YOUR OWN RISK!!!! | |
801 | ||
802 | Various dummy values are used to represent 'NoChange' state for | |
803 | VLink configuration NOT being changed by a VLink command, and | |
804 | special syntax is used within the command strings so that the | |
805 | typed in command verbs can be seen in the configuration command | |
806 | bacckend handler. This is to drastically reduce the verbeage | |
807 | required to coe up with a reasonably compatible Cisco VLink command | |
808 | ||
809 | - Matthew Grant <grantma@anathoth.gen.nz> | |
810 | Wed, 21 Feb 2001 15:13:52 +1300 | |
811 | */ | |
812 | ||
718e3744 | 813 | /* Configuration data for virtual links |
814 | */ | |
815 | struct ospf_vl_config_data { | |
816 | struct vty *vty; /* vty stuff */ | |
817 | struct in_addr area_id; /* area ID from command line */ | |
818 | int format; /* command line area ID format */ | |
819 | struct in_addr vl_peer; /* command line vl_peer */ | |
820 | int auth_type; /* Authehntication type, if given */ | |
821 | char *auth_key; /* simple password if present */ | |
822 | int crypto_key_id; /* Cryptographic key ID */ | |
823 | char *md5_key; /* MD5 authentication key */ | |
824 | int hello_interval; /* Obvious what these are... */ | |
825 | int retransmit_interval; | |
826 | int transmit_delay; | |
827 | int dead_interval; | |
828 | }; | |
829 | ||
4dadc291 | 830 | static void |
718e3744 | 831 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
832 | struct vty *vty) | |
833 | { | |
834 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
835 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
836 | vl_config->vty = vty; | |
837 | } | |
838 | ||
4dadc291 | 839 | static struct ospf_vl_data * |
68980084 | 840 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 841 | { |
842 | struct ospf_area *area; | |
843 | struct ospf_vl_data *vl_data; | |
844 | struct vty *vty; | |
845 | struct in_addr area_id; | |
846 | ||
847 | vty = vl_config->vty; | |
848 | area_id = vl_config->area_id; | |
849 | ||
850 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
851 | { | |
852 | vty_out (vty, | |
853 | "Configuring VLs over the backbone is not allowed%s", | |
854 | VTY_NEWLINE); | |
855 | return NULL; | |
856 | } | |
68980084 | 857 | area = ospf_area_get (ospf, area_id, vl_config->format); |
718e3744 | 858 | |
859 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
860 | { | |
861 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
862 | vty_out (vty, "Area %s is %s%s", | |
863 | inet_ntoa (area_id), | |
718e3744 | 864 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 865 | VTY_NEWLINE); |
866 | else | |
867 | vty_out (vty, "Area %ld is %s%s", | |
868 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 869 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 870 | VTY_NEWLINE); |
871 | return NULL; | |
872 | } | |
873 | ||
9c27ef9b | 874 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 875 | { |
876 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
877 | if (vl_data->vl_oi == NULL) | |
878 | { | |
68980084 | 879 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
880 | ospf_vl_add (ospf, vl_data); | |
d3a9c768 | 881 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 882 | } |
883 | } | |
884 | return vl_data; | |
885 | } | |
886 | ||
887 | ||
4dadc291 | 888 | static int |
718e3744 | 889 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
890 | struct ospf_vl_config_data *vl_config) | |
891 | { | |
892 | struct crypt_key *ck; | |
893 | struct vty *vty; | |
894 | struct interface *ifp = vl_data->vl_oi->ifp; | |
895 | ||
896 | vty = vl_config->vty; | |
897 | ||
898 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
899 | { | |
900 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
901 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
902 | } | |
903 | ||
904 | if (vl_config->auth_key) | |
905 | { | |
906 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 907 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 908 | OSPF_AUTH_SIMPLE_SIZE); |
909 | } | |
910 | else if (vl_config->md5_key) | |
911 | { | |
912 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
913 | != NULL) | |
914 | { | |
915 | vty_out (vty, "OSPF: Key %d already exists%s", | |
916 | vl_config->crypto_key_id, VTY_NEWLINE); | |
917 | return CMD_WARNING; | |
918 | } | |
919 | ck = ospf_crypt_key_new (); | |
920 | ck->key_id = vl_config->crypto_key_id; | |
921 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 922 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 923 | |
924 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
925 | } | |
926 | else if (vl_config->crypto_key_id != 0) | |
927 | { | |
928 | /* Delete a key */ | |
929 | ||
930 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
931 | vl_config->crypto_key_id) == NULL) | |
932 | { | |
933 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
934 | vl_config->crypto_key_id, VTY_NEWLINE); | |
935 | return CMD_WARNING; | |
936 | } | |
937 | ||
938 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
939 | ||
940 | } | |
941 | ||
942 | return CMD_SUCCESS; | |
943 | } | |
944 | ||
4dadc291 | 945 | static int |
718e3744 | 946 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
947 | struct ospf_vl_config_data *vl_config) | |
948 | { | |
c8cdf5c7 | 949 | struct interface *ifp = vl_data->vl_oi->ifp; |
718e3744 | 950 | /* Virtual Link data initialised to defaults, so only set |
951 | if a value given */ | |
952 | if (vl_config->hello_interval) | |
953 | { | |
954 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
955 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
956 | } | |
957 | ||
958 | if (vl_config->dead_interval) | |
959 | { | |
960 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
961 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
962 | } | |
963 | ||
964 | if (vl_config->retransmit_interval) | |
965 | { | |
966 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
967 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
968 | } | |
969 | ||
970 | if (vl_config->transmit_delay) | |
971 | { | |
972 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
973 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
974 | } | |
975 | ||
976 | return CMD_SUCCESS; | |
977 | } | |
978 | ||
979 | ||
718e3744 | 980 | /* The business end of all of the above */ |
4dadc291 | 981 | static int |
68980084 | 982 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 983 | { |
984 | struct ospf_vl_data *vl_data; | |
985 | int ret; | |
986 | ||
68980084 | 987 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 988 | if (!vl_data) |
989 | return CMD_WARNING; | |
990 | ||
991 | /* Process this one first as it can have a fatal result, which can | |
992 | only logically occur if the virtual link exists already | |
993 | Thus a command error does not result in a change to the | |
994 | running configuration such as unexpectedly altered timer | |
995 | values etc.*/ | |
996 | ret = ospf_vl_set_security (vl_data, vl_config); | |
997 | if (ret != CMD_SUCCESS) | |
998 | return ret; | |
999 | ||
1000 | /* Set any time based parameters, these area already range checked */ | |
1001 | ||
1002 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
1003 | if (ret != CMD_SUCCESS) | |
1004 | return ret; | |
1005 | ||
1006 | return CMD_SUCCESS; | |
1007 | ||
1008 | } | |
1009 | ||
1010 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1011 | */ | |
1012 | #define VLINK_HELPSTR_IPADDR \ | |
1013 | "OSPF area parameters\n" \ | |
1014 | "OSPF area ID in IP address format\n" \ | |
1015 | "OSPF area ID as a decimal value\n" \ | |
1016 | "Configure a virtual link\n" \ | |
1017 | "Router ID of the remote ABR\n" | |
1018 | ||
1019 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1020 | "Enable authentication on this virtual link\n" \ | |
1021 | "dummy string \n" | |
1022 | ||
1023 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1024 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1025 | "Use null authentication\n" \ | |
1026 | "Use message-digest authentication\n" | |
1027 | ||
1028 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1029 | "Time between HELLO packets\n" \ | |
1030 | "Time between retransmitting lost link state advertisements\n" \ | |
1031 | "Link state transmit delay\n" \ | |
1032 | "Interval after which a neighbor is declared dead\n" | |
1033 | ||
1034 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1035 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1036 | "Seconds\n" | |
1037 | ||
1038 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1039 | "Authentication password (key)\n" \ | |
1040 | "The OSPF password (key)" | |
1041 | ||
1042 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1043 | "Message digest authentication password (key)\n" \ | |
1044 | "dummy string \n" \ | |
1045 | "Key ID\n" \ | |
1046 | "Use MD5 algorithm\n" \ | |
1047 | "The OSPF password (key)" | |
1048 | ||
a2c62831 | 1049 | DEFUN (ospf_area_vlink, |
1050 | ospf_area_vlink_cmd, | |
22b27e95 | 1051 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", |
7a7be519 | 1052 | VLINK_HELPSTR_IPADDR |
1053 | "Enable authentication on this virtual link\n" \ | |
1054 | "Use null authentication\n" \ | |
1055 | "Use message-digest authentication\n" | |
1056 | "Message digest authentication password (key)\n" \ | |
1057 | "Key ID\n" \ | |
1058 | "Use MD5 algorithm\n" \ | |
1059 | "The OSPF password (key)") | |
718e3744 | 1060 | { |
8d769265 DW |
1061 | int idx_ipv4_number = 1; |
1062 | int idx_ipv4 = 3; | |
68980084 | 1063 | struct ospf *ospf = vty->index; |
718e3744 | 1064 | struct ospf_vl_config_data vl_config; |
1065 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1066 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1067 | int i; | |
1068 | int ret; | |
1069 | ||
7c8ff89e DS |
1070 | if (!ospf) |
1071 | return CMD_SUCCESS; | |
1072 | ||
718e3744 | 1073 | ospf_vl_config_data_init(&vl_config, vty); |
1074 | ||
1075 | /* Read off first 2 parameters and check them */ | |
8d769265 | 1076 | ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &vl_config.format); |
718e3744 | 1077 | if (ret < 0) |
1078 | { | |
1079 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1080 | return CMD_WARNING; | |
1081 | } | |
1082 | ||
8d769265 | 1083 | ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); |
718e3744 | 1084 | if (! ret) |
1085 | { | |
1086 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1087 | VTY_NEWLINE); | |
1088 | return CMD_WARNING; | |
1089 | } | |
1090 | ||
7a7be519 | 1091 | if (argc <=4) |
718e3744 | 1092 | { |
1093 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1094 | ||
68980084 | 1095 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1096 | } |
1097 | ||
1098 | /* Deal with other parameters */ | |
7a7be519 | 1099 | for (i=5; i < argc; i++) |
718e3744 | 1100 | { |
1101 | ||
7a7be519 | 1102 | /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */ |
718e3744 | 1103 | |
7a7be519 | 1104 | switch (argv[i]->arg[0]) |
718e3744 | 1105 | { |
1106 | ||
1107 | case 'a': | |
7a7be519 | 1108 | if (i >5 || strncmp (argv[i]->arg, "authentication-", 15) == 0) |
718e3744 | 1109 | { |
1110 | /* authentication-key - this option can occur anywhere on | |
1111 | command line. At start of command line | |
1112 | must check for authentication option. */ | |
1113 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
7a7be519 | 1114 | strncpy (auth_key, argv[i+1]->text, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 1115 | vl_config.auth_key = auth_key; |
1116 | i++; | |
1117 | } | |
7a7be519 | 1118 | else if (strncmp (argv[i]->arg, "authentication", 14) == 0) |
718e3744 | 1119 | { |
1120 | /* authentication - this option can only occur at start | |
1121 | of command line */ | |
1122 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1123 | if ((i+1) < argc) | |
1124 | { | |
7a7be519 | 1125 | if (strncmp (argv[i+1]->arg, "n", 1) == 0) |
718e3744 | 1126 | { |
1127 | /* "authentication null" */ | |
1128 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1129 | i++; | |
1130 | } | |
7a7be519 | 1131 | else if (strncmp (argv[i+1]->arg, "m", 1) == 0 |
1132 | && strcmp (argv[i+1]->arg, "message-digest-") != 0) | |
718e3744 | 1133 | { |
1134 | /* "authentication message-digest" */ | |
1135 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1136 | i++; | |
1137 | } | |
1138 | } | |
1139 | } | |
1140 | break; | |
1141 | ||
1142 | case 'm': | |
1143 | /* message-digest-key */ | |
1144 | i++; | |
7a7be519 | 1145 | vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); |
718e3744 | 1146 | if (vl_config.crypto_key_id < 0) |
1147 | return CMD_WARNING; | |
1148 | i++; | |
1149 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
7a7be519 | 1150 | strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); |
718e3744 | 1151 | vl_config.md5_key = md5_key; |
1152 | break; | |
1153 | ||
7a7be519 | 1154 | } |
1155 | } | |
1156 | ||
1157 | ||
1158 | /* Action configuration */ | |
1159 | ||
1160 | return ospf_vl_set (ospf, &vl_config); | |
1161 | ||
1162 | } | |
1163 | ||
1164 | DEFUN (ospf_area_vlink_intervals, | |
1165 | ospf_area_vlink_intervals_cmd, | |
bc7d452f QY |
1166 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D" |
1167 | "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1168 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1169 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1170 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1171 | "]]]", | |
7a7be519 | 1172 | VLINK_HELPSTR_IPADDR |
1173 | VLINK_HELPSTR_TIME_PARAM | |
1174 | VLINK_HELPSTR_TIME_PARAM | |
1175 | VLINK_HELPSTR_TIME_PARAM | |
1176 | VLINK_HELPSTR_TIME_PARAM) | |
1177 | { | |
7a7be519 | 1178 | struct ospf *ospf = vty->index; |
1179 | struct ospf_vl_config_data vl_config; | |
bc7d452f | 1180 | int ret = 0; |
7a7be519 | 1181 | |
1182 | if (!ospf) | |
1183 | return CMD_SUCCESS; | |
1184 | ||
1185 | ospf_vl_config_data_init(&vl_config, vty); | |
1186 | ||
bc7d452f QY |
1187 | char *area_id = argv[1]->arg; |
1188 | char *router_id = argv[3]->arg; | |
1189 | ||
1190 | ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format); | |
7a7be519 | 1191 | if (ret < 0) |
1192 | { | |
1193 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1194 | return CMD_WARNING; | |
1195 | } | |
1196 | ||
bc7d452f | 1197 | ret = inet_aton (router_id, &vl_config.vl_peer); |
7a7be519 | 1198 | if (! ret) |
1199 | { | |
bc7d452f | 1200 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); |
7a7be519 | 1201 | return CMD_WARNING; |
1202 | } | |
bc7d452f | 1203 | for (unsigned int i = 0; i < 4; i++) |
7a7be519 | 1204 | { |
bc7d452f QY |
1205 | int idx = 0; |
1206 | if (argv_find (argv, argc, "hello-interval", &idx)) | |
1207 | vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10); | |
1208 | else if (argv_find (argv, argc, "retransmit-interval", &idx)) | |
1209 | vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10); | |
1210 | else if (argv_find (argv, argc, "transmit-delay", &idx)) | |
1211 | vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10); | |
1212 | else if (argv_find (argv, argc, "dead-interval", &idx)) | |
1213 | vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10); | |
7a7be519 | 1214 | } |
1215 | ||
718e3744 | 1216 | /* Action configuration */ |
68980084 | 1217 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1218 | } |
1219 | ||
a2c62831 | 1220 | DEFUN (no_ospf_area_vlink, |
1221 | no_ospf_area_vlink_cmd, | |
bc7d452f | 1222 | "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", |
718e3744 | 1223 | NO_STR |
7a7be519 | 1224 | VLINK_HELPSTR_IPADDR |
1225 | "Enable authentication on this virtual link\n" \ | |
1226 | "Use null authentication\n" \ | |
1227 | "Use message-digest authentication\n" | |
1228 | "Message digest authentication password (key)\n" \ | |
1229 | "Key ID\n" \ | |
1230 | "Use MD5 algorithm\n" \ | |
1231 | "The OSPF password (key)") | |
718e3744 | 1232 | { |
8d769265 DW |
1233 | int idx_ipv4_number = 2; |
1234 | int idx_ipv4 = 4; | |
68980084 | 1235 | struct ospf *ospf = vty->index; |
718e3744 | 1236 | struct ospf_area *area; |
1237 | struct ospf_vl_config_data vl_config; | |
1238 | struct ospf_vl_data *vl_data = NULL; | |
1239 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1240 | int i; | |
1241 | int ret, format; | |
1242 | ||
7c8ff89e DS |
1243 | if (!ospf) |
1244 | return CMD_SUCCESS; | |
1245 | ||
718e3744 | 1246 | ospf_vl_config_data_init(&vl_config, vty); |
1247 | ||
8d769265 | 1248 | ret = ospf_str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); |
718e3744 | 1249 | if (ret < 0) |
1250 | { | |
1251 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1252 | return CMD_WARNING; | |
1253 | } | |
1254 | ||
68980084 | 1255 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1256 | if (!area) |
1257 | { | |
1258 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1259 | return CMD_WARNING; | |
1260 | } | |
1261 | ||
8d769265 | 1262 | ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); |
718e3744 | 1263 | if (! ret) |
1264 | { | |
1265 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1266 | VTY_NEWLINE); | |
1267 | return CMD_WARNING; | |
1268 | } | |
1269 | ||
7a7be519 | 1270 | if (argc <=5) |
718e3744 | 1271 | { |
1272 | /* Basic VLink no command */ | |
1273 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1274 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1275 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1276 | |
68980084 | 1277 | ospf_area_check_free (ospf, vl_config.area_id); |
7a7be519 | 1278 | |
718e3744 | 1279 | return CMD_SUCCESS; |
1280 | } | |
1281 | ||
1282 | /* If we are down here, we are reseting parameters */ | |
1283 | ||
1284 | /* Deal with other parameters */ | |
7a7be519 | 1285 | for (i=6; argc; i++) |
718e3744 | 1286 | { |
718e3744 | 1287 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1288 | ||
7a7be519 | 1289 | switch (argv[i]->arg[0]) |
718e3744 | 1290 | { |
1291 | ||
1292 | case 'a': | |
7a7be519 | 1293 | if (i > 2 || strncmp (argv[i]->text, "authentication-", 15) == 0) |
718e3744 | 1294 | { |
1295 | /* authentication-key - this option can occur anywhere on | |
1296 | command line. At start of command line | |
1297 | must check for authentication option. */ | |
1298 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1299 | vl_config.auth_key = auth_key; | |
1300 | } | |
7a7be519 | 1301 | else if (strncmp (argv[i]->text, "authentication", 14) == 0) |
718e3744 | 1302 | { |
1303 | /* authentication - this option can only occur at start | |
1304 | of command line */ | |
1305 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1306 | } | |
1307 | break; | |
1308 | ||
1309 | case 'm': | |
1310 | /* message-digest-key */ | |
1311 | /* Delete one key */ | |
1312 | i++; | |
7a7be519 | 1313 | vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); |
718e3744 | 1314 | if (vl_config.crypto_key_id < 0) |
1315 | return CMD_WARNING; | |
1316 | vl_config.md5_key = NULL; | |
1317 | break; | |
1318 | ||
7a7be519 | 1319 | } |
1320 | } | |
1321 | ||
1322 | ||
1323 | /* Action configuration */ | |
1324 | ||
1325 | return ospf_vl_set (ospf, &vl_config); | |
1326 | } | |
1327 | ||
1328 | DEFUN (no_ospf_area_vlink_intervals, | |
1329 | no_ospf_area_vlink_intervals_cmd, | |
bc7d452f QY |
1330 | "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D" |
1331 | "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1332 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1333 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1334 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1335 | "]]]", | |
7a7be519 | 1336 | VLINK_HELPSTR_IPADDR |
1337 | VLINK_HELPSTR_TIME_PARAM | |
1338 | VLINK_HELPSTR_TIME_PARAM | |
1339 | VLINK_HELPSTR_TIME_PARAM | |
1340 | VLINK_HELPSTR_TIME_PARAM) | |
1341 | { | |
7a7be519 | 1342 | struct ospf *ospf = vty->index; |
7a7be519 | 1343 | struct ospf_vl_config_data vl_config; |
bc7d452f | 1344 | int ret = 0; |
7a7be519 | 1345 | |
1346 | if (!ospf) | |
1347 | return CMD_SUCCESS; | |
1348 | ||
1349 | ospf_vl_config_data_init(&vl_config, vty); | |
1350 | ||
bc7d452f QY |
1351 | char *area_id = argv[2]->arg; |
1352 | char *router_id = argv[4]->arg; | |
1353 | ||
1354 | ret = ospf_str2area_id (area_id, &vl_config.area_id, &vl_config.format); | |
7a7be519 | 1355 | if (ret < 0) |
1356 | { | |
1357 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1358 | return CMD_WARNING; | |
1359 | } | |
1360 | ||
bc7d452f | 1361 | ret = inet_aton (router_id, &vl_config.vl_peer); |
7a7be519 | 1362 | if (! ret) |
1363 | { | |
bc7d452f | 1364 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); |
7a7be519 | 1365 | return CMD_WARNING; |
1366 | } | |
1367 | ||
bc7d452f | 1368 | for (unsigned int i = 0; i < 4; i++) |
7a7be519 | 1369 | { |
bc7d452f QY |
1370 | int idx = 0; |
1371 | if (argv_find (argv, argc, "hello-interval", &idx)) | |
1372 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1373 | else if (argv_find (argv, argc, "retransmit-interval", &idx)) | |
1374 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1375 | else if (argv_find (argv, argc, "transmit-delay", &idx)) | |
1376 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1377 | else if (argv_find (argv, argc, "dead-interval", &idx)) | |
1378 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
718e3744 | 1379 | } |
1380 | ||
718e3744 | 1381 | /* Action configuration */ |
68980084 | 1382 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1383 | } |
1384 | ||
a2c62831 | 1385 | DEFUN (ospf_area_shortcut, |
1386 | ospf_area_shortcut_cmd, | |
6147e2c6 | 1387 | "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>", |
718e3744 | 1388 | "OSPF area parameters\n" |
1389 | "OSPF area ID in IP address format\n" | |
1390 | "OSPF area ID as a decimal value\n" | |
1391 | "Configure the area's shortcutting mode\n" | |
1392 | "Set default shortcutting behavior\n" | |
1393 | "Enable shortcutting through the area\n" | |
1394 | "Disable shortcutting through the area\n") | |
1395 | { | |
8d769265 DW |
1396 | int idx_ipv4_number = 1; |
1397 | int idx_enable_disable = 3; | |
68980084 | 1398 | struct ospf *ospf = vty->index; |
718e3744 | 1399 | struct ospf_area *area; |
1400 | struct in_addr area_id; | |
1401 | int mode; | |
1402 | int format; | |
1403 | ||
7c8ff89e DS |
1404 | if (!ospf) |
1405 | return CMD_SUCCESS; | |
1406 | ||
8d769265 | 1407 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1408 | |
68980084 | 1409 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1410 | |
8d769265 | 1411 | if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0) |
718e3744 | 1412 | mode = OSPF_SHORTCUT_DEFAULT; |
8d769265 | 1413 | else if (strncmp (argv[idx_enable_disable]->arg, "di", 2) == 0) |
718e3744 | 1414 | mode = OSPF_SHORTCUT_DISABLE; |
8d769265 | 1415 | else if (strncmp (argv[idx_enable_disable]->arg, "e", 1) == 0) |
718e3744 | 1416 | mode = OSPF_SHORTCUT_ENABLE; |
1417 | else | |
1418 | return CMD_WARNING; | |
1419 | ||
68980084 | 1420 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1421 | |
68980084 | 1422 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1423 | vty_out (vty, "Shortcut area setting will take effect " |
1424 | "only when the router is configured as Shortcut ABR%s", | |
1425 | VTY_NEWLINE); | |
1426 | ||
1427 | return CMD_SUCCESS; | |
1428 | } | |
1429 | ||
a2c62831 | 1430 | DEFUN (no_ospf_area_shortcut, |
1431 | no_ospf_area_shortcut_cmd, | |
6147e2c6 | 1432 | "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>", |
718e3744 | 1433 | NO_STR |
1434 | "OSPF area parameters\n" | |
1435 | "OSPF area ID in IP address format\n" | |
1436 | "OSPF area ID as a decimal value\n" | |
1437 | "Deconfigure the area's shortcutting mode\n" | |
1438 | "Deconfigure enabled shortcutting through the area\n" | |
1439 | "Deconfigure disabled shortcutting through the area\n") | |
1440 | { | |
8d769265 | 1441 | int idx_ipv4_number = 2; |
68980084 | 1442 | struct ospf *ospf = vty->index; |
718e3744 | 1443 | struct ospf_area *area; |
1444 | struct in_addr area_id; | |
1445 | int format; | |
1446 | ||
7c8ff89e DS |
1447 | if (!ospf) |
1448 | return CMD_SUCCESS; | |
1449 | ||
8d769265 | 1450 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1451 | |
68980084 | 1452 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1453 | if (!area) |
1454 | return CMD_SUCCESS; | |
1455 | ||
68980084 | 1456 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1457 | |
1458 | return CMD_SUCCESS; | |
1459 | } | |
1460 | ||
6b0655a2 | 1461 | |
a2c62831 | 1462 | DEFUN (ospf_area_stub, |
1463 | ospf_area_stub_cmd, | |
6147e2c6 | 1464 | "area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1465 | "OSPF area parameters\n" |
1466 | "OSPF area ID in IP address format\n" | |
1467 | "OSPF area ID as a decimal value\n" | |
1468 | "Configure OSPF area as stub\n") | |
1469 | { | |
8d769265 | 1470 | int idx_ipv4_number = 1; |
718e3744 | 1471 | struct ospf *ospf = vty->index; |
1472 | struct in_addr area_id; | |
1473 | int ret, format; | |
1474 | ||
7c8ff89e DS |
1475 | if (!ospf) |
1476 | return CMD_SUCCESS; | |
1477 | ||
8d769265 | 1478 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1479 | |
1480 | ret = ospf_area_stub_set (ospf, area_id); | |
1481 | if (ret == 0) | |
1482 | { | |
1483 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1484 | VTY_NEWLINE); | |
1485 | return CMD_WARNING; | |
1486 | } | |
1487 | ||
1488 | ospf_area_no_summary_unset (ospf, area_id); | |
1489 | ||
1490 | return CMD_SUCCESS; | |
1491 | } | |
1492 | ||
a2c62831 | 1493 | DEFUN (ospf_area_stub_no_summary, |
1494 | ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1495 | "area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1496 | "OSPF stub parameters\n" |
1497 | "OSPF area ID in IP address format\n" | |
1498 | "OSPF area ID as a decimal value\n" | |
1499 | "Configure OSPF area as stub\n" | |
1500 | "Do not inject inter-area routes into stub\n") | |
1501 | { | |
8d769265 | 1502 | int idx_ipv4_number = 1; |
718e3744 | 1503 | struct ospf *ospf = vty->index; |
1504 | struct in_addr area_id; | |
1505 | int ret, format; | |
1506 | ||
7c8ff89e DS |
1507 | if (!ospf) |
1508 | return CMD_SUCCESS; | |
1509 | ||
8d769265 | 1510 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1511 | |
1512 | ret = ospf_area_stub_set (ospf, area_id); | |
1513 | if (ret == 0) | |
1514 | { | |
b0a053be | 1515 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1516 | VTY_NEWLINE); |
1517 | return CMD_WARNING; | |
1518 | } | |
1519 | ||
1520 | ospf_area_no_summary_set (ospf, area_id); | |
1521 | ||
1522 | return CMD_SUCCESS; | |
1523 | } | |
1524 | ||
a2c62831 | 1525 | DEFUN (no_ospf_area_stub, |
1526 | no_ospf_area_stub_cmd, | |
6147e2c6 | 1527 | "no area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1528 | NO_STR |
1529 | "OSPF area parameters\n" | |
1530 | "OSPF area ID in IP address format\n" | |
1531 | "OSPF area ID as a decimal value\n" | |
1532 | "Configure OSPF area as stub\n") | |
1533 | { | |
8d769265 | 1534 | int idx_ipv4_number = 2; |
718e3744 | 1535 | struct ospf *ospf = vty->index; |
1536 | struct in_addr area_id; | |
1537 | int format; | |
1538 | ||
7c8ff89e DS |
1539 | if (!ospf) |
1540 | return CMD_SUCCESS; | |
1541 | ||
8d769265 | 1542 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1543 | |
1544 | ospf_area_stub_unset (ospf, area_id); | |
1545 | ospf_area_no_summary_unset (ospf, area_id); | |
1546 | ||
1547 | return CMD_SUCCESS; | |
1548 | } | |
1549 | ||
a2c62831 | 1550 | DEFUN (no_ospf_area_stub_no_summary, |
1551 | no_ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1552 | "no area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1553 | NO_STR |
1554 | "OSPF area parameters\n" | |
1555 | "OSPF area ID in IP address format\n" | |
1556 | "OSPF area ID as a decimal value\n" | |
1557 | "Configure OSPF area as stub\n" | |
1558 | "Do not inject inter-area routes into area\n") | |
1559 | { | |
8d769265 | 1560 | int idx_ipv4_number = 2; |
718e3744 | 1561 | struct ospf *ospf = vty->index; |
1562 | struct in_addr area_id; | |
1563 | int format; | |
1564 | ||
7c8ff89e DS |
1565 | if (!ospf) |
1566 | return CMD_SUCCESS; | |
1567 | ||
8d769265 | 1568 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1569 | ospf_area_no_summary_unset (ospf, area_id); |
1570 | ||
1571 | return CMD_SUCCESS; | |
1572 | } | |
1573 | ||
4dadc291 | 1574 | static int |
7a7be519 | 1575 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, |
6c835671 | 1576 | int nosum) |
718e3744 | 1577 | { |
1578 | struct ospf *ospf = vty->index; | |
1579 | struct in_addr area_id; | |
1580 | int ret, format; | |
1581 | ||
7c8ff89e DS |
1582 | if (!ospf) |
1583 | return CMD_SUCCESS; | |
1584 | ||
7a7be519 | 1585 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg); |
718e3744 | 1586 | |
1587 | ret = ospf_area_nssa_set (ospf, area_id); | |
1588 | if (ret == 0) | |
1589 | { | |
1590 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1591 | VTY_NEWLINE); | |
1592 | return CMD_WARNING; | |
1593 | } | |
1594 | ||
1595 | if (argc > 1) | |
1596 | { | |
7a7be519 | 1597 | if (strncmp (argv[3]->text, "translate-c", 11) == 0) |
b0a053be | 1598 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1599 | OSPF_NSSA_ROLE_CANDIDATE); |
7a7be519 | 1600 | else if (strncmp (argv[3]->text, "translate-n", 11) == 0) |
b0a053be | 1601 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1602 | OSPF_NSSA_ROLE_NEVER); |
7a7be519 | 1603 | else if (strncmp (argv[3]->text, "translate-a", 11) == 0) |
b0a053be | 1604 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1605 | OSPF_NSSA_ROLE_ALWAYS); |
1606 | } | |
b0a053be | 1607 | else |
1608 | { | |
1609 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1610 | OSPF_NSSA_ROLE_CANDIDATE); | |
1611 | } | |
718e3744 | 1612 | |
b0a053be | 1613 | if (nosum) |
718e3744 | 1614 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1615 | else |
1616 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1617 | |
b0a053be | 1618 | ospf_schedule_abr_task (ospf); |
1619 | ||
718e3744 | 1620 | return CMD_SUCCESS; |
1621 | } | |
1622 | ||
b0a053be | 1623 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1624 | ospf_area_nssa_translate_no_summary_cmd, |
6147e2c6 | 1625 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary", |
718e3744 | 1626 | "OSPF area parameters\n" |
1627 | "OSPF area ID in IP address format\n" | |
1628 | "OSPF area ID as a decimal value\n" | |
1629 | "Configure OSPF area as nssa\n" | |
1630 | "Configure NSSA-ABR for translate election (default)\n" | |
1631 | "Configure NSSA-ABR to never translate\n" | |
1632 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1633 | "Do not inject inter-area routes into nssa\n") |
1634 | { | |
1635 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1636 | } | |
718e3744 | 1637 | |
b0a053be | 1638 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1639 | ospf_area_nssa_translate_cmd, |
6147e2c6 | 1640 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>", |
718e3744 | 1641 | "OSPF area parameters\n" |
1642 | "OSPF area ID in IP address format\n" | |
1643 | "OSPF area ID as a decimal value\n" | |
1644 | "Configure OSPF area as nssa\n" | |
1645 | "Configure NSSA-ABR for translate election (default)\n" | |
1646 | "Configure NSSA-ABR to never translate\n" | |
1647 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1648 | { |
1649 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1650 | } | |
1651 | ||
1652 | DEFUN (ospf_area_nssa, | |
1653 | ospf_area_nssa_cmd, | |
6147e2c6 | 1654 | "area <A.B.C.D|(0-4294967295)> nssa", |
b0a053be | 1655 | "OSPF area parameters\n" |
1656 | "OSPF area ID in IP address format\n" | |
1657 | "OSPF area ID as a decimal value\n" | |
1658 | "Configure OSPF area as nssa\n") | |
1659 | { | |
1660 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1661 | } | |
718e3744 | 1662 | |
a2c62831 | 1663 | DEFUN (ospf_area_nssa_no_summary, |
1664 | ospf_area_nssa_no_summary_cmd, | |
6147e2c6 | 1665 | "area <A.B.C.D|(0-4294967295)> nssa no-summary", |
718e3744 | 1666 | "OSPF area parameters\n" |
1667 | "OSPF area ID in IP address format\n" | |
1668 | "OSPF area ID as a decimal value\n" | |
1669 | "Configure OSPF area as nssa\n" | |
1670 | "Do not inject inter-area routes into nssa\n") | |
1671 | { | |
b0a053be | 1672 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1673 | } |
1674 | ||
a2c62831 | 1675 | DEFUN (no_ospf_area_nssa, |
1676 | no_ospf_area_nssa_cmd, | |
7a7be519 | 1677 | "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]", |
718e3744 | 1678 | NO_STR |
1679 | "OSPF area parameters\n" | |
1680 | "OSPF area ID in IP address format\n" | |
1681 | "OSPF area ID as a decimal value\n" | |
7a7be519 | 1682 | "Configure OSPF area as nssa\n" |
1683 | "Configure NSSA-ABR for translate election (default)\n" | |
1684 | "Configure NSSA-ABR to never translate\n" | |
1685 | "Configure NSSA-ABR to always translate\n" | |
1686 | "Do not inject inter-area routes into nssa\n") | |
22b27e95 | 1687 | { |
8d769265 | 1688 | int idx_ipv4_number = 2; |
718e3744 | 1689 | struct ospf *ospf = vty->index; |
1690 | struct in_addr area_id; | |
1691 | int format; | |
1692 | ||
7c8ff89e DS |
1693 | if (!ospf) |
1694 | return CMD_SUCCESS; | |
1695 | ||
8d769265 | 1696 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1697 | |
1698 | ospf_area_nssa_unset (ospf, area_id); | |
1699 | ospf_area_no_summary_unset (ospf, area_id); | |
1700 | ||
b0a053be | 1701 | ospf_schedule_abr_task (ospf); |
1702 | ||
718e3744 | 1703 | return CMD_SUCCESS; |
1704 | } | |
1705 | ||
718e3744 | 1706 | |
a2c62831 | 1707 | DEFUN (ospf_area_default_cost, |
1708 | ospf_area_default_cost_cmd, | |
6147e2c6 | 1709 | "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1710 | "OSPF area parameters\n" |
1711 | "OSPF area ID in IP address format\n" | |
1712 | "OSPF area ID as a decimal value\n" | |
1713 | "Set the summary-default cost of a NSSA or stub area\n" | |
1714 | "Stub's advertised default summary cost\n") | |
1715 | { | |
8d769265 DW |
1716 | int idx_ipv4_number = 1; |
1717 | int idx_number = 3; | |
68980084 | 1718 | struct ospf *ospf = vty->index; |
718e3744 | 1719 | struct ospf_area *area; |
1720 | struct in_addr area_id; | |
1721 | u_int32_t cost; | |
1722 | int format; | |
ba682537 | 1723 | struct prefix_ipv4 p; |
718e3744 | 1724 | |
7c8ff89e DS |
1725 | if (!ospf) |
1726 | return CMD_SUCCESS; | |
1727 | ||
8d769265 DW |
1728 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); |
1729 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215); | |
718e3744 | 1730 | |
68980084 | 1731 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1732 | |
1733 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1734 | { | |
1735 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1736 | return CMD_WARNING; | |
1737 | } | |
1738 | ||
1739 | area->default_cost = cost; | |
1740 | ||
ba682537 | 1741 | p.family = AF_INET; |
1742 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1743 | p.prefixlen = 0; | |
1744 | if (IS_DEBUG_OSPF_EVENT) | |
1745 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1746 | "announcing 0.0.0.0/0 to area %s", | |
1747 | inet_ntoa (area->area_id)); | |
1748 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1749 | ||
718e3744 | 1750 | return CMD_SUCCESS; |
1751 | } | |
1752 | ||
a2c62831 | 1753 | DEFUN (no_ospf_area_default_cost, |
1754 | no_ospf_area_default_cost_cmd, | |
6147e2c6 | 1755 | "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1756 | NO_STR |
1757 | "OSPF area parameters\n" | |
1758 | "OSPF area ID in IP address format\n" | |
1759 | "OSPF area ID as a decimal value\n" | |
1760 | "Set the summary-default cost of a NSSA or stub area\n" | |
1761 | "Stub's advertised default summary cost\n") | |
1762 | { | |
8d769265 DW |
1763 | int idx_ipv4_number = 2; |
1764 | int idx_number = 4; | |
68980084 | 1765 | struct ospf *ospf = vty->index; |
718e3744 | 1766 | struct ospf_area *area; |
1767 | struct in_addr area_id; | |
718e3744 | 1768 | int format; |
ba682537 | 1769 | struct prefix_ipv4 p; |
718e3744 | 1770 | |
7c8ff89e DS |
1771 | if (!ospf) |
1772 | return CMD_SUCCESS; | |
1773 | ||
8d769265 DW |
1774 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); |
1775 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[idx_number]->arg, 0, OSPF_LS_INFINITY); | |
718e3744 | 1776 | |
68980084 | 1777 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1778 | if (area == NULL) |
1779 | return CMD_SUCCESS; | |
1780 | ||
1781 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1782 | { | |
1783 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1784 | return CMD_WARNING; | |
1785 | } | |
1786 | ||
1787 | area->default_cost = 1; | |
1788 | ||
ba682537 | 1789 | p.family = AF_INET; |
1790 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1791 | p.prefixlen = 0; | |
1792 | if (IS_DEBUG_OSPF_EVENT) | |
1793 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1794 | "announcing 0.0.0.0/0 to area %s", | |
1795 | inet_ntoa (area->area_id)); | |
1796 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1797 | ||
1798 | ||
68980084 | 1799 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1800 | |
1801 | return CMD_SUCCESS; | |
1802 | } | |
1803 | ||
a2c62831 | 1804 | DEFUN (ospf_area_export_list, |
1805 | ospf_area_export_list_cmd, | |
6147e2c6 | 1806 | "area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1807 | "OSPF area parameters\n" |
1808 | "OSPF area ID in IP address format\n" | |
1809 | "OSPF area ID as a decimal value\n" | |
1810 | "Set the filter for networks announced to other areas\n" | |
1811 | "Name of the access-list\n") | |
1812 | { | |
8d769265 | 1813 | int idx_ipv4_number = 1; |
68980084 | 1814 | struct ospf *ospf = vty->index; |
718e3744 | 1815 | struct ospf_area *area; |
1816 | struct in_addr area_id; | |
1817 | int format; | |
1818 | ||
7c8ff89e DS |
1819 | if (!ospf) |
1820 | return CMD_SUCCESS; | |
1821 | ||
8d769265 | 1822 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1823 | |
68980084 | 1824 | area = ospf_area_get (ospf, area_id, format); |
7a7be519 | 1825 | ospf_area_export_list_set (ospf, area, argv[3]->arg); |
718e3744 | 1826 | |
1827 | return CMD_SUCCESS; | |
1828 | } | |
1829 | ||
a2c62831 | 1830 | DEFUN (no_ospf_area_export_list, |
1831 | no_ospf_area_export_list_cmd, | |
6147e2c6 | 1832 | "no area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1833 | NO_STR |
1834 | "OSPF area parameters\n" | |
1835 | "OSPF area ID in IP address format\n" | |
1836 | "OSPF area ID as a decimal value\n" | |
1837 | "Unset the filter for networks announced to other areas\n" | |
1838 | "Name of the access-list\n") | |
1839 | { | |
8d769265 | 1840 | int idx_ipv4_number = 2; |
68980084 | 1841 | struct ospf *ospf = vty->index; |
718e3744 | 1842 | struct ospf_area *area; |
1843 | struct in_addr area_id; | |
1844 | int format; | |
1845 | ||
7c8ff89e DS |
1846 | if (!ospf) |
1847 | return CMD_SUCCESS; | |
1848 | ||
8d769265 | 1849 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1850 | |
68980084 | 1851 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1852 | if (area == NULL) |
1853 | return CMD_SUCCESS; | |
1854 | ||
68980084 | 1855 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 1856 | |
1857 | return CMD_SUCCESS; | |
1858 | } | |
1859 | ||
1860 | ||
a2c62831 | 1861 | DEFUN (ospf_area_import_list, |
1862 | ospf_area_import_list_cmd, | |
6147e2c6 | 1863 | "area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1864 | "OSPF area parameters\n" |
1865 | "OSPF area ID in IP address format\n" | |
1866 | "OSPF area ID as a decimal value\n" | |
1867 | "Set the filter for networks from other areas announced to the specified one\n" | |
1868 | "Name of the access-list\n") | |
1869 | { | |
8d769265 | 1870 | int idx_ipv4_number = 1; |
68980084 | 1871 | struct ospf *ospf = vty->index; |
718e3744 | 1872 | struct ospf_area *area; |
1873 | struct in_addr area_id; | |
1874 | int format; | |
1875 | ||
7c8ff89e DS |
1876 | if (!ospf) |
1877 | return CMD_SUCCESS; | |
1878 | ||
8d769265 | 1879 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1880 | |
68980084 | 1881 | area = ospf_area_get (ospf, area_id, format); |
7a7be519 | 1882 | ospf_area_import_list_set (ospf, area, argv[3]->arg); |
718e3744 | 1883 | |
1884 | return CMD_SUCCESS; | |
1885 | } | |
1886 | ||
a2c62831 | 1887 | DEFUN (no_ospf_area_import_list, |
1888 | no_ospf_area_import_list_cmd, | |
6147e2c6 | 1889 | "no area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1890 | NO_STR |
1891 | "OSPF area parameters\n" | |
1892 | "OSPF area ID in IP address format\n" | |
1893 | "OSPF area ID as a decimal value\n" | |
1894 | "Unset the filter for networks announced to other areas\n" | |
1895 | "Name of the access-list\n") | |
1896 | { | |
8d769265 | 1897 | int idx_ipv4_number = 2; |
68980084 | 1898 | struct ospf *ospf = vty->index; |
718e3744 | 1899 | struct ospf_area *area; |
1900 | struct in_addr area_id; | |
1901 | int format; | |
1902 | ||
7c8ff89e DS |
1903 | if (!ospf) |
1904 | return CMD_SUCCESS; | |
1905 | ||
8d769265 | 1906 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1907 | |
68980084 | 1908 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1909 | if (area == NULL) |
1910 | return CMD_SUCCESS; | |
1911 | ||
68980084 | 1912 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 1913 | |
1914 | return CMD_SUCCESS; | |
1915 | } | |
1916 | ||
a2c62831 | 1917 | DEFUN (ospf_area_filter_list, |
1918 | ospf_area_filter_list_cmd, | |
6147e2c6 | 1919 | "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1920 | "OSPF area parameters\n" |
1921 | "OSPF area ID in IP address format\n" | |
1922 | "OSPF area ID as a decimal value\n" | |
1923 | "Filter networks between OSPF areas\n" | |
1924 | "Filter prefixes between OSPF areas\n" | |
1925 | "Name of an IP prefix-list\n" | |
1926 | "Filter networks sent to this area\n" | |
1927 | "Filter networks sent from this area\n") | |
1928 | { | |
8d769265 DW |
1929 | int idx_ipv4_number = 1; |
1930 | int idx_word = 4; | |
1931 | int idx_in_out = 5; | |
68980084 | 1932 | struct ospf *ospf = vty->index; |
718e3744 | 1933 | struct ospf_area *area; |
1934 | struct in_addr area_id; | |
1935 | struct prefix_list *plist; | |
1936 | int format; | |
1937 | ||
7c8ff89e DS |
1938 | if (!ospf) |
1939 | return CMD_SUCCESS; | |
1940 | ||
8d769265 | 1941 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1942 | |
68980084 | 1943 | area = ospf_area_get (ospf, area_id, format); |
8d769265 DW |
1944 | plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg); |
1945 | if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) | |
718e3744 | 1946 | { |
1947 | PREFIX_LIST_IN (area) = plist; | |
1948 | if (PREFIX_NAME_IN (area)) | |
1949 | free (PREFIX_NAME_IN (area)); | |
1950 | ||
8d769265 | 1951 | PREFIX_NAME_IN (area) = strdup (argv[idx_word]->arg); |
68980084 | 1952 | ospf_schedule_abr_task (ospf); |
718e3744 | 1953 | } |
1954 | else | |
1955 | { | |
1956 | PREFIX_LIST_OUT (area) = plist; | |
1957 | if (PREFIX_NAME_OUT (area)) | |
1958 | free (PREFIX_NAME_OUT (area)); | |
1959 | ||
8d769265 | 1960 | PREFIX_NAME_OUT (area) = strdup (argv[idx_word]->arg); |
68980084 | 1961 | ospf_schedule_abr_task (ospf); |
718e3744 | 1962 | } |
1963 | ||
1964 | return CMD_SUCCESS; | |
1965 | } | |
1966 | ||
a2c62831 | 1967 | DEFUN (no_ospf_area_filter_list, |
1968 | no_ospf_area_filter_list_cmd, | |
6147e2c6 | 1969 | "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1970 | NO_STR |
1971 | "OSPF area parameters\n" | |
1972 | "OSPF area ID in IP address format\n" | |
1973 | "OSPF area ID as a decimal value\n" | |
1974 | "Filter networks between OSPF areas\n" | |
1975 | "Filter prefixes between OSPF areas\n" | |
1976 | "Name of an IP prefix-list\n" | |
1977 | "Filter networks sent to this area\n" | |
1978 | "Filter networks sent from this area\n") | |
1979 | { | |
8d769265 DW |
1980 | int idx_ipv4_number = 2; |
1981 | int idx_word = 5; | |
1982 | int idx_in_out = 6; | |
68980084 | 1983 | struct ospf *ospf = vty->index; |
718e3744 | 1984 | struct ospf_area *area; |
1985 | struct in_addr area_id; | |
718e3744 | 1986 | int format; |
1987 | ||
7c8ff89e DS |
1988 | if (!ospf) |
1989 | return CMD_SUCCESS; | |
1990 | ||
8d769265 | 1991 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1992 | |
1a8ec2b9 PJ |
1993 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
1994 | return CMD_SUCCESS; | |
1995 | ||
8d769265 | 1996 | if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) |
718e3744 | 1997 | { |
1998 | if (PREFIX_NAME_IN (area)) | |
8d769265 | 1999 | if (strcmp (PREFIX_NAME_IN (area), argv[idx_word]->arg) != 0) |
718e3744 | 2000 | return CMD_SUCCESS; |
2001 | ||
2002 | PREFIX_LIST_IN (area) = NULL; | |
2003 | if (PREFIX_NAME_IN (area)) | |
2004 | free (PREFIX_NAME_IN (area)); | |
2005 | ||
2006 | PREFIX_NAME_IN (area) = NULL; | |
2007 | ||
68980084 | 2008 | ospf_schedule_abr_task (ospf); |
718e3744 | 2009 | } |
2010 | else | |
2011 | { | |
2012 | if (PREFIX_NAME_OUT (area)) | |
8d769265 | 2013 | if (strcmp (PREFIX_NAME_OUT (area), argv[idx_word]->arg) != 0) |
718e3744 | 2014 | return CMD_SUCCESS; |
2015 | ||
2016 | PREFIX_LIST_OUT (area) = NULL; | |
2017 | if (PREFIX_NAME_OUT (area)) | |
2018 | free (PREFIX_NAME_OUT (area)); | |
2019 | ||
2020 | PREFIX_NAME_OUT (area) = NULL; | |
2021 | ||
68980084 | 2022 | ospf_schedule_abr_task (ospf); |
718e3744 | 2023 | } |
2024 | ||
2025 | return CMD_SUCCESS; | |
2026 | } | |
2027 | ||
6b0655a2 | 2028 | |
a2c62831 | 2029 | DEFUN (ospf_area_authentication_message_digest, |
2030 | ospf_area_authentication_message_digest_cmd, | |
6147e2c6 | 2031 | "area <A.B.C.D|(0-4294967295)> authentication message-digest", |
718e3744 | 2032 | "OSPF area parameters\n" |
2b00515a CF |
2033 | "OSPF area ID in IP address format\n" |
2034 | "OSPF area ID as a decimal value\n" | |
718e3744 | 2035 | "Enable authentication\n" |
2036 | "Use message-digest authentication\n") | |
2037 | { | |
8d769265 | 2038 | int idx_ipv4_number = 1; |
68980084 | 2039 | struct ospf *ospf = vty->index; |
718e3744 | 2040 | struct ospf_area *area; |
2041 | struct in_addr area_id; | |
2042 | int format; | |
2043 | ||
7c8ff89e DS |
2044 | if (!ospf) |
2045 | return CMD_SUCCESS; | |
2046 | ||
8d769265 | 2047 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 2048 | |
68980084 | 2049 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2050 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
2051 | ||
2052 | return CMD_SUCCESS; | |
2053 | } | |
2054 | ||
a2c62831 | 2055 | DEFUN (ospf_area_authentication, |
2056 | ospf_area_authentication_cmd, | |
6147e2c6 | 2057 | "area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 2058 | "OSPF area parameters\n" |
2059 | "OSPF area ID in IP address format\n" | |
2060 | "OSPF area ID as a decimal value\n" | |
2061 | "Enable authentication\n") | |
2062 | { | |
8d769265 | 2063 | int idx_ipv4_number = 1; |
68980084 | 2064 | struct ospf *ospf = vty->index; |
718e3744 | 2065 | struct ospf_area *area; |
2066 | struct in_addr area_id; | |
2067 | int format; | |
2068 | ||
7c8ff89e DS |
2069 | if (!ospf) |
2070 | return CMD_SUCCESS; | |
2071 | ||
8d769265 | 2072 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 2073 | |
68980084 | 2074 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2075 | area->auth_type = OSPF_AUTH_SIMPLE; |
2076 | ||
2077 | return CMD_SUCCESS; | |
2078 | } | |
2079 | ||
a2c62831 | 2080 | DEFUN (no_ospf_area_authentication, |
2081 | no_ospf_area_authentication_cmd, | |
6147e2c6 | 2082 | "no area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 2083 | NO_STR |
2084 | "OSPF area parameters\n" | |
2085 | "OSPF area ID in IP address format\n" | |
2086 | "OSPF area ID as a decimal value\n" | |
2087 | "Enable authentication\n") | |
2088 | { | |
8d769265 | 2089 | int idx_ipv4_number = 2; |
68980084 | 2090 | struct ospf *ospf = vty->index; |
718e3744 | 2091 | struct ospf_area *area; |
2092 | struct in_addr area_id; | |
2093 | int format; | |
2094 | ||
7c8ff89e DS |
2095 | if (!ospf) |
2096 | return CMD_SUCCESS; | |
2097 | ||
8d769265 | 2098 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 2099 | |
68980084 | 2100 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2101 | if (area == NULL) |
2102 | return CMD_SUCCESS; | |
2103 | ||
2104 | area->auth_type = OSPF_AUTH_NULL; | |
2105 | ||
68980084 | 2106 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2107 | |
2108 | return CMD_SUCCESS; | |
2109 | } | |
2110 | ||
6b0655a2 | 2111 | |
718e3744 | 2112 | DEFUN (ospf_abr_type, |
2113 | ospf_abr_type_cmd, | |
6147e2c6 | 2114 | "ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2115 | "OSPF specific commands\n" |
2116 | "Set OSPF ABR type\n" | |
2117 | "Alternative ABR, cisco implementation\n" | |
2118 | "Alternative ABR, IBM implementation\n" | |
2119 | "Shortcut ABR\n" | |
2120 | "Standard behavior (RFC2328)\n") | |
2121 | { | |
8d769265 | 2122 | int idx_vendor = 2; |
68980084 | 2123 | struct ospf *ospf = vty->index; |
718e3744 | 2124 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2125 | ||
7c8ff89e DS |
2126 | if (!ospf) |
2127 | return CMD_SUCCESS; | |
2128 | ||
8d769265 | 2129 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) |
718e3744 | 2130 | abr_type = OSPF_ABR_CISCO; |
8d769265 | 2131 | else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) |
718e3744 | 2132 | abr_type = OSPF_ABR_IBM; |
8d769265 | 2133 | else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) |
718e3744 | 2134 | abr_type = OSPF_ABR_SHORTCUT; |
8d769265 | 2135 | else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) |
718e3744 | 2136 | abr_type = OSPF_ABR_STAND; |
2137 | else | |
2138 | return CMD_WARNING; | |
2139 | ||
2140 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2141 | if (ospf->abr_type != abr_type) |
718e3744 | 2142 | { |
68980084 | 2143 | ospf->abr_type = abr_type; |
2144 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2145 | } |
2146 | ||
2147 | return CMD_SUCCESS; | |
2148 | } | |
2149 | ||
2150 | DEFUN (no_ospf_abr_type, | |
2151 | no_ospf_abr_type_cmd, | |
6147e2c6 | 2152 | "no ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2153 | NO_STR |
2154 | "OSPF specific commands\n" | |
2155 | "Set OSPF ABR type\n" | |
2156 | "Alternative ABR, cisco implementation\n" | |
2157 | "Alternative ABR, IBM implementation\n" | |
2158 | "Shortcut ABR\n") | |
2159 | { | |
8d769265 | 2160 | int idx_vendor = 3; |
68980084 | 2161 | struct ospf *ospf = vty->index; |
718e3744 | 2162 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2163 | ||
7c8ff89e DS |
2164 | if (!ospf) |
2165 | return CMD_SUCCESS; | |
2166 | ||
8d769265 | 2167 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) |
718e3744 | 2168 | abr_type = OSPF_ABR_CISCO; |
8d769265 | 2169 | else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) |
718e3744 | 2170 | abr_type = OSPF_ABR_IBM; |
8d769265 | 2171 | else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) |
718e3744 | 2172 | abr_type = OSPF_ABR_SHORTCUT; |
8d769265 | 2173 | else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) |
04d23314 | 2174 | abr_type = OSPF_ABR_STAND; |
718e3744 | 2175 | else |
2176 | return CMD_WARNING; | |
2177 | ||
2178 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2179 | if (ospf->abr_type == abr_type) |
718e3744 | 2180 | { |
d57834f6 | 2181 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2182 | ospf_schedule_abr_task (ospf); |
718e3744 | 2183 | } |
2184 | ||
2185 | return CMD_SUCCESS; | |
2186 | } | |
2187 | ||
d7e60dd7 AS |
2188 | DEFUN (ospf_log_adjacency_changes, |
2189 | ospf_log_adjacency_changes_cmd, | |
2190 | "log-adjacency-changes", | |
2191 | "Log changes in adjacency state\n") | |
2192 | { | |
2193 | struct ospf *ospf = vty->index; | |
2194 | ||
7c8ff89e DS |
2195 | if (!ospf) |
2196 | return CMD_SUCCESS; | |
2197 | ||
d7e60dd7 | 2198 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
692c7954 | 2199 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
d7e60dd7 AS |
2200 | return CMD_SUCCESS; |
2201 | } | |
2202 | ||
2203 | DEFUN (ospf_log_adjacency_changes_detail, | |
2204 | ospf_log_adjacency_changes_detail_cmd, | |
2205 | "log-adjacency-changes detail", | |
2206 | "Log changes in adjacency state\n" | |
2207 | "Log all state changes\n") | |
2208 | { | |
2209 | struct ospf *ospf = vty->index; | |
2210 | ||
7c8ff89e DS |
2211 | if (!ospf) |
2212 | return CMD_SUCCESS; | |
2213 | ||
d7e60dd7 AS |
2214 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2215 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2216 | return CMD_SUCCESS; | |
2217 | } | |
2218 | ||
2219 | DEFUN (no_ospf_log_adjacency_changes, | |
2220 | no_ospf_log_adjacency_changes_cmd, | |
2221 | "no log-adjacency-changes", | |
2222 | NO_STR | |
2223 | "Log changes in adjacency state\n") | |
2224 | { | |
2225 | struct ospf *ospf = vty->index; | |
2226 | ||
7c8ff89e DS |
2227 | if (!ospf) |
2228 | return CMD_SUCCESS; | |
2229 | ||
d7e60dd7 AS |
2230 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2231 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2232 | return CMD_SUCCESS; | |
2233 | } | |
2234 | ||
2235 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2236 | no_ospf_log_adjacency_changes_detail_cmd, | |
2237 | "no log-adjacency-changes detail", | |
2238 | NO_STR | |
2239 | "Log changes in adjacency state\n" | |
2240 | "Log all state changes\n") | |
2241 | { | |
2242 | struct ospf *ospf = vty->index; | |
2243 | ||
7c8ff89e DS |
2244 | if (!ospf) |
2245 | return CMD_SUCCESS; | |
2246 | ||
692c7954 | 2247 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
d7e60dd7 AS |
2248 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2249 | return CMD_SUCCESS; | |
2250 | } | |
2251 | ||
718e3744 | 2252 | DEFUN (ospf_compatible_rfc1583, |
2253 | ospf_compatible_rfc1583_cmd, | |
2254 | "compatible rfc1583", | |
2255 | "OSPF compatibility list\n" | |
2256 | "compatible with RFC 1583\n") | |
2257 | { | |
2258 | struct ospf *ospf = vty->index; | |
2259 | ||
7c8ff89e DS |
2260 | if (!ospf) |
2261 | return CMD_SUCCESS; | |
2262 | ||
718e3744 | 2263 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2264 | { | |
2265 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2266 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2267 | } |
2268 | return CMD_SUCCESS; | |
2269 | } | |
2270 | ||
2271 | DEFUN (no_ospf_compatible_rfc1583, | |
2272 | no_ospf_compatible_rfc1583_cmd, | |
2273 | "no compatible rfc1583", | |
2274 | NO_STR | |
2275 | "OSPF compatibility list\n" | |
2276 | "compatible with RFC 1583\n") | |
2277 | { | |
2278 | struct ospf *ospf = vty->index; | |
2279 | ||
7c8ff89e DS |
2280 | if (!ospf) |
2281 | return CMD_SUCCESS; | |
2282 | ||
718e3744 | 2283 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2284 | { | |
2285 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2286 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2287 | } |
2288 | return CMD_SUCCESS; | |
2289 | } | |
2290 | ||
7a7be519 | 2291 | ALIAS (ospf_compatible_rfc1583, |
2292 | ospf_rfc1583_flag_cmd, | |
2293 | "ospf rfc1583compatibility", | |
2294 | "OSPF specific commands\n" | |
2295 | "Enable the RFC1583Compatibility flag\n") | |
718e3744 | 2296 | |
7a7be519 | 2297 | ALIAS (no_ospf_compatible_rfc1583, |
2298 | no_ospf_rfc1583_flag_cmd, | |
2299 | "no ospf rfc1583compatibility", | |
2300 | NO_STR | |
2301 | "OSPF specific commands\n" | |
2302 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2303 | |
d24f6e2a | 2304 | static int |
2305 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2306 | unsigned int hold, | |
2307 | unsigned int max) | |
2308 | { | |
2309 | struct ospf *ospf = vty->index; | |
2310 | ||
7c8ff89e DS |
2311 | if (!ospf) |
2312 | return CMD_SUCCESS; | |
2313 | ||
d24f6e2a | 2314 | ospf->spf_delay = delay; |
2315 | ospf->spf_holdtime = hold; | |
2316 | ospf->spf_max_holdtime = max; | |
2317 | ||
2318 | return CMD_SUCCESS; | |
2319 | } | |
718e3744 | 2320 | |
ac7424f9 MR |
2321 | DEFUN (ospf_timers_min_ls_interval, |
2322 | ospf_timers_min_ls_interval_cmd, | |
6147e2c6 | 2323 | "timers throttle lsa all (0-5000)", |
ac7424f9 MR |
2324 | "Adjust routing timers\n" |
2325 | "Throttling adaptive timer\n" | |
2326 | "LSA delay between transmissions\n" | |
813d4307 | 2327 | "All LSA types\n" |
ac7424f9 MR |
2328 | "Delay (msec) between sending LSAs\n") |
2329 | { | |
8d769265 | 2330 | int idx_number = 4; |
ac7424f9 MR |
2331 | struct ospf *ospf = vty->index; |
2332 | unsigned int interval; | |
2333 | ||
d8f70b86 DS |
2334 | if (!ospf) |
2335 | return CMD_SUCCESS; | |
2336 | ||
ac7424f9 MR |
2337 | if (argc != 1) |
2338 | { | |
2339 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2340 | return CMD_WARNING; | |
2341 | } | |
2342 | ||
8d769265 | 2343 | VTY_GET_INTEGER ("LSA interval", interval, argv[idx_number]->arg); |
ac7424f9 MR |
2344 | |
2345 | ospf->min_ls_interval = interval; | |
2346 | ||
2347 | return CMD_SUCCESS; | |
2348 | } | |
2349 | ||
2350 | DEFUN (no_ospf_timers_min_ls_interval, | |
2351 | no_ospf_timers_min_ls_interval_cmd, | |
7a7be519 | 2352 | "no timers throttle lsa all [(0-5000)]", |
ac7424f9 MR |
2353 | NO_STR |
2354 | "Adjust routing timers\n" | |
2355 | "Throttling adaptive timer\n" | |
813d4307 | 2356 | "LSA delay between transmissions\n" |
7a7be519 | 2357 | "All LSA types\n" |
2358 | "Delay (msec) between sending LSAs\n") | |
ac7424f9 MR |
2359 | { |
2360 | struct ospf *ospf = vty->index; | |
2361 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; | |
2362 | ||
2363 | return CMD_SUCCESS; | |
2364 | } | |
2365 | ||
813d4307 | 2366 | |
ac7424f9 MR |
2367 | DEFUN (ospf_timers_min_ls_arrival, |
2368 | ospf_timers_min_ls_arrival_cmd, | |
6147e2c6 | 2369 | "timers lsa arrival (0-1000)", |
ac7424f9 MR |
2370 | "Adjust routing timers\n" |
2371 | "Throttling link state advertisement delays\n" | |
2372 | "OSPF minimum arrival interval delay\n" | |
2373 | "Delay (msec) between accepted LSAs\n") | |
2374 | { | |
8d769265 | 2375 | int idx_number = 3; |
ac7424f9 MR |
2376 | struct ospf *ospf = vty->index; |
2377 | unsigned int arrival; | |
2378 | ||
d8f70b86 DS |
2379 | if (!ospf) |
2380 | return CMD_SUCCESS; | |
2381 | ||
ac7424f9 MR |
2382 | if (argc != 1) |
2383 | { | |
2384 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2385 | return CMD_WARNING; | |
2386 | } | |
2387 | ||
8d769265 | 2388 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[idx_number]->arg, 0, 1000); |
ac7424f9 MR |
2389 | |
2390 | ospf->min_ls_arrival = arrival; | |
2391 | ||
2392 | return CMD_SUCCESS; | |
2393 | } | |
2394 | ||
2395 | DEFUN (no_ospf_timers_min_ls_arrival, | |
2396 | no_ospf_timers_min_ls_arrival_cmd, | |
7a7be519 | 2397 | "no timers lsa arrival [(0-1000)]", |
ac7424f9 MR |
2398 | NO_STR |
2399 | "Adjust routing timers\n" | |
2400 | "Throttling link state advertisement delays\n" | |
7a7be519 | 2401 | "OSPF minimum arrival interval delay\n" |
2402 | "Delay (msec) between accepted LSAs\n") | |
ac7424f9 MR |
2403 | { |
2404 | struct ospf *ospf = vty->index; | |
d8f70b86 DS |
2405 | |
2406 | if (!ospf) | |
2407 | return CMD_SUCCESS; | |
2408 | ||
ac7424f9 MR |
2409 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
2410 | ||
2411 | return CMD_SUCCESS; | |
2412 | } | |
2413 | ||
813d4307 | 2414 | |
d24f6e2a | 2415 | DEFUN (ospf_timers_throttle_spf, |
2416 | ospf_timers_throttle_spf_cmd, | |
6147e2c6 | 2417 | "timers throttle spf (0-600000) (0-600000) (0-600000)", |
d24f6e2a | 2418 | "Adjust routing timers\n" |
2419 | "Throttling adaptive timer\n" | |
2420 | "OSPF SPF timers\n" | |
2421 | "Delay (msec) from first change received till SPF calculation\n" | |
2422 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2423 | "Maximum hold time (msec)\n") | |
2424 | { | |
8d769265 DW |
2425 | int idx_number = 3; |
2426 | int idx_number_2 = 4; | |
2427 | int idx_number_3 = 5; | |
d24f6e2a | 2428 | unsigned int delay, hold, max; |
2429 | ||
2430 | if (argc != 3) | |
2431 | { | |
2432 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2433 | return CMD_WARNING; | |
2434 | } | |
2435 | ||
8d769265 DW |
2436 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000); |
2437 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000); | |
2438 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000); | |
d24f6e2a | 2439 | |
2440 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2441 | } | |
2442 | ||
d24f6e2a | 2443 | DEFUN (no_ospf_timers_throttle_spf, |
2444 | no_ospf_timers_throttle_spf_cmd, | |
7a7be519 | 2445 | "no timers throttle spf [(0-600000)(0-600000)(0-600000)]", |
718e3744 | 2446 | NO_STR |
2447 | "Adjust routing timers\n" | |
d24f6e2a | 2448 | "Throttling adaptive timer\n" |
7a7be519 | 2449 | "OSPF SPF timers\n" |
2450 | "Delay (msec) from first change received till SPF calculation\n" | |
2451 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2452 | "Maximum hold time (msec)\n") | |
22b27e95 | 2453 | { |
d24f6e2a | 2454 | return ospf_timers_spf_set (vty, |
2455 | OSPF_SPF_DELAY_DEFAULT, | |
2456 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2457 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2458 | } |
2459 | ||
b4a039bf | 2460 | |
b6927875 DS |
2461 | DEFUN (ospf_timers_lsa, |
2462 | ospf_timers_lsa_cmd, | |
6147e2c6 | 2463 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
2464 | "Adjust routing timers\n" |
2465 | "OSPF LSA timers\n" | |
2466 | "Minimum delay in receiving new version of a LSA\n" | |
2467 | "Delay in milliseconds\n") | |
2468 | { | |
8d769265 | 2469 | int idx_number = 3; |
b6927875 DS |
2470 | unsigned int minarrival; |
2471 | struct ospf *ospf = vty->index; | |
2472 | ||
2473 | if (!ospf) | |
2474 | return CMD_SUCCESS; | |
2475 | ||
2476 | if (argc != 1) | |
2477 | { | |
2478 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2479 | return CMD_WARNING; | |
2480 | } | |
2481 | ||
8d769265 | 2482 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); |
b6927875 | 2483 | |
ac7424f9 | 2484 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2485 | |
2486 | return CMD_SUCCESS; | |
2487 | } | |
2488 | ||
2489 | DEFUN (no_ospf_timers_lsa, | |
2490 | no_ospf_timers_lsa_cmd, | |
7a7be519 | 2491 | "no timers lsa min-arrival [(0-600000)]", |
b6927875 DS |
2492 | NO_STR |
2493 | "Adjust routing timers\n" | |
2494 | "OSPF LSA timers\n" | |
7a7be519 | 2495 | "Minimum delay in receiving new version of a LSA\n" |
2496 | "Delay in milliseconds\n") | |
b6927875 DS |
2497 | { |
2498 | unsigned int minarrival; | |
2499 | struct ospf *ospf = vty->index; | |
2500 | ||
2501 | if (!ospf) | |
2502 | return CMD_SUCCESS; | |
2503 | ||
7a7be519 | 2504 | if (argc > 4) |
b6927875 | 2505 | { |
7a7be519 | 2506 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[4]->arg); |
b6927875 | 2507 | |
ac7424f9 | 2508 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2509 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2510 | return CMD_SUCCESS; | |
2511 | } | |
2512 | ||
ac7424f9 | 2513 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2514 | |
2515 | return CMD_SUCCESS; | |
2516 | } | |
2517 | ||
a2c62831 | 2518 | DEFUN (ospf_neighbor, |
2519 | ospf_neighbor_cmd, | |
7a7be519 | 2520 | "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]", |
718e3744 | 2521 | NEIGHBOR_STR |
7a7be519 | 2522 | "Neighbor IP address\n" |
2523 | "Neighbor Priority\n" | |
2524 | "Priority\n" | |
2525 | "Dead Neighbor Polling interval\n" | |
2526 | "Seconds\n") | |
718e3744 | 2527 | { |
8d769265 | 2528 | int idx_ipv4 = 1; |
7a7be519 | 2529 | int idx_pri = 3; |
2530 | int idx_poll = 5; | |
718e3744 | 2531 | struct ospf *ospf = vty->index; |
2532 | struct in_addr nbr_addr; | |
eb1ce605 | 2533 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2534 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2535 | |
7c8ff89e DS |
2536 | if (!ospf) |
2537 | return CMD_SUCCESS; | |
2538 | ||
8d769265 | 2539 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2540 | |
718e3744 | 2541 | if (argc > 2) |
7a7be519 | 2542 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); |
2543 | ||
2544 | if (argc > 4) | |
2545 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); | |
718e3744 | 2546 | |
2547 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
7a7be519 | 2548 | |
718e3744 | 2549 | if (argc > 2) |
7a7be519 | 2550 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
2551 | ||
2552 | if (argc > 4) | |
1a61ad10 | 2553 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2554 | |
2555 | return CMD_SUCCESS; | |
2556 | } | |
2557 | ||
a2c62831 | 2558 | DEFUN (ospf_neighbor_poll_interval, |
2559 | ospf_neighbor_poll_interval_cmd, | |
7a7be519 | 2560 | "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", |
718e3744 | 2561 | NEIGHBOR_STR |
2562 | "Neighbor IP address\n" | |
2563 | "Dead Neighbor Polling interval\n" | |
7a7be519 | 2564 | "Seconds\n" |
2565 | "OSPF priority of non-broadcast neighbor\n" | |
2566 | "Priority\n") | |
22b27e95 | 2567 | { |
8d769265 | 2568 | int idx_ipv4 = 1; |
7a7be519 | 2569 | int idx_poll = 3; |
2570 | int idx_pri = 5; | |
718e3744 | 2571 | struct ospf *ospf = vty->index; |
2572 | struct in_addr nbr_addr; | |
eb1ce605 | 2573 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2574 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2575 | |
7c8ff89e DS |
2576 | if (!ospf) |
2577 | return CMD_SUCCESS; | |
2578 | ||
8d769265 | 2579 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2580 | |
7a7be519 | 2581 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); |
718e3744 | 2582 | |
7a7be519 | 2583 | if (argc > 4) |
2584 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); | |
718e3744 | 2585 | |
2586 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
7a7be519 | 2587 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
2588 | ||
2589 | if (argc > 4) | |
718e3744 | 2590 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
2591 | ||
2592 | return CMD_SUCCESS; | |
2593 | } | |
2594 | ||
a2c62831 | 2595 | DEFUN (no_ospf_neighbor, |
2596 | no_ospf_neighbor_cmd, | |
7a7be519 | 2597 | "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]", |
718e3744 | 2598 | NO_STR |
2599 | NEIGHBOR_STR | |
7a7be519 | 2600 | "Neighbor IP address\n" |
2601 | "Neighbor Priority\n" | |
2602 | "Priority\n" | |
2603 | "Dead Neighbor Polling interval\n" | |
2604 | "Seconds\n") | |
718e3744 | 2605 | { |
8d769265 | 2606 | int idx_ipv4 = 2; |
718e3744 | 2607 | struct ospf *ospf = vty->index; |
2608 | struct in_addr nbr_addr; | |
718e3744 | 2609 | |
7c8ff89e DS |
2610 | if (!ospf) |
2611 | return CMD_SUCCESS; | |
2612 | ||
8d769265 | 2613 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2614 | |
0798cee3 | 2615 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2616 | |
2617 | return CMD_SUCCESS; | |
2618 | } | |
2619 | ||
7a7be519 | 2620 | DEFUN (no_ospf_neighbor_poll, |
2621 | no_ospf_neighbor_poll_cmd, | |
2622 | "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", | |
2623 | NO_STR | |
2624 | NEIGHBOR_STR | |
2625 | "Neighbor IP address\n" | |
2626 | "Dead Neighbor Polling interval\n" | |
2627 | "Seconds\n" | |
2628 | "Neighbor Priority\n" | |
2629 | "Priority\n") | |
2630 | { | |
2631 | int idx_ipv4 = 2; | |
2632 | struct ospf *ospf = vty->index; | |
2633 | struct in_addr nbr_addr; | |
2634 | ||
2635 | if (!ospf) | |
2636 | return CMD_SUCCESS; | |
718e3744 | 2637 | |
7a7be519 | 2638 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2639 | |
7a7be519 | 2640 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
813d4307 | 2641 | |
7a7be519 | 2642 | return CMD_SUCCESS; |
2643 | } | |
718e3744 | 2644 | |
bf2bfafd DW |
2645 | DEFUN (ospf_refresh_timer, |
2646 | ospf_refresh_timer_cmd, | |
6147e2c6 | 2647 | "refresh timer (10-1800)", |
718e3744 | 2648 | "Adjust refresh parameters\n" |
2649 | "Set refresh timer\n" | |
2650 | "Timer value in seconds\n") | |
2651 | { | |
8d769265 | 2652 | int idx_number = 2; |
718e3744 | 2653 | struct ospf *ospf = vty->index; |
eb1ce605 | 2654 | unsigned int interval; |
718e3744 | 2655 | |
7c8ff89e DS |
2656 | if (!ospf) |
2657 | return CMD_SUCCESS; | |
2658 | ||
8d769265 | 2659 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); |
535c84b1 | 2660 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; |
718e3744 | 2661 | |
2662 | ospf_timers_refresh_set (ospf, interval); | |
2663 | ||
2664 | return CMD_SUCCESS; | |
2665 | } | |
2666 | ||
bf2bfafd DW |
2667 | DEFUN (no_ospf_refresh_timer, |
2668 | no_ospf_refresh_timer_val_cmd, | |
7a7be519 | 2669 | "no refresh timer [(10-1800)]", |
718e3744 | 2670 | "Adjust refresh parameters\n" |
2671 | "Unset refresh timer\n" | |
2672 | "Timer value in seconds\n") | |
2673 | { | |
8d769265 | 2674 | int idx_number = 3; |
718e3744 | 2675 | struct ospf *ospf = vty->index; |
eb1ce605 | 2676 | unsigned int interval; |
718e3744 | 2677 | |
7c8ff89e DS |
2678 | if (!ospf) |
2679 | return CMD_SUCCESS; | |
2680 | ||
718e3744 | 2681 | if (argc == 1) |
2682 | { | |
8d769265 | 2683 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); |
718e3744 | 2684 | |
2685 | if (ospf->lsa_refresh_interval != interval || | |
2686 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2687 | return CMD_SUCCESS; | |
2688 | } | |
2689 | ||
2690 | ospf_timers_refresh_unset (ospf); | |
2691 | ||
2692 | return CMD_SUCCESS; | |
2693 | } | |
2694 | ||
718e3744 | 2695 | |
a2c62831 | 2696 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2697 | ospf_auto_cost_reference_bandwidth_cmd, | |
6147e2c6 | 2698 | "auto-cost reference-bandwidth (1-4294967)", |
718e3744 | 2699 | "Calculate OSPF interface cost according to bandwidth\n" |
2700 | "Use reference bandwidth method to assign OSPF cost\n" | |
2701 | "The reference bandwidth in terms of Mbits per second\n") | |
2702 | { | |
8d769265 | 2703 | int idx_number = 2; |
68980084 | 2704 | struct ospf *ospf = vty->index; |
718e3744 | 2705 | u_int32_t refbw; |
52dc7ee6 | 2706 | struct listnode *node; |
1eb8ef25 | 2707 | struct interface *ifp; |
718e3744 | 2708 | |
7c8ff89e DS |
2709 | if (!ospf) |
2710 | return CMD_SUCCESS; | |
2711 | ||
8d769265 | 2712 | refbw = strtol (argv[idx_number]->arg, NULL, 10); |
718e3744 | 2713 | if (refbw < 1 || refbw > 4294967) |
2714 | { | |
2715 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2716 | return CMD_WARNING; | |
2717 | } | |
2718 | ||
2719 | /* If reference bandwidth is changed. */ | |
70bd3c43 | 2720 | if ((refbw) == ospf->ref_bandwidth) |
718e3744 | 2721 | return CMD_SUCCESS; |
2722 | ||
70bd3c43 | 2723 | ospf->ref_bandwidth = refbw; |
1eb8ef25 | 2724 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2725 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2726 | |
2727 | return CMD_SUCCESS; | |
2728 | } | |
2729 | ||
a2c62831 | 2730 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2731 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
7a7be519 | 2732 | "no auto-cost reference-bandwidth [(1-4294967)]", |
718e3744 | 2733 | NO_STR |
2734 | "Calculate OSPF interface cost according to bandwidth\n" | |
7a7be519 | 2735 | "Use reference bandwidth method to assign OSPF cost\n" |
2736 | "The reference bandwidth in terms of Mbits per second\n") | |
718e3744 | 2737 | { |
68980084 | 2738 | struct ospf *ospf = vty->index; |
1eb8ef25 | 2739 | struct listnode *node, *nnode; |
2740 | struct interface *ifp; | |
718e3744 | 2741 | |
7c8ff89e DS |
2742 | if (!ospf) |
2743 | return CMD_SUCCESS; | |
2744 | ||
68980084 | 2745 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2746 | return CMD_SUCCESS; |
2747 | ||
68980084 | 2748 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2749 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2750 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2751 | ||
1eb8ef25 | 2752 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2753 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2754 | |
2755 | return CMD_SUCCESS; | |
2756 | } | |
2757 | ||
2f8f370e DS |
2758 | DEFUN (ospf_write_multiplier, |
2759 | ospf_write_multiplier_cmd, | |
6147e2c6 | 2760 | "ospf write-multiplier (1-100)", |
e8f45e82 DS |
2761 | "OSPF specific commands\n" |
2762 | "Write multiplier\n" | |
2763 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2764 | { |
7a7be519 | 2765 | int idx_number; |
2f8f370e | 2766 | struct ospf *ospf = vty->index; |
e8f45e82 | 2767 | u_int32_t write_oi_count; |
2f8f370e | 2768 | |
7c8ff89e DS |
2769 | if (!ospf) |
2770 | return CMD_SUCCESS; | |
2771 | ||
7a7be519 | 2772 | if (argc == 3) |
2773 | idx_number = 2; | |
2774 | else | |
2775 | idx_number = 1; | |
2776 | ||
8d769265 | 2777 | write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); |
e8f45e82 | 2778 | if (write_oi_count < 1 || write_oi_count > 100) |
2f8f370e DS |
2779 | { |
2780 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2781 | return CMD_WARNING; | |
2782 | } | |
2783 | ||
e8f45e82 | 2784 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2785 | return CMD_SUCCESS; |
2786 | } | |
2787 | ||
7a7be519 | 2788 | ALIAS (ospf_write_multiplier, |
2789 | write_multiplier_cmd, | |
2790 | "write-multiplier (1-100)", | |
2791 | "Write multiplier\n" | |
2792 | "Maximum number of interface serviced per write\n") | |
e8f45e82 | 2793 | |
2f8f370e DS |
2794 | DEFUN (no_ospf_write_multiplier, |
2795 | no_ospf_write_multiplier_cmd, | |
6147e2c6 | 2796 | "no ospf write-multiplier (1-100)", |
2f8f370e | 2797 | NO_STR |
e8f45e82 | 2798 | "OSPF specific commands\n" |
813d4307 DW |
2799 | "Write multiplier\n" |
2800 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2801 | { |
2802 | struct ospf *ospf = vty->index; | |
2803 | ||
7c8ff89e DS |
2804 | if (!ospf) |
2805 | return CMD_SUCCESS; | |
2806 | ||
e8f45e82 | 2807 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
2808 | return CMD_SUCCESS; |
2809 | } | |
2810 | ||
7a7be519 | 2811 | ALIAS (no_ospf_write_multiplier, |
2812 | no_write_multiplier_cmd, | |
2813 | "no write-multiplier (1-100)", | |
2814 | NO_STR | |
2815 | "Write multiplier\n" | |
2816 | "Maximum number of interface serviced per write\n") | |
813d4307 | 2817 | |
eb1ce605 | 2818 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 2819 | { |
2820 | "Unknown", | |
2821 | "Standard (RFC2328)", | |
2822 | "Alternative IBM", | |
2823 | "Alternative Cisco", | |
2824 | "Alternative Shortcut" | |
2825 | }; | |
2826 | ||
eb1ce605 | 2827 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 2828 | { |
2829 | "Default", | |
2830 | "Enabled", | |
2831 | "Disabled" | |
2832 | }; | |
2833 | ||
4dadc291 | 2834 | static void |
ca08c43d | 2835 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 2836 | { |
ca08c43d DS |
2837 | json_object *json_area = NULL; |
2838 | ||
2839 | if (use_json) | |
2840 | json_area = json_object_new_object(); | |
2841 | ||
718e3744 | 2842 | /* Show Area ID. */ |
ca08c43d DS |
2843 | if (!use_json) |
2844 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 2845 | |
2846 | /* Show Area type/mode. */ | |
2847 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
2848 | { |
2849 | if (use_json) | |
2850 | json_object_boolean_true_add(json_area, "backbone"); | |
2851 | else | |
2852 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
2853 | } | |
718e3744 | 2854 | else |
2855 | { | |
ca08c43d DS |
2856 | if (use_json) |
2857 | { | |
2858 | if (area->external_routing == OSPF_AREA_STUB) | |
2859 | { | |
2860 | if (area->no_summary) | |
2861 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
2862 | if (area->shortcut_configured) | |
2863 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
2864 | } | |
2865 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2866 | { | |
2867 | if (area->no_summary) | |
2868 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
2869 | if (area->shortcut_configured) | |
2870 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
2871 | } | |
2872 | ||
2873 | json_object_string_add(json_area,"shortcuttingMode", | |
2874 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
2875 | if (area->shortcut_capability) | |
2876 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
2877 | } | |
2878 | else | |
2879 | { | |
2880 | if (area->external_routing == OSPF_AREA_STUB) | |
2881 | vty_out (vty, " (Stub%s%s)", | |
2882 | area->no_summary ? ", no summary" : "", | |
2883 | area->shortcut_configured ? "; " : ""); | |
2884 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2885 | vty_out (vty, " (NSSA%s%s)", | |
2886 | area->no_summary ? ", no summary" : "", | |
2887 | area->shortcut_configured ? "; " : ""); | |
2888 | ||
2889 | vty_out (vty, "%s", VTY_NEWLINE); | |
2890 | vty_out (vty, " Shortcutting mode: %s", | |
2891 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
2892 | vty_out (vty, ", S-bit consensus: %s%s", | |
2893 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); | |
2894 | } | |
2895 | } | |
2896 | ||
2897 | /* Show number of interfaces */ | |
2898 | if (use_json) | |
2899 | { | |
3ac237f8 MS |
2900 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
2901 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 2902 | } |
ca08c43d DS |
2903 | else |
2904 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
2905 | "Active: %d%s", listcount (area->oiflist), | |
2906 | area->act_ints, VTY_NEWLINE); | |
718e3744 | 2907 | |
718e3744 | 2908 | if (area->external_routing == OSPF_AREA_NSSA) |
2909 | { | |
ca08c43d DS |
2910 | if (use_json) |
2911 | { | |
2912 | json_object_boolean_true_add(json_area, "nssa"); | |
2913 | if (! IS_OSPF_ABR (area->ospf)) | |
2914 | json_object_boolean_false_add(json_area, "abr"); | |
2915 | else if (area->NSSATranslatorState) | |
2916 | { | |
2917 | json_object_boolean_true_add(json_area, "abr"); | |
2918 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2919 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
2920 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
2921 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
2922 | } | |
2923 | else | |
2924 | { | |
2925 | json_object_boolean_true_add(json_area, "abr"); | |
2926 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2927 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
2928 | else | |
2929 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
2930 | } | |
2931 | } | |
718e3744 | 2932 | else |
ca08c43d DS |
2933 | { |
2934 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
2935 | if (! IS_OSPF_ABR (area->ospf)) | |
2936 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
2937 | VTY_NEWLINE); | |
2938 | else if (area->NSSATranslatorState) | |
2939 | { | |
2940 | vty_out (vty, " We are an ABR and "); | |
2941 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2942 | vty_out (vty, "the NSSA Elected Translator. %s", | |
2943 | VTY_NEWLINE); | |
2944 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
2945 | vty_out (vty, "always an NSSA Translator. %s", | |
2946 | VTY_NEWLINE); | |
2947 | } | |
2948 | else | |
2949 | { | |
2950 | vty_out (vty, " We are an ABR, but "); | |
2951 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2952 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
2953 | VTY_NEWLINE); | |
2954 | else | |
2955 | vty_out (vty, "never an NSSA Translator. %s", | |
2956 | VTY_NEWLINE); | |
2957 | } | |
2958 | } | |
718e3744 | 2959 | } |
ca08c43d | 2960 | |
88d6cf37 | 2961 | /* Stub-router state for this area */ |
2962 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
2963 | { | |
649654ab | 2964 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
2965 | |
2966 | if (use_json) | |
2967 | { | |
2968 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
2969 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2970 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
2971 | if (area->t_stub_router) | |
2972 | { | |
2973 | struct timeval result; | |
2974 | unsigned long time_store = 0; | |
2975 | result = tv_sub (area->t_stub_router->u.sands, recent_relative_time()); | |
2976 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
2977 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); | |
2978 | } | |
2979 | } | |
2980 | else | |
2981 | { | |
2982 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
2983 | VTY_NEWLINE); | |
2984 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2985 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
2986 | VTY_NEWLINE); | |
2987 | if (area->t_stub_router) | |
2988 | vty_out (vty, " Active from startup, %s remaining%s", | |
2989 | ospf_timer_dump (area->t_stub_router, timebuf, | |
2990 | sizeof(timebuf)), VTY_NEWLINE); | |
2991 | } | |
2992 | } | |
2993 | ||
2994 | if (use_json) | |
2995 | { | |
2996 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 2997 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
2998 | |
2999 | /* Show authentication type. */ | |
3000 | if (area->auth_type == OSPF_AUTH_NULL) | |
3001 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
3002 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3003 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
3004 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3005 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
3006 | ||
3007 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 3008 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
3009 | |
3010 | /* Show SPF calculation times. */ | |
3ac237f8 | 3011 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
3012 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
3013 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
3014 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
3015 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
3016 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
3017 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
3018 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
3019 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3020 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3021 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
3022 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 3023 | } |
ca08c43d DS |
3024 | else |
3025 | { | |
3026 | /* Show number of fully adjacent neighbors. */ | |
3027 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
3028 | " %d%s", area->full_nbrs, VTY_NEWLINE); | |
3029 | ||
3030 | /* Show authentication type. */ | |
3031 | vty_out (vty, " Area has "); | |
3032 | if (area->auth_type == OSPF_AUTH_NULL) | |
3033 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
3034 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3035 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
3036 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3037 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
3038 | ||
3039 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3040 | vty_out (vty, " Number of full virtual adjacencies going through" | |
3041 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
3042 | ||
3043 | /* Show SPF calculation times. */ | |
3044 | vty_out (vty, " SPF algorithm executed %d times%s", | |
3045 | area->spf_calculation, VTY_NEWLINE); | |
3046 | ||
3047 | /* Show number of LSA. */ | |
3048 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
3049 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", | |
3050 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
3051 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
3052 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
3053 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
3054 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
3055 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
3056 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
3057 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
3058 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
3059 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
3060 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
3061 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
3062 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
3063 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
3064 | } | |
3065 | ||
ca08c43d DS |
3066 | if (use_json) |
3067 | { | |
3068 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3069 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3070 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3071 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3072 | } | |
3073 | else | |
3074 | { | |
3075 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
3076 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
3077 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
3078 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
3079 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
3080 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
3081 | } | |
ca08c43d DS |
3082 | |
3083 | if (use_json) | |
3084 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
3085 | else | |
3086 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 3087 | } |
3088 | ||
7c8ff89e | 3089 | static int |
ca08c43d | 3090 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3091 | { |
1eb8ef25 | 3092 | struct listnode *node, *nnode; |
718e3744 | 3093 | struct ospf_area * area; |
d24f6e2a | 3094 | struct timeval result; |
649654ab | 3095 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3096 | json_object *json = NULL; |
3097 | json_object *json_areas = NULL; | |
3098 | ||
3099 | if (use_json) | |
3100 | json = json_object_new_object(); | |
3101 | json_areas = json_object_new_object(); | |
718e3744 | 3102 | |
7c8ff89e | 3103 | if (ospf->instance) |
ca08c43d DS |
3104 | { |
3105 | if (use_json) | |
3106 | { | |
3107 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3108 | } | |
3109 | else | |
3110 | { | |
3111 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3112 | VTY_NEWLINE, VTY_NEWLINE); | |
3113 | } | |
3114 | } | |
718e3744 | 3115 | |
3116 | /* Show Router ID. */ | |
ca08c43d DS |
3117 | if (use_json) |
3118 | { | |
3119 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
3120 | } | |
3121 | else | |
3122 | { | |
3123 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
3124 | inet_ntoa (ospf->router_id), | |
3125 | VTY_NEWLINE); | |
3126 | } | |
7c8ff89e | 3127 | |
88d6cf37 | 3128 | /* Graceful shutdown */ |
c9c93d50 | 3129 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
3130 | { |
3131 | if (use_json) | |
3132 | { | |
3133 | unsigned long time_store = 0; | |
3134 | result = tv_sub (ospf->t_deferred_shutdown->u.sands, recent_relative_time()); | |
3135 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3136 | json_object_int_add(json, "deferredShutdownMsecs", time_store); | |
3137 | } | |
3138 | else | |
3139 | { | |
3140 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
3141 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
3142 | timebuf, sizeof (timebuf)), VTY_NEWLINE); | |
3143 | } | |
3144 | } | |
3145 | ||
718e3744 | 3146 | /* Show capability. */ |
ca08c43d DS |
3147 | if (use_json) |
3148 | { | |
3149 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
3150 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
3151 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
3152 | { | |
3153 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
3154 | } | |
3155 | } | |
3156 | else | |
3157 | { | |
3158 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
3159 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
3160 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
3161 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
3162 | "enabled" : "disabled", VTY_NEWLINE); | |
3163 | } | |
3164 | ||
ca08c43d DS |
3165 | if (use_json) |
3166 | { | |
3167 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
3168 | { | |
3169 | json_object_boolean_true_add(json, "opaqueCapable"); | |
3170 | } | |
ca08c43d DS |
3171 | } |
3172 | else | |
3173 | { | |
801e0e14 | 3174 | vty_out (vty, " OpaqueCapability flag is %s%s", |
ca08c43d | 3175 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", |
ca08c43d DS |
3176 | VTY_NEWLINE); |
3177 | } | |
ca08c43d | 3178 | |
88d6cf37 | 3179 | /* Show stub-router configuration */ |
3180 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3181 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3182 | { | |
ca08c43d DS |
3183 | if (use_json) |
3184 | { | |
3185 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3186 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3187 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3188 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3189 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3190 | } | |
3191 | else | |
3192 | { | |
3193 | vty_out (vty, " Stub router advertisement is configured%s", | |
3194 | VTY_NEWLINE); | |
3195 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3196 | vty_out (vty, " Enabled for %us after start-up%s", | |
3197 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3198 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3199 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3200 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3201 | } | |
88d6cf37 | 3202 | } |
ca08c43d | 3203 | |
718e3744 | 3204 | /* Show SPF timers. */ |
ca08c43d DS |
3205 | if (use_json) |
3206 | { | |
3207 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3208 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3209 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3210 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3211 | } |
3212 | else | |
ca08c43d DS |
3213 | { |
3214 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3215 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3216 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3217 | " Hold time multiplier is currently %d%s", | |
3218 | ospf->spf_delay, VTY_NEWLINE, | |
3219 | ospf->spf_holdtime, VTY_NEWLINE, | |
3220 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3221 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
3222 | } | |
b6927875 | 3223 | |
ca08c43d DS |
3224 | if (use_json) |
3225 | { | |
3226 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3227 | { | |
3228 | unsigned long time_store = 0; | |
3229 | ||
3230 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3231 | result = tv_sub (result, recent_relative_time()); | |
3232 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3233 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); | |
3234 | ||
3235 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3236 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3237 | } | |
3238 | else | |
3239 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3240 | } | |
3241 | else | |
3242 | { | |
3243 | vty_out (vty, " SPF algorithm "); | |
3244 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3245 | { | |
3246 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3247 | vty_out (vty, "last executed %s ago%s", | |
3248 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3249 | VTY_NEWLINE); | |
3250 | vty_out (vty, " Last SPF duration %s%s", | |
3251 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3252 | VTY_NEWLINE); | |
3253 | } | |
3254 | else | |
3255 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
3256 | } | |
3257 | ||
3258 | if (use_json) | |
3259 | { | |
3260 | struct timeval temp_time; | |
3261 | unsigned long time_store = 0; | |
3262 | ||
3263 | if (ospf->t_spf_calc) | |
3264 | { | |
3265 | temp_time = tv_sub (ospf->t_spf_calc->u.sands, recent_relative_time()); | |
3266 | time_store = (1000 * temp_time.tv_sec) + (temp_time.tv_usec / 1000); | |
3267 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); | |
3268 | } | |
3269 | ||
ac7424f9 MR |
3270 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3271 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3272 | /* Show write multiplier values */ |
3273 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3274 | /* Show refresh parameters. */ | |
54b7214f | 3275 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000); |
ca08c43d DS |
3276 | } |
3277 | else | |
3278 | { | |
3279 | vty_out (vty, " SPF timer %s%s%s", | |
3280 | (ospf->t_spf_calc ? "due in " : "is "), | |
3281 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3282 | VTY_NEWLINE); | |
3283 | ||
ac7424f9 MR |
3284 | vty_out (vty, " LSA minimum interval %d msecs%s", |
3285 | ospf->min_ls_interval, VTY_NEWLINE); | |
ca08c43d | 3286 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
ac7424f9 | 3287 | ospf->min_ls_arrival, VTY_NEWLINE); |
ca08c43d DS |
3288 | |
3289 | /* Show write multiplier values */ | |
3290 | vty_out (vty, " Write Multiplier set to %d %s", | |
3291 | ospf->write_oi_count, VTY_NEWLINE); | |
3292 | ||
3293 | /* Show refresh parameters. */ | |
3294 | vty_out (vty, " Refresh timer %d secs%s", | |
3295 | ospf->lsa_refresh_interval, VTY_NEWLINE); | |
3296 | } | |
2f8f370e | 3297 | |
718e3744 | 3298 | /* Show ABR/ASBR flags. */ |
68980084 | 3299 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3300 | { |
3301 | if (use_json) | |
3302 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3303 | else | |
3304 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
3305 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); | |
3306 | } | |
68980084 | 3307 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3308 | { |
3309 | if (use_json) | |
3310 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3311 | else | |
3312 | vty_out (vty, " This router is an ASBR " | |
3313 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3314 | } | |
718e3744 | 3315 | |
3316 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3317 | if (use_json) |
3318 | { | |
3ac237f8 | 3319 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3320 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3321 | json_object_int_add(json, "lsaExternalChecksum", | |
3322 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3323 | } | |
3324 | else | |
3325 | { | |
3326 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3327 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3328 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3329 | } | |
3330 | ||
ca08c43d DS |
3331 | if (use_json) |
3332 | { | |
3ac237f8 | 3333 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3334 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3335 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3336 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3337 | } | |
3338 | else | |
3339 | { | |
3340 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3341 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3342 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3343 | } | |
ca08c43d | 3344 | |
718e3744 | 3345 | /* Show number of areas attached. */ |
ca08c43d | 3346 | if (use_json) |
3ac237f8 | 3347 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3348 | else |
3349 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
3350 | listcount (ospf->areas), VTY_NEWLINE); | |
d7e60dd7 AS |
3351 | |
3352 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3353 | { | |
3354 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3355 | { |
3356 | if (use_json) | |
3357 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3358 | else | |
3359 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3360 | } | |
d7e60dd7 | 3361 | else |
ca08c43d DS |
3362 | { |
3363 | if (use_json) | |
3364 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3365 | else | |
3366 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3367 | } | |
d7e60dd7 | 3368 | } |
718e3744 | 3369 | /* Show each area status. */ |
1eb8ef25 | 3370 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3371 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3372 | ||
3373 | if (use_json) | |
3374 | { | |
3375 | json_object_object_add(json, "areas", json_areas); | |
2aac5767 | 3376 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
ca08c43d DS |
3377 | json_object_free(json); |
3378 | } | |
3379 | else | |
3380 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3381 | |
3382 | return CMD_SUCCESS; | |
3383 | } | |
3384 | ||
7c8ff89e DS |
3385 | DEFUN (show_ip_ospf, |
3386 | show_ip_ospf_cmd, | |
b162fa78 | 3387 | "show ip ospf [json]", |
7c8ff89e DS |
3388 | SHOW_STR |
3389 | IP_STR | |
ca08c43d DS |
3390 | "OSPF information\n" |
3391 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3392 | { |
3393 | struct ospf *ospf; | |
db7c8528 | 3394 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3395 | |
0bad4851 | 3396 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3397 | return CMD_SUCCESS; |
3398 | ||
db7c8528 | 3399 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3400 | } |
3401 | ||
3402 | DEFUN (show_ip_ospf_instance, | |
3403 | show_ip_ospf_instance_cmd, | |
6147e2c6 | 3404 | "show ip ospf (1-65535) [json]", |
7c8ff89e DS |
3405 | SHOW_STR |
3406 | IP_STR | |
3407 | "OSPF information\n" | |
ca08c43d DS |
3408 | "Instance ID\n" |
3409 | "JavaScript Object Notation\n") | |
7c8ff89e | 3410 | { |
8d769265 | 3411 | int idx_number = 3; |
7c8ff89e DS |
3412 | struct ospf *ospf; |
3413 | u_short instance = 0; | |
db7c8528 | 3414 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3415 | |
8d769265 | 3416 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3417 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3418 | return CMD_SUCCESS; |
3419 | ||
db7c8528 | 3420 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3421 | } |
3422 | ||
fd651fa6 | 3423 | static void |
7ec4159b DS |
3424 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3425 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3426 | { |
fd651fa6 | 3427 | int is_up; |
718e3744 | 3428 | struct ospf_neighbor *nbr; |
718e3744 | 3429 | struct route_node *rn; |
718e3744 | 3430 | |
718e3744 | 3431 | /* Is interface up? */ |
7ec4159b DS |
3432 | if (use_json) |
3433 | { | |
3434 | is_up = if_is_operative(ifp); | |
3435 | if (is_up) | |
3436 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3437 | else | |
3438 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3439 | ||
3440 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3441 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
70bd3c43 | 3442 | json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth); |
7ec4159b DS |
3443 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); |
3444 | } | |
3445 | else | |
3446 | { | |
3447 | vty_out (vty, "%s is %s%s", ifp->name, | |
3448 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
70bd3c43 | 3449 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s", |
7ec4159b DS |
3450 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
3451 | VTY_NEWLINE); | |
3452 | } | |
718e3744 | 3453 | |
3454 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3455 | if (use_json) |
718e3744 | 3456 | { |
7ec4159b DS |
3457 | if (ospf_oi_count(ifp) == 0) |
3458 | { | |
3459 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3460 | return; | |
3461 | } | |
3462 | else if (!is_up) | |
3463 | { | |
3464 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3465 | return; | |
3466 | } | |
3467 | else | |
3468 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3469 | } |
7ec4159b | 3470 | else |
fd651fa6 | 3471 | { |
7ec4159b DS |
3472 | if (ospf_oi_count(ifp) == 0) |
3473 | { | |
3474 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3475 | return; | |
3476 | } | |
3477 | else if (!is_up) | |
3478 | { | |
3479 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3480 | VTY_NEWLINE); | |
3481 | return; | |
3482 | } | |
fd651fa6 | 3483 | } |
3484 | ||
718e3744 | 3485 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3486 | { | |
3487 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3488 | |
718e3744 | 3489 | if (oi == NULL) |
7ec4159b DS |
3490 | continue; |
3491 | ||
525c1839 DS |
3492 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3493 | { | |
7ec4159b DS |
3494 | if (use_json) |
3495 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3496 | else | |
3497 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3498 | } |
3499 | else | |
9c27ef9b | 3500 | { |
525c1839 | 3501 | /* Show OSPF interface information. */ |
7ec4159b DS |
3502 | if (use_json) |
3503 | { | |
3504 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3505 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3506 | } | |
3507 | else | |
3508 | vty_out (vty, " Internet Address %s/%d,", | |
3509 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3510 | |
3511 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3512 | { | |
3513 | struct in_addr *dest; | |
3514 | const char *dstr; | |
3515 | ||
3516 | if (CONNECTED_PEER(oi->connected) | |
3517 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3518 | dstr = "Peer"; | |
3519 | else | |
3520 | dstr = "Broadcast"; | |
3521 | ||
3522 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3523 | * * * * * informative than the local interface that is being used |
3524 | * * * * */ | |
525c1839 DS |
3525 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3526 | dest = &oi->vl_data->peer_addr; | |
3527 | else | |
3528 | dest = &oi->connected->destination->u.prefix4; | |
3529 | ||
7ec4159b DS |
3530 | if (use_json) |
3531 | { | |
3532 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3533 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3534 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3535 | else | |
3536 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3537 | } | |
3538 | else | |
3539 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3540 | } |
9c27ef9b | 3541 | } |
7ec4159b DS |
3542 | if (use_json) |
3543 | { | |
3544 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3545 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3546 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3547 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3548 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3549 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3550 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
3551 | json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state)); | |
3552 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); | |
3553 | } | |
3554 | else | |
3555 | { | |
3556 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), | |
3557 | VTY_NEWLINE); | |
3fb9cd6e | 3558 | |
7ec4159b DS |
3559 | vty_out (vty, " MTU mismatch detection:%s%s", |
3560 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
ba682537 | 3561 | |
7ec4159b DS |
3562 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
3563 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3564 | oi->output_cost, VTY_NEWLINE); | |
718e3744 | 3565 | |
7ec4159b DS |
3566 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
3567 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3568 | PRIORITY (oi), VTY_NEWLINE); | |
3569 | } | |
718e3744 | 3570 | |
3571 | /* Show DR information. */ | |
3572 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3573 | { |
3574 | if (!use_json) | |
3575 | vty_out (vty, " No backup designated router on this network%s", | |
3576 | VTY_NEWLINE); | |
3577 | } | |
718e3744 | 3578 | else |
7ec4159b DS |
3579 | { |
3580 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3581 | if (nbr == NULL) | |
3582 | { | |
3583 | if (!use_json) | |
3584 | vty_out (vty, " No backup designated router on this network%s", | |
3585 | VTY_NEWLINE); | |
3586 | } | |
3587 | else | |
3588 | { | |
3589 | if (use_json) | |
3590 | { | |
3591 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3592 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3593 | } | |
3594 | else | |
3595 | { | |
3596 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3597 | inet_ntoa (nbr->router_id)); | |
3598 | vty_out (vty, " Interface Address %s%s", | |
3599 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3600 | } | |
3601 | } | |
3602 | } | |
525c1839 | 3603 | |
7eb5b47e | 3604 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3605 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3606 | { |
7ec4159b DS |
3607 | if (use_json) |
3608 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3609 | else | |
3610 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3611 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3612 | } | |
3613 | ||
3614 | if (use_json) | |
3615 | { | |
3616 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3617 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3618 | { | |
3619 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3620 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3621 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3622 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3623 | } | |
429ac78c PJ |
3624 | } |
3625 | else | |
7ec4159b DS |
3626 | { |
3627 | vty_out (vty, " Multicast group memberships:"); | |
3628 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3629 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3630 | { | |
3631 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3632 | vty_out (vty, " OSPFAllRouters"); | |
3633 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3634 | vty_out (vty, " OSPFDesignatedRouters"); | |
3635 | } | |
3636 | else | |
3637 | vty_out (vty, " <None>"); | |
3638 | vty_out (vty, "%s", VTY_NEWLINE); | |
3639 | } | |
ba6454ec | 3640 | |
7ec4159b DS |
3641 | if (use_json) |
3642 | { | |
3643 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3644 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3645 | else | |
3646 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3647 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3648 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3649 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3650 | } | |
f9ad937f | 3651 | else |
7ec4159b DS |
3652 | { |
3653 | vty_out (vty, " Timer intervals configured,"); | |
3654 | vty_out (vty, " Hello "); | |
3655 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3656 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3657 | else | |
3658 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3659 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3660 | OSPF_IF_PARAM (oi, v_wait), | |
3661 | OSPF_IF_PARAM (oi, v_wait), | |
3662 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3663 | VTY_NEWLINE); | |
3664 | } | |
3665 | ||
7ffa8fa2 | 3666 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3667 | { |
7ec4159b DS |
3668 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3669 | if (use_json) | |
3670 | { | |
3671 | struct timeval result; | |
3672 | unsigned long time_store = 0; | |
b8dfa544 DS |
3673 | if (oi->t_hello) |
3674 | result = tv_sub (oi->t_hello->u.sands, recent_relative_time()); | |
3675 | else | |
3676 | { | |
3677 | result.tv_sec = 0; | |
3678 | result.tv_usec = 0; | |
3679 | } | |
7ec4159b DS |
3680 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); |
3681 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); | |
3682 | } | |
3683 | else | |
3684 | vty_out (vty, " Hello due in %s%s", | |
3685 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
3686 | VTY_NEWLINE); | |
f9ad937f | 3687 | } |
7ffa8fa2 | 3688 | else /* passive-interface is set */ |
7ec4159b DS |
3689 | { |
3690 | if (use_json) | |
3691 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3692 | else | |
3693 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); | |
3694 | } | |
3695 | ||
3696 | if (use_json) | |
3697 | { | |
3698 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3699 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3700 | } | |
3701 | else | |
3702 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3703 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
3704 | VTY_NEWLINE); | |
68fe91d6 | 3705 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3706 | } |
3707 | } | |
3708 | ||
7c8ff89e | 3709 | static int |
7ec4159b | 3710 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
7a7be519 | 3711 | struct cmd_token **argv, int iface_argv, u_char use_json) |
718e3744 | 3712 | { |
3713 | struct interface *ifp; | |
52dc7ee6 | 3714 | struct listnode *node; |
7ec4159b DS |
3715 | json_object *json = NULL; |
3716 | json_object *json_interface_sub = NULL; | |
3717 | ||
3718 | if (use_json) | |
3719 | { | |
3720 | json = json_object_new_object(); | |
3721 | json_interface_sub = json_object_new_object(); | |
3722 | } | |
718e3744 | 3723 | |
7c8ff89e | 3724 | if (ospf->instance) |
7ec4159b DS |
3725 | { |
3726 | if (use_json) | |
3727 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3728 | else | |
3729 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3730 | VTY_NEWLINE, VTY_NEWLINE); | |
3731 | } | |
7c8ff89e | 3732 | |
7ec4159b DS |
3733 | if (argc == (iface_argv + 1)) |
3734 | { | |
3735 | /* Show All Interfaces.*/ | |
b2d7c082 | 3736 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3737 | { |
3738 | if (ospf_oi_count(ifp)) | |
3739 | { | |
3740 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3741 | if (use_json) |
3742 | json_object_object_add (json, ifp->name, json_interface_sub); | |
7ec4159b DS |
3743 | } |
3744 | } | |
3745 | } | |
7a7be519 | 3746 | else if (argv[iface_argv] && strcmp(argv[iface_argv]->arg, "json") == 0) |
cac3b5c4 | 3747 | { |
b8dfa544 DS |
3748 | if (!use_json) |
3749 | { | |
3750 | json = json_object_new_object(); | |
3751 | json_interface_sub = json_object_new_object (); | |
3752 | use_json = 1; | |
3753 | } | |
7c8ff89e | 3754 | /* Show All Interfaces. */ |
b2d7c082 | 3755 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3756 | { |
3757 | if (ospf_oi_count(ifp)) | |
3758 | { | |
3759 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3760 | if (use_json) |
3761 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3762 | } | |
3763 | } | |
cac3b5c4 | 3764 | } |
718e3744 | 3765 | else |
3766 | { | |
7c8ff89e | 3767 | /* Interface name is specified. */ |
7a7be519 | 3768 | if ((ifp = if_lookup_by_name (argv[iface_argv]->arg)) == NULL) |
7ec4159b DS |
3769 | { |
3770 | if (use_json) | |
3771 | json_object_boolean_true_add(json, "noSuchIface"); | |
3772 | else | |
3773 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
3774 | } | |
718e3744 | 3775 | else |
7ec4159b DS |
3776 | { |
3777 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3778 | if (use_json) | |
3779 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3780 | } | |
718e3744 | 3781 | } |
3782 | ||
7ec4159b DS |
3783 | if (use_json) |
3784 | { | |
2aac5767 | 3785 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
7ec4159b DS |
3786 | json_object_free(json); |
3787 | } | |
3788 | else | |
3789 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3790 | |
718e3744 | 3791 | return CMD_SUCCESS; |
3792 | } | |
3793 | ||
7c8ff89e DS |
3794 | DEFUN (show_ip_ospf_interface, |
3795 | show_ip_ospf_interface_cmd, | |
b162fa78 | 3796 | "show ip ospf interface [INTERFACE] [json]", |
7c8ff89e DS |
3797 | SHOW_STR |
3798 | IP_STR | |
3799 | "OSPF information\n" | |
3800 | "Interface information\n" | |
7ec4159b DS |
3801 | "Interface name\n" |
3802 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3803 | { |
3804 | struct ospf *ospf; | |
db7c8528 | 3805 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3806 | |
0bad4851 | 3807 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3808 | return CMD_SUCCESS; |
3809 | ||
db7c8528 | 3810 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj); |
7c8ff89e DS |
3811 | } |
3812 | ||
3813 | DEFUN (show_ip_ospf_instance_interface, | |
3814 | show_ip_ospf_instance_interface_cmd, | |
6147e2c6 | 3815 | "show ip ospf (1-65535) interface [INTERFACE] [json]", |
7c8ff89e DS |
3816 | SHOW_STR |
3817 | IP_STR | |
3818 | "OSPF information\n" | |
3819 | "Instance ID\n" | |
3820 | "Interface information\n" | |
7ec4159b DS |
3821 | "Interface name\n" |
3822 | "JavaScript Object Notation\n") | |
7c8ff89e | 3823 | { |
8d769265 | 3824 | int idx_number = 3; |
7c8ff89e DS |
3825 | struct ospf *ospf; |
3826 | u_short instance = 0; | |
db7c8528 | 3827 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3828 | |
8d769265 | 3829 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3830 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3831 | return CMD_SUCCESS; |
3832 | ||
db7c8528 | 3833 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj); |
7c8ff89e DS |
3834 | } |
3835 | ||
d24f6e2a | 3836 | static void |
3837 | show_ip_ospf_neighbour_header (struct vty *vty) | |
3838 | { | |
490578f3 | 3839 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 3840 | VTY_NEWLINE, |
3841 | "Neighbor ID", "Pri", "State", "Dead Time", | |
3842 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
3843 | VTY_NEWLINE); | |
3844 | } | |
3845 | ||
4dadc291 | 3846 | static void |
91756b38 | 3847 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 3848 | { |
3849 | struct route_node *rn; | |
3850 | struct ospf_neighbor *nbr; | |
3851 | char msgbuf[16]; | |
649654ab | 3852 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 3853 | json_object *json_neighbor = NULL; |
718e3744 | 3854 | |
3855 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
3856 | { |
3857 | if ((nbr = rn->info)) | |
3858 | { | |
3859 | /* Do not show myself. */ | |
3860 | if (nbr != oi->nbr_self) | |
3861 | { | |
3862 | /* Down state is not shown. */ | |
3863 | if (nbr->state != NSM_Down) | |
3864 | { | |
3865 | if (use_json) | |
3866 | { | |
3867 | json_neighbor = json_object_new_object(); | |
3868 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3869 | ||
3870 | struct timeval result; | |
3871 | unsigned long time_store = 0; | |
3872 | ||
3873 | result = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time()); | |
3874 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3875 | ||
3876 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
3877 | json_object_string_add (json_neighbor, "state", msgbuf); | |
3878 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
3879 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
3880 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
3881 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
3882 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
3883 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
3884 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
3885 | json_object_object_add(json, "neighbor", json_neighbor); | |
3886 | else | |
3887 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
3888 | } | |
3889 | else | |
3890 | { | |
3891 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3892 | ||
3893 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
3894 | vty_out (vty, "%-15s %3d %-15s ", | |
3895 | "-", nbr->priority, | |
3896 | msgbuf); | |
3897 | else | |
3898 | vty_out (vty, "%-15s %3d %-15s ", | |
3899 | inet_ntoa (nbr->router_id), nbr->priority, | |
3900 | msgbuf); | |
3901 | ||
3902 | vty_out (vty, "%9s ", | |
3903 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
3904 | sizeof(timebuf))); | |
3905 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
3906 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
3907 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
3908 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
3909 | VTY_NEWLINE); | |
3910 | } | |
3911 | } | |
3912 | } | |
3913 | } | |
3914 | } | |
718e3744 | 3915 | } |
3916 | ||
7c8ff89e | 3917 | static int |
91756b38 | 3918 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3919 | { |
1eb8ef25 | 3920 | struct ospf_interface *oi; |
52dc7ee6 | 3921 | struct listnode *node; |
91756b38 | 3922 | json_object *json = NULL; |
718e3744 | 3923 | |
91756b38 DS |
3924 | if (use_json) |
3925 | json = json_object_new_object(); | |
3926 | else | |
3927 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 3928 | |
91756b38 DS |
3929 | if (ospf->instance) |
3930 | { | |
3931 | if (use_json) | |
3932 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3933 | else | |
3934 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3935 | VTY_NEWLINE, VTY_NEWLINE); | |
3936 | } | |
718e3744 | 3937 | |
1eb8ef25 | 3938 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 3939 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3940 | |
91756b38 DS |
3941 | if (use_json) |
3942 | { | |
2aac5767 | 3943 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
3944 | json_object_free(json); |
3945 | } | |
3946 | else | |
3947 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3948 | |
718e3744 | 3949 | return CMD_SUCCESS; |
3950 | } | |
3951 | ||
7c8ff89e DS |
3952 | DEFUN (show_ip_ospf_neighbor, |
3953 | show_ip_ospf_neighbor_cmd, | |
b162fa78 | 3954 | "show ip ospf neighbor [json]", |
718e3744 | 3955 | SHOW_STR |
3956 | IP_STR | |
3957 | "OSPF information\n" | |
91756b38 DS |
3958 | "Neighbor list\n" |
3959 | "JavaScript Object Notation\n") | |
718e3744 | 3960 | { |
7c8ff89e | 3961 | struct ospf *ospf; |
db7c8528 | 3962 | u_char uj = use_json(argc, argv); |
718e3744 | 3963 | |
0bad4851 | 3964 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3965 | return CMD_SUCCESS; |
3966 | ||
db7c8528 | 3967 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
3968 | } |
3969 | ||
3970 | ||
3971 | DEFUN (show_ip_ospf_instance_neighbor, | |
3972 | show_ip_ospf_instance_neighbor_cmd, | |
6147e2c6 | 3973 | "show ip ospf (1-65535) neighbor [json]", |
7c8ff89e DS |
3974 | SHOW_STR |
3975 | IP_STR | |
3976 | "OSPF information\n" | |
3977 | "Instance ID\n" | |
91756b38 DS |
3978 | "Neighbor list\n" |
3979 | "JavaScript Object Notation\n") | |
7c8ff89e | 3980 | { |
8d769265 | 3981 | int idx_number = 3; |
7c8ff89e DS |
3982 | struct ospf *ospf; |
3983 | u_short instance = 0; | |
db7c8528 | 3984 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3985 | |
8d769265 | 3986 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3987 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3988 | return CMD_SUCCESS; |
3989 | ||
db7c8528 | 3990 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
3991 | } |
3992 | ||
3993 | static int | |
91756b38 | 3994 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
3995 | { |
3996 | struct listnode *node; | |
3997 | struct ospf_interface *oi; | |
91756b38 DS |
3998 | json_object *json = NULL; |
3999 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 4000 | |
91756b38 DS |
4001 | if (use_json) |
4002 | { | |
4003 | json = json_object_new_object(); | |
4004 | json_neighbor_sub = json_object_new_object(); | |
4005 | } | |
4006 | else | |
4007 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 4008 | |
91756b38 DS |
4009 | if (ospf->instance) |
4010 | { | |
4011 | if (use_json) | |
4012 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4013 | else | |
4014 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4015 | VTY_NEWLINE, VTY_NEWLINE); | |
4016 | } | |
7c8ff89e DS |
4017 | |
4018 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
4019 | { | |
52dc7ee6 | 4020 | struct listnode *nbr_node; |
1eb8ef25 | 4021 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4022 | |
91756b38 | 4023 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4024 | |
91756b38 DS |
4025 | /* print Down neighbor status */ |
4026 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
4027 | { | |
4028 | if (nbr_nbma->nbr == NULL | |
4029 | || nbr_nbma->nbr->state == NSM_Down) | |
4030 | { | |
4031 | if (use_json) | |
4032 | { | |
4033 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
4034 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
4035 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4036 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
4037 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
4038 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
4039 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
4040 | } | |
4041 | else | |
4042 | { | |
4043 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
4044 | "-", nbr_nbma->priority, "Down", "-"); | |
4045 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
4046 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
4047 | 0, 0, 0, VTY_NEWLINE); | |
4048 | } | |
4049 | } | |
4050 | } | |
718e3744 | 4051 | } |
4052 | ||
91756b38 DS |
4053 | if (use_json) |
4054 | { | |
2aac5767 | 4055 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
4056 | json_object_free(json); |
4057 | } | |
4058 | else | |
4059 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4060 | |
718e3744 | 4061 | return CMD_SUCCESS; |
4062 | } | |
4063 | ||
7c8ff89e DS |
4064 | DEFUN (show_ip_ospf_neighbor_all, |
4065 | show_ip_ospf_neighbor_all_cmd, | |
b162fa78 | 4066 | "show ip ospf neighbor all [json]", |
718e3744 | 4067 | SHOW_STR |
4068 | IP_STR | |
4069 | "OSPF information\n" | |
4070 | "Neighbor list\n" | |
91756b38 DS |
4071 | "include down status neighbor\n" |
4072 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4073 | { |
4074 | struct ospf *ospf; | |
db7c8528 | 4075 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4076 | |
0bad4851 | 4077 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4078 | return CMD_SUCCESS; |
4079 | ||
db7c8528 | 4080 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4081 | } |
4082 | ||
4083 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
4084 | show_ip_ospf_instance_neighbor_all_cmd, | |
6147e2c6 | 4085 | "show ip ospf (1-65535) neighbor all [json]", |
7c8ff89e DS |
4086 | SHOW_STR |
4087 | IP_STR | |
4088 | "OSPF information\n" | |
4089 | "Instance ID\n" | |
4090 | "Neighbor list\n" | |
91756b38 DS |
4091 | "include down status neighbor\n" |
4092 | "JavaScript Object Notation\n") | |
718e3744 | 4093 | { |
8d769265 | 4094 | int idx_number = 3; |
020709f9 | 4095 | struct ospf *ospf; |
7c8ff89e | 4096 | u_short instance = 0; |
db7c8528 | 4097 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4098 | |
8d769265 | 4099 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4100 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4101 | return CMD_SUCCESS; |
4102 | ||
db7c8528 | 4103 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4104 | } |
4105 | ||
4106 | static int | |
4107 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
7a7be519 | 4108 | struct cmd_token **argv, u_char use_json) |
7c8ff89e | 4109 | { |
bb5b7552 | 4110 | struct interface *ifp; |
4111 | struct route_node *rn; | |
91756b38 DS |
4112 | json_object *json = NULL; |
4113 | ||
4114 | if (use_json) | |
4115 | json = json_object_new_object(); | |
4116 | else | |
4117 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
4118 | |
4119 | if (ospf->instance) | |
91756b38 DS |
4120 | { |
4121 | if (use_json) | |
4122 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4123 | else | |
4124 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4125 | VTY_NEWLINE, VTY_NEWLINE); | |
4126 | } | |
7c8ff89e | 4127 | |
7a7be519 | 4128 | ifp = if_lookup_by_name (argv[arg_base]->arg); |
bb5b7552 | 4129 | if (!ifp) |
718e3744 | 4130 | { |
91756b38 DS |
4131 | if (use_json) |
4132 | json_object_boolean_true_add(json, "noSuchIface"); | |
4133 | else | |
4134 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4135 | return CMD_WARNING; |
4136 | } | |
d24f6e2a | 4137 | |
bb5b7552 | 4138 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 4139 | { |
bb5b7552 | 4140 | struct ospf_interface *oi = rn->info; |
4141 | ||
4142 | if (oi == NULL) | |
91756b38 | 4143 | continue; |
bb5b7552 | 4144 | |
91756b38 | 4145 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4146 | } |
4147 | ||
91756b38 DS |
4148 | if (use_json) |
4149 | { | |
2aac5767 | 4150 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
4151 | json_object_free(json); |
4152 | } | |
4153 | else | |
4154 | vty_out (vty, "%s", VTY_NEWLINE); | |
4155 | ||
718e3744 | 4156 | return CMD_SUCCESS; |
4157 | } | |
4158 | ||
7c8ff89e DS |
4159 | DEFUN (show_ip_ospf_neighbor_int, |
4160 | show_ip_ospf_neighbor_int_cmd, | |
b162fa78 | 4161 | "show ip ospf neighbor IFNAME [json]", |
7c8ff89e DS |
4162 | SHOW_STR |
4163 | IP_STR | |
4164 | "OSPF information\n" | |
4165 | "Neighbor list\n" | |
91756b38 DS |
4166 | "Interface name\n" |
4167 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4168 | { |
4169 | struct ospf *ospf; | |
db7c8528 | 4170 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4171 | |
0bad4851 | 4172 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4173 | return CMD_SUCCESS; |
4174 | ||
db7c8528 | 4175 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4176 | } |
4177 | ||
4178 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
4179 | show_ip_ospf_instance_neighbor_int_cmd, | |
6147e2c6 | 4180 | "show ip ospf (1-65535) neighbor IFNAME [json]", |
7c8ff89e DS |
4181 | SHOW_STR |
4182 | IP_STR | |
4183 | "OSPF information\n" | |
4184 | "Instance ID\n" | |
4185 | "Neighbor list\n" | |
91756b38 DS |
4186 | "Interface name\n" |
4187 | "JavaScript Object Notation\n") | |
7c8ff89e | 4188 | { |
8d769265 | 4189 | int idx_number = 3; |
7c8ff89e DS |
4190 | struct ospf *ospf; |
4191 | u_short instance = 0; | |
db7c8528 | 4192 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4193 | |
8d769265 | 4194 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4195 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4196 | return CMD_SUCCESS; |
4197 | ||
db7c8528 | 4198 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4199 | } |
4200 | ||
4dadc291 | 4201 | static void |
3ac237f8 MS |
4202 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4203 | u_char use_json, json_object *json) | |
718e3744 | 4204 | { |
649654ab | 4205 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4206 | json_object *json_sub = NULL; |
718e3744 | 4207 | |
3ac237f8 MS |
4208 | if (use_json) |
4209 | json_sub = json_object_new_object(); | |
4210 | else /* Show neighbor ID. */ | |
4211 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4212 | |
4213 | /* Show interface address. */ | |
3ac237f8 MS |
4214 | if (use_json) |
4215 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4216 | else | |
4217 | vty_out (vty, " interface address %s%s", | |
4218 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
4219 | ||
718e3744 | 4220 | /* Show Area ID. */ |
3ac237f8 MS |
4221 | if (use_json) |
4222 | { | |
4223 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4224 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4225 | } | |
4226 | else | |
4227 | vty_out (vty, " In the area %s via interface %s%s", | |
4228 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
4229 | ||
718e3744 | 4230 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4231 | if (use_json) |
4232 | { | |
4233 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4234 | json_object_string_add(json_sub, "nbrState", "down"); | |
4235 | } | |
4236 | else | |
4237 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4238 | nbr_nbma->priority, "Down"); | |
4239 | ||
718e3744 | 4240 | /* Show state changes. */ |
3ac237f8 MS |
4241 | if (use_json) |
4242 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4243 | else | |
4244 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
718e3744 | 4245 | |
4246 | /* Show PollInterval */ | |
3ac237f8 MS |
4247 | if (use_json) |
4248 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4249 | else | |
4250 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
718e3744 | 4251 | |
4252 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4253 | if (use_json) |
4254 | { | |
4255 | struct timeval res = tv_sub (nbr_nbma->t_poll->u.sands, recent_relative_time ()); | |
4256 | unsigned long time_store = 0; | |
4257 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4258 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); | |
4259 | } | |
4260 | else | |
4261 | vty_out (vty, " Poll timer due in %s%s", | |
4262 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
4263 | VTY_NEWLINE); | |
718e3744 | 4264 | |
4265 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4266 | if (use_json) |
4267 | { | |
4268 | if (nbr_nbma->t_poll != NULL) | |
4269 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4270 | } | |
4271 | else | |
4272 | vty_out (vty, " Thread Poll Timer %s%s", | |
4273 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
4274 | ||
4275 | if (use_json) | |
4276 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4277 | } |
4278 | ||
4dadc291 | 4279 | static void |
718e3744 | 4280 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4281 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4282 | { |
649654ab | 4283 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4284 | json_object *json_sub = NULL; |
718e3744 | 4285 | |
3ac237f8 MS |
4286 | if (use_json) |
4287 | json_sub = json_object_new_object(); | |
718e3744 | 4288 | else |
3ac237f8 MS |
4289 | { |
4290 | /* Show neighbor ID. */ | |
4291 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4292 | vty_out (vty, " Neighbor %s,", "-"); | |
4293 | else | |
4294 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4295 | } | |
718e3744 | 4296 | |
4297 | /* Show interface address. */ | |
3ac237f8 MS |
4298 | if (use_json) |
4299 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4300 | else | |
4301 | vty_out (vty, " interface address %s%s", | |
4302 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
4303 | ||
718e3744 | 4304 | /* Show Area ID. */ |
3ac237f8 MS |
4305 | if (use_json) |
4306 | { | |
4307 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4308 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4309 | } | |
4310 | else | |
4311 | vty_out (vty, " In the area %s via interface %s%s", | |
4312 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
4313 | ||
718e3744 | 4314 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4315 | if (use_json) |
4316 | { | |
4317 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4318 | json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4319 | } | |
4320 | else | |
4321 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4322 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4323 | ||
718e3744 | 4324 | /* Show state changes. */ |
3ac237f8 MS |
4325 | if (use_json) |
4326 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4327 | else | |
4328 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
4329 | ||
3fed4160 | 4330 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4331 | { |
3ac237f8 MS |
4332 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
4333 | if (use_json) | |
4334 | { | |
4335 | unsigned long time_store = 0; | |
4336 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4337 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store); | |
4338 | } | |
4339 | else | |
4340 | { | |
4341 | vty_out (vty, " Most recent state change statistics:%s", | |
4342 | VTY_NEWLINE); | |
4343 | vty_out (vty, " Progressive change %s ago%s", | |
4344 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4345 | VTY_NEWLINE); | |
4346 | } | |
3fed4160 | 4347 | } |
3ac237f8 | 4348 | |
3fed4160 PJ |
4349 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4350 | { | |
3ac237f8 MS |
4351 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
4352 | if (use_json) | |
4353 | { | |
4354 | unsigned long time_store = 0; | |
4355 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4356 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); | |
4357 | if (nbr->last_regress_str) | |
4358 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4359 | } | |
4360 | else | |
4361 | { | |
4362 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4363 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4364 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
4365 | VTY_NEWLINE); | |
4366 | } | |
90c33177 | 4367 | } |
3ac237f8 | 4368 | |
718e3744 | 4369 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4370 | if (use_json) |
4371 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4372 | else | |
4373 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4374 | ||
718e3744 | 4375 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4376 | if (use_json) |
4377 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4378 | else | |
4379 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
4380 | ||
718e3744 | 4381 | /* Show options. */ |
3ac237f8 MS |
4382 | if (use_json) |
4383 | { | |
4384 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4385 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4386 | } | |
4387 | else | |
4388 | vty_out (vty, " Options %d %s%s", nbr->options, | |
4389 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
4390 | ||
718e3744 | 4391 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4392 | if (use_json) |
4393 | { | |
4394 | struct timeval res = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time ()); | |
4395 | unsigned long time_store = 0; | |
4396 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4397 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); | |
4398 | } | |
4399 | else | |
4400 | vty_out (vty, " Dead timer due in %s%s", | |
4401 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
4402 | VTY_NEWLINE); | |
4403 | ||
718e3744 | 4404 | /* Show Database Summary list. */ |
3ac237f8 MS |
4405 | if (use_json) |
4406 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4407 | else | |
4408 | vty_out (vty, " Database Summary List %d%s", | |
4409 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
4410 | ||
718e3744 | 4411 | /* Show Link State Request list. */ |
3ac237f8 MS |
4412 | if (use_json) |
4413 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4414 | else | |
4415 | vty_out (vty, " Link State Request List %ld%s", | |
4416 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
4417 | ||
718e3744 | 4418 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4419 | if (use_json) |
4420 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4421 | else | |
4422 | vty_out (vty, " Link State Retransmission List %ld%s", | |
4423 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
4424 | ||
718e3744 | 4425 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4426 | if (use_json) |
4427 | { | |
4428 | if (nbr->t_inactivity != NULL) | |
4429 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4430 | } | |
4431 | else | |
4432 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
4433 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
4434 | ||
718e3744 | 4435 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4436 | if (use_json) |
4437 | { | |
4438 | if (nbr->t_db_desc != NULL) | |
4439 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4440 | } | |
4441 | else | |
4442 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
4443 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
4444 | ||
718e3744 | 4445 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4446 | if (use_json) |
4447 | { | |
4448 | if (nbr->t_ls_req != NULL) | |
4449 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4450 | } | |
4451 | else | |
4452 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
4453 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
4454 | ||
718e3744 | 4455 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4456 | if (use_json) |
4457 | { | |
4458 | if (nbr->t_ls_upd != NULL) | |
4459 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4460 | } | |
4461 | else | |
4462 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
4463 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
4464 | ||
4465 | if (use_json) | |
4466 | { | |
4467 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4468 | json_object_object_add(json, "noNbrId", json_sub); | |
4469 | else | |
4470 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4471 | } | |
68fe91d6 | 4472 | |
4473 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4474 | } |
4475 | ||
7c8ff89e DS |
4476 | static int |
4477 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 4478 | int arg_base, struct cmd_token **argv, u_char use_json) |
718e3744 | 4479 | { |
52dc7ee6 | 4480 | struct listnode *node; |
718e3744 | 4481 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4482 | struct ospf_interface *oi; |
718e3744 | 4483 | struct in_addr router_id; |
4484 | int ret; | |
3ac237f8 MS |
4485 | json_object *json = NULL; |
4486 | ||
4487 | if (use_json) | |
4488 | json = json_object_new_object(); | |
718e3744 | 4489 | |
7c8ff89e | 4490 | if (ospf->instance) |
3ac237f8 MS |
4491 | { |
4492 | if (use_json) | |
4493 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4494 | else | |
4495 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4496 | VTY_NEWLINE, VTY_NEWLINE); | |
4497 | } | |
7c8ff89e | 4498 | |
7a7be519 | 4499 | ret = inet_aton (argv[arg_base]->arg, &router_id); |
718e3744 | 4500 | if (!ret) |
4501 | { | |
3ac237f8 MS |
4502 | if (!use_json) |
4503 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
718e3744 | 4504 | return CMD_WARNING; |
4505 | } | |
4506 | ||
1eb8ef25 | 4507 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4508 | { |
4509 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4510 | { | |
4511 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4512 | } | |
4513 | } | |
4514 | ||
4515 | if (use_json) | |
4516 | { | |
2aac5767 | 4517 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4518 | json_object_free(json); |
4519 | } | |
4520 | else | |
4521 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4522 | |
718e3744 | 4523 | return CMD_SUCCESS; |
4524 | } | |
4525 | ||
7c8ff89e DS |
4526 | DEFUN (show_ip_ospf_neighbor_id, |
4527 | show_ip_ospf_neighbor_id_cmd, | |
b162fa78 | 4528 | "show ip ospf neighbor A.B.C.D [json]", |
718e3744 | 4529 | SHOW_STR |
4530 | IP_STR | |
4531 | "OSPF information\n" | |
4532 | "Neighbor list\n" | |
3ac237f8 MS |
4533 | "Neighbor ID\n" |
4534 | "JavaScript Object Notation\n") | |
718e3744 | 4535 | { |
020709f9 | 4536 | struct ospf *ospf; |
db7c8528 | 4537 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4538 | |
0bad4851 | 4539 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4540 | return CMD_SUCCESS; |
4541 | ||
db7c8528 | 4542 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4543 | } |
4544 | ||
4545 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4546 | show_ip_ospf_instance_neighbor_id_cmd, | |
6147e2c6 | 4547 | "show ip ospf (1-65535) neighbor A.B.C.D [json]", |
7c8ff89e DS |
4548 | SHOW_STR |
4549 | IP_STR | |
4550 | "OSPF information\n" | |
4551 | "Instance ID\n" | |
4552 | "Neighbor list\n" | |
3ac237f8 MS |
4553 | "Neighbor ID\n" |
4554 | "JavaScript Object Notation\n") | |
7c8ff89e | 4555 | { |
8d769265 | 4556 | int idx_number = 3; |
7c8ff89e DS |
4557 | struct ospf *ospf; |
4558 | u_short instance = 0; | |
db7c8528 | 4559 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4560 | |
8d769265 | 4561 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4562 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4563 | return CMD_SUCCESS; |
4564 | ||
db7c8528 | 4565 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4566 | } |
4567 | ||
4568 | static int | |
3ac237f8 | 4569 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4570 | { |
1eb8ef25 | 4571 | struct ospf_interface *oi; |
52dc7ee6 | 4572 | struct listnode *node; |
3ac237f8 MS |
4573 | json_object *json = NULL; |
4574 | ||
4575 | if (use_json) | |
4576 | json = json_object_new_object(); | |
718e3744 | 4577 | |
7c8ff89e | 4578 | if (ospf->instance) |
3ac237f8 MS |
4579 | { |
4580 | if (use_json) | |
4581 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4582 | else | |
4583 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4584 | VTY_NEWLINE, VTY_NEWLINE); | |
4585 | } | |
718e3744 | 4586 | |
1eb8ef25 | 4587 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4588 | { |
718e3744 | 4589 | struct route_node *rn; |
4590 | struct ospf_neighbor *nbr; | |
4591 | ||
4592 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4593 | { |
4594 | if ((nbr = rn->info)) | |
4595 | { | |
4596 | if (nbr != oi->nbr_self) | |
4597 | { | |
4598 | if (nbr->state != NSM_Down) | |
4599 | { | |
4600 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4601 | } | |
4602 | } | |
4603 | } | |
4604 | } | |
718e3744 | 4605 | } |
4606 | ||
3ac237f8 MS |
4607 | if (use_json) |
4608 | { | |
2aac5767 | 4609 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4610 | json_object_free(json); |
4611 | } | |
4612 | else | |
4613 | vty_out (vty, "%s", VTY_NEWLINE); | |
4614 | ||
718e3744 | 4615 | return CMD_SUCCESS; |
4616 | } | |
4617 | ||
7c8ff89e DS |
4618 | DEFUN (show_ip_ospf_neighbor_detail, |
4619 | show_ip_ospf_neighbor_detail_cmd, | |
b162fa78 | 4620 | "show ip ospf neighbor detail [json]", |
718e3744 | 4621 | SHOW_STR |
4622 | IP_STR | |
4623 | "OSPF information\n" | |
4624 | "Neighbor list\n" | |
3ac237f8 MS |
4625 | "detail of all neighbors\n" |
4626 | "JavaScript Object Notation\n") | |
718e3744 | 4627 | { |
020709f9 | 4628 | struct ospf *ospf; |
db7c8528 | 4629 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4630 | |
0bad4851 | 4631 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4632 | return CMD_SUCCESS; |
4633 | ||
db7c8528 | 4634 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4635 | } |
4636 | ||
4637 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4638 | show_ip_ospf_instance_neighbor_detail_cmd, | |
6147e2c6 | 4639 | "show ip ospf (1-65535) neighbor detail [json]", |
7c8ff89e DS |
4640 | SHOW_STR |
4641 | IP_STR | |
4642 | "OSPF information\n" | |
4643 | "Instance ID\n" | |
4644 | "Neighbor list\n" | |
3ac237f8 MS |
4645 | "detail of all neighbors\n" |
4646 | "JavaScript Object Notation\n") | |
7c8ff89e | 4647 | { |
8d769265 | 4648 | int idx_number = 3; |
7c8ff89e DS |
4649 | struct ospf *ospf; |
4650 | u_short instance = 0; | |
db7c8528 | 4651 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4652 | |
8d769265 | 4653 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4654 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4655 | return CMD_SUCCESS; |
4656 | ||
db7c8528 | 4657 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4658 | } |
4659 | ||
4660 | static int | |
3ac237f8 | 4661 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4662 | { |
52dc7ee6 | 4663 | struct listnode *node; |
1eb8ef25 | 4664 | struct ospf_interface *oi; |
3ac237f8 MS |
4665 | json_object *json = NULL; |
4666 | ||
4667 | if (use_json) | |
4668 | json = json_object_new_object(); | |
718e3744 | 4669 | |
7c8ff89e | 4670 | if (ospf->instance) |
3ac237f8 MS |
4671 | { |
4672 | if (use_json) | |
4673 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4674 | else | |
4675 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4676 | VTY_NEWLINE, VTY_NEWLINE); | |
4677 | } | |
718e3744 | 4678 | |
1eb8ef25 | 4679 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4680 | { |
718e3744 | 4681 | struct route_node *rn; |
4682 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4683 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4684 | |
4685 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4686 | if ((nbr = rn->info)) | |
4687 | if (nbr != oi->nbr_self) | |
a452df33 | 4688 | if (nbr->state != NSM_Down) |
3ac237f8 | 4689 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4690 | |
4691 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4692 | { |
4693 | struct listnode *nd; | |
718e3744 | 4694 | |
3ac237f8 MS |
4695 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4696 | { | |
4697 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4698 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4699 | } | |
4700 | } | |
4701 | } | |
4702 | ||
4703 | if (use_json) | |
4704 | { | |
2aac5767 | 4705 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4706 | json_object_free(json); |
4707 | } | |
4708 | else | |
4709 | { | |
4710 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4711 | } |
4712 | ||
4713 | return CMD_SUCCESS; | |
4714 | } | |
4715 | ||
7c8ff89e DS |
4716 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4717 | show_ip_ospf_neighbor_detail_all_cmd, | |
b162fa78 | 4718 | "show ip ospf neighbor detail all [json]", |
718e3744 | 4719 | SHOW_STR |
4720 | IP_STR | |
4721 | "OSPF information\n" | |
4722 | "Neighbor list\n" | |
7c8ff89e | 4723 | "detail of all neighbors\n" |
3ac237f8 MS |
4724 | "include down status neighbor\n" |
4725 | "JavaScript Object Notation\n") | |
718e3744 | 4726 | { |
020709f9 | 4727 | struct ospf *ospf; |
db7c8528 | 4728 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4729 | |
0bad4851 | 4730 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4731 | return CMD_SUCCESS; |
4732 | ||
db7c8528 | 4733 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4734 | } |
4735 | ||
4736 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4737 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
6147e2c6 | 4738 | "show ip ospf (1-65535) neighbor detail all [json]", |
7c8ff89e DS |
4739 | SHOW_STR |
4740 | IP_STR | |
4741 | "OSPF information\n" | |
4742 | "Instance ID\n" | |
4743 | "Neighbor list\n" | |
4744 | "detail of all neighbors\n" | |
3ac237f8 MS |
4745 | "include down status neighbor\n" |
4746 | "JavaScript Object Notation\n") | |
7c8ff89e | 4747 | { |
8d769265 | 4748 | int idx_number = 3; |
7c8ff89e DS |
4749 | struct ospf *ospf; |
4750 | u_short instance = 0; | |
db7c8528 | 4751 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4752 | |
8d769265 | 4753 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4754 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4755 | return CMD_SUCCESS; |
4756 | ||
db7c8528 | 4757 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4758 | } |
4759 | ||
4760 | static int | |
4761 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 4762 | int arg_base, struct cmd_token **argv, u_char use_json) |
7c8ff89e | 4763 | { |
718e3744 | 4764 | struct ospf_interface *oi; |
bb5b7552 | 4765 | struct interface *ifp; |
4766 | struct route_node *rn, *nrn; | |
4767 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4768 | json_object *json = NULL; |
4769 | ||
4770 | if (use_json) | |
4771 | json = json_object_new_object(); | |
bb5b7552 | 4772 | |
7c8ff89e | 4773 | if (ospf->instance) |
3ac237f8 MS |
4774 | { |
4775 | if (use_json) | |
4776 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4777 | else | |
4778 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4779 | VTY_NEWLINE, VTY_NEWLINE); | |
4780 | } | |
7c8ff89e | 4781 | |
7a7be519 | 4782 | ifp = if_lookup_by_name (argv[arg_base]->arg); |
bb5b7552 | 4783 | if (!ifp) |
718e3744 | 4784 | { |
3ac237f8 MS |
4785 | if (!use_json) |
4786 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4787 | return CMD_WARNING; |
4788 | } | |
4789 | ||
bb5b7552 | 4790 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
4791 | { |
4792 | if ((oi = rn->info)) | |
4793 | { | |
4794 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
4795 | { | |
4796 | if ((nbr = nrn->info)) | |
4797 | { | |
4798 | if (nbr != oi->nbr_self) | |
4799 | { | |
4800 | if (nbr->state != NSM_Down) | |
4801 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4802 | } | |
4803 | } | |
4804 | } | |
4805 | } | |
4806 | } | |
4807 | ||
4808 | if (use_json) | |
4809 | { | |
2aac5767 | 4810 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4811 | json_object_free(json); |
4812 | } | |
4813 | else | |
4814 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4815 | |
4816 | return CMD_SUCCESS; | |
4817 | } | |
4818 | ||
7c8ff89e DS |
4819 | DEFUN (show_ip_ospf_neighbor_int_detail, |
4820 | show_ip_ospf_neighbor_int_detail_cmd, | |
b162fa78 | 4821 | "show ip ospf neighbor IFNAME detail [json]", |
7c8ff89e DS |
4822 | SHOW_STR |
4823 | IP_STR | |
4824 | "OSPF information\n" | |
4825 | "Neighbor list\n" | |
4826 | "Interface name\n" | |
3ac237f8 MS |
4827 | "detail of all neighbors\n" |
4828 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4829 | { |
4830 | struct ospf *ospf; | |
db7c8528 | 4831 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4832 | |
0bad4851 | 4833 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4834 | return CMD_SUCCESS; |
4835 | ||
db7c8528 | 4836 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4837 | } |
4838 | ||
4839 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
4840 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
6147e2c6 | 4841 | "show ip ospf (1-65535) neighbor IFNAME detail [json]", |
7c8ff89e DS |
4842 | SHOW_STR |
4843 | IP_STR | |
4844 | "OSPF information\n" | |
4845 | "Instance ID\n" | |
4846 | "Neighbor list\n" | |
4847 | "Interface name\n" | |
3ac237f8 MS |
4848 | "detail of all neighbors\n" |
4849 | "JavaScript Object Notation\n") | |
7c8ff89e | 4850 | { |
8d769265 | 4851 | int idx_number = 3; |
7c8ff89e DS |
4852 | struct ospf *ospf; |
4853 | u_short instance = 0; | |
db7c8528 | 4854 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4855 | |
8d769265 | 4856 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4857 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4858 | return CMD_SUCCESS; |
4859 | ||
db7c8528 | 4860 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); |
7c8ff89e | 4861 | } |
6b0655a2 | 4862 | |
718e3744 | 4863 | /* Show functions */ |
4dadc291 | 4864 | static int |
020709f9 | 4865 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 4866 | { |
718e3744 | 4867 | struct router_lsa *rl; |
4868 | struct summary_lsa *sl; | |
4869 | struct as_external_lsa *asel; | |
4870 | struct prefix_ipv4 p; | |
4871 | ||
4872 | if (lsa != NULL) | |
4873 | /* If self option is set, check LSA self flag. */ | |
4874 | if (self == 0 || IS_LSA_SELF (lsa)) | |
4875 | { | |
4876 | /* LSA common part show. */ | |
4877 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
4878 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
4879 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
4880 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
4881 | /* LSA specific part show. */ | |
4882 | switch (lsa->data->type) | |
4883 | { | |
4884 | case OSPF_ROUTER_LSA: | |
4885 | rl = (struct router_lsa *) lsa->data; | |
4886 | vty_out (vty, " %-d", ntohs (rl->links)); | |
4887 | break; | |
4888 | case OSPF_SUMMARY_LSA: | |
4889 | sl = (struct summary_lsa *) lsa->data; | |
4890 | ||
4891 | p.family = AF_INET; | |
4892 | p.prefix = sl->header.id; | |
4893 | p.prefixlen = ip_masklen (sl->mask); | |
4894 | apply_mask_ipv4 (&p); | |
4895 | ||
4896 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
4897 | break; | |
4898 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 4899 | case OSPF_AS_NSSA_LSA: |
718e3744 | 4900 | asel = (struct as_external_lsa *) lsa->data; |
4901 | ||
4902 | p.family = AF_INET; | |
4903 | p.prefix = asel->header.id; | |
4904 | p.prefixlen = ip_masklen (asel->mask); | |
4905 | apply_mask_ipv4 (&p); | |
4906 | ||
4907 | vty_out (vty, " %s %s/%d [0x%lx]", | |
4908 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
4909 | inet_ntoa (p.prefix), p.prefixlen, | |
4910 | (u_long)ntohl (asel->e[0].route_tag)); | |
4911 | break; | |
4912 | case OSPF_NETWORK_LSA: | |
4913 | case OSPF_ASBR_SUMMARY_LSA: | |
718e3744 | 4914 | case OSPF_OPAQUE_LINK_LSA: |
4915 | case OSPF_OPAQUE_AREA_LSA: | |
4916 | case OSPF_OPAQUE_AS_LSA: | |
718e3744 | 4917 | default: |
4918 | break; | |
4919 | } | |
4920 | vty_out (vty, VTY_NEWLINE); | |
4921 | } | |
4922 | ||
4923 | return 0; | |
4924 | } | |
4925 | ||
8b6a15b2 | 4926 | static const char *show_database_desc[] = |
718e3744 | 4927 | { |
4928 | "unknown", | |
4929 | "Router Link States", | |
4930 | "Net Link States", | |
4931 | "Summary Link States", | |
4932 | "ASBR-Summary Link States", | |
4933 | "AS External Link States", | |
718e3744 | 4934 | "Group Membership LSA", |
4935 | "NSSA-external Link States", | |
718e3744 | 4936 | "Type-8 LSA", |
4937 | "Link-Local Opaque-LSA", | |
4938 | "Area-Local Opaque-LSA", | |
4939 | "AS-external Opaque-LSA", | |
718e3744 | 4940 | }; |
4941 | ||
8b6a15b2 | 4942 | static const char *show_database_header[] = |
718e3744 | 4943 | { |
4944 | "", | |
4945 | "Link ID ADV Router Age Seq# CkSum Link count", | |
4946 | "Link ID ADV Router Age Seq# CkSum", | |
4947 | "Link ID ADV Router Age Seq# CkSum Route", | |
4948 | "Link ID ADV Router Age Seq# CkSum", | |
4949 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4950 | " --- header for Group Member ----", |
4951 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4952 | " --- type-8 ---", |
4953 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4954 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4955 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
718e3744 | 4956 | }; |
4957 | ||
4dadc291 | 4958 | static void |
718e3744 | 4959 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
4960 | { | |
4961 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 4962 | |
718e3744 | 4963 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 4964 | vty_out (vty, " Options: 0x%-2x : %s%s", |
4965 | lsa->data->options, | |
4966 | ospf_options_dump(lsa->data->options), | |
4967 | VTY_NEWLINE); | |
4968 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 4969 | lsa->flags, |
4957f494 | 4970 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
4971 | VTY_NEWLINE); | |
718e3744 | 4972 | |
4973 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
4974 | { | |
4975 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
4976 | ||
4977 | if (rlsa->flags) | |
4978 | vty_out (vty, " :%s%s%s%s", | |
4979 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
4980 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
4981 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
4982 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
4983 | ||
4984 | vty_out (vty, "%s", VTY_NEWLINE); | |
4985 | } | |
4986 | vty_out (vty, " LS Type: %s%s", | |
4987 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
4988 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
4989 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
4990 | vty_out (vty, " Advertising Router: %s%s", | |
4991 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
4992 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
4993 | VTY_NEWLINE); | |
4994 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
4995 | VTY_NEWLINE); | |
4996 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
4997 | } | |
4998 | ||
eb1ce605 | 4999 | const char *link_type_desc[] = |
718e3744 | 5000 | { |
5001 | "(null)", | |
5002 | "another Router (point-to-point)", | |
5003 | "a Transit Network", | |
5004 | "Stub Network", | |
5005 | "a Virtual Link", | |
5006 | }; | |
5007 | ||
eb1ce605 | 5008 | const char *link_id_desc[] = |
718e3744 | 5009 | { |
5010 | "(null)", | |
5011 | "Neighboring Router ID", | |
5012 | "Designated Router address", | |
68980084 | 5013 | "Net", |
718e3744 | 5014 | "Neighboring Router ID", |
5015 | }; | |
5016 | ||
eb1ce605 | 5017 | const char *link_data_desc[] = |
718e3744 | 5018 | { |
5019 | "(null)", | |
5020 | "Router Interface address", | |
5021 | "Router Interface address", | |
5022 | "Network Mask", | |
5023 | "Router Interface address", | |
5024 | }; | |
5025 | ||
5026 | /* Show router-LSA each Link information. */ | |
4dadc291 | 5027 | static void |
718e3744 | 5028 | show_ip_ospf_database_router_links (struct vty *vty, |
5029 | struct router_lsa *rl) | |
5030 | { | |
b07c4cb3 DS |
5031 | int len, type; |
5032 | unsigned int i; | |
718e3744 | 5033 | |
5034 | len = ntohs (rl->header.length) - 4; | |
5035 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
5036 | { | |
5037 | type = rl->link[i].type; | |
5038 | ||
5039 | vty_out (vty, " Link connected to: %s%s", | |
5040 | link_type_desc[type], VTY_NEWLINE); | |
5041 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
5042 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
5043 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
5044 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
5045 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
5046 | vty_out (vty, " TOS 0 Metric: %d%s", | |
5047 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
5048 | vty_out (vty, "%s", VTY_NEWLINE); | |
5049 | } | |
5050 | } | |
5051 | ||
5052 | /* Show router-LSA detail information. */ | |
4dadc291 | 5053 | static int |
718e3744 | 5054 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5055 | { | |
5056 | if (lsa != NULL) | |
5057 | { | |
5058 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
5059 | ||
5060 | show_ip_ospf_database_header (vty, lsa); | |
5061 | ||
5062 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
5063 | VTY_NEWLINE, VTY_NEWLINE); | |
5064 | ||
5065 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 5066 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5067 | } |
5068 | ||
5069 | return 0; | |
5070 | } | |
5071 | ||
5072 | /* Show network-LSA detail information. */ | |
4dadc291 | 5073 | static int |
718e3744 | 5074 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5075 | { | |
5076 | int length, i; | |
5077 | ||
5078 | if (lsa != NULL) | |
5079 | { | |
5080 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
5081 | ||
5082 | show_ip_ospf_database_header (vty, lsa); | |
5083 | ||
5084 | vty_out (vty, " Network Mask: /%d%s", | |
5085 | ip_masklen (nl->mask), VTY_NEWLINE); | |
5086 | ||
5087 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
5088 | ||
5089 | for (i = 0; length > 0; i++, length -= 4) | |
5090 | vty_out (vty, " Attached Router: %s%s", | |
5091 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
5092 | ||
5093 | vty_out (vty, "%s", VTY_NEWLINE); | |
5094 | } | |
5095 | ||
5096 | return 0; | |
5097 | } | |
5098 | ||
5099 | /* Show summary-LSA detail information. */ | |
4dadc291 | 5100 | static int |
718e3744 | 5101 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5102 | { | |
5103 | if (lsa != NULL) | |
5104 | { | |
5105 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5106 | ||
5107 | show_ip_ospf_database_header (vty, lsa); | |
5108 | ||
5109 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
5110 | VTY_NEWLINE); | |
5111 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5112 | VTY_NEWLINE); | |
b0a053be | 5113 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5114 | } |
5115 | ||
5116 | return 0; | |
5117 | } | |
5118 | ||
5119 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 5120 | static int |
718e3744 | 5121 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5122 | { | |
5123 | if (lsa != NULL) | |
5124 | { | |
5125 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5126 | ||
5127 | show_ip_ospf_database_header (vty, lsa); | |
5128 | ||
5129 | vty_out (vty, " Network Mask: /%d%s", | |
5130 | ip_masklen (sl->mask), VTY_NEWLINE); | |
5131 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5132 | VTY_NEWLINE); | |
b0a053be | 5133 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5134 | } |
5135 | ||
5136 | return 0; | |
5137 | } | |
5138 | ||
5139 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 5140 | static int |
718e3744 | 5141 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5142 | { | |
5143 | if (lsa != NULL) | |
5144 | { | |
5145 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5146 | ||
5147 | show_ip_ospf_database_header (vty, lsa); | |
5148 | ||
5149 | vty_out (vty, " Network Mask: /%d%s", | |
5150 | ip_masklen (al->mask), VTY_NEWLINE); | |
5151 | vty_out (vty, " Metric Type: %s%s", | |
5152 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5153 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5154 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5155 | vty_out (vty, " Metric: %d%s", | |
5156 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5157 | vty_out (vty, " Forward Address: %s%s", | |
5158 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5159 | ||
dc9ffce8 CF |
5160 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5161 | (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 5162 | } |
5163 | ||
5164 | return 0; | |
5165 | } | |
075e12f5 | 5166 | #if 0 |
4dadc291 | 5167 | static int |
718e3744 | 5168 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
5169 | { | |
5170 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5171 | ||
5172 | /* show_ip_ospf_database_header (vty, lsa); */ | |
5173 | ||
2a42e285 | 5174 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 5175 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5176 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5177 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5178 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5179 | zlog_debug( " TOS: 0%s", "\n"); |
5180 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5181 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5182 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5183 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5184 | ||
dc9ffce8 CF |
5185 | zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5186 | (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n"); | |
718e3744 | 5187 | |
5188 | return 0; | |
5189 | } | |
075e12f5 | 5190 | #endif |
718e3744 | 5191 | /* Show AS-NSSA-LSA detail information. */ |
4dadc291 | 5192 | static int |
718e3744 | 5193 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5194 | { | |
5195 | if (lsa != NULL) | |
5196 | { | |
5197 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5198 | ||
5199 | show_ip_ospf_database_header (vty, lsa); | |
5200 | ||
5201 | vty_out (vty, " Network Mask: /%d%s", | |
5202 | ip_masklen (al->mask), VTY_NEWLINE); | |
5203 | vty_out (vty, " Metric Type: %s%s", | |
5204 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5205 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5206 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5207 | vty_out (vty, " Metric: %d%s", | |
5208 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5209 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
5210 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5211 | ||
dc9ffce8 CF |
5212 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5213 | (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 5214 | } |
5215 | ||
5216 | return 0; | |
5217 | } | |
5218 | ||
4dadc291 | 5219 | static int |
718e3744 | 5220 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5221 | { | |
5222 | return 0; | |
5223 | } | |
5224 | ||
4dadc291 | 5225 | static int |
718e3744 | 5226 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5227 | { | |
5228 | if (lsa != NULL) | |
5229 | { | |
5230 | show_ip_ospf_database_header (vty, lsa); | |
5231 | show_opaque_info_detail (vty, lsa); | |
5232 | ||
5233 | vty_out (vty, "%s", VTY_NEWLINE); | |
5234 | } | |
5235 | return 0; | |
5236 | } | |
718e3744 | 5237 | |
5238 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5239 | { | |
5240 | NULL, | |
5241 | show_router_lsa_detail, | |
5242 | show_network_lsa_detail, | |
5243 | show_summary_lsa_detail, | |
5244 | show_summary_asbr_lsa_detail, | |
5245 | show_as_external_lsa_detail, | |
718e3744 | 5246 | show_func_dummy, |
5247 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5248 | NULL, /* type-8 */ |
5249 | show_opaque_lsa_detail, | |
5250 | show_opaque_lsa_detail, | |
5251 | show_opaque_lsa_detail, | |
718e3744 | 5252 | }; |
5253 | ||
4dadc291 | 5254 | static void |
718e3744 | 5255 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5256 | struct in_addr *adv_router) | |
5257 | { | |
5258 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5259 | lp->family = 0; | |
5260 | if (id == NULL) | |
5261 | lp->prefixlen = 0; | |
5262 | else if (adv_router == NULL) | |
5263 | { | |
5264 | lp->prefixlen = 32; | |
5265 | lp->id = *id; | |
5266 | } | |
5267 | else | |
5268 | { | |
5269 | lp->prefixlen = 64; | |
5270 | lp->id = *id; | |
5271 | lp->adv_router = *adv_router; | |
5272 | } | |
5273 | } | |
5274 | ||
4dadc291 | 5275 | static void |
718e3744 | 5276 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5277 | struct in_addr *id, struct in_addr *adv_router) | |
5278 | { | |
5279 | struct prefix_ls lp; | |
5280 | struct route_node *rn, *start; | |
5281 | struct ospf_lsa *lsa; | |
5282 | ||
5283 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5284 | start = route_node_get (rt, (struct prefix *) &lp); | |
5285 | if (start) | |
5286 | { | |
5287 | route_lock_node (start); | |
5288 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5289 | if ((lsa = rn->info)) | |
5290 | { | |
718e3744 | 5291 | if (show_function[lsa->data->type] != NULL) |
5292 | show_function[lsa->data->type] (vty, lsa); | |
5293 | } | |
5294 | route_unlock_node (start); | |
5295 | } | |
5296 | } | |
5297 | ||
5298 | /* Show detail LSA information | |
5299 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5300 | static void |
020709f9 | 5301 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5302 | struct in_addr *id, struct in_addr *adv_router) |
5303 | { | |
52dc7ee6 | 5304 | struct listnode *node; |
1eb8ef25 | 5305 | struct ospf_area *area; |
5306 | ||
718e3744 | 5307 | switch (type) |
5308 | { | |
5309 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5310 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5311 | vty_out (vty, " %s %s%s", |
5312 | show_database_desc[type], | |
5313 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5314 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5315 | break; |
5316 | default: | |
1eb8ef25 | 5317 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5318 | { |
718e3744 | 5319 | vty_out (vty, "%s %s (Area %s)%s%s", |
5320 | VTY_NEWLINE, show_database_desc[type], | |
5321 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5322 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
5323 | } | |
5324 | break; | |
5325 | } | |
5326 | } | |
5327 | ||
4dadc291 | 5328 | static void |
718e3744 | 5329 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5330 | struct in_addr *adv_router) | |
5331 | { | |
5332 | struct route_node *rn; | |
5333 | struct ospf_lsa *lsa; | |
5334 | ||
5335 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5336 | if ((lsa = rn->info)) | |
5337 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5338 | { | |
718e3744 | 5339 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5340 | continue; | |
718e3744 | 5341 | if (show_function[lsa->data->type] != NULL) |
5342 | show_function[lsa->data->type] (vty, lsa); | |
5343 | } | |
5344 | } | |
5345 | ||
5346 | /* Show detail LSA information. */ | |
4dadc291 | 5347 | static void |
020709f9 | 5348 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5349 | struct in_addr *adv_router) |
5350 | { | |
52dc7ee6 | 5351 | struct listnode *node; |
1eb8ef25 | 5352 | struct ospf_area *area; |
718e3744 | 5353 | |
5354 | switch (type) | |
5355 | { | |
5356 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5357 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5358 | vty_out (vty, " %s %s%s", |
5359 | show_database_desc[type], | |
5360 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5361 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5362 | adv_router); |
5363 | break; | |
5364 | default: | |
1eb8ef25 | 5365 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5366 | { |
718e3744 | 5367 | vty_out (vty, "%s %s (Area %s)%s%s", |
5368 | VTY_NEWLINE, show_database_desc[type], | |
5369 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5370 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
5371 | adv_router); | |
5372 | } | |
5373 | break; | |
5374 | } | |
5375 | } | |
5376 | ||
4dadc291 | 5377 | static void |
020709f9 | 5378 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5379 | { |
020709f9 | 5380 | struct ospf_lsa *lsa; |
5381 | struct route_node *rn; | |
1eb8ef25 | 5382 | struct ospf_area *area; |
52dc7ee6 | 5383 | struct listnode *node; |
718e3744 | 5384 | int type; |
5385 | ||
1eb8ef25 | 5386 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5387 | { |
718e3744 | 5388 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5389 | { | |
5390 | switch (type) | |
5391 | { | |
5392 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5393 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5394 | continue; |
5395 | default: | |
5396 | break; | |
5397 | } | |
5398 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5399 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5400 | { | |
5401 | vty_out (vty, " %s (Area %s)%s%s", | |
5402 | show_database_desc[type], | |
5403 | ospf_area_desc_string (area), | |
5404 | VTY_NEWLINE, VTY_NEWLINE); | |
5405 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
5406 | ||
020709f9 | 5407 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5408 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5409 | |
5410 | vty_out (vty, "%s", VTY_NEWLINE); | |
5411 | } | |
5412 | } | |
5413 | } | |
5414 | ||
5415 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5416 | { | |
5417 | switch (type) | |
5418 | { | |
5419 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5420 | case OSPF_OPAQUE_AS_LSA: |
e8e1946e | 5421 | break; |
718e3744 | 5422 | default: |
5423 | continue; | |
5424 | } | |
68980084 | 5425 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5426 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5427 | { |
5428 | vty_out (vty, " %s%s%s", | |
5429 | show_database_desc[type], | |
5430 | VTY_NEWLINE, VTY_NEWLINE); | |
5431 | vty_out (vty, "%s%s", show_database_header[type], | |
5432 | VTY_NEWLINE); | |
020709f9 | 5433 | |
5434 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5435 | show_lsa_summary (vty, lsa, self); | |
5436 | ||
718e3744 | 5437 | vty_out (vty, "%s", VTY_NEWLINE); |
5438 | } | |
5439 | } | |
5440 | ||
5441 | vty_out (vty, "%s", VTY_NEWLINE); | |
5442 | } | |
5443 | ||
4dadc291 | 5444 | static void |
020709f9 | 5445 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5446 | { |
91e6a0e5 | 5447 | struct route_node *rn; |
718e3744 | 5448 | |
5449 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
5450 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
5451 | ||
91e6a0e5 | 5452 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5453 | { |
91e6a0e5 DD |
5454 | struct ospf_lsa *lsa; |
5455 | ||
5456 | if ((lsa = rn->info) != NULL) | |
5457 | { | |
5458 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
5459 | vty_out (vty, "Link State ID: %s%s", | |
5460 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
5461 | vty_out (vty, "Advertising Router: %s%s", | |
5462 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5463 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
5464 | vty_out (vty, "%s", VTY_NEWLINE); | |
5465 | } | |
1eb8ef25 | 5466 | } |
718e3744 | 5467 | } |
5468 | ||
718e3744 | 5469 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5470 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5471 | |
718e3744 | 5472 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
5473 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
5474 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
5475 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
718e3744 | 5476 | |
718e3744 | 5477 | #define OSPF_LSA_TYPES_DESC \ |
5478 | "ASBR summary link states\n" \ | |
5479 | "External link states\n" \ | |
5480 | "Network link states\n" \ | |
5481 | "Router link states\n" \ | |
5482 | "Network summary link states\n" \ | |
5483 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5484 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5485 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5486 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5487 | ||
7c8ff89e DS |
5488 | static int |
5489 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 5490 | int arg_base, int argc, struct cmd_token **argv) |
718e3744 | 5491 | { |
7a7be519 | 5492 | int idx_type = 4; |
718e3744 | 5493 | int type, ret; |
5494 | struct in_addr id, adv_router; | |
5495 | ||
7c8ff89e DS |
5496 | if (ospf->instance) |
5497 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5498 | VTY_NEWLINE); | |
718e3744 | 5499 | |
5500 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5501 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5502 | |
5503 | /* Show all LSA. */ | |
7a7be519 | 5504 | if (argc == arg_base + 4) |
718e3744 | 5505 | { |
020709f9 | 5506 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5507 | return CMD_SUCCESS; |
5508 | } | |
5509 | ||
5510 | /* Set database type to show. */ | |
7a7be519 | 5511 | if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) |
718e3744 | 5512 | type = OSPF_ROUTER_LSA; |
7a7be519 | 5513 | else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) |
718e3744 | 5514 | type = OSPF_NETWORK_LSA; |
7a7be519 | 5515 | else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) |
718e3744 | 5516 | type = OSPF_AS_NSSA_LSA; |
7a7be519 | 5517 | else if (strncmp (argv[arg_base + idx_type]->text, "su", 2) == 0) |
718e3744 | 5518 | type = OSPF_SUMMARY_LSA; |
7a7be519 | 5519 | else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) |
718e3744 | 5520 | type = OSPF_ASBR_SUMMARY_LSA; |
7a7be519 | 5521 | else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) |
718e3744 | 5522 | type = OSPF_AS_EXTERNAL_LSA; |
7a7be519 | 5523 | else if (strncmp (argv[arg_base + idx_type]->text, "se", 2) == 0) |
718e3744 | 5524 | { |
020709f9 | 5525 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5526 | return CMD_SUCCESS; |
5527 | } | |
7a7be519 | 5528 | else if (strncmp (argv[arg_base + idx_type]->text, "m", 1) == 0) |
718e3744 | 5529 | { |
020709f9 | 5530 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5531 | return CMD_SUCCESS; |
5532 | } | |
7a7be519 | 5533 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) |
718e3744 | 5534 | type = OSPF_OPAQUE_LINK_LSA; |
7a7be519 | 5535 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) |
718e3744 | 5536 | type = OSPF_OPAQUE_AREA_LSA; |
7a7be519 | 5537 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) |
718e3744 | 5538 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5539 | else |
5540 | return CMD_WARNING; | |
5541 | ||
5542 | /* `show ip ospf database LSA'. */ | |
7a7be519 | 5543 | if (argc == arg_base + 5) |
020709f9 | 5544 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7a7be519 | 5545 | else if (argc >= arg_base + 6) |
718e3744 | 5546 | { |
7a7be519 | 5547 | ret = inet_aton (argv[arg_base + 5]->arg, &id); |
718e3744 | 5548 | if (!ret) |
5549 | return CMD_WARNING; | |
5550 | ||
5551 | /* `show ip ospf database LSA ID'. */ | |
7a7be519 | 5552 | if (argc == arg_base + 6) |
020709f9 | 5553 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5554 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7a7be519 | 5555 | else if (argc == arg_base + 7) |
718e3744 | 5556 | { |
7a7be519 | 5557 | if (strncmp (argv[arg_base + 6]->text, "s", 1) == 0) |
68980084 | 5558 | adv_router = ospf->router_id; |
718e3744 | 5559 | else |
5560 | { | |
7a7be519 | 5561 | ret = inet_aton (argv[arg_base + 7]->arg, &adv_router); |
718e3744 | 5562 | if (!ret) |
5563 | return CMD_WARNING; | |
5564 | } | |
020709f9 | 5565 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5566 | } |
5567 | } | |
5568 | ||
5569 | return CMD_SUCCESS; | |
5570 | } | |
5571 | ||
7c8ff89e DS |
5572 | DEFUN (show_ip_ospf_database, |
5573 | show_ip_ospf_database_cmd, | |
7a7be519 | 5574 | "show ip ospf database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]", |
7c8ff89e DS |
5575 | SHOW_STR |
5576 | IP_STR | |
5577 | "OSPF information\n" | |
7a7be519 | 5578 | "Database summary\n" |
5579 | OSPF_LSA_TYPES_DESC | |
5580 | "Link State ID (as an IP address)\n" | |
5581 | "Self-originated link states\n" | |
5582 | "Advertising Router link states\n" | |
5583 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
5584 | { |
5585 | struct ospf *ospf; | |
5586 | ||
0bad4851 | 5587 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5588 | return CMD_SUCCESS; |
5589 | ||
5590 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); | |
5591 | } | |
5592 | ||
7a7be519 | 5593 | DEFUN (show_ip_ospf_database_max, |
5594 | show_ip_ospf_database_max_cmd, | |
5595 | "show ip ospf database <max-age|self-originate>", | |
5596 | SHOW_STR | |
5597 | IP_STR | |
5598 | "OSPF information\n" | |
5599 | "Database summary\n" | |
5600 | "LSAs in MaxAge list\n" | |
5601 | "Self-originated link states\n") | |
5602 | { | |
5603 | struct ospf *ospf; | |
f412b39a | 5604 | |
7a7be519 | 5605 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
5606 | return CMD_SUCCESS; | |
f412b39a | 5607 | |
7a7be519 | 5608 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); |
5609 | } | |
f412b39a | 5610 | |
f412b39a DW |
5611 | DEFUN (show_ip_ospf_instance_database, |
5612 | show_ip_ospf_instance_database_cmd, | |
7a7be519 | 5613 | "show ip ospf (1-65535) database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]", |
718e3744 | 5614 | SHOW_STR |
5615 | IP_STR | |
5616 | "OSPF information\n" | |
7c8ff89e | 5617 | "Instance ID\n" |
7a7be519 | 5618 | "Database summary\n" |
5619 | OSPF_LSA_TYPES_DESC | |
5620 | "Link State ID (as an IP address)\n" | |
5621 | "Self-originated link states\n" | |
5622 | "Advertising Router link states\n" | |
5623 | "Advertising Router (as an IP address)\n") | |
7c8ff89e | 5624 | { |
8d769265 | 5625 | int idx_number = 3; |
7c8ff89e DS |
5626 | struct ospf *ospf; |
5627 | u_short instance = 0; | |
5628 | ||
8d769265 | 5629 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
7c8ff89e | 5630 | |
0bad4851 | 5631 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5632 | return CMD_SUCCESS; |
5633 | ||
5634 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); | |
5635 | } | |
5636 | ||
7a7be519 | 5637 | DEFUN (show_ip_ospf_instance_database_max, |
5638 | show_ip_ospf_instance_database_max_cmd, | |
5639 | "show ip ospf (1-65535) database <max-age|self-originate>", | |
5640 | SHOW_STR | |
5641 | IP_STR | |
5642 | "OSPF information\n" | |
5643 | "Instance ID\n" | |
5644 | "Database summary\n" | |
5645 | "LSAs in MaxAge list\n" | |
5646 | "Self-originated link states\n") | |
5647 | { | |
5648 | int idx_number = 3; | |
5649 | struct ospf *ospf; | |
5650 | u_short instance = 0; | |
7c8ff89e | 5651 | |
7a7be519 | 5652 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
7c8ff89e | 5653 | |
7a7be519 | 5654 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
5655 | return CMD_SUCCESS; | |
7c8ff89e | 5656 | |
7a7be519 | 5657 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); |
5658 | } | |
7c8ff89e DS |
5659 | |
5660 | ||
5661 | static int | |
5662 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 5663 | int arg_base, int argc, struct cmd_token **argv) |
718e3744 | 5664 | { |
7a7be519 | 5665 | int idx_type = 4; |
718e3744 | 5666 | int type, ret; |
5667 | struct in_addr adv_router; | |
5668 | ||
7c8ff89e DS |
5669 | if (ospf->instance) |
5670 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5671 | VTY_NEWLINE); | |
718e3744 | 5672 | |
5673 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5674 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5675 | |
7a7be519 | 5676 | if (argc != arg_base + 7) |
718e3744 | 5677 | return CMD_WARNING; |
5678 | ||
5679 | /* Set database type to show. */ | |
7a7be519 | 5680 | if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) |
718e3744 | 5681 | type = OSPF_ROUTER_LSA; |
7a7be519 | 5682 | else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) |
718e3744 | 5683 | type = OSPF_NETWORK_LSA; |
7a7be519 | 5684 | else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) |
718e3744 | 5685 | type = OSPF_AS_NSSA_LSA; |
7a7be519 | 5686 | else if (strncmp (argv[arg_base + idx_type]->text, "s", 1) == 0) |
718e3744 | 5687 | type = OSPF_SUMMARY_LSA; |
7a7be519 | 5688 | else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) |
718e3744 | 5689 | type = OSPF_ASBR_SUMMARY_LSA; |
7a7be519 | 5690 | else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) |
718e3744 | 5691 | type = OSPF_AS_EXTERNAL_LSA; |
7a7be519 | 5692 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) |
718e3744 | 5693 | type = OSPF_OPAQUE_LINK_LSA; |
7a7be519 | 5694 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) |
718e3744 | 5695 | type = OSPF_OPAQUE_AREA_LSA; |
7a7be519 | 5696 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) |
718e3744 | 5697 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5698 | else |
5699 | return CMD_WARNING; | |
5700 | ||
7c8ff89e | 5701 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
7a7be519 | 5702 | if (strncmp (argv[arg_base + 5]->text, "s", 1) == 0) |
7c8ff89e DS |
5703 | adv_router = ospf->router_id; |
5704 | else | |
5705 | { | |
7a7be519 | 5706 | ret = inet_aton (argv[arg_base + 6]->arg, &adv_router); |
7c8ff89e DS |
5707 | if (!ret) |
5708 | return CMD_WARNING; | |
5709 | } | |
5710 | ||
5711 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5712 | ||
5713 | return CMD_SUCCESS; | |
5714 | } | |
5715 | ||
5716 | DEFUN (show_ip_ospf_database_type_adv_router, | |
5717 | show_ip_ospf_database_type_adv_router_cmd, | |
7a7be519 | 5718 | "show ip ospf database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", |
7c8ff89e DS |
5719 | SHOW_STR |
5720 | IP_STR | |
5721 | "OSPF information\n" | |
5722 | "Database summary\n" | |
5723 | OSPF_LSA_TYPES_DESC | |
5724 | "Advertising Router link states\n" | |
16cedbb0 QY |
5725 | "Advertising Router (as an IP address)\n" |
5726 | "Self-originated link states\n") | |
7c8ff89e DS |
5727 | { |
5728 | struct ospf *ospf; | |
5729 | ||
0bad4851 | 5730 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5731 | return CMD_SUCCESS; |
5732 | ||
5733 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
5734 | } | |
5735 | ||
7c8ff89e DS |
5736 | DEFUN (show_ip_ospf_instance_database_type_adv_router, |
5737 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
7a7be519 | 5738 | "show ip ospf (1-65535) database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", |
7c8ff89e DS |
5739 | SHOW_STR |
5740 | IP_STR | |
5741 | "OSPF information\n" | |
5742 | "Instance ID\n" | |
5743 | "Database summary\n" | |
5744 | OSPF_LSA_TYPES_DESC | |
5745 | "Advertising Router link states\n" | |
5746 | "Advertising Router (as an IP address)\n") | |
5747 | { | |
8d769265 | 5748 | int idx_number = 3; |
7c8ff89e DS |
5749 | struct ospf *ospf; |
5750 | u_short instance = 0; | |
5751 | ||
8d769265 | 5752 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
718e3744 | 5753 | |
0bad4851 | 5754 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 5755 | return CMD_SUCCESS; |
718e3744 | 5756 | |
7c8ff89e | 5757 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 5758 | } |
5759 | ||
718e3744 | 5760 | DEFUN (ip_ospf_authentication_args, |
5761 | ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 5762 | "ip ospf authentication <null|message-digest> [A.B.C.D]", |
718e3744 | 5763 | "IP Information\n" |
5764 | "OSPF interface commands\n" | |
5765 | "Enable authentication on this interface\n" | |
5766 | "Use null authentication\n" | |
5767 | "Use message-digest authentication\n" | |
7a7be519 | 5768 | "Address of interface\n") |
718e3744 | 5769 | { |
8d769265 DW |
5770 | int idx_encryption = 3; |
5771 | int idx_ipv4 = 4; | |
718e3744 | 5772 | struct interface *ifp; |
5773 | struct in_addr addr; | |
5774 | int ret; | |
5775 | struct ospf_if_params *params; | |
5776 | ||
5777 | ifp = vty->index; | |
5778 | params = IF_DEF_PARAMS (ifp); | |
5779 | ||
7a7be519 | 5780 | if (argc == 5) |
718e3744 | 5781 | { |
8d769265 | 5782 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5783 | if (!ret) |
5784 | { | |
5785 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5786 | VTY_NEWLINE); | |
5787 | return CMD_WARNING; | |
5788 | } | |
5789 | ||
5790 | params = ospf_get_if_params (ifp, addr); | |
5791 | ospf_if_update_params (ifp, addr); | |
5792 | } | |
5793 | ||
5794 | /* Handle null authentication */ | |
8d769265 | 5795 | if ( argv[idx_encryption]->arg[0] == 'n' ) |
718e3744 | 5796 | { |
5797 | SET_IF_PARAM (params, auth_type); | |
5798 | params->auth_type = OSPF_AUTH_NULL; | |
5799 | return CMD_SUCCESS; | |
5800 | } | |
5801 | ||
5802 | /* Handle message-digest authentication */ | |
8d769265 | 5803 | if ( argv[idx_encryption]->arg[0] == 'm' ) |
718e3744 | 5804 | { |
5805 | SET_IF_PARAM (params, auth_type); | |
5806 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5807 | return CMD_SUCCESS; | |
5808 | } | |
5809 | ||
5810 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
5811 | return CMD_WARNING; | |
5812 | } | |
5813 | ||
718e3744 | 5814 | DEFUN (ip_ospf_authentication, |
5815 | ip_ospf_authentication_addr_cmd, | |
7a7be519 | 5816 | "ip ospf authentication [A.B.C.D]", |
718e3744 | 5817 | "IP Information\n" |
5818 | "OSPF interface commands\n" | |
5819 | "Enable authentication on this interface\n" | |
5820 | "Address of interface") | |
5821 | { | |
8d769265 | 5822 | int idx_ipv4 = 3; |
718e3744 | 5823 | struct interface *ifp; |
5824 | struct in_addr addr; | |
5825 | int ret; | |
5826 | struct ospf_if_params *params; | |
5827 | ||
5828 | ifp = vty->index; | |
5829 | params = IF_DEF_PARAMS (ifp); | |
5830 | ||
7a7be519 | 5831 | if (argc == 4) |
718e3744 | 5832 | { |
8d769265 | 5833 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5834 | if (!ret) |
5835 | { | |
5836 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5837 | VTY_NEWLINE); | |
5838 | return CMD_WARNING; | |
5839 | } | |
5840 | ||
5841 | params = ospf_get_if_params (ifp, addr); | |
5842 | ospf_if_update_params (ifp, addr); | |
5843 | } | |
5844 | ||
5845 | SET_IF_PARAM (params, auth_type); | |
5846 | params->auth_type = OSPF_AUTH_SIMPLE; | |
5847 | ||
5848 | return CMD_SUCCESS; | |
5849 | } | |
5850 | ||
b4a039bf DS |
5851 | DEFUN (no_ip_ospf_authentication_args, |
5852 | no_ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 5853 | "no ip ospf authentication <null|message-digest> [A.B.C.D]", |
b4a039bf DS |
5854 | NO_STR |
5855 | "IP Information\n" | |
5856 | "OSPF interface commands\n" | |
5857 | "Enable authentication on this interface\n" | |
5858 | "Use null authentication\n" | |
5859 | "Use message-digest authentication\n" | |
5860 | "Address of interface") | |
5861 | { | |
8d769265 DW |
5862 | int idx_encryption = 4; |
5863 | int idx_ipv4 = 5; | |
b4a039bf DS |
5864 | struct interface *ifp; |
5865 | struct in_addr addr; | |
5866 | int ret; | |
5867 | struct ospf_if_params *params; | |
5868 | struct route_node *rn; | |
5869 | int auth_type; | |
5870 | ||
5871 | ifp = vty->index; | |
5872 | params = IF_DEF_PARAMS (ifp); | |
5873 | ||
7a7be519 | 5874 | if (argc == 6) |
b4a039bf | 5875 | { |
8d769265 | 5876 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
b4a039bf DS |
5877 | if (!ret) |
5878 | { | |
5879 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5880 | VTY_NEWLINE); | |
5881 | return CMD_WARNING; | |
5882 | } | |
5883 | ||
5884 | params = ospf_lookup_if_params (ifp, addr); | |
5885 | if (params == NULL) | |
5886 | { | |
5887 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
5888 | return CMD_WARNING; | |
5889 | } | |
5890 | params->auth_type = OSPF_AUTH_NOTSET; | |
5891 | UNSET_IF_PARAM (params, auth_type); | |
5892 | if (params != IF_DEF_PARAMS (ifp)) | |
5893 | { | |
5894 | ospf_free_if_params (ifp, addr); | |
5895 | ospf_if_update_params (ifp, addr); | |
5896 | } | |
5897 | } | |
5898 | else | |
5899 | { | |
8d769265 | 5900 | if ( argv[idx_encryption]->arg[0] == 'n' ) |
b4a039bf DS |
5901 | { |
5902 | auth_type = OSPF_AUTH_NULL; | |
5903 | } | |
8d769265 | 5904 | else if ( argv[idx_encryption]->arg[0] == 'm' ) |
b4a039bf DS |
5905 | { |
5906 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5907 | } | |
5908 | else | |
5909 | { | |
5910 | vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE); | |
5911 | return CMD_WARNING; | |
5912 | } | |
5913 | /* | |
5914 | * Here we have a case where the user has entered | |
5915 | * 'no ip ospf authentication (null | message_digest )' | |
5916 | * we need to find if we have any ip addresses underneath it that | |
5917 | * correspond to the associated type. | |
5918 | */ | |
813d4307 DW |
5919 | if (params->auth_type == auth_type) |
5920 | { | |
5921 | params->auth_type = OSPF_AUTH_NOTSET; | |
5922 | UNSET_IF_PARAM (params, auth_type); | |
5923 | } | |
5924 | ||
b4a039bf DS |
5925 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
5926 | { | |
5927 | if ((params = rn->info)) | |
5928 | { | |
5929 | if (params->auth_type == auth_type) | |
5930 | { | |
5931 | params->auth_type = OSPF_AUTH_NOTSET; | |
5932 | UNSET_IF_PARAM (params, auth_type); | |
5933 | if (params != IF_DEF_PARAMS (ifp)) | |
5934 | { | |
5935 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
5936 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
5937 | } | |
5938 | } | |
5939 | } | |
5940 | } | |
5941 | } | |
5942 | ||
5943 | return CMD_SUCCESS; | |
5944 | } | |
5945 | ||
718e3744 | 5946 | DEFUN (no_ip_ospf_authentication, |
5947 | no_ip_ospf_authentication_addr_cmd, | |
7a7be519 | 5948 | "no ip ospf authentication [A.B.C.D]", |
718e3744 | 5949 | NO_STR |
5950 | "IP Information\n" | |
5951 | "OSPF interface commands\n" | |
5952 | "Enable authentication on this interface\n" | |
5953 | "Address of interface") | |
5954 | { | |
8d769265 | 5955 | int idx_ipv4 = 4; |
718e3744 | 5956 | struct interface *ifp; |
5957 | struct in_addr addr; | |
5958 | int ret; | |
5959 | struct ospf_if_params *params; | |
b4a039bf DS |
5960 | struct route_node *rn; |
5961 | ||
718e3744 | 5962 | ifp = vty->index; |
5963 | params = IF_DEF_PARAMS (ifp); | |
5964 | ||
7a7be519 | 5965 | if (argc == 5) |
718e3744 | 5966 | { |
8d769265 | 5967 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5968 | if (!ret) |
5969 | { | |
5970 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5971 | VTY_NEWLINE); | |
5972 | return CMD_WARNING; | |
5973 | } | |
5974 | ||
5975 | params = ospf_lookup_if_params (ifp, addr); | |
5976 | if (params == NULL) | |
b4a039bf DS |
5977 | { |
5978 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
5979 | return CMD_WARNING; | |
5980 | } | |
718e3744 | 5981 | |
b4a039bf DS |
5982 | params->auth_type = OSPF_AUTH_NOTSET; |
5983 | UNSET_IF_PARAM (params, auth_type); | |
5984 | if (params != IF_DEF_PARAMS (ifp)) | |
5985 | { | |
5986 | ospf_free_if_params (ifp, addr); | |
5987 | ospf_if_update_params (ifp, addr); | |
5988 | } | |
5989 | } | |
5990 | else | |
718e3744 | 5991 | { |
b4a039bf DS |
5992 | /* |
5993 | * When a user enters 'no ip ospf authentication' | |
5994 | * We should remove all authentication types from | |
5995 | * the interface. | |
5996 | */ | |
813d4307 DW |
5997 | if ((params->auth_type == OSPF_AUTH_NULL) || |
5998 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
5999 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6000 | { | |
6001 | params->auth_type = OSPF_AUTH_NOTSET; | |
6002 | UNSET_IF_PARAM (params, auth_type); | |
6003 | } | |
6004 | ||
b4a039bf DS |
6005 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6006 | { | |
6007 | if ((params = rn->info)) | |
6008 | { | |
813d4307 | 6009 | |
b4a039bf DS |
6010 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6011 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6012 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6013 | { | |
6014 | params->auth_type = OSPF_AUTH_NOTSET; | |
6015 | UNSET_IF_PARAM (params, auth_type); | |
6016 | if (params != IF_DEF_PARAMS (ifp)) | |
6017 | { | |
6018 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6019 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6020 | } | |
6021 | } | |
6022 | } | |
6023 | } | |
718e3744 | 6024 | } |
6025 | ||
6026 | return CMD_SUCCESS; | |
6027 | } | |
6028 | ||
0d829fa7 | 6029 | |
718e3744 | 6030 | DEFUN (ip_ospf_authentication_key, |
6031 | ip_ospf_authentication_key_addr_cmd, | |
7a7be519 | 6032 | "ip ospf authentication-key AUTH_KEY [A.B.C.D]", |
718e3744 | 6033 | "IP Information\n" |
6034 | "OSPF interface commands\n" | |
6035 | "Authentication password (key)\n" | |
6036 | "The OSPF password (key)\n" | |
6037 | "Address of interface") | |
6038 | { | |
0d829fa7 | 6039 | int idx = 0; |
718e3744 | 6040 | struct interface *ifp; |
6041 | struct in_addr addr; | |
718e3744 | 6042 | struct ospf_if_params *params; |
6043 | ||
6044 | ifp = vty->index; | |
6045 | params = IF_DEF_PARAMS (ifp); | |
6046 | ||
0d829fa7 | 6047 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6048 | { |
0d829fa7 | 6049 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6050 | { |
6051 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6052 | VTY_NEWLINE); | |
6053 | return CMD_WARNING; | |
6054 | } | |
6055 | ||
6056 | params = ospf_get_if_params (ifp, addr); | |
6057 | ospf_if_update_params (ifp, addr); | |
6058 | } | |
6059 | ||
718e3744 | 6060 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
7a7be519 | 6061 | strncpy ((char *) params->auth_simple, argv[3]->arg, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 6062 | SET_IF_PARAM (params, auth_simple); |
6063 | ||
6064 | return CMD_SUCCESS; | |
6065 | } | |
6066 | ||
7a7be519 | 6067 | DEFUN_HIDDEN (ospf_authentication_key, |
747e489c | 6068 | ospf_authentication_key_cmd, |
0d829fa7 | 6069 | "ospf authentication-key AUTH_KEY [A.B.C.D]", |
747e489c DW |
6070 | "OSPF interface commands\n" |
6071 | "Authentication password (key)\n" | |
0d829fa7 QY |
6072 | "The OSPF password (key)\n" |
6073 | "Address of interface\n") | |
718e3744 | 6074 | { |
0d829fa7 | 6075 | return ip_ospf_authentication_key (self, vty, argc, argv); |
718e3744 | 6076 | } |
6077 | ||
7a7be519 | 6078 | DEFUN (no_ip_ospf_authentication_key, |
6079 | no_ip_ospf_authentication_key_authkey_addr_cmd, | |
6080 | "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
6081 | NO_STR | |
6082 | "IP Information\n" | |
6083 | "OSPF interface commands\n" | |
6084 | "Authentication password (key)\n" | |
6085 | "The OSPF password (key)") | |
6086 | { | |
0d829fa7 | 6087 | int idx = 0; |
7a7be519 | 6088 | struct interface *ifp; |
6089 | struct in_addr addr; | |
6090 | struct ospf_if_params *params; | |
7a7be519 | 6091 | ifp = vty->index; |
6092 | params = IF_DEF_PARAMS (ifp); | |
6093 | ||
0d829fa7 | 6094 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 6095 | { |
0d829fa7 | 6096 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 6097 | { |
6098 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6099 | VTY_NEWLINE); | |
6100 | return CMD_WARNING; | |
6101 | } | |
813d4307 | 6102 | |
7a7be519 | 6103 | params = ospf_lookup_if_params (ifp, addr); |
6104 | if (params == NULL) | |
6105 | return CMD_SUCCESS; | |
6106 | } | |
718e3744 | 6107 | |
7a7be519 | 6108 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
6109 | UNSET_IF_PARAM (params, auth_simple); | |
718e3744 | 6110 | |
7a7be519 | 6111 | if (params != IF_DEF_PARAMS (ifp)) |
6112 | { | |
6113 | ospf_free_if_params (ifp, addr); | |
6114 | ospf_if_update_params (ifp, addr); | |
6115 | } | |
813d4307 | 6116 | |
7a7be519 | 6117 | return CMD_SUCCESS; |
6118 | } | |
813d4307 | 6119 | |
0d829fa7 QY |
6120 | DEFUN_HIDDEN (no_ospf_authentication_key, |
6121 | no_ospf_authentication_key_authkey_addr_cmd, | |
6122 | "no ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
6123 | NO_STR | |
6124 | "OSPF interface commands\n" | |
6125 | "Authentication password (key)\n" | |
6126 | "The OSPF password (key)") | |
6127 | { | |
6128 | return no_ip_ospf_authentication_key (self, vty, argc, argv); | |
6129 | } | |
6130 | ||
718e3744 | 6131 | DEFUN (ip_ospf_message_digest_key, |
6132 | ip_ospf_message_digest_key_addr_cmd, | |
7a7be519 | 6133 | "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
718e3744 | 6134 | "IP Information\n" |
6135 | "OSPF interface commands\n" | |
6136 | "Message digest authentication password (key)\n" | |
6137 | "Key ID\n" | |
6138 | "Use MD5 algorithm\n" | |
fefa0d82 QY |
6139 | "The OSPF password (key)\n" |
6140 | "Address of interface\n") | |
718e3744 | 6141 | { |
6142 | struct interface *ifp; | |
6143 | struct crypt_key *ck; | |
6144 | u_char key_id; | |
6145 | struct in_addr addr; | |
718e3744 | 6146 | struct ospf_if_params *params; |
6147 | ||
6148 | ifp = vty->index; | |
6149 | params = IF_DEF_PARAMS (ifp); | |
fefa0d82 QY |
6150 | int idx = 0; |
6151 | ||
6152 | argv_find (argv, argc, "(1-255)", &idx); | |
0d829fa7 | 6153 | char *keyid = argv[idx]->arg; |
fefa0d82 QY |
6154 | argv_find (argv, argc, "KEY", &idx); |
6155 | char *cryptkey = argv[idx]->arg; | |
718e3744 | 6156 | |
0d829fa7 | 6157 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6158 | { |
0d829fa7 | 6159 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6160 | { |
6161 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6162 | VTY_NEWLINE); | |
6163 | return CMD_WARNING; | |
6164 | } | |
6165 | ||
6166 | params = ospf_get_if_params (ifp, addr); | |
6167 | ospf_if_update_params (ifp, addr); | |
6168 | } | |
6169 | ||
fefa0d82 | 6170 | key_id = strtol (keyid, NULL, 10); |
718e3744 | 6171 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
6172 | { | |
6173 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
6174 | return CMD_WARNING; | |
6175 | } | |
6176 | ||
6177 | ck = ospf_crypt_key_new (); | |
6178 | ck->key_id = (u_char) key_id; | |
6179 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
fefa0d82 | 6180 | strncpy ((char *) ck->auth_key, cryptkey, OSPF_AUTH_MD5_SIZE); |
718e3744 | 6181 | |
6182 | ospf_crypt_key_add (params->auth_crypt, ck); | |
6183 | SET_IF_PARAM (params, auth_crypt); | |
6184 | ||
6185 | return CMD_SUCCESS; | |
6186 | } | |
6187 | ||
7a7be519 | 6188 | DEFUN_HIDDEN (ospf_message_digest_key, |
747e489c | 6189 | ospf_message_digest_key_cmd, |
0d829fa7 | 6190 | "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
747e489c DW |
6191 | "OSPF interface commands\n" |
6192 | "Message digest authentication password (key)\n" | |
6193 | "Key ID\n" | |
6194 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
6195 | "The OSPF password (key)\n" |
6196 | "Address of interface\n") | |
7a7be519 | 6197 | { |
0d829fa7 | 6198 | return ip_ospf_message_digest_key (self, vty, argc, argv); |
7a7be519 | 6199 | } |
718e3744 | 6200 | |
813d4307 DW |
6201 | DEFUN (no_ip_ospf_message_digest_key_md5, |
6202 | no_ip_ospf_message_digest_key_md5_addr_cmd, | |
0d829fa7 | 6203 | "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
813d4307 DW |
6204 | NO_STR |
6205 | "IP Information\n" | |
6206 | "OSPF interface commands\n" | |
6207 | "Message digest authentication password (key)\n" | |
6208 | "Key ID\n" | |
6209 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
6210 | "The OSPF password (key)\n" |
6211 | "Address of interface\n") | |
813d4307 | 6212 | { |
0d829fa7 | 6213 | int idx = 0; |
813d4307 DW |
6214 | struct interface *ifp; |
6215 | struct crypt_key *ck; | |
6216 | int key_id; | |
6217 | struct in_addr addr; | |
813d4307 | 6218 | struct ospf_if_params *params; |
813d4307 DW |
6219 | ifp = vty->index; |
6220 | params = IF_DEF_PARAMS (ifp); | |
6221 | ||
0d829fa7 QY |
6222 | argv_find (argv, argc, "(1-255)", &idx); |
6223 | char *keyid = argv[idx]->arg; | |
7a7be519 | 6224 | |
0d829fa7 | 6225 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 6226 | { |
0d829fa7 | 6227 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 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) | |
6236 | return CMD_SUCCESS; | |
6237 | } | |
6238 | ||
0d829fa7 | 6239 | key_id = strtol (keyid, NULL, 10); |
7a7be519 | 6240 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
6241 | if (ck == NULL) | |
6242 | { | |
6243 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6244 | return CMD_WARNING; | |
6245 | } | |
6246 | ||
6247 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6248 | ||
6249 | if (params != IF_DEF_PARAMS (ifp)) | |
6250 | { | |
6251 | ospf_free_if_params (ifp, addr); | |
6252 | ospf_if_update_params (ifp, addr); | |
6253 | } | |
6254 | ||
6255 | return CMD_SUCCESS; | |
6256 | } | |
813d4307 | 6257 | |
0d829fa7 QY |
6258 | DEFUN_HIDDEN (no_ospf_message_digest_key, |
6259 | no_ospf_message_digest_key_addr_cmd, | |
6260 | "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", | |
6261 | NO_STR | |
6262 | "OSPF interface commands\n" | |
6263 | "Message digest authentication password (key)\n" | |
6264 | "Key ID\n" | |
6265 | "Address of interface") | |
718e3744 | 6266 | { |
0d829fa7 | 6267 | return no_ip_ospf_message_digest_key_md5 (self, vty, argc, argv); |
718e3744 | 6268 | } |
6269 | ||
718e3744 | 6270 | DEFUN (ip_ospf_cost, |
5c2fc921 | 6271 | ip_ospf_cost_cmd, |
7a7be519 | 6272 | "ip ospf cost (1-65535) [A.B.C.D]", |
718e3744 | 6273 | "IP Information\n" |
6274 | "OSPF interface commands\n" | |
6275 | "Interface cost\n" | |
6276 | "Cost\n" | |
5c2fc921 | 6277 | "Address of interface\n") |
718e3744 | 6278 | { |
5c2fc921 | 6279 | int idx = 0; |
718e3744 | 6280 | struct interface *ifp = vty->index; |
6281 | u_int32_t cost; | |
6282 | struct in_addr addr; | |
718e3744 | 6283 | struct ospf_if_params *params; |
718e3744 | 6284 | params = IF_DEF_PARAMS (ifp); |
6285 | ||
5c2fc921 QY |
6286 | // get arguments |
6287 | char *coststr = NULL, *ifaddr = NULL; | |
6288 | coststr = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL; | |
6289 | ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 6290 | |
5c2fc921 | 6291 | cost = strtol (coststr, NULL, 10); |
718e3744 | 6292 | |
5c2fc921 | 6293 | if (ifaddr) |
718e3744 | 6294 | { |
5c2fc921 | 6295 | if(!inet_aton(ifaddr, &addr)) |
718e3744 | 6296 | { |
6297 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6298 | VTY_NEWLINE); | |
6299 | return CMD_WARNING; | |
6300 | } | |
6301 | ||
6302 | params = ospf_get_if_params (ifp, addr); | |
6303 | ospf_if_update_params (ifp, addr); | |
6304 | } | |
6305 | ||
6306 | SET_IF_PARAM (params, output_cost_cmd); | |
6307 | params->output_cost_cmd = cost; | |
6308 | ||
6309 | ospf_if_recalculate_output_cost (ifp); | |
5c2fc921 | 6310 | |
718e3744 | 6311 | return CMD_SUCCESS; |
6312 | } | |
6313 | ||
7a7be519 | 6314 | DEFUN_HIDDEN (ospf_cost, |
5c2fc921 QY |
6315 | ospf_cost_cmd, |
6316 | "ospf cost (1-65535) [A.B.C.D]", | |
747e489c DW |
6317 | "OSPF interface commands\n" |
6318 | "Interface cost\n" | |
6319 | "Cost\n" | |
5c2fc921 | 6320 | "Address of interface\n") |
7a7be519 | 6321 | { |
5c2fc921 | 6322 | return ip_ospf_cost (self, vty, argc, argv); |
7a7be519 | 6323 | } |
9eff36b3 | 6324 | |
718e3744 | 6325 | DEFUN (no_ip_ospf_cost, |
5c2fc921 QY |
6326 | no_ip_ospf_cost_cmd, |
6327 | "no ip ospf cost [(1-65535)] [A.B.C.D]", | |
718e3744 | 6328 | NO_STR |
718e3744 | 6329 | "OSPF interface commands\n" |
6330 | "Interface cost\n" | |
6331 | "Address of interface") | |
6332 | { | |
5c2fc921 | 6333 | int idx = 0; |
718e3744 | 6334 | struct interface *ifp = vty->index; |
6335 | struct in_addr addr; | |
718e3744 | 6336 | struct ospf_if_params *params; |
7a7be519 | 6337 | |
718e3744 | 6338 | ifp = vty->index; |
6339 | params = IF_DEF_PARAMS (ifp); | |
6340 | ||
5c2fc921 QY |
6341 | // get arguments |
6342 | char *ifaddr = NULL; | |
6343 | ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 6344 | |
7a7be519 | 6345 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
6346 | * always treated as "no ip ospf cost" regardless of the actual value | |
5c2fc921 | 6347 | * of N already configured for the interface. Thus ignore cost. */ |
7a7be519 | 6348 | |
5c2fc921 | 6349 | if (ifaddr) |
7a7be519 | 6350 | { |
5c2fc921 | 6351 | if (!inet_aton(ifaddr, &addr)) |
7a7be519 | 6352 | { |
6353 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6354 | VTY_NEWLINE); | |
6355 | return CMD_WARNING; | |
6356 | } | |
6357 | ||
6358 | params = ospf_lookup_if_params (ifp, addr); | |
6359 | if (params == NULL) | |
6360 | return CMD_SUCCESS; | |
6361 | } | |
6362 | ||
6363 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6364 | ||
6365 | if (params != IF_DEF_PARAMS (ifp)) | |
6366 | { | |
6367 | ospf_free_if_params (ifp, addr); | |
6368 | ospf_if_update_params (ifp, addr); | |
6369 | } | |
6370 | ||
6371 | ospf_if_recalculate_output_cost (ifp); | |
6372 | ||
6373 | return CMD_SUCCESS; | |
6374 | } | |
9eff36b3 | 6375 | |
5c2fc921 QY |
6376 | DEFUN_HIDDEN (no_ospf_cost, |
6377 | no_ospf_cost_cmd, | |
6378 | "no ospf cost [(1-65535)] [A.B.C.D]", | |
6379 | NO_STR | |
6380 | "OSPF interface commands\n" | |
6381 | "Interface cost\n" | |
6382 | "Cost\n" | |
6383 | "Address of interface\n") | |
827341b7 | 6384 | { |
5c2fc921 | 6385 | return no_ip_ospf_cost (self, vty, argc, argv); |
827341b7 DO |
6386 | } |
6387 | ||
4dadc291 | 6388 | static void |
718e3744 | 6389 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6390 | { | |
6391 | struct route_node *rn; | |
6392 | struct ospf_neighbor *nbr; | |
6393 | ||
6394 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6395 | if ((nbr = rn->info)) | |
6396 | { | |
6397 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6398 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6399 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6400 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6401 | } | |
6402 | } | |
6403 | ||
f9ad937f | 6404 | static int |
6405 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6406 | const char *nbr_str, | |
6407 | const char *fast_hello_str) | |
718e3744 | 6408 | { |
6409 | struct interface *ifp = vty->index; | |
6410 | u_int32_t seconds; | |
f9ad937f | 6411 | u_char hellomult; |
718e3744 | 6412 | struct in_addr addr; |
6413 | int ret; | |
6414 | struct ospf_if_params *params; | |
6415 | struct ospf_interface *oi; | |
6416 | struct route_node *rn; | |
6417 | ||
6418 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6419 | |
6420 | if (nbr_str) | |
718e3744 | 6421 | { |
f9ad937f | 6422 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6423 | if (!ret) |
6424 | { | |
6425 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6426 | VTY_NEWLINE); | |
6427 | return CMD_WARNING; | |
6428 | } | |
6429 | ||
6430 | params = ospf_get_if_params (ifp, addr); | |
6431 | ospf_if_update_params (ifp, addr); | |
6432 | } | |
6433 | ||
f9ad937f | 6434 | if (interval_str) |
6435 | { | |
6436 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
6437 | 1, 65535); | |
6438 | ||
6439 | /* reset fast_hello too, just to be sure */ | |
6440 | UNSET_IF_PARAM (params, fast_hello); | |
6441 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6442 | } | |
6443 | else if (fast_hello_str) | |
6444 | { | |
6445 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
6446 | 1, 10); | |
6447 | /* 1s dead-interval with sub-second hellos desired */ | |
6448 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6449 | SET_IF_PARAM (params, fast_hello); | |
6450 | params->fast_hello = hellomult; | |
6451 | } | |
6452 | else | |
6453 | { | |
6454 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
6455 | VTY_NEWLINE); | |
6456 | return CMD_WARNING; | |
6457 | } | |
6458 | ||
718e3744 | 6459 | SET_IF_PARAM (params, v_wait); |
6460 | params->v_wait = seconds; | |
6461 | ||
6462 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6463 | if (nbr_str) |
718e3744 | 6464 | { |
cac3b5c4 PJ |
6465 | struct ospf *ospf; |
6466 | if ((ospf = ospf_lookup())) | |
68980084 | 6467 | { |
6468 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6469 | if (oi) | |
6470 | ospf_nbr_timer_update (oi); | |
6471 | } | |
718e3744 | 6472 | } |
6473 | else | |
6474 | { | |
6475 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6476 | if ((oi = rn->info)) | |
6477 | ospf_nbr_timer_update (oi); | |
6478 | } | |
6479 | ||
6480 | return CMD_SUCCESS; | |
6481 | } | |
6482 | ||
f9ad937f | 6483 | DEFUN (ip_ospf_dead_interval, |
0d829fa7 | 6484 | ip_ospf_dead_interval_cmd, |
7a7be519 | 6485 | "ip ospf dead-interval (1-65535) [A.B.C.D]", |
f9ad937f | 6486 | "IP Information\n" |
6487 | "OSPF interface commands\n" | |
6488 | "Interval after which a neighbor is declared dead\n" | |
6489 | "Seconds\n" | |
6490 | "Address of interface\n") | |
6491 | { | |
0d829fa7 QY |
6492 | int idx = 0; |
6493 | char *interval = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL; | |
6494 | char *ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
6495 | return ospf_vty_dead_interval_set (vty, interval, ifaddr, NULL); | |
f9ad937f | 6496 | } |
6497 | ||
718e3744 | 6498 | |
7a7be519 | 6499 | DEFUN_HIDDEN (ospf_dead_interval, |
747e489c | 6500 | ospf_dead_interval_cmd, |
0d829fa7 | 6501 | "ospf dead-interval (1-65535) [A.B.C.D]", |
747e489c DW |
6502 | "OSPF interface commands\n" |
6503 | "Interval after which a neighbor is declared dead\n" | |
0d829fa7 QY |
6504 | "Seconds\n" |
6505 | "Address of interface\n") | |
7a7be519 | 6506 | { |
0d829fa7 | 6507 | return ip_ospf_dead_interval (self, vty, argc, argv); |
7a7be519 | 6508 | } |
718e3744 | 6509 | |
f9ad937f | 6510 | DEFUN (ip_ospf_dead_interval_minimal, |
6511 | ip_ospf_dead_interval_minimal_addr_cmd, | |
7a7be519 | 6512 | "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]", |
f9ad937f | 6513 | "IP Information\n" |
6514 | "OSPF interface commands\n" | |
6515 | "Interval after which a neighbor is declared dead\n" | |
6516 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
6517 | "Hello multiplier factor\n" | |
6518 | "Number of Hellos to send each second\n" | |
6519 | "Address of interface\n") | |
6520 | { | |
8d769265 DW |
6521 | int idx_number = 5; |
6522 | int idx_ipv4 = 6; | |
7a7be519 | 6523 | if (argc == 7) |
8d769265 | 6524 | return ospf_vty_dead_interval_set (vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); |
f9ad937f | 6525 | else |
8d769265 | 6526 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[idx_number]->arg); |
f9ad937f | 6527 | } |
6528 | ||
718e3744 | 6529 | DEFUN (no_ip_ospf_dead_interval, |
0d829fa7 | 6530 | no_ip_ospf_dead_interval_cmd, |
e83a9414 | 6531 | "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", |
718e3744 | 6532 | NO_STR |
6533 | "IP Information\n" | |
6534 | "OSPF interface commands\n" | |
6535 | "Interval after which a neighbor is declared dead\n" | |
f9dfba8d | 6536 | "Seconds\n" |
718e3744 | 6537 | "Address of interface") |
6538 | { | |
7a7be519 | 6539 | int idx_ipv4 = argc - 1; |
718e3744 | 6540 | struct interface *ifp = vty->index; |
6541 | struct in_addr addr; | |
6542 | int ret; | |
6543 | struct ospf_if_params *params; | |
6544 | struct ospf_interface *oi; | |
6545 | struct route_node *rn; | |
020709f9 | 6546 | |
718e3744 | 6547 | ifp = vty->index; |
6548 | params = IF_DEF_PARAMS (ifp); | |
6549 | ||
7a7be519 | 6550 | if (argv[idx_ipv4]->type == IPV4_TKN) |
718e3744 | 6551 | { |
8d769265 | 6552 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 6553 | if (!ret) |
6554 | { | |
6555 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6556 | VTY_NEWLINE); | |
6557 | return CMD_WARNING; | |
6558 | } | |
6559 | ||
6560 | params = ospf_lookup_if_params (ifp, addr); | |
6561 | if (params == NULL) | |
6562 | return CMD_SUCCESS; | |
6563 | } | |
6564 | ||
6565 | UNSET_IF_PARAM (params, v_wait); | |
6566 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 6567 | |
6568 | UNSET_IF_PARAM (params, fast_hello); | |
6569 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6570 | ||
718e3744 | 6571 | if (params != IF_DEF_PARAMS (ifp)) |
6572 | { | |
6573 | ospf_free_if_params (ifp, addr); | |
6574 | ospf_if_update_params (ifp, addr); | |
6575 | } | |
6576 | ||
6577 | /* Update timer values in neighbor structure. */ | |
6578 | if (argc == 1) | |
6579 | { | |
cac3b5c4 PJ |
6580 | struct ospf *ospf; |
6581 | ||
6582 | if ((ospf = ospf_lookup())) | |
68980084 | 6583 | { |
6584 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6585 | if (oi) | |
6586 | ospf_nbr_timer_update (oi); | |
6587 | } | |
718e3744 | 6588 | } |
6589 | else | |
6590 | { | |
6591 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6592 | if ((oi = rn->info)) | |
6593 | ospf_nbr_timer_update (oi); | |
6594 | } | |
6595 | ||
6596 | return CMD_SUCCESS; | |
6597 | } | |
6598 | ||
0d829fa7 QY |
6599 | DEFUN_HIDDEN (no_ospf_dead_interval, |
6600 | no_ospf_dead_interval_cmd, | |
6601 | "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", | |
6602 | NO_STR | |
6603 | "OSPF interface commands\n" | |
6604 | "Interval after which a neighbor is declared dead\n" | |
6605 | "Seconds\n" | |
6606 | "Address of interface") | |
6607 | { | |
6608 | return no_ip_ospf_dead_interval (self, vty, argc, argv); | |
6609 | } | |
6610 | ||
718e3744 | 6611 | DEFUN (ip_ospf_hello_interval, |
0d829fa7 | 6612 | ip_ospf_hello_interval_cmd, |
7a7be519 | 6613 | "ip ospf hello-interval (1-65535) [A.B.C.D]", |
718e3744 | 6614 | "IP Information\n" |
6615 | "OSPF interface commands\n" | |
6616 | "Time between HELLO packets\n" | |
6617 | "Seconds\n" | |
0d829fa7 | 6618 | "Address of interface\n") |
718e3744 | 6619 | { |
0d829fa7 | 6620 | int idx = 0; |
718e3744 | 6621 | struct interface *ifp = vty->index; |
718e3744 | 6622 | struct in_addr addr; |
718e3744 | 6623 | struct ospf_if_params *params; |
718e3744 | 6624 | params = IF_DEF_PARAMS (ifp); |
0d829fa7 | 6625 | u_int32_t seconds = 0; |
718e3744 | 6626 | |
0d829fa7 QY |
6627 | argv_find (argv, argc, "(1-65535)", &idx); |
6628 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6629 | |
0d829fa7 | 6630 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6631 | { |
0d829fa7 | 6632 | if(!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6633 | { |
6634 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6635 | VTY_NEWLINE); | |
6636 | return CMD_WARNING; | |
6637 | } | |
6638 | ||
6639 | params = ospf_get_if_params (ifp, addr); | |
6640 | ospf_if_update_params (ifp, addr); | |
6641 | } | |
6642 | ||
f9ad937f | 6643 | SET_IF_PARAM (params, v_hello); |
718e3744 | 6644 | params->v_hello = seconds; |
6645 | ||
6646 | return CMD_SUCCESS; | |
6647 | } | |
6648 | ||
7a7be519 | 6649 | DEFUN_HIDDEN (ospf_hello_interval, |
747e489c | 6650 | ospf_hello_interval_cmd, |
0d829fa7 | 6651 | "ospf hello-interval (1-65535) [A.B.C.D]", |
747e489c DW |
6652 | "OSPF interface commands\n" |
6653 | "Time between HELLO packets\n" | |
0d829fa7 QY |
6654 | "Seconds\n" |
6655 | "Address of interface\n") | |
7a7be519 | 6656 | { |
0d829fa7 | 6657 | return ip_ospf_hello_interval (self, vty, argc, argv); |
7a7be519 | 6658 | } |
718e3744 | 6659 | |
6660 | DEFUN (no_ip_ospf_hello_interval, | |
0d829fa7 QY |
6661 | no_ip_ospf_hello_interval_cmd, |
6662 | "no ip ospf hello-interval [(1-65535) [A.B.C.D]]", | |
718e3744 | 6663 | NO_STR |
6664 | "IP Information\n" | |
6665 | "OSPF interface commands\n" | |
0d829fa7 | 6666 | "Time between HELLO packets\n" // ignored |
f9dfba8d | 6667 | "Seconds\n" |
0d829fa7 | 6668 | "Address of interface\n") |
718e3744 | 6669 | { |
0d829fa7 | 6670 | int idx = 0; |
718e3744 | 6671 | struct interface *ifp = vty->index; |
6672 | struct in_addr addr; | |
718e3744 | 6673 | struct ospf_if_params *params; |
718e3744 | 6674 | params = IF_DEF_PARAMS (ifp); |
6675 | ||
0d829fa7 | 6676 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6677 | { |
0d829fa7 | 6678 | if(!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6679 | { |
6680 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6681 | VTY_NEWLINE); | |
6682 | return CMD_WARNING; | |
6683 | } | |
6684 | ||
6685 | params = ospf_lookup_if_params (ifp, addr); | |
6686 | if (params == NULL) | |
6687 | return CMD_SUCCESS; | |
6688 | } | |
6689 | ||
6690 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 6691 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 6692 | |
6693 | if (params != IF_DEF_PARAMS (ifp)) | |
6694 | { | |
6695 | ospf_free_if_params (ifp, addr); | |
6696 | ospf_if_update_params (ifp, addr); | |
6697 | } | |
6698 | ||
6699 | return CMD_SUCCESS; | |
6700 | } | |
6701 | ||
0d829fa7 QY |
6702 | DEFUN_HIDDEN (no_ospf_hello_interval, |
6703 | no_ospf_hello_interval_cmd, | |
6704 | "no ospf hello-interval [(1-65535) [A.B.C.D]]", | |
6705 | NO_STR | |
6706 | "OSPF interface commands\n" | |
6707 | "Time between HELLO packets\n" // ignored | |
6708 | "Seconds\n" | |
6709 | "Address of interface\n") | |
6710 | { | |
6711 | return no_ospf_hello_interval (self, vty, argc, argv); | |
6712 | } | |
718e3744 | 6713 | |
6714 | DEFUN (ip_ospf_network, | |
6715 | ip_ospf_network_cmd, | |
6147e2c6 | 6716 | "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
718e3744 | 6717 | "IP Information\n" |
6718 | "OSPF interface commands\n" | |
6719 | "Network type\n" | |
6720 | "Specify OSPF broadcast multi-access network\n" | |
6721 | "Specify OSPF NBMA network\n" | |
6722 | "Specify OSPF point-to-multipoint network\n" | |
6723 | "Specify OSPF point-to-point network\n") | |
6724 | { | |
0d829fa7 | 6725 | int idx = 0; |
718e3744 | 6726 | struct interface *ifp = vty->index; |
6727 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
6728 | struct route_node *rn; | |
4b4bda9b CF |
6729 | |
6730 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
6731 | { | |
6732 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
6733 | return CMD_WARNING; | |
6734 | } | |
6735 | ||
0d829fa7 | 6736 | if (argv_find (argv, argc, "broadcast", &idx)) |
718e3744 | 6737 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
0d829fa7 | 6738 | else if (argv_find (argv, argc, "non-broadcast", &idx)) |
718e3744 | 6739 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
0d829fa7 | 6740 | else if (argv_find (argv, argc, "point-to-multipoint", &idx)) |
718e3744 | 6741 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
0d829fa7 | 6742 | else if (argv_find (argv, argc, "point-to-point", &idx)) |
718e3744 | 6743 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
6744 | ||
6745 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6746 | return CMD_SUCCESS; | |
6747 | ||
6748 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
6749 | ||
6750 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6751 | { | |
6752 | struct ospf_interface *oi = rn->info; | |
6753 | ||
6754 | if (!oi) | |
6755 | continue; | |
6756 | ||
6757 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6758 | ||
6759 | if (oi->state > ISM_Down) | |
6760 | { | |
7a7be519 | 6761 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
6762 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6763 | } | |
6764 | } | |
6765 | ||
6766 | return CMD_SUCCESS; | |
6767 | } | |
6768 | ||
6769 | DEFUN_HIDDEN (ospf_network, | |
6770 | ospf_network_cmd, | |
e83a9414 | 6771 | "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
7a7be519 | 6772 | "OSPF interface commands\n" |
6773 | "Network type\n" | |
6774 | "Specify OSPF broadcast multi-access network\n" | |
6775 | "Specify OSPF NBMA network\n" | |
6776 | "Specify OSPF point-to-multipoint network\n" | |
6777 | "Specify OSPF point-to-point network\n") | |
6778 | { | |
0d829fa7 | 6779 | return ip_ospf_network (self, vty, argc, argv); |
7a7be519 | 6780 | } |
6781 | ||
6782 | DEFUN (no_ip_ospf_network, | |
6783 | no_ip_ospf_network_cmd, | |
6784 | "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
6785 | NO_STR | |
6786 | "IP Information\n" | |
6787 | "OSPF interface commands\n" | |
6788 | "Network type\n" | |
6789 | "Specify OSPF broadcast multi-access network\n" | |
6790 | "Specify OSPF NBMA network\n" | |
6791 | "Specify OSPF point-to-multipoint network\n" | |
6792 | "Specify OSPF point-to-point network\n") | |
22b27e95 | 6793 | { |
7a7be519 | 6794 | struct interface *ifp = vty->index; |
6795 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
6796 | struct route_node *rn; | |
6797 | ||
6798 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); | |
6799 | ||
6800 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6801 | return CMD_SUCCESS; | |
6802 | ||
6803 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6804 | { | |
6805 | struct ospf_interface *oi = rn->info; | |
6806 | ||
6807 | if (!oi) | |
6808 | continue; | |
6809 | ||
6810 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6811 | ||
6812 | if (oi->state > ISM_Down) | |
6813 | { | |
6814 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
6815 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6816 | } | |
6817 | } | |
6818 | ||
6819 | return CMD_SUCCESS; | |
6820 | } | |
6821 | ||
0d829fa7 QY |
6822 | DEFUN_HIDDEN (no_ospf_network, |
6823 | no_ospf_network_cmd, | |
6824 | "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
6825 | NO_STR | |
6826 | "OSPF interface commands\n" | |
6827 | "Network type\n" | |
6828 | "Specify OSPF broadcast multi-access network\n" | |
6829 | "Specify OSPF NBMA network\n" | |
6830 | "Specify OSPF point-to-multipoint network\n" | |
6831 | "Specify OSPF point-to-point network\n") | |
6832 | { | |
6833 | return no_ip_ospf_network (self, vty, argc, argv); | |
6834 | } | |
6835 | ||
7a7be519 | 6836 | DEFUN (ip_ospf_priority, |
6837 | ip_ospf_priority_addr_cmd, | |
6838 | "ip ospf priority (0-255) [A.B.C.D]", | |
6839 | "IP Information\n" | |
6840 | "OSPF interface commands\n" | |
6841 | "Router priority\n" | |
6842 | "Priority\n" | |
6843 | "Address of interface") | |
6844 | { | |
0d829fa7 | 6845 | int idx = 0; |
7a7be519 | 6846 | struct interface *ifp = vty->index; |
6847 | long priority; | |
6848 | struct route_node *rn; | |
6849 | struct in_addr addr; | |
7a7be519 | 6850 | struct ospf_if_params *params; |
7a7be519 | 6851 | params = IF_DEF_PARAMS (ifp); |
6852 | ||
0d829fa7 QY |
6853 | argv_find (argv, argc, "(0-255)", &idx); |
6854 | priority = strtol (argv[idx]->arg, NULL, 10); | |
7a7be519 | 6855 | |
0d829fa7 | 6856 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 6857 | { |
0d829fa7 | 6858 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 6859 | { |
6860 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6861 | VTY_NEWLINE); | |
6862 | return CMD_WARNING; | |
6863 | } | |
6864 | ||
6865 | params = ospf_get_if_params (ifp, addr); | |
6866 | ospf_if_update_params (ifp, addr); | |
6867 | } | |
6868 | ||
6869 | SET_IF_PARAM (params, priority); | |
6870 | params->priority = priority; | |
6871 | ||
6872 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6873 | { | |
6874 | struct ospf_interface *oi = rn->info; | |
6875 | ||
6876 | if (!oi) | |
6877 | continue; | |
6878 | ||
6879 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
6880 | { | |
6881 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6882 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
718e3744 | 6883 | } |
6884 | } | |
6885 | ||
6886 | return CMD_SUCCESS; | |
6887 | } | |
6888 | ||
7a7be519 | 6889 | DEFUN_HIDDEN (ospf_priority, |
6890 | ospf_priority_cmd, | |
0d829fa7 | 6891 | "ospf priority (0-255) [A.B.C.D]", |
7a7be519 | 6892 | "OSPF interface commands\n" |
6893 | "Router priority\n" | |
6894 | "Priority\n") | |
718e3744 | 6895 | { |
0d829fa7 | 6896 | return ip_ospf_priority (self, vty, argc, argv); |
718e3744 | 6897 | } |
6898 | ||
718e3744 | 6899 | DEFUN (no_ip_ospf_priority, |
6900 | no_ip_ospf_priority_addr_cmd, | |
7a7be519 | 6901 | "no ip ospf priority [(0-255) [A.B.C.D]]", |
718e3744 | 6902 | NO_STR |
6903 | "IP Information\n" | |
6904 | "OSPF interface commands\n" | |
0d829fa7 | 6905 | "Router priority\n" // ignored |
813d4307 | 6906 | "Priority\n" |
718e3744 | 6907 | "Address of interface") |
6908 | { | |
0d829fa7 | 6909 | int idx = 0; |
718e3744 | 6910 | struct interface *ifp = vty->index; |
6911 | struct route_node *rn; | |
6912 | struct in_addr addr; | |
718e3744 | 6913 | struct ospf_if_params *params; |
6914 | ||
6915 | ifp = vty->index; | |
6916 | params = IF_DEF_PARAMS (ifp); | |
6917 | ||
0d829fa7 | 6918 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6919 | { |
0d829fa7 | 6920 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6921 | { |
6922 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6923 | VTY_NEWLINE); | |
6924 | return CMD_WARNING; | |
6925 | } | |
6926 | ||
6927 | params = ospf_lookup_if_params (ifp, addr); | |
6928 | if (params == NULL) | |
6929 | return CMD_SUCCESS; | |
6930 | } | |
6931 | ||
6932 | UNSET_IF_PARAM (params, priority); | |
6933 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
6934 | ||
6935 | if (params != IF_DEF_PARAMS (ifp)) | |
6936 | { | |
6937 | ospf_free_if_params (ifp, addr); | |
6938 | ospf_if_update_params (ifp, addr); | |
6939 | } | |
6940 | ||
6941 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6942 | { | |
6943 | struct ospf_interface *oi = rn->info; | |
6944 | ||
6945 | if (!oi) | |
6946 | continue; | |
6947 | ||
718e3744 | 6948 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
6949 | { | |
6950 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6951 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
6952 | } | |
6953 | } | |
6954 | ||
6955 | return CMD_SUCCESS; | |
6956 | } | |
6957 | ||
0d829fa7 QY |
6958 | DEFUN_HIDDEN (no_ospf_priority, |
6959 | no_ospf_priority_addr_cmd, | |
6960 | "no ospf priority [(0-255) [A.B.C.D]]", | |
6961 | NO_STR | |
6962 | "OSPF interface commands\n" | |
6963 | "Router priority\n" | |
6964 | "Priority\n" | |
6965 | "Address of interface") | |
6966 | { | |
6967 | return no_ip_ospf_priority (self, vty, argc, argv); | |
6968 | } | |
a1afa410 | 6969 | |
718e3744 | 6970 | DEFUN (ip_ospf_retransmit_interval, |
6971 | ip_ospf_retransmit_interval_addr_cmd, | |
7a7be519 | 6972 | "ip ospf retransmit-interval (3-65535) [A.B.C.D]", |
718e3744 | 6973 | "IP Information\n" |
6974 | "OSPF interface commands\n" | |
6975 | "Time between retransmitting lost link state advertisements\n" | |
6976 | "Seconds\n" | |
6977 | "Address of interface") | |
6978 | { | |
0d829fa7 | 6979 | int idx = 0; |
718e3744 | 6980 | struct interface *ifp = vty->index; |
6981 | u_int32_t seconds; | |
6982 | struct in_addr addr; | |
718e3744 | 6983 | struct ospf_if_params *params; |
718e3744 | 6984 | params = IF_DEF_PARAMS (ifp); |
718e3744 | 6985 | |
0d829fa7 QY |
6986 | argv_find (argv, argc, "(3-65535)", &idx); |
6987 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6988 | |
0d829fa7 | 6989 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6990 | { |
0d829fa7 | 6991 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6992 | { |
6993 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6994 | VTY_NEWLINE); | |
6995 | return CMD_WARNING; | |
6996 | } | |
6997 | ||
6998 | params = ospf_get_if_params (ifp, addr); | |
6999 | ospf_if_update_params (ifp, addr); | |
7000 | } | |
7001 | ||
7002 | SET_IF_PARAM (params, retransmit_interval); | |
7003 | params->retransmit_interval = seconds; | |
7004 | ||
7005 | return CMD_SUCCESS; | |
7006 | } | |
7007 | ||
7a7be519 | 7008 | DEFUN_HIDDEN (ospf_retransmit_interval, |
747e489c | 7009 | ospf_retransmit_interval_cmd, |
0d829fa7 | 7010 | "ospf retransmit-interval (3-65535) [A.B.C.D]", |
747e489c DW |
7011 | "OSPF interface commands\n" |
7012 | "Time between retransmitting lost link state advertisements\n" | |
7013 | "Seconds\n") | |
7a7be519 | 7014 | { |
0d829fa7 | 7015 | return ip_ospf_retransmit_interval (self, vty, argc, argv); |
7a7be519 | 7016 | } |
718e3744 | 7017 | |
7018 | DEFUN (no_ip_ospf_retransmit_interval, | |
7019 | no_ip_ospf_retransmit_interval_addr_cmd, | |
0d829fa7 | 7020 | "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]", |
718e3744 | 7021 | NO_STR |
7022 | "IP Information\n" | |
7023 | "OSPF interface commands\n" | |
0d829fa7 QY |
7024 | "Time between retransmitting lost link state advertisements\n" //ignored |
7025 | "Address of interface\n") | |
718e3744 | 7026 | { |
0d829fa7 | 7027 | int idx = 0; |
718e3744 | 7028 | struct interface *ifp = vty->index; |
7029 | struct in_addr addr; | |
718e3744 | 7030 | struct ospf_if_params *params; |
7031 | ||
7032 | ifp = vty->index; | |
7033 | params = IF_DEF_PARAMS (ifp); | |
7034 | ||
0d829fa7 | 7035 | if (argv_find (argv, argc, "(3-65535)", &idx)) |
718e3744 | 7036 | { |
0d829fa7 | 7037 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 7038 | { |
7039 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7040 | VTY_NEWLINE); | |
7041 | return CMD_WARNING; | |
7042 | } | |
7043 | ||
7044 | params = ospf_lookup_if_params (ifp, addr); | |
7045 | if (params == NULL) | |
7046 | return CMD_SUCCESS; | |
7047 | } | |
7048 | ||
7049 | UNSET_IF_PARAM (params, retransmit_interval); | |
7050 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7051 | ||
7052 | if (params != IF_DEF_PARAMS (ifp)) | |
7053 | { | |
7054 | ospf_free_if_params (ifp, addr); | |
7055 | ospf_if_update_params (ifp, addr); | |
7056 | } | |
7057 | ||
7058 | return CMD_SUCCESS; | |
7059 | } | |
7060 | ||
0d829fa7 QY |
7061 | DEFUN_HIDDEN (no_ospf_retransmit_interval, |
7062 | no_ospf_retransmit_interval_cmd, | |
7063 | "no ospf retransmit-interval [(3-65535)] [A.B.C.D]", | |
7064 | NO_STR | |
7065 | "OSPF interface commands\n" | |
7066 | "Time between retransmitting lost link state advertisements\n") | |
7067 | { | |
7068 | return no_ip_ospf_retransmit_interval (self, vty, argc, argv); | |
7069 | } | |
813d4307 | 7070 | |
718e3744 | 7071 | DEFUN (ip_ospf_transmit_delay, |
7072 | ip_ospf_transmit_delay_addr_cmd, | |
7a7be519 | 7073 | "ip ospf transmit-delay (1-65535) [A.B.C.D]", |
718e3744 | 7074 | "IP Information\n" |
7075 | "OSPF interface commands\n" | |
7076 | "Link state transmit delay\n" | |
7077 | "Seconds\n" | |
7078 | "Address of interface") | |
7079 | { | |
0d829fa7 | 7080 | int idx = 0; |
718e3744 | 7081 | struct interface *ifp = vty->index; |
7082 | u_int32_t seconds; | |
7083 | struct in_addr addr; | |
718e3744 | 7084 | struct ospf_if_params *params; |
7085 | ||
7086 | params = IF_DEF_PARAMS (ifp); | |
0d829fa7 QY |
7087 | argv_find (argv, argc, "(1-65535)", &idx); |
7088 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 7089 | |
0d829fa7 | 7090 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 7091 | { |
0d829fa7 | 7092 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 7093 | { |
7094 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7095 | VTY_NEWLINE); | |
7096 | return CMD_WARNING; | |
7097 | } | |
7098 | ||
7099 | params = ospf_get_if_params (ifp, addr); | |
7100 | ospf_if_update_params (ifp, addr); | |
7101 | } | |
7102 | ||
7103 | SET_IF_PARAM (params, transmit_delay); | |
7104 | params->transmit_delay = seconds; | |
7105 | ||
7106 | return CMD_SUCCESS; | |
7107 | } | |
7108 | ||
7a7be519 | 7109 | DEFUN_HIDDEN (ospf_transmit_delay, |
747e489c | 7110 | ospf_transmit_delay_cmd, |
0d829fa7 | 7111 | "ospf transmit-delay (1-65535) [A.B.C.D]", |
747e489c DW |
7112 | "OSPF interface commands\n" |
7113 | "Link state transmit delay\n" | |
7114 | "Seconds\n") | |
7a7be519 | 7115 | { |
0d829fa7 | 7116 | return ip_ospf_transmit_delay (self, vty, argc, argv); |
7a7be519 | 7117 | } |
718e3744 | 7118 | |
7119 | DEFUN (no_ip_ospf_transmit_delay, | |
7120 | no_ip_ospf_transmit_delay_addr_cmd, | |
0d829fa7 | 7121 | "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]", |
718e3744 | 7122 | NO_STR |
7123 | "IP Information\n" | |
7124 | "OSPF interface commands\n" | |
7125 | "Link state transmit delay\n" | |
7126 | "Address of interface") | |
7127 | { | |
0d829fa7 | 7128 | int idx = 0; |
718e3744 | 7129 | struct interface *ifp = vty->index; |
7130 | struct in_addr addr; | |
718e3744 | 7131 | struct ospf_if_params *params; |
7132 | ||
7133 | ifp = vty->index; | |
7134 | params = IF_DEF_PARAMS (ifp); | |
7135 | ||
0d829fa7 | 7136 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 7137 | { |
0d829fa7 | 7138 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 7139 | { |
7140 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7141 | VTY_NEWLINE); | |
7142 | return CMD_WARNING; | |
7143 | } | |
7144 | ||
7145 | params = ospf_lookup_if_params (ifp, addr); | |
7146 | if (params == NULL) | |
7147 | return CMD_SUCCESS; | |
7148 | } | |
7149 | ||
7150 | UNSET_IF_PARAM (params, transmit_delay); | |
7151 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7152 | ||
7153 | if (params != IF_DEF_PARAMS (ifp)) | |
7154 | { | |
7155 | ospf_free_if_params (ifp, addr); | |
7156 | ospf_if_update_params (ifp, addr); | |
7157 | } | |
7158 | ||
7159 | return CMD_SUCCESS; | |
7160 | } | |
7161 | ||
813d4307 | 7162 | |
0d829fa7 QY |
7163 | DEFUN_HIDDEN (no_ospf_transmit_delay, |
7164 | no_ospf_transmit_delay_cmd, | |
7165 | "no ospf transmit-delay", | |
7166 | NO_STR | |
7167 | "OSPF interface commands\n" | |
7168 | "Link state transmit delay\n") | |
813d4307 | 7169 | { |
0d829fa7 | 7170 | return no_ip_ospf_transmit_delay (self, vty, argc, argv); |
813d4307 DW |
7171 | } |
7172 | ||
e723861d DS |
7173 | DEFUN (ip_ospf_area, |
7174 | ip_ospf_area_cmd, | |
22b27e95 | 7175 | "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>", |
e723861d DS |
7176 | "IP Information\n" |
7177 | "OSPF interface commands\n" | |
7a7be519 | 7178 | "Instance ID\n" |
e723861d DS |
7179 | "Enable OSPF on this interface\n" |
7180 | "OSPF area ID in IP address format\n" | |
7181 | "OSPF area ID as a decimal value\n") | |
7182 | { | |
0d829fa7 | 7183 | int idx = 0; |
e723861d DS |
7184 | struct interface *ifp = vty->index; |
7185 | int format, ret; | |
7186 | struct in_addr area_id; | |
7187 | struct ospf *ospf; | |
7188 | struct ospf_if_params *params; | |
7189 | struct route_node *rn; | |
7c8ff89e | 7190 | u_short instance = 0; |
e723861d | 7191 | |
0d829fa7 QY |
7192 | if (argv_find (argv, argc, "(1-65535)", &idx)) |
7193 | instance = strtol (argv[idx]->arg, NULL, 10); | |
7194 | char *areaid = argv[argc - 1]->arg; | |
7c8ff89e DS |
7195 | |
7196 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
7197 | if (ospf == NULL) |
7198 | { | |
7c8ff89e DS |
7199 | params = IF_DEF_PARAMS (ifp); |
7200 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7201 | { | |
7202 | ospf_interface_unset (ifp); | |
7203 | ospf = ospf_lookup(); | |
7204 | ospf->if_ospf_cli_count--; | |
7205 | } | |
e723861d DS |
7206 | return CMD_SUCCESS; |
7207 | } | |
7208 | ||
0d829fa7 | 7209 | ret = ospf_str2area_id (areaid, &area_id, &format); |
e723861d DS |
7210 | if (ret < 0) |
7211 | { | |
7212 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
7213 | VTY_NEWLINE); | |
7214 | return CMD_WARNING; | |
7215 | } | |
7216 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
7217 | { | |
7218 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
7219 | return CMD_WARNING; | |
7220 | } | |
7221 | ||
7222 | params = IF_DEF_PARAMS (ifp); | |
7223 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7224 | { | |
73b9f703 VK |
7225 | vty_out (vty, |
7226 | "Must remove previous area config before changing ospf area %s", | |
7227 | VTY_NEWLINE); | |
e723861d DS |
7228 | return CMD_WARNING; |
7229 | } | |
7230 | ||
7231 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
7232 | { | |
7233 | if (rn->info != NULL) | |
7234 | { | |
7235 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
7236 | return CMD_WARNING; | |
7237 | } | |
7238 | } | |
7239 | ||
7240 | /* enable ospf on this interface with area_id */ | |
7241 | ospf_interface_set (ifp, area_id); | |
7242 | ospf->if_ospf_cli_count++; | |
7243 | ||
7244 | return CMD_SUCCESS; | |
7245 | } | |
7246 | ||
7247 | DEFUN (no_ip_ospf_area, | |
7248 | no_ip_ospf_area_cmd, | |
0d829fa7 | 7249 | "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]", |
e723861d DS |
7250 | NO_STR |
7251 | "IP Information\n" | |
7252 | "OSPF interface commands\n" | |
7a7be519 | 7253 | "Disable OSPF on this interface\n" |
7254 | "OSPF area ID in IP address format\n" | |
7255 | "OSPF area ID as a decimal value\n") | |
e723861d | 7256 | { |
0d829fa7 | 7257 | int idx = 0; |
e723861d DS |
7258 | struct interface *ifp = vty->index; |
7259 | struct ospf *ospf; | |
7260 | struct ospf_if_params *params; | |
7c8ff89e | 7261 | u_short instance = 0; |
e723861d | 7262 | |
0d829fa7 QY |
7263 | if (argv_find (argv, argc, "(1-65535)", &idx)) |
7264 | instance = strtol (argv[idx]->arg, NULL, 10); | |
813d4307 DW |
7265 | |
7266 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
7267 | return CMD_SUCCESS; | |
7268 | ||
7269 | params = IF_DEF_PARAMS (ifp); | |
7270 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7271 | { | |
0d829fa7 | 7272 | vty_out (vty, "Can't find specified interface area configuration.%s", VTY_NEWLINE); |
813d4307 DW |
7273 | return CMD_WARNING; |
7274 | } | |
7275 | ||
7276 | ospf_interface_unset (ifp); | |
7277 | ospf->if_ospf_cli_count--; | |
7278 | return CMD_SUCCESS; | |
7279 | } | |
7280 | ||
6f2a6703 CF |
7281 | DEFUN (ospf_redistribute_source, |
7282 | ospf_redistribute_source_cmd, | |
e83a9414 | 7283 | "redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
d1c65c21 PJ |
7284 | REDIST_STR |
7285 | QUAGGA_REDIST_HELP_STR_OSPFD | |
718e3744 | 7286 | "Metric for redistributed routes\n" |
7287 | "OSPF default metric\n" | |
7288 | "OSPF exterior metric type for redistributed routes\n" | |
7289 | "Set OSPF External Type 1 metrics\n" | |
7290 | "Set OSPF External Type 2 metrics\n" | |
7291 | "Route map reference\n" | |
7292 | "Pointer to route-map entries\n") | |
7293 | { | |
8d769265 DW |
7294 | int idx_protocol = 1; |
7295 | int idx_redist_param = 2; | |
020709f9 | 7296 | struct ospf *ospf = vty->index; |
718e3744 | 7297 | int source; |
7298 | int type = -1; | |
7299 | int metric = -1; | |
7c8ff89e | 7300 | struct ospf_redist *red; |
718e3744 | 7301 | |
d8f70b86 DS |
7302 | if (!ospf) |
7303 | return CMD_SUCCESS; | |
7304 | ||
6f2a6703 CF |
7305 | if (argc < 4) |
7306 | return CMD_WARNING; /* should not happen */ | |
7307 | ||
7c8ff89e DS |
7308 | if (!ospf) |
7309 | return CMD_SUCCESS; | |
7310 | ||
718e3744 | 7311 | /* Get distribute source. */ |
8d769265 | 7312 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 7313 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
718e3744 | 7314 | return CMD_WARNING; |
7315 | ||
7316 | /* Get metric value. */ | |
7a7be519 | 7317 | if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) |
7318 | if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) | |
718e3744 | 7319 | return CMD_WARNING; |
7320 | ||
7321 | /* Get metric type. */ | |
7a7be519 | 7322 | if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) |
7323 | if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) | |
718e3744 | 7324 | return CMD_WARNING; |
7325 | ||
7c8ff89e DS |
7326 | red = ospf_redist_add(ospf, source, 0); |
7327 | ||
7a7be519 | 7328 | if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) |
7329 | ospf_routemap_set (red, argv[idx_redist_param+1]->arg); | |
718e3744 | 7330 | else |
7c8ff89e | 7331 | ospf_routemap_unset (red); |
718e3744 | 7332 | |
7c8ff89e | 7333 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 7334 | } |
7335 | ||
718e3744 | 7336 | DEFUN (no_ospf_redistribute_source, |
7337 | no_ospf_redistribute_source_cmd, | |
e83a9414 | 7338 | "no redistribute <kernel|connected|static|rip|isis|bgp|pim|table> [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7339 | NO_STR |
d1c65c21 | 7340 | REDIST_STR |
813d4307 DW |
7341 | QUAGGA_REDIST_HELP_STR_OSPFD |
7342 | "Metric for redistributed routes\n" | |
7343 | "OSPF default metric\n" | |
7344 | "OSPF exterior metric type for redistributed routes\n" | |
7345 | "Set OSPF External Type 1 metrics\n" | |
7346 | "Set OSPF External Type 2 metrics\n" | |
7347 | "Route map reference\n" | |
7348 | "Pointer to route-map entries\n") | |
718e3744 | 7349 | { |
8d769265 | 7350 | int idx_protocol = 2; |
020709f9 | 7351 | struct ospf *ospf = vty->index; |
718e3744 | 7352 | int source; |
7c8ff89e DS |
7353 | struct ospf_redist *red; |
7354 | if (!ospf) | |
7355 | return CMD_SUCCESS; | |
718e3744 | 7356 | |
8d769265 | 7357 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 7358 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
718e3744 | 7359 | return CMD_WARNING; |
7360 | ||
7c8ff89e DS |
7361 | red = ospf_redist_lookup(ospf, source, 0); |
7362 | if (!red) | |
7363 | return CMD_SUCCESS; | |
7364 | ||
7365 | ospf_routemap_unset (red); | |
7366 | return ospf_redistribute_unset (ospf, source, 0); | |
7367 | } | |
7368 | ||
7369 | DEFUN (ospf_redistribute_instance_source, | |
7370 | ospf_redistribute_instance_source_cmd, | |
ccb8e0c7 | 7371 | "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
7c8ff89e DS |
7372 | REDIST_STR |
7373 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7374 | "Non-main Kernel Routing Table\n" |
7375 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
7376 | "Metric for redistributed routes\n" |
7377 | "OSPF default metric\n" | |
7378 | "OSPF exterior metric type for redistributed routes\n" | |
7379 | "Set OSPF External Type 1 metrics\n" | |
7380 | "Set OSPF External Type 2 metrics\n" | |
7381 | "Route map reference\n" | |
7382 | "Pointer to route-map entries\n") | |
7383 | { | |
8d769265 DW |
7384 | int idx_ospf_table = 1; |
7385 | int idx_number = 2; | |
7386 | int idx_redist_param = 3; | |
7c8ff89e DS |
7387 | struct ospf *ospf = vty->index; |
7388 | int source; | |
7389 | int type = -1; | |
7390 | int metric = -1; | |
7391 | u_short instance; | |
7392 | struct ospf_redist *red; | |
7393 | ||
d8f70b86 DS |
7394 | if (!ospf) |
7395 | return CMD_SUCCESS; | |
7396 | ||
8d769265 | 7397 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
2d627ff5 DS |
7398 | source = ZEBRA_ROUTE_OSPF; |
7399 | else | |
7400 | source = ZEBRA_ROUTE_TABLE; | |
7401 | ||
8d769265 | 7402 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7c8ff89e DS |
7403 | |
7404 | if (!ospf) | |
7405 | return CMD_SUCCESS; | |
7406 | ||
2d627ff5 | 7407 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7408 | { |
7409 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
7410 | VTY_NEWLINE); | |
7411 | return CMD_WARNING; | |
7412 | } | |
7413 | ||
2d627ff5 | 7414 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7415 | { |
7416 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
7417 | VTY_NEWLINE); | |
7418 | return CMD_WARNING; | |
7419 | } | |
7420 | ||
7c8ff89e | 7421 | /* Get metric value. */ |
7a7be519 | 7422 | if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) |
7423 | if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) | |
7c8ff89e DS |
7424 | return CMD_WARNING; |
7425 | ||
7426 | /* Get metric type. */ | |
7a7be519 | 7427 | if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) |
7428 | if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) | |
7c8ff89e DS |
7429 | return CMD_WARNING; |
7430 | ||
7431 | red = ospf_redist_add(ospf, source, instance); | |
7a7be519 | 7432 | |
7433 | if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) | |
7434 | ospf_routemap_set (red, argv[idx_redist_param+1]->arg); | |
7c8ff89e DS |
7435 | else |
7436 | ospf_routemap_unset (red); | |
7437 | ||
7438 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
7439 | } | |
7440 | ||
7441 | DEFUN (no_ospf_redistribute_instance_source, | |
7442 | no_ospf_redistribute_instance_source_cmd, | |
ccb8e0c7 | 7443 | "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
7c8ff89e DS |
7444 | NO_STR |
7445 | REDIST_STR | |
7446 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7447 | "Non-main Kernel Routing Table\n" |
7448 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
7449 | "Metric for redistributed routes\n" |
7450 | "OSPF default metric\n" | |
7451 | "OSPF exterior metric type for redistributed routes\n" | |
7452 | "Set OSPF External Type 1 metrics\n" | |
7453 | "Set OSPF External Type 2 metrics\n" | |
7454 | "Route map reference\n" | |
7455 | "Pointer to route-map entries\n") | |
7456 | { | |
8d769265 DW |
7457 | int idx_ospf_table = 2; |
7458 | int idx_number = 3; | |
7c8ff89e DS |
7459 | struct ospf *ospf = vty->index; |
7460 | u_int instance; | |
7461 | struct ospf_redist *red; | |
7462 | int source; | |
7463 | ||
7464 | if (!ospf) | |
7465 | return CMD_SUCCESS; | |
7466 | ||
8d769265 | 7467 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
2d627ff5 DS |
7468 | source = ZEBRA_ROUTE_OSPF; |
7469 | else | |
7470 | source = ZEBRA_ROUTE_TABLE; | |
7471 | ||
8d769265 | 7472 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7c8ff89e | 7473 | |
2d627ff5 | 7474 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7475 | { |
7476 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
7477 | VTY_NEWLINE); | |
7478 | return CMD_WARNING; | |
7479 | } | |
7480 | ||
2d627ff5 | 7481 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7482 | { |
7483 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
7484 | VTY_NEWLINE); | |
7485 | return CMD_WARNING; | |
7486 | } | |
7487 | ||
7c8ff89e DS |
7488 | red = ospf_redist_lookup(ospf, source, instance); |
7489 | if (!red) | |
7490 | return CMD_SUCCESS; | |
7491 | ||
7492 | ospf_routemap_unset (red); | |
7493 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 7494 | } |
7495 | ||
7496 | DEFUN (ospf_distribute_list_out, | |
7497 | ospf_distribute_list_out_cmd, | |
9ccf14f7 | 7498 | "distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>", |
718e3744 | 7499 | "Filter networks in routing updates\n" |
6f2a6703 CF |
7500 | "Access-list name\n" |
7501 | OUT_STR | |
7502 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 7503 | { |
8d769265 | 7504 | int idx_word = 1; |
020709f9 | 7505 | struct ospf *ospf = vty->index; |
6f2a6703 | 7506 | int source; |
718e3744 | 7507 | |
7c8ff89e DS |
7508 | if (!ospf) |
7509 | return CMD_SUCCESS; | |
7510 | ||
6f2a6703 | 7511 | /* Get distribute source. */ |
bf2bfafd | 7512 | source = proto_redistnum(AFI_IP, argv[4]->arg); |
6f2a6703 CF |
7513 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
7514 | return CMD_WARNING; | |
718e3744 | 7515 | |
8d769265 | 7516 | return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); |
718e3744 | 7517 | } |
7518 | ||
6f2a6703 CF |
7519 | DEFUN (no_ospf_distribute_list_out, |
7520 | no_ospf_distribute_list_out_cmd, | |
9ccf14f7 | 7521 | "no distribute-list WORD out <kernel|connected|static|rip|isis|bgp|pim|table>", |
6f2a6703 CF |
7522 | NO_STR |
7523 | "Filter networks in routing updates\n" | |
7524 | "Access-list name\n" | |
7525 | OUT_STR | |
7526 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 7527 | { |
8d769265 | 7528 | int idx_word = 2; |
020709f9 | 7529 | struct ospf *ospf = vty->index; |
6f2a6703 | 7530 | int source; |
020709f9 | 7531 | |
7c8ff89e DS |
7532 | if (!ospf) |
7533 | return CMD_SUCCESS; | |
7534 | ||
bf2bfafd | 7535 | source = proto_redistnum(AFI_IP, argv[5]->arg); |
6f2a6703 CF |
7536 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
7537 | return CMD_WARNING; | |
718e3744 | 7538 | |
8d769265 | 7539 | return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); |
718e3744 | 7540 | } |
7541 | ||
6f2a6703 CF |
7542 | /* Default information originate. */ |
7543 | DEFUN (ospf_default_information_originate, | |
7544 | ospf_default_information_originate_cmd, | |
e83a9414 | 7545 | "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7546 | "Control distribution of default information\n" |
7547 | "Distribute a default route\n" | |
7548 | "Always advertise default route\n" | |
6f2a6703 CF |
7549 | "OSPF default metric\n" |
7550 | "OSPF metric\n" | |
718e3744 | 7551 | "OSPF metric type for default routes\n" |
7552 | "Set OSPF External Type 1 metrics\n" | |
7553 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 7554 | "Route map reference\n" |
7555 | "Pointer to route-map entries\n") | |
7556 | { | |
8d769265 | 7557 | int idx_redist_param = 2; |
020709f9 | 7558 | struct ospf *ospf = vty->index; |
6f2a6703 | 7559 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 7560 | int type = -1; |
7561 | int metric = -1; | |
7c8ff89e DS |
7562 | struct ospf_redist *red; |
7563 | ||
7564 | if (!ospf) | |
7565 | return CMD_SUCCESS; | |
718e3744 | 7566 | |
6f2a6703 CF |
7567 | if (argc < 4) |
7568 | return CMD_WARNING; /* this should not happen */ | |
7569 | ||
7570 | /* Check whether "always" was specified */ | |
8d769265 | 7571 | if (argv[idx_redist_param]->arg != NULL) |
6f2a6703 | 7572 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
718e3744 | 7573 | |
7c8ff89e DS |
7574 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
7575 | ||
718e3744 | 7576 | /* Get metric value. */ |
7a7be519 | 7577 | if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) |
7578 | if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) | |
718e3744 | 7579 | return CMD_WARNING; |
7580 | ||
718e3744 | 7581 | /* Get metric type. */ |
7a7be519 | 7582 | if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) |
7583 | if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) | |
718e3744 | 7584 | return CMD_WARNING; |
7585 | ||
7a7be519 | 7586 | if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) |
7587 | ospf_routemap_set (red, argv[idx_redist_param+1]->arg); | |
718e3744 | 7588 | else |
7c8ff89e | 7589 | ospf_routemap_unset (red); |
718e3744 | 7590 | |
6f2a6703 CF |
7591 | return ospf_redistribute_default_set (ospf, default_originate, |
7592 | type, metric); | |
718e3744 | 7593 | } |
7594 | ||
7595 | DEFUN (no_ospf_default_information_originate, | |
7596 | no_ospf_default_information_originate_cmd, | |
12dcf78e | 7597 | "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7598 | NO_STR |
7599 | "Control distribution of default information\n" | |
813d4307 DW |
7600 | "Distribute a default route\n" |
7601 | "Always advertise default route\n" | |
7602 | "OSPF default metric\n" | |
7603 | "OSPF metric\n" | |
7604 | "OSPF metric type for default routes\n" | |
7605 | "Set OSPF External Type 1 metrics\n" | |
7606 | "Set OSPF External Type 2 metrics\n" | |
7607 | "Route map reference\n" | |
7608 | "Pointer to route-map entries\n") | |
718e3744 | 7609 | { |
68980084 | 7610 | struct ospf *ospf = vty->index; |
718e3744 | 7611 | struct prefix_ipv4 p; |
7c8ff89e DS |
7612 | struct ospf_external *ext; |
7613 | struct ospf_redist *red; | |
718e3744 | 7614 | |
7c8ff89e DS |
7615 | if (!ospf) |
7616 | return CMD_SUCCESS; | |
7617 | ||
718e3744 | 7618 | p.family = AF_INET; |
7619 | p.prefix.s_addr = 0; | |
7620 | p.prefixlen = 0; | |
7621 | ||
5339cfdb | 7622 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 7623 | |
7c8ff89e DS |
7624 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
7625 | EXTERNAL_INFO (ext)) { | |
7626 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
7627 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 7628 | } |
7629 | ||
7c8ff89e DS |
7630 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
7631 | if (!red) | |
7632 | return CMD_SUCCESS; | |
7633 | ||
7634 | ospf_routemap_unset (red); | |
020709f9 | 7635 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 7636 | } |
7637 | ||
7638 | DEFUN (ospf_default_metric, | |
7639 | ospf_default_metric_cmd, | |
6147e2c6 | 7640 | "default-metric (0-16777214)", |
718e3744 | 7641 | "Set metric of redistributed routes\n" |
7642 | "Default metric\n") | |
7643 | { | |
8d769265 | 7644 | int idx_number = 1; |
68980084 | 7645 | struct ospf *ospf = vty->index; |
718e3744 | 7646 | int metric = -1; |
7647 | ||
7c8ff89e DS |
7648 | if (!ospf) |
7649 | return CMD_SUCCESS; | |
7650 | ||
8d769265 | 7651 | if (!str2metric (argv[idx_number]->arg, &metric)) |
718e3744 | 7652 | return CMD_WARNING; |
7653 | ||
68980084 | 7654 | ospf->default_metric = metric; |
718e3744 | 7655 | |
7656 | return CMD_SUCCESS; | |
7657 | } | |
7658 | ||
7659 | DEFUN (no_ospf_default_metric, | |
7660 | no_ospf_default_metric_cmd, | |
7a7be519 | 7661 | "no default-metric [(0-16777214)]", |
718e3744 | 7662 | NO_STR |
7a7be519 | 7663 | "Set metric of redistributed routes\n" |
7664 | "Default metric\n") | |
718e3744 | 7665 | { |
68980084 | 7666 | struct ospf *ospf = vty->index; |
7667 | ||
7c8ff89e DS |
7668 | if (!ospf) |
7669 | return CMD_SUCCESS; | |
7670 | ||
68980084 | 7671 | ospf->default_metric = -1; |
7672 | ||
718e3744 | 7673 | return CMD_SUCCESS; |
7674 | } | |
7675 | ||
718e3744 | 7676 | |
7677 | DEFUN (ospf_distance, | |
7678 | ospf_distance_cmd, | |
6147e2c6 | 7679 | "distance (1-255)", |
718e3744 | 7680 | "Define an administrative distance\n" |
7681 | "OSPF Administrative distance\n") | |
7682 | { | |
8d769265 | 7683 | int idx_number = 1; |
68980084 | 7684 | struct ospf *ospf = vty->index; |
7685 | ||
7c8ff89e DS |
7686 | if (!ospf) |
7687 | return CMD_SUCCESS; | |
7688 | ||
8d769265 | 7689 | ospf->distance_all = atoi (argv[idx_number]->arg); |
68980084 | 7690 | |
718e3744 | 7691 | return CMD_SUCCESS; |
7692 | } | |
7693 | ||
7694 | DEFUN (no_ospf_distance, | |
7695 | no_ospf_distance_cmd, | |
6147e2c6 | 7696 | "no distance (1-255)", |
718e3744 | 7697 | NO_STR |
7698 | "Define an administrative distance\n" | |
7699 | "OSPF Administrative distance\n") | |
7700 | { | |
68980084 | 7701 | struct ospf *ospf = vty->index; |
7702 | ||
7c8ff89e DS |
7703 | if (!ospf) |
7704 | return CMD_SUCCESS; | |
7705 | ||
68980084 | 7706 | ospf->distance_all = 0; |
7707 | ||
718e3744 | 7708 | return CMD_SUCCESS; |
7709 | } | |
7710 | ||
7711 | DEFUN (no_ospf_distance_ospf, | |
7712 | no_ospf_distance_ospf_cmd, | |
22b27e95 | 7713 | "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]", |
718e3744 | 7714 | NO_STR |
7715 | "Define an administrative distance\n" | |
7716 | "OSPF Administrative distance\n" | |
718e3744 | 7717 | "Intra-area routes\n" |
813d4307 | 7718 | "Distance for intra-area routes\n" |
718e3744 | 7719 | "Inter-area routes\n" |
813d4307 DW |
7720 | "Distance for inter-area routes\n" |
7721 | "External routes\n" | |
7722 | "Distance for external routes\n") | |
718e3744 | 7723 | { |
8d769265 | 7724 | int idx_area_distance = 3; |
68980084 | 7725 | struct ospf *ospf = vty->index; |
7726 | ||
d8f70b86 DS |
7727 | if (!ospf) |
7728 | return CMD_SUCCESS; | |
7729 | ||
6f2a6703 CF |
7730 | if (argc < 3) |
7731 | return CMD_WARNING; | |
718e3744 | 7732 | |
7c8ff89e DS |
7733 | if (!ospf) |
7734 | return CMD_SUCCESS; | |
7735 | ||
8d769265 | 7736 | if (argv[idx_area_distance]->arg != NULL) |
6f2a6703 | 7737 | ospf->distance_intra = 0; |
68980084 | 7738 | |
6f2a6703 CF |
7739 | if (argv[1] != NULL) |
7740 | ospf->distance_inter = 0; | |
68980084 | 7741 | |
6f2a6703 CF |
7742 | if (argv[2] != NULL) |
7743 | ospf->distance_external = 0; | |
718e3744 | 7744 | |
8d769265 | 7745 | if (argv[idx_area_distance]->arg || argv[1] || argv[2]) |
6f2a6703 | 7746 | return CMD_SUCCESS; |
68980084 | 7747 | |
6f2a6703 CF |
7748 | /* If no arguments are given, clear all distance information */ |
7749 | ospf->distance_intra = 0; | |
7750 | ospf->distance_inter = 0; | |
7751 | ospf->distance_external = 0; | |
68980084 | 7752 | |
718e3744 | 7753 | return CMD_SUCCESS; |
7754 | } | |
7755 | ||
6f2a6703 CF |
7756 | DEFUN (ospf_distance_ospf, |
7757 | ospf_distance_ospf_cmd, | |
22b27e95 | 7758 | "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]", |
718e3744 | 7759 | "Define an administrative distance\n" |
7760 | "OSPF Administrative distance\n" | |
718e3744 | 7761 | "Intra-area routes\n" |
7762 | "Distance for intra-area routes\n" | |
718e3744 | 7763 | "Inter-area routes\n" |
7764 | "Distance for inter-area routes\n" | |
7765 | "External routes\n" | |
718e3744 | 7766 | "Distance for external routes\n") |
7767 | { | |
8d769265 | 7768 | int idx_area_distance = 2; |
68980084 | 7769 | struct ospf *ospf = vty->index; |
7770 | ||
d8f70b86 DS |
7771 | if (!ospf) |
7772 | return CMD_SUCCESS; | |
7773 | ||
6f2a6703 CF |
7774 | if (argc < 3) /* should not happen */ |
7775 | return CMD_WARNING; | |
68980084 | 7776 | |
8d769265 | 7777 | if (!argv[idx_area_distance]->arg && !argv[1] && !argv[2]) |
6f2a6703 CF |
7778 | { |
7779 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", | |
7780 | VTY_NEWLINE); | |
7781 | return CMD_WARNING; | |
7782 | } | |
68980084 | 7783 | |
7a7be519 | 7784 | if (strcmp (argv[idx_area_distance]->text, "intra") == 0) |
7785 | ospf->distance_intra = atoi(argv[idx_area_distance+1]->arg); | |
718e3744 | 7786 | |
7a7be519 | 7787 | if (strcmp (argv[idx_area_distance]->text, "inter") == 0) |
7788 | ospf->distance_inter = atoi(argv[idx_area_distance+1]->arg); | |
68980084 | 7789 | |
7a7be519 | 7790 | if (strcmp (argv[idx_area_distance]->text, "external") == 0) |
7791 | ospf->distance_external = atoi(argv[idx_area_distance+1]->arg); | |
68980084 | 7792 | |
718e3744 | 7793 | return CMD_SUCCESS; |
7794 | } | |
7795 | ||
7796 | DEFUN (ospf_distance_source, | |
7797 | ospf_distance_source_cmd, | |
6147e2c6 | 7798 | "distance (1-255) A.B.C.D/M", |
718e3744 | 7799 | "Administrative distance\n" |
7800 | "Distance value\n" | |
7801 | "IP source prefix\n") | |
7802 | { | |
8d769265 DW |
7803 | int idx_number = 1; |
7804 | int idx_ipv4_prefixlen = 2; | |
020709f9 | 7805 | struct ospf *ospf = vty->index; |
7806 | ||
7c8ff89e DS |
7807 | if (!ospf) |
7808 | return CMD_SUCCESS; | |
7809 | ||
8d769265 | 7810 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
68980084 | 7811 | |
718e3744 | 7812 | return CMD_SUCCESS; |
7813 | } | |
7814 | ||
7815 | DEFUN (no_ospf_distance_source, | |
7816 | no_ospf_distance_source_cmd, | |
6147e2c6 | 7817 | "no distance (1-255) A.B.C.D/M", |
718e3744 | 7818 | NO_STR |
7819 | "Administrative distance\n" | |
7820 | "Distance value\n" | |
7821 | "IP source prefix\n") | |
7822 | { | |
8d769265 DW |
7823 | int idx_number = 2; |
7824 | int idx_ipv4_prefixlen = 3; | |
020709f9 | 7825 | struct ospf *ospf = vty->index; |
7826 | ||
7c8ff89e DS |
7827 | if (!ospf) |
7828 | return CMD_SUCCESS; | |
7829 | ||
8d769265 | 7830 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
020709f9 | 7831 | |
718e3744 | 7832 | return CMD_SUCCESS; |
7833 | } | |
7834 | ||
7835 | DEFUN (ospf_distance_source_access_list, | |
7836 | ospf_distance_source_access_list_cmd, | |
6147e2c6 | 7837 | "distance (1-255) A.B.C.D/M WORD", |
718e3744 | 7838 | "Administrative distance\n" |
7839 | "Distance value\n" | |
7840 | "IP source prefix\n" | |
7841 | "Access list name\n") | |
7842 | { | |
8d769265 DW |
7843 | int idx_number = 1; |
7844 | int idx_ipv4_prefixlen = 2; | |
7845 | int idx_word = 3; | |
020709f9 | 7846 | struct ospf *ospf = vty->index; |
7847 | ||
7c8ff89e DS |
7848 | if (!ospf) |
7849 | return CMD_SUCCESS; | |
7850 | ||
8d769265 | 7851 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 7852 | |
718e3744 | 7853 | return CMD_SUCCESS; |
7854 | } | |
7855 | ||
7856 | DEFUN (no_ospf_distance_source_access_list, | |
7857 | no_ospf_distance_source_access_list_cmd, | |
6147e2c6 | 7858 | "no distance (1-255) A.B.C.D/M WORD", |
718e3744 | 7859 | NO_STR |
7860 | "Administrative distance\n" | |
7861 | "Distance value\n" | |
7862 | "IP source prefix\n" | |
7863 | "Access list name\n") | |
7864 | { | |
8d769265 DW |
7865 | int idx_number = 2; |
7866 | int idx_ipv4_prefixlen = 3; | |
7867 | int idx_word = 4; | |
020709f9 | 7868 | struct ospf *ospf = vty->index; |
7869 | ||
7c8ff89e DS |
7870 | if (!ospf) |
7871 | return CMD_SUCCESS; | |
7872 | ||
8d769265 | 7873 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 7874 | |
718e3744 | 7875 | return CMD_SUCCESS; |
7876 | } | |
7877 | ||
ba682537 | 7878 | DEFUN (ip_ospf_mtu_ignore, |
7879 | ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 7880 | "ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 7881 | "IP Information\n" |
7882 | "OSPF interface commands\n" | |
7883 | "Disable mtu mismatch detection\n" | |
7884 | "Address of interface") | |
7885 | { | |
8d769265 | 7886 | int idx_ipv4 = 3; |
ba682537 | 7887 | struct interface *ifp = vty->index; |
7888 | struct in_addr addr; | |
7889 | int ret; | |
7890 | ||
7891 | struct ospf_if_params *params; | |
7892 | params = IF_DEF_PARAMS (ifp); | |
7893 | ||
7a7be519 | 7894 | if (argc == 4) |
ba682537 | 7895 | { |
8d769265 | 7896 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
ba682537 | 7897 | if (!ret) |
7898 | { | |
7899 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7900 | VTY_NEWLINE); | |
7901 | return CMD_WARNING; | |
7902 | } | |
7903 | params = ospf_get_if_params (ifp, addr); | |
7904 | ospf_if_update_params (ifp, addr); | |
7905 | } | |
7906 | params->mtu_ignore = 1; | |
7907 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7908 | SET_IF_PARAM (params, mtu_ignore); | |
7909 | else | |
7910 | { | |
7911 | UNSET_IF_PARAM (params, mtu_ignore); | |
7912 | if (params != IF_DEF_PARAMS (ifp)) | |
7913 | { | |
7914 | ospf_free_if_params (ifp, addr); | |
7915 | ospf_if_update_params (ifp, addr); | |
7916 | } | |
7917 | } | |
7918 | return CMD_SUCCESS; | |
7919 | } | |
7920 | ||
ba682537 | 7921 | DEFUN (no_ip_ospf_mtu_ignore, |
7922 | no_ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 7923 | "no ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 7924 | "IP Information\n" |
7925 | "OSPF interface commands\n" | |
7926 | "Disable mtu mismatch detection\n" | |
7927 | "Address of interface") | |
7928 | { | |
8d769265 | 7929 | int idx_ipv4 = 4; |
ba682537 | 7930 | struct interface *ifp = vty->index; |
7931 | struct in_addr addr; | |
7932 | int ret; | |
7933 | ||
7934 | struct ospf_if_params *params; | |
7935 | params = IF_DEF_PARAMS (ifp); | |
7936 | ||
7a7be519 | 7937 | if (argc == 5) |
ba682537 | 7938 | { |
8d769265 | 7939 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
ba682537 | 7940 | if (!ret) |
7941 | { | |
7942 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7943 | VTY_NEWLINE); | |
7944 | return CMD_WARNING; | |
7945 | } | |
7946 | params = ospf_get_if_params (ifp, addr); | |
7947 | ospf_if_update_params (ifp, addr); | |
7948 | } | |
7949 | params->mtu_ignore = 0; | |
7950 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7951 | SET_IF_PARAM (params, mtu_ignore); | |
7952 | else | |
7953 | { | |
7954 | UNSET_IF_PARAM (params, mtu_ignore); | |
7955 | if (params != IF_DEF_PARAMS (ifp)) | |
7956 | { | |
7957 | ospf_free_if_params (ifp, addr); | |
7958 | ospf_if_update_params (ifp, addr); | |
7959 | } | |
7960 | } | |
7961 | return CMD_SUCCESS; | |
7962 | } | |
7963 | ||
6b0655a2 | 7964 | |
88d6cf37 | 7965 | DEFUN (ospf_max_metric_router_lsa_admin, |
7966 | ospf_max_metric_router_lsa_admin_cmd, | |
7967 | "max-metric router-lsa administrative", | |
7968 | "OSPF maximum / infinite-distance metric\n" | |
7969 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7970 | "Administratively applied, for an indefinite period\n") | |
7971 | { | |
7972 | struct listnode *ln; | |
7973 | struct ospf_area *area; | |
7974 | struct ospf *ospf = vty->index; | |
ba682537 | 7975 | |
7c8ff89e DS |
7976 | if (!ospf) |
7977 | return CMD_SUCCESS; | |
7978 | ||
88d6cf37 | 7979 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7980 | { | |
7981 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7982 | ||
7983 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 7984 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7985 | } |
4ba4fc85 AB |
7986 | |
7987 | /* Allows for areas configured later to get the property */ | |
7988 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
7989 | ||
88d6cf37 | 7990 | return CMD_SUCCESS; |
7991 | } | |
7992 | ||
7993 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
7994 | no_ospf_max_metric_router_lsa_admin_cmd, | |
7995 | "no max-metric router-lsa administrative", | |
7996 | NO_STR | |
7997 | "OSPF maximum / infinite-distance metric\n" | |
7998 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7999 | "Administratively applied, for an indefinite period\n") | |
8000 | { | |
8001 | struct listnode *ln; | |
8002 | struct ospf_area *area; | |
8003 | struct ospf *ospf = vty->index; | |
8004 | ||
7c8ff89e DS |
8005 | if (!ospf) |
8006 | return CMD_SUCCESS; | |
8007 | ||
88d6cf37 | 8008 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8009 | { | |
8010 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8011 | ||
8012 | /* Don't trample on the start-up stub timer */ | |
8013 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
8014 | && !area->t_stub_router) | |
8015 | { | |
8016 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8017 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8018 | } |
8019 | } | |
4ba4fc85 | 8020 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 8021 | return CMD_SUCCESS; |
8022 | } | |
8023 | ||
8024 | DEFUN (ospf_max_metric_router_lsa_startup, | |
8025 | ospf_max_metric_router_lsa_startup_cmd, | |
6147e2c6 | 8026 | "max-metric router-lsa on-startup (5-86400)", |
88d6cf37 | 8027 | "OSPF maximum / infinite-distance metric\n" |
8028 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8029 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8030 | "Time (seconds) to advertise self as stub-router\n") | |
8031 | { | |
8d769265 | 8032 | int idx_number = 3; |
88d6cf37 | 8033 | unsigned int seconds; |
8034 | struct ospf *ospf = vty->index; | |
8035 | ||
7c8ff89e DS |
8036 | if (!ospf) |
8037 | return CMD_SUCCESS; | |
8038 | ||
88d6cf37 | 8039 | if (argc != 1) |
8040 | { | |
8041 | vty_out (vty, "%% Must supply stub-router period"); | |
8042 | return CMD_WARNING; | |
8043 | } | |
8044 | ||
8d769265 | 8045 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[idx_number]->arg); |
88d6cf37 | 8046 | |
8047 | ospf->stub_router_startup_time = seconds; | |
8048 | ||
8049 | return CMD_SUCCESS; | |
8050 | } | |
8051 | ||
8052 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
8053 | no_ospf_max_metric_router_lsa_startup_cmd, | |
7a7be519 | 8054 | "no max-metric router-lsa on-startup [(5-86400)]", |
88d6cf37 | 8055 | NO_STR |
8056 | "OSPF maximum / infinite-distance metric\n" | |
8057 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8058 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
8059 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 8060 | { |
8061 | struct listnode *ln; | |
8062 | struct ospf_area *area; | |
8063 | struct ospf *ospf = vty->index; | |
8064 | ||
7c8ff89e DS |
8065 | if (!ospf) |
8066 | return CMD_SUCCESS; | |
8067 | ||
88d6cf37 | 8068 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8069 | ||
8070 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8071 | { | |
8072 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
8073 | OSPF_TIMER_OFF (area->t_stub_router); | |
8074 | ||
8075 | /* Don't trample on admin stub routed */ | |
8076 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8077 | { | |
8078 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8079 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8080 | } |
8081 | } | |
8082 | return CMD_SUCCESS; | |
8083 | } | |
8084 | ||
a1afa410 | 8085 | |
88d6cf37 | 8086 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
8087 | ospf_max_metric_router_lsa_shutdown_cmd, | |
6147e2c6 | 8088 | "max-metric router-lsa on-shutdown (5-100)", |
88d6cf37 | 8089 | "OSPF maximum / infinite-distance metric\n" |
8090 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8091 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
8092 | "Time (seconds) to wait till full shutdown\n") | |
8093 | { | |
8d769265 | 8094 | int idx_number = 3; |
88d6cf37 | 8095 | unsigned int seconds; |
8096 | struct ospf *ospf = vty->index; | |
8097 | ||
7c8ff89e DS |
8098 | if (!ospf) |
8099 | return CMD_SUCCESS; | |
8100 | ||
88d6cf37 | 8101 | if (argc != 1) |
8102 | { | |
8103 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
8104 | return CMD_WARNING; | |
8105 | } | |
8106 | ||
8d769265 | 8107 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[idx_number]->arg); |
88d6cf37 | 8108 | |
8109 | ospf->stub_router_shutdown_time = seconds; | |
8110 | ||
8111 | return CMD_SUCCESS; | |
8112 | } | |
8113 | ||
8114 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
8115 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
7a7be519 | 8116 | "no max-metric router-lsa on-shutdown [(5-100)]", |
88d6cf37 | 8117 | NO_STR |
8118 | "OSPF maximum / infinite-distance metric\n" | |
8119 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8120 | "Advertise stub-router prior to full shutdown of OSPF\n" |
8121 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 8122 | { |
8123 | struct ospf *ospf = vty->index; | |
8124 | ||
7c8ff89e DS |
8125 | if (!ospf) |
8126 | return CMD_SUCCESS; | |
8127 | ||
88d6cf37 | 8128 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8129 | ||
8130 | return CMD_SUCCESS; | |
8131 | } | |
8132 | ||
a636c635 DW |
8133 | static void |
8134 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
88d6cf37 | 8135 | { |
8136 | struct listnode *ln; | |
8137 | struct ospf_area *area; | |
8138 | ||
8139 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8140 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
8141 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
8142 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8143 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
8144 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
8145 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8146 | { | |
8147 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8148 | { | |
8149 | vty_out (vty, " max-metric router-lsa administrative%s", | |
8150 | VTY_NEWLINE); | |
8151 | break; | |
8152 | } | |
8153 | } | |
8154 | return; | |
8155 | } | |
6b0655a2 | 8156 | |
4dadc291 | 8157 | static void |
718e3744 | 8158 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
8159 | { | |
8160 | struct route_node *rn; | |
8161 | struct ospf_route *or; | |
1eb8ef25 | 8162 | struct listnode *pnode, *pnnode; |
718e3744 | 8163 | struct ospf_path *path; |
8164 | ||
8165 | vty_out (vty, "============ OSPF network routing table ============%s", | |
8166 | VTY_NEWLINE); | |
8167 | ||
8168 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8169 | if ((or = rn->info) != NULL) | |
8170 | { | |
8171 | char buf1[19]; | |
8172 | snprintf (buf1, 19, "%s/%d", | |
8173 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8174 | ||
8175 | switch (or->path_type) | |
8176 | { | |
8177 | case OSPF_PATH_INTER_AREA: | |
8178 | if (or->type == OSPF_DESTINATION_NETWORK) | |
8179 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
8180 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8181 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
8182 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
8183 | break; | |
8184 | case OSPF_PATH_INTRA_AREA: | |
8185 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
8186 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8187 | break; | |
8188 | default: | |
8189 | break; | |
8190 | } | |
8191 | ||
8192 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 8193 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 8194 | { |
a8ba847f | 8195 | if (if_lookup_by_index(path->ifindex)) |
96735eea | 8196 | { |
8197 | if (path->nexthop.s_addr == 0) | |
8198 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f | 8199 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 8200 | else |
8201 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
8202 | inet_ntoa (path->nexthop), |
8203 | ifindex2ifname (path->ifindex), VTY_NEWLINE); | |
96735eea | 8204 | } |
8205 | } | |
718e3744 | 8206 | } |
8207 | vty_out (vty, "%s", VTY_NEWLINE); | |
8208 | } | |
8209 | ||
4dadc291 | 8210 | static void |
718e3744 | 8211 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
8212 | { | |
8213 | struct route_node *rn; | |
8214 | struct ospf_route *or; | |
1eb8ef25 | 8215 | struct listnode *pnode; |
8216 | struct listnode *node; | |
718e3744 | 8217 | struct ospf_path *path; |
8218 | ||
8219 | vty_out (vty, "============ OSPF router routing table =============%s", | |
8220 | VTY_NEWLINE); | |
8221 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
8222 | if (rn->info) | |
8223 | { | |
8224 | int flag = 0; | |
8225 | ||
8226 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
8227 | ||
1eb8ef25 | 8228 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
8229 | { | |
8230 | if (flag++) | |
8231 | vty_out (vty, "%24s", ""); | |
8232 | ||
8233 | /* Show path. */ | |
8234 | vty_out (vty, "%s [%d] area: %s", | |
8235 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
8236 | or->cost, inet_ntoa (or->u.std.area_id)); | |
8237 | /* Show flags. */ | |
8238 | vty_out (vty, "%s%s%s", | |
8239 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
8240 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
8241 | VTY_NEWLINE); | |
8242 | ||
8243 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
8244 | { | |
a8ba847f | 8245 | if (if_lookup_by_index(path->ifindex)) |
54bedb55 | 8246 | { |
8247 | if (path->nexthop.s_addr == 0) | |
8248 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f JT |
8249 | "", ifindex2ifname (path->ifindex), |
8250 | VTY_NEWLINE); | |
54bedb55 | 8251 | else |
8252 | vty_out (vty, "%24s via %s, %s%s", "", | |
8253 | inet_ntoa (path->nexthop), | |
a8ba847f JT |
8254 | ifindex2ifname (path->ifindex), |
8255 | VTY_NEWLINE); | |
54bedb55 | 8256 | } |
1eb8ef25 | 8257 | } |
8258 | } | |
718e3744 | 8259 | } |
8260 | vty_out (vty, "%s", VTY_NEWLINE); | |
8261 | } | |
8262 | ||
4dadc291 | 8263 | static void |
718e3744 | 8264 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
8265 | { | |
8266 | struct route_node *rn; | |
8267 | struct ospf_route *er; | |
1eb8ef25 | 8268 | struct listnode *pnode, *pnnode; |
718e3744 | 8269 | struct ospf_path *path; |
8270 | ||
8271 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
8272 | VTY_NEWLINE); | |
8273 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8274 | if ((er = rn->info) != NULL) | |
8275 | { | |
8276 | char buf1[19]; | |
8277 | snprintf (buf1, 19, "%s/%d", | |
8278 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8279 | ||
8280 | switch (er->path_type) | |
8281 | { | |
8282 | case OSPF_PATH_TYPE1_EXTERNAL: | |
dc9ffce8 | 8283 | vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1, |
718e3744 | 8284 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
8285 | break; | |
8286 | case OSPF_PATH_TYPE2_EXTERNAL: | |
dc9ffce8 | 8287 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost, |
718e3744 | 8288 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
8289 | break; | |
8290 | } | |
8291 | ||
1eb8ef25 | 8292 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 8293 | { |
a8ba847f | 8294 | if (if_lookup_by_index(path->ifindex)) |
718e3744 | 8295 | { |
8296 | if (path->nexthop.s_addr == 0) | |
96735eea | 8297 | vty_out (vty, "%24s directly attached to %s%s", |
a8ba847f | 8298 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 8299 | else |
8300 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
8301 | inet_ntoa (path->nexthop), |
8302 | ifindex2ifname (path->ifindex), | |
96735eea | 8303 | VTY_NEWLINE); |
718e3744 | 8304 | } |
8305 | } | |
8306 | } | |
8307 | vty_out (vty, "%s", VTY_NEWLINE); | |
8308 | } | |
8309 | ||
7c8ff89e DS |
8310 | static int |
8311 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 8312 | { |
7c8ff89e DS |
8313 | if (ospf->instance) |
8314 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
8315 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 8316 | |
68980084 | 8317 | if (ospf->new_table == NULL) |
718e3744 | 8318 | { |
8319 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
8320 | return CMD_SUCCESS; | |
8321 | } | |
8322 | ||
8323 | /* Show Network routes. | |
020709f9 | 8324 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 8325 | |
8326 | /* Show Router routes. */ | |
68980084 | 8327 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8328 | |
7c8ff89e DS |
8329 | vty_out (vty, "%s", VTY_NEWLINE); |
8330 | ||
718e3744 | 8331 | return CMD_SUCCESS; |
8332 | } | |
718e3744 | 8333 | |
7c8ff89e DS |
8334 | DEFUN (show_ip_ospf_border_routers, |
8335 | show_ip_ospf_border_routers_cmd, | |
8336 | "show ip ospf border-routers", | |
718e3744 | 8337 | SHOW_STR |
8338 | IP_STR | |
8339 | "OSPF information\n" | |
7c8ff89e | 8340 | "Show all the ABR's and ASBR's\n") |
718e3744 | 8341 | { |
020709f9 | 8342 | struct ospf *ospf; |
68980084 | 8343 | |
0bad4851 | 8344 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8345 | return CMD_SUCCESS; |
8346 | ||
8347 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8348 | } | |
8349 | ||
8350 | DEFUN (show_ip_ospf_instance_border_routers, | |
8351 | show_ip_ospf_instance_border_routers_cmd, | |
6147e2c6 | 8352 | "show ip ospf (1-65535) border-routers", |
7c8ff89e DS |
8353 | SHOW_STR |
8354 | IP_STR | |
8355 | "OSPF information\n" | |
8356 | "Instance ID\n" | |
8357 | "Show all the ABR's and ASBR's\n") | |
8358 | { | |
8d769265 | 8359 | int idx_number = 3; |
7c8ff89e DS |
8360 | struct ospf *ospf; |
8361 | u_short instance = 0; | |
8362 | ||
8d769265 | 8363 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 8364 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8365 | return CMD_SUCCESS; |
8366 | ||
8367 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8368 | } | |
8369 | ||
8370 | static int | |
8371 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
8372 | { | |
8373 | if (ospf->instance) | |
8374 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
8375 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 8376 | |
68980084 | 8377 | if (ospf->new_table == NULL) |
718e3744 | 8378 | { |
8379 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
8380 | return CMD_SUCCESS; | |
8381 | } | |
8382 | ||
8383 | /* Show Network routes. */ | |
68980084 | 8384 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 8385 | |
8386 | /* Show Router routes. */ | |
68980084 | 8387 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8388 | |
8389 | /* Show AS External routes. */ | |
68980084 | 8390 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 8391 | |
7c8ff89e DS |
8392 | vty_out (vty, "%s", VTY_NEWLINE); |
8393 | ||
718e3744 | 8394 | return CMD_SUCCESS; |
8395 | } | |
8396 | ||
7c8ff89e DS |
8397 | DEFUN (show_ip_ospf_route, |
8398 | show_ip_ospf_route_cmd, | |
8399 | "show ip ospf route", | |
8400 | SHOW_STR | |
8401 | IP_STR | |
8402 | "OSPF information\n" | |
8403 | "OSPF routing table\n") | |
8404 | { | |
8405 | struct ospf *ospf; | |
8406 | ||
0bad4851 | 8407 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8408 | return CMD_SUCCESS; |
8409 | ||
8410 | return show_ip_ospf_route_common(vty, ospf); | |
8411 | } | |
8412 | ||
8413 | DEFUN (show_ip_ospf_instance_route, | |
8414 | show_ip_ospf_instance_route_cmd, | |
6147e2c6 | 8415 | "show ip ospf (1-65535) route", |
7c8ff89e DS |
8416 | SHOW_STR |
8417 | IP_STR | |
8418 | "OSPF information\n" | |
8419 | "Instance ID\n" | |
8420 | "OSPF routing table\n") | |
8421 | { | |
8d769265 | 8422 | int idx_number = 3; |
7c8ff89e DS |
8423 | struct ospf *ospf; |
8424 | u_short instance = 0; | |
8425 | ||
8d769265 | 8426 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 8427 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8428 | return CMD_SUCCESS; |
8429 | ||
8430 | return show_ip_ospf_route_common(vty, ospf); | |
8431 | } | |
6b0655a2 | 8432 | |
eb1ce605 | 8433 | const char *ospf_abr_type_str[] = |
718e3744 | 8434 | { |
8435 | "unknown", | |
8436 | "standard", | |
8437 | "ibm", | |
8438 | "cisco", | |
8439 | "shortcut" | |
8440 | }; | |
8441 | ||
eb1ce605 | 8442 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 8443 | { |
8444 | "default", | |
8445 | "enable", | |
8446 | "disable" | |
8447 | }; | |
8448 | ||
8449 | ||
4dadc291 | 8450 | static void |
718e3744 | 8451 | area_id2str (char *buf, int length, struct ospf_area *area) |
8452 | { | |
8453 | memset (buf, 0, length); | |
8454 | ||
8455 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
8456 | strncpy (buf, inet_ntoa (area->area_id), length); | |
8457 | else | |
8458 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); | |
8459 | } | |
8460 | ||
6b0655a2 | 8461 | |
eb1ce605 | 8462 | const char *ospf_int_type_str[] = |
718e3744 | 8463 | { |
8464 | "unknown", /* should never be used. */ | |
8465 | "point-to-point", | |
8466 | "broadcast", | |
8467 | "non-broadcast", | |
8468 | "point-to-multipoint", | |
8469 | "virtual-link", /* should never be used. */ | |
8470 | "loopback" | |
8471 | }; | |
8472 | ||
8473 | /* Configuration write function for ospfd. */ | |
4dadc291 | 8474 | static int |
718e3744 | 8475 | config_write_interface (struct vty *vty) |
8476 | { | |
52dc7ee6 | 8477 | struct listnode *n1, *n2; |
718e3744 | 8478 | struct interface *ifp; |
8479 | struct crypt_key *ck; | |
8480 | int write = 0; | |
8481 | struct route_node *rn = NULL; | |
8482 | struct ospf_if_params *params; | |
7c8ff89e | 8483 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 8484 | |
b2d7c082 | 8485 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp)) |
718e3744 | 8486 | { |
718e3744 | 8487 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
8488 | continue; | |
8489 | ||
84361d61 DS |
8490 | if (ifp->ifindex == IFINDEX_DELETED) |
8491 | continue; | |
8492 | ||
718e3744 | 8493 | vty_out (vty, "!%s", VTY_NEWLINE); |
8494 | vty_out (vty, "interface %s%s", ifp->name, | |
8495 | VTY_NEWLINE); | |
8496 | if (ifp->desc) | |
8497 | vty_out (vty, " description %s%s", ifp->desc, | |
8498 | VTY_NEWLINE); | |
8499 | ||
8500 | write++; | |
8501 | ||
8502 | params = IF_DEF_PARAMS (ifp); | |
8503 | ||
8504 | do { | |
8505 | /* Interface Network print. */ | |
8506 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 8507 | params->type != OSPF_IFTYPE_LOOPBACK) |
8508 | { | |
bc18d616 | 8509 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 8510 | { |
8511 | vty_out (vty, " ip ospf network %s", | |
8512 | ospf_int_type_str[params->type]); | |
8513 | if (params != IF_DEF_PARAMS (ifp)) | |
8514 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8515 | vty_out (vty, "%s", VTY_NEWLINE); | |
8516 | } | |
718e3744 | 8517 | } |
8518 | ||
8519 | /* OSPF interface authentication print */ | |
8520 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
8521 | params->auth_type != OSPF_AUTH_NOTSET) | |
8522 | { | |
eb1ce605 | 8523 | const char *auth_str; |
718e3744 | 8524 | |
8525 | /* Translation tables are not that much help here due to syntax | |
8526 | of the simple option */ | |
8527 | switch (params->auth_type) | |
8528 | { | |
8529 | ||
8530 | case OSPF_AUTH_NULL: | |
8531 | auth_str = " null"; | |
8532 | break; | |
8533 | ||
8534 | case OSPF_AUTH_SIMPLE: | |
8535 | auth_str = ""; | |
8536 | break; | |
8537 | ||
8538 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
8539 | auth_str = " message-digest"; | |
8540 | break; | |
8541 | ||
8542 | default: | |
8543 | auth_str = ""; | |
8544 | break; | |
8545 | } | |
8546 | ||
8547 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
8548 | if (params != IF_DEF_PARAMS (ifp)) | |
8549 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8550 | vty_out (vty, "%s", VTY_NEWLINE); | |
8551 | } | |
8552 | ||
8553 | /* Simple Authentication Password print. */ | |
8554 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
8555 | params->auth_simple[0] != '\0') | |
8556 | { | |
8557 | vty_out (vty, " ip ospf authentication-key %s", | |
8558 | params->auth_simple); | |
8559 | if (params != IF_DEF_PARAMS (ifp)) | |
8560 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8561 | vty_out (vty, "%s", VTY_NEWLINE); | |
8562 | } | |
8563 | ||
8564 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 8565 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 8566 | { |
718e3744 | 8567 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 8568 | ck->key_id, ck->auth_key); |
718e3744 | 8569 | if (params != IF_DEF_PARAMS (ifp)) |
8570 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8571 | vty_out (vty, "%s", VTY_NEWLINE); | |
8572 | } | |
8573 | ||
8574 | /* Interface Output Cost print. */ | |
8575 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
8576 | { | |
8577 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
8578 | if (params != IF_DEF_PARAMS (ifp)) | |
8579 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8580 | vty_out (vty, "%s", VTY_NEWLINE); | |
8581 | } | |
8582 | ||
8583 | /* Hello Interval print. */ | |
8584 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
8585 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
8586 | { | |
8587 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
8588 | if (params != IF_DEF_PARAMS (ifp)) | |
8589 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8590 | vty_out (vty, "%s", VTY_NEWLINE); | |
8591 | } | |
8592 | ||
8593 | ||
8594 | /* Router Dead Interval print. */ | |
8595 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
8596 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
8597 | { | |
f9ad937f | 8598 | vty_out (vty, " ip ospf dead-interval "); |
8599 | ||
8600 | /* fast hello ? */ | |
8601 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
8602 | vty_out (vty, "minimal hello-multiplier %d", | |
8603 | params->fast_hello); | |
8604 | else | |
8605 | vty_out (vty, "%u", params->v_wait); | |
8606 | ||
718e3744 | 8607 | if (params != IF_DEF_PARAMS (ifp)) |
8608 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8609 | vty_out (vty, "%s", VTY_NEWLINE); | |
8610 | } | |
8611 | ||
8612 | /* Router Priority print. */ | |
8613 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
8614 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
8615 | { | |
8616 | vty_out (vty, " ip ospf priority %u", params->priority); | |
8617 | if (params != IF_DEF_PARAMS (ifp)) | |
8618 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8619 | vty_out (vty, "%s", VTY_NEWLINE); | |
8620 | } | |
8621 | ||
8622 | /* Retransmit Interval print. */ | |
8623 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
8624 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
8625 | { | |
8626 | vty_out (vty, " ip ospf retransmit-interval %u", | |
8627 | params->retransmit_interval); | |
8628 | if (params != IF_DEF_PARAMS (ifp)) | |
8629 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8630 | vty_out (vty, "%s", VTY_NEWLINE); | |
8631 | } | |
8632 | ||
8633 | /* Transmit Delay print. */ | |
8634 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
8635 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8636 | { | |
8637 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
8638 | if (params != IF_DEF_PARAMS (ifp)) | |
8639 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8640 | vty_out (vty, "%s", VTY_NEWLINE); | |
8641 | } | |
8642 | ||
953cde65 JT |
8643 | /* Area print. */ |
8644 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
8645 | { | |
8646 | if (ospf->instance) | |
8647 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
8648 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
8649 | else | |
8650 | vty_out (vty, " ip ospf area %s%s", | |
8651 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
8652 | ||
8653 | } | |
8654 | ||
d5a5c8f0 | 8655 | /* bfd print. */ |
7f342629 | 8656 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 8657 | |
ba682537 | 8658 | /* MTU ignore print. */ |
8659 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
8660 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8661 | { | |
8662 | if (params->mtu_ignore == 0) | |
8663 | vty_out (vty, " no ip ospf mtu-ignore"); | |
8664 | else | |
8665 | vty_out (vty, " ip ospf mtu-ignore"); | |
8666 | if (params != IF_DEF_PARAMS (ifp)) | |
8667 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8668 | vty_out (vty, "%s", VTY_NEWLINE); | |
8669 | } | |
8670 | ||
8671 | ||
718e3744 | 8672 | while (1) |
8673 | { | |
8674 | if (rn == NULL) | |
8675 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
8676 | else | |
8677 | rn = route_next (rn); | |
8678 | ||
8679 | if (rn == NULL) | |
8680 | break; | |
8681 | params = rn->info; | |
8682 | if (params != NULL) | |
8683 | break; | |
8684 | } | |
8685 | } while (rn); | |
8686 | ||
718e3744 | 8687 | ospf_opaque_config_write_if (vty, ifp); |
718e3744 | 8688 | } |
8689 | ||
8690 | return write; | |
8691 | } | |
8692 | ||
4dadc291 | 8693 | static int |
68980084 | 8694 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8695 | { |
8696 | struct route_node *rn; | |
8697 | u_char buf[INET_ADDRSTRLEN]; | |
8698 | ||
8699 | /* `network area' print. */ | |
68980084 | 8700 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 8701 | if (rn->info) |
8702 | { | |
8703 | struct ospf_network *n = rn->info; | |
8704 | ||
8705 | memset (buf, 0, INET_ADDRSTRLEN); | |
8706 | ||
8707 | /* Create Area ID string by specified Area ID format. */ | |
8708 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 8709 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 8710 | else |
c9e52be3 | 8711 | sprintf ((char *) buf, "%lu", |
718e3744 | 8712 | (unsigned long int) ntohl (n->area_id.s_addr)); |
8713 | ||
8714 | /* Network print. */ | |
8715 | vty_out (vty, " network %s/%d area %s%s", | |
8716 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
8717 | buf, VTY_NEWLINE); | |
8718 | } | |
8719 | ||
8720 | return 0; | |
8721 | } | |
8722 | ||
4dadc291 | 8723 | static int |
68980084 | 8724 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8725 | { |
52dc7ee6 | 8726 | struct listnode *node; |
1eb8ef25 | 8727 | struct ospf_area *area; |
718e3744 | 8728 | u_char buf[INET_ADDRSTRLEN]; |
8729 | ||
8730 | /* Area configuration print. */ | |
1eb8ef25 | 8731 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 8732 | { |
718e3744 | 8733 | struct route_node *rn1; |
8734 | ||
c9e52be3 | 8735 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
718e3744 | 8736 | |
8737 | if (area->auth_type != OSPF_AUTH_NULL) | |
8738 | { | |
8739 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
8740 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
8741 | else | |
8742 | vty_out (vty, " area %s authentication message-digest%s", | |
8743 | buf, VTY_NEWLINE); | |
8744 | } | |
8745 | ||
8746 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
8747 | vty_out (vty, " area %s shortcut %s%s", buf, | |
8748 | ospf_shortcut_mode_str[area->shortcut_configured], | |
8749 | VTY_NEWLINE); | |
8750 | ||
8751 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 8752 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 8753 | ) |
8754 | { | |
b0a053be | 8755 | if (area->external_routing == OSPF_AREA_STUB) |
8756 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 8757 | else if (area->external_routing == OSPF_AREA_NSSA) |
8758 | { | |
8759 | vty_out (vty, " area %s nssa", buf); | |
8760 | switch (area->NSSATranslatorRole) | |
8761 | { | |
8762 | case OSPF_NSSA_ROLE_NEVER: | |
8763 | vty_out (vty, " translate-never"); | |
8764 | break; | |
8765 | case OSPF_NSSA_ROLE_ALWAYS: | |
8766 | vty_out (vty, " translate-always"); | |
8767 | break; | |
8768 | case OSPF_NSSA_ROLE_CANDIDATE: | |
8769 | default: | |
8770 | vty_out (vty, " translate-candidate"); | |
8771 | } | |
8772 | } | |
718e3744 | 8773 | |
8774 | if (area->no_summary) | |
8775 | vty_out (vty, " no-summary"); | |
8776 | ||
8777 | vty_out (vty, "%s", VTY_NEWLINE); | |
8778 | ||
8779 | if (area->default_cost != 1) | |
8780 | vty_out (vty, " area %s default-cost %d%s", buf, | |
8781 | area->default_cost, VTY_NEWLINE); | |
8782 | } | |
8783 | ||
8784 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
8785 | if (rn1->info) | |
8786 | { | |
8787 | struct ospf_area_range *range = rn1->info; | |
8788 | ||
8789 | vty_out (vty, " area %s range %s/%d", buf, | |
8790 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
8791 | ||
6c835671 | 8792 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 8793 | vty_out (vty, " cost %d", range->cost_config); |
8794 | ||
8795 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
8796 | vty_out (vty, " not-advertise"); | |
8797 | ||
8798 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
8799 | vty_out (vty, " substitute %s/%d", | |
8800 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
8801 | ||
8802 | vty_out (vty, "%s", VTY_NEWLINE); | |
8803 | } | |
8804 | ||
8805 | if (EXPORT_NAME (area)) | |
8806 | vty_out (vty, " area %s export-list %s%s", buf, | |
8807 | EXPORT_NAME (area), VTY_NEWLINE); | |
8808 | ||
8809 | if (IMPORT_NAME (area)) | |
8810 | vty_out (vty, " area %s import-list %s%s", buf, | |
8811 | IMPORT_NAME (area), VTY_NEWLINE); | |
8812 | ||
8813 | if (PREFIX_NAME_IN (area)) | |
8814 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
8815 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
8816 | ||
8817 | if (PREFIX_NAME_OUT (area)) | |
8818 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
8819 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
8820 | } | |
8821 | ||
8822 | return 0; | |
8823 | } | |
8824 | ||
4dadc291 | 8825 | static int |
68980084 | 8826 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 8827 | { |
8828 | struct ospf_nbr_nbma *nbr_nbma; | |
8829 | struct route_node *rn; | |
8830 | ||
8831 | /* Static Neighbor configuration print. */ | |
68980084 | 8832 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 8833 | if ((nbr_nbma = rn->info)) |
8834 | { | |
8835 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
8836 | ||
8837 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
8838 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
8839 | ||
8840 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
8841 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
8842 | ||
8843 | vty_out (vty, "%s", VTY_NEWLINE); | |
8844 | } | |
8845 | ||
8846 | return 0; | |
8847 | } | |
8848 | ||
4dadc291 | 8849 | static int |
68980084 | 8850 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 8851 | { |
52dc7ee6 | 8852 | struct listnode *node; |
1eb8ef25 | 8853 | struct ospf_vl_data *vl_data; |
718e3744 | 8854 | u_char buf[INET_ADDRSTRLEN]; |
8855 | ||
8856 | /* Virtual-Link print */ | |
1eb8ef25 | 8857 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 8858 | { |
52dc7ee6 | 8859 | struct listnode *n2; |
718e3744 | 8860 | struct crypt_key *ck; |
718e3744 | 8861 | struct ospf_interface *oi; |
8862 | ||
8863 | if (vl_data != NULL) | |
8864 | { | |
8865 | memset (buf, 0, INET_ADDRSTRLEN); | |
8866 | ||
8867 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 8868 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
718e3744 | 8869 | else |
c9e52be3 | 8870 | sprintf ((char *) buf, "%lu", |
718e3744 | 8871 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
8872 | oi = vl_data->vl_oi; | |
8873 | ||
8874 | /* timers */ | |
8875 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
8876 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
8877 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
8878 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8879 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
8880 | buf, | |
8881 | inet_ntoa (vl_data->vl_peer), | |
8882 | OSPF_IF_PARAM (oi, v_hello), | |
8883 | OSPF_IF_PARAM (oi, retransmit_interval), | |
8884 | OSPF_IF_PARAM (oi, transmit_delay), | |
8885 | OSPF_IF_PARAM (oi, v_wait), | |
8886 | VTY_NEWLINE); | |
8887 | else | |
8888 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
8889 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
8890 | /* Auth key */ | |
8891 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
8892 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
8893 | buf, | |
8894 | inet_ntoa (vl_data->vl_peer), | |
8895 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
8896 | VTY_NEWLINE); | |
8897 | /* md5 keys */ | |
1eb8ef25 | 8898 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
8899 | n2, ck)) | |
8900 | vty_out (vty, " area %s virtual-link %s" | |
8901 | " message-digest-key %d md5 %s%s", | |
8902 | buf, | |
8903 | inet_ntoa (vl_data->vl_peer), | |
8904 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 8905 | |
8906 | } | |
8907 | } | |
8908 | ||
8909 | return 0; | |
8910 | } | |
8911 | ||
6b0655a2 | 8912 | |
4dadc291 | 8913 | static int |
68980084 | 8914 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8915 | { |
8916 | int type; | |
8917 | ||
8918 | /* redistribute print. */ | |
8919 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
8920 | { |
8921 | struct list *red_list; | |
8922 | struct listnode *node; | |
8923 | struct ospf_redist *red; | |
718e3744 | 8924 | |
7c8ff89e DS |
8925 | red_list = ospf->redist[type]; |
8926 | if (!red_list) | |
8927 | continue; | |
8928 | ||
8929 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
8930 | { | |
8931 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
8932 | if (red->instance) | |
8933 | vty_out (vty, " %d", red->instance); | |
8934 | ||
8935 | if (red->dmetric.value >= 0) | |
8936 | vty_out (vty, " metric %d", red->dmetric.value); | |
8937 | ||
8938 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8939 | vty_out (vty, " metric-type 1"); | |
8940 | ||
8941 | if (ROUTEMAP_NAME (red)) | |
8942 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
8943 | ||
8944 | vty_out (vty, "%s", VTY_NEWLINE); | |
8945 | } | |
8946 | } | |
718e3744 | 8947 | |
8948 | return 0; | |
8949 | } | |
8950 | ||
4dadc291 | 8951 | static int |
68980084 | 8952 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 8953 | { |
68980084 | 8954 | if (ospf->default_metric != -1) |
8955 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 8956 | VTY_NEWLINE); |
8957 | return 0; | |
8958 | } | |
8959 | ||
4dadc291 | 8960 | static int |
68980084 | 8961 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8962 | { |
8963 | int type; | |
7c8ff89e | 8964 | struct ospf_redist *red; |
718e3744 | 8965 | |
68980084 | 8966 | if (ospf) |
718e3744 | 8967 | { |
8968 | /* distribute-list print. */ | |
8969 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 8970 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 8971 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 8972 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 8973 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 8974 | |
8975 | /* default-information print. */ | |
68980084 | 8976 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 8977 | { |
c42c177d | 8978 | vty_out (vty, " default-information originate"); |
8979 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
8980 | vty_out (vty, " always"); | |
718e3744 | 8981 | |
7c8ff89e DS |
8982 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8983 | if (red) | |
8984 | { | |
8985 | if (red->dmetric.value >= 0) | |
8986 | vty_out (vty, " metric %d", | |
8987 | red->dmetric.value); | |
8988 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8989 | vty_out (vty, " metric-type 1"); | |
8990 | ||
8991 | if (ROUTEMAP_NAME (red)) | |
8992 | vty_out (vty, " route-map %s", | |
8993 | ROUTEMAP_NAME (red)); | |
8994 | } | |
718e3744 | 8995 | |
8996 | vty_out (vty, "%s", VTY_NEWLINE); | |
8997 | } | |
8998 | ||
8999 | } | |
9000 | ||
9001 | return 0; | |
9002 | } | |
9003 | ||
4dadc291 | 9004 | static int |
68980084 | 9005 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 9006 | { |
9007 | struct route_node *rn; | |
9008 | struct ospf_distance *odistance; | |
9009 | ||
68980084 | 9010 | if (ospf->distance_all) |
9011 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 9012 | |
68980084 | 9013 | if (ospf->distance_intra |
9014 | || ospf->distance_inter | |
9015 | || ospf->distance_external) | |
718e3744 | 9016 | { |
9017 | vty_out (vty, " distance ospf"); | |
9018 | ||
68980084 | 9019 | if (ospf->distance_intra) |
9020 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
9021 | if (ospf->distance_inter) | |
9022 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
9023 | if (ospf->distance_external) | |
9024 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 9025 | |
9026 | vty_out (vty, "%s", VTY_NEWLINE); | |
9027 | } | |
9028 | ||
68980084 | 9029 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 9030 | if ((odistance = rn->info) != NULL) |
9031 | { | |
9032 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
9033 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9034 | odistance->access_list ? odistance->access_list : "", | |
9035 | VTY_NEWLINE); | |
9036 | } | |
9037 | return 0; | |
9038 | } | |
9039 | ||
9040 | /* OSPF configuration write function. */ | |
4dadc291 | 9041 | static int |
718e3744 | 9042 | ospf_config_write (struct vty *vty) |
9043 | { | |
020709f9 | 9044 | struct ospf *ospf; |
1eb8ef25 | 9045 | struct interface *ifp; |
9046 | struct ospf_interface *oi; | |
52dc7ee6 | 9047 | struct listnode *node; |
718e3744 | 9048 | int write = 0; |
9049 | ||
020709f9 | 9050 | ospf = ospf_lookup (); |
0bad4851 | 9051 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 9052 | { |
9053 | /* `router ospf' print. */ | |
7c8ff89e DS |
9054 | if (ospf->instance) |
9055 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
9056 | else | |
9057 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 9058 | |
9059 | write++; | |
9060 | ||
68980084 | 9061 | if (!ospf->networks) |
718e3744 | 9062 | return write; |
9063 | ||
9064 | /* Router ID print. */ | |
68980084 | 9065 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 9066 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 9067 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 9068 | |
9069 | /* ABR type print. */ | |
d57834f6 | 9070 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 9071 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 9072 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 9073 | |
d7e60dd7 AS |
9074 | /* log-adjacency-changes flag print. */ |
9075 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
9076 | { | |
d7e60dd7 | 9077 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
692c7954 | 9078 | vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE); |
d7e60dd7 | 9079 | } |
692c7954 DW |
9080 | else |
9081 | { | |
9082 | vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE); | |
9083 | } | |
d7e60dd7 | 9084 | |
718e3744 | 9085 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 9086 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 9087 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
9088 | ||
9089 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 9090 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 9091 | { |
9092 | vty_out (vty, "! Important: ensure reference bandwidth " | |
9093 | "is consistent across all routers%s", VTY_NEWLINE); | |
9094 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
70bd3c43 | 9095 | ospf->ref_bandwidth, VTY_NEWLINE); |
f9ad937f | 9096 | } |
718e3744 | 9097 | |
9098 | /* SPF timers print. */ | |
68980084 | 9099 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 9100 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
9101 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
9102 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 9103 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 9104 | ospf->spf_max_holdtime, VTY_NEWLINE); |
b6927875 DS |
9105 | |
9106 | /* LSA timers print. */ | |
ac7424f9 MR |
9107 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
9108 | vty_out (vty, " timers throttle lsa all %d%s", | |
9109 | ospf->min_ls_interval, VTY_NEWLINE); | |
9110 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
b6927875 | 9111 | vty_out (vty, " timers lsa min-arrival %d%s", |
ac7424f9 | 9112 | ospf->min_ls_arrival, VTY_NEWLINE); |
b6927875 | 9113 | |
2f8f370e | 9114 | /* Write multiplier print. */ |
e8f45e82 | 9115 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 9116 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 9117 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 9118 | |
88d6cf37 | 9119 | /* Max-metric router-lsa print */ |
9120 | config_write_stub_router (vty, ospf); | |
9121 | ||
718e3744 | 9122 | /* SPF refresh parameters print. */ |
68980084 | 9123 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 9124 | vty_out (vty, " refresh timer %d%s", |
68980084 | 9125 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 9126 | |
9127 | /* Redistribute information print. */ | |
68980084 | 9128 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 9129 | |
9130 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
9131 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
9132 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
9133 | ||
1eb8ef25 | 9134 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
9135 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
9136 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
9137 | ospf->passive_interface_default) | |
9138 | { | |
9139 | vty_out (vty, " %spassive-interface %s%s", | |
9140 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
9141 | ifp->name, VTY_NEWLINE); | |
9142 | } | |
1eb8ef25 | 9143 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
9144 | { |
9145 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
9146 | continue; | |
9147 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
9148 | passive_interface)) | |
9149 | { | |
9150 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
9151 | continue; | |
9152 | } | |
9153 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
9154 | continue; | |
9155 | ||
9156 | vty_out (vty, " %spassive-interface %s %s%s", | |
9157 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 9158 | oi->ifp->name, |
9159 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 9160 | } |
718e3744 | 9161 | |
9162 | /* Network area print. */ | |
68980084 | 9163 | config_write_network_area (vty, ospf); |
718e3744 | 9164 | |
9165 | /* Area config print. */ | |
68980084 | 9166 | config_write_ospf_area (vty, ospf); |
718e3744 | 9167 | |
9168 | /* static neighbor print. */ | |
68980084 | 9169 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 9170 | |
9171 | /* Virtual-Link print. */ | |
68980084 | 9172 | config_write_virtual_link (vty, ospf); |
718e3744 | 9173 | |
9174 | /* Default metric configuration. */ | |
68980084 | 9175 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 9176 | |
9177 | /* Distribute-list and default-information print. */ | |
68980084 | 9178 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 9179 | |
9180 | /* Distance configuration. */ | |
68980084 | 9181 | config_write_ospf_distance (vty, ospf); |
718e3744 | 9182 | |
68980084 | 9183 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 9184 | } |
9185 | ||
9186 | return write; | |
9187 | } | |
9188 | ||
9189 | void | |
4dadc291 | 9190 | ospf_vty_show_init (void) |
718e3744 | 9191 | { |
9192 | /* "show ip ospf" commands. */ | |
9193 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
718e3744 | 9194 | |
7c8ff89e | 9195 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
7c8ff89e | 9196 | |
718e3744 | 9197 | /* "show ip ospf database" commands. */ |
718e3744 | 9198 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
718e3744 | 9199 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
7a7be519 | 9200 | install_element (VIEW_NODE, &show_ip_ospf_database_max_cmd); |
718e3744 | 9201 | |
7c8ff89e | 9202 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); |
7c8ff89e | 9203 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); |
7a7be519 | 9204 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_max_cmd); |
7c8ff89e | 9205 | |
718e3744 | 9206 | /* "show ip ospf interface" commands. */ |
9207 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
718e3744 | 9208 | |
7c8ff89e | 9209 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
7c8ff89e | 9210 | |
718e3744 | 9211 | /* "show ip ospf neighbor" commands. */ |
9212 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
9213 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
9214 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
9215 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
9216 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
9217 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
9218 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
718e3744 | 9219 | |
7c8ff89e DS |
9220 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
9221 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
9222 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
9223 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
9224 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
9225 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
9226 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
7c8ff89e | 9227 | |
718e3744 | 9228 | /* "show ip ospf route" commands. */ |
9229 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 9230 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
7c8ff89e DS |
9231 | |
9232 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
7c8ff89e | 9233 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); |
718e3744 | 9234 | } |
9235 | ||
6b0655a2 | 9236 | |
718e3744 | 9237 | /* ospfd's interface node. */ |
7fc626de | 9238 | static struct cmd_node interface_node = |
718e3744 | 9239 | { |
9240 | INTERFACE_NODE, | |
9241 | "%s(config-if)# ", | |
9242 | 1 | |
9243 | }; | |
9244 | ||
9245 | /* Initialization of OSPF interface. */ | |
4dadc291 | 9246 | static void |
9247 | ospf_vty_if_init (void) | |
718e3744 | 9248 | { |
9249 | /* Install interface node. */ | |
9250 | install_node (&interface_node, config_write_interface); | |
9251 | ||
9252 | install_element (CONFIG_NODE, &interface_cmd); | |
32d2463c | 9253 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 9254 | install_default (INTERFACE_NODE); |
9255 | ||
9256 | /* "description" commands. */ | |
9257 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
9258 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
9259 | ||
9260 | /* "ip ospf authentication" commands. */ | |
9261 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
718e3744 | 9262 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
b4a039bf | 9263 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
718e3744 | 9264 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
718e3744 | 9265 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
813d4307 | 9266 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); |
7a7be519 | 9267 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_addr_cmd); |
718e3744 | 9268 | |
9269 | /* "ip ospf message-digest-key" commands. */ | |
9270 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); | |
813d4307 | 9271 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd); |
7a7be519 | 9272 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_addr_cmd); |
718e3744 | 9273 | |
9274 | /* "ip ospf cost" commands. */ | |
5c2fc921 QY |
9275 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
9276 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); | |
9277 | install_element (INTERFACE_NODE, &ospf_cost_cmd); | |
9278 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); | |
718e3744 | 9279 | |
ba682537 | 9280 | /* "ip ospf mtu-ignore" commands. */ |
9281 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
ba682537 | 9282 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
ba682537 | 9283 | |
718e3744 | 9284 | /* "ip ospf dead-interval" commands. */ |
0d829fa7 | 9285 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
f9ad937f | 9286 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
0d829fa7 | 9287 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
f9ad937f | 9288 | |
718e3744 | 9289 | /* "ip ospf hello-interval" commands. */ |
0d829fa7 QY |
9290 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
9291 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
718e3744 | 9292 | |
9293 | /* "ip ospf network" commands. */ | |
9294 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
9295 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
7a7be519 | 9296 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
718e3744 | 9297 | |
9298 | /* "ip ospf priority" commands. */ | |
9299 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); | |
813d4307 | 9300 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
7a7be519 | 9301 | install_element (INTERFACE_NODE, &no_ospf_priority_addr_cmd); |
718e3744 | 9302 | |
9303 | /* "ip ospf retransmit-interval" commands. */ | |
9304 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
718e3744 | 9305 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
7a7be519 | 9306 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
718e3744 | 9307 | |
9308 | /* "ip ospf transmit-delay" commands. */ | |
9309 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
718e3744 | 9310 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
7a7be519 | 9311 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
718e3744 | 9312 | |
953cde65 JT |
9313 | /* "ip ospf area" commands. */ |
9314 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
9315 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
953cde65 | 9316 | |
718e3744 | 9317 | /* These commands are compatibitliy for previous version. */ |
9318 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
718e3744 | 9319 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
718e3744 | 9320 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
718e3744 | 9321 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
718e3744 | 9322 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
718e3744 | 9323 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
718e3744 | 9324 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
718e3744 | 9325 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
718e3744 | 9326 | } |
9327 | ||
4dadc291 | 9328 | static void |
9329 | ospf_vty_zebra_init (void) | |
718e3744 | 9330 | { |
718e3744 | 9331 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 9332 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
9333 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
9334 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 9335 | |
9336 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
9337 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
9338 | ||
718e3744 | 9339 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 9340 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
9341 | ||
9342 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
9343 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
718e3744 | 9344 | |
9345 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
9346 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
9347 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 9348 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 9349 | #if 0 |
9350 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
9351 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
9352 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
9353 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
9354 | #endif /* 0 */ | |
9355 | } | |
9356 | ||
7fc626de | 9357 | static struct cmd_node ospf_node = |
718e3744 | 9358 | { |
9359 | OSPF_NODE, | |
9360 | "%s(config-router)# ", | |
9361 | 1 | |
9362 | }; | |
9363 | ||
09f35f8c DS |
9364 | static void |
9365 | ospf_interface_clear (struct interface *ifp) | |
9366 | { | |
9367 | if (!if_is_operative (ifp)) return; | |
9368 | ||
9369 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
9370 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); | |
9371 | ||
9372 | ospf_if_reset(ifp); | |
9373 | } | |
9374 | ||
9375 | DEFUN (clear_ip_ospf_interface, | |
9376 | clear_ip_ospf_interface_cmd, | |
9377 | "clear ip ospf interface [IFNAME]", | |
9378 | CLEAR_STR | |
9379 | IP_STR | |
9380 | "OSPF information\n" | |
9381 | "Interface information\n" | |
9382 | "Interface name\n") | |
9383 | { | |
8d769265 | 9384 | int idx_ifname = 4; |
09f35f8c DS |
9385 | struct interface *ifp; |
9386 | struct listnode *node; | |
9387 | ||
7a7be519 | 9388 | if (argc == 4) /* Clear all the ospfv2 interfaces. */ |
09f35f8c | 9389 | { |
b2d7c082 | 9390 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
09f35f8c DS |
9391 | ospf_interface_clear(ifp); |
9392 | } | |
9393 | else /* Interface name is specified. */ | |
9394 | { | |
7a7be519 | 9395 | if ((ifp = if_lookup_by_name (argv[idx_ifname]->text)) == NULL) |
09f35f8c DS |
9396 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
9397 | else | |
9398 | ospf_interface_clear(ifp); | |
9399 | } | |
9400 | ||
9401 | return CMD_SUCCESS; | |
9402 | } | |
9403 | ||
9404 | void | |
9405 | ospf_vty_clear_init (void) | |
9406 | { | |
9407 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
9408 | } | |
9409 | ||
6b0655a2 | 9410 | |
718e3744 | 9411 | /* Install OSPF related vty commands. */ |
9412 | void | |
4dadc291 | 9413 | ospf_vty_init (void) |
718e3744 | 9414 | { |
9415 | /* Install ospf top node. */ | |
9416 | install_node (&ospf_node, ospf_config_write); | |
9417 | ||
9418 | /* "router ospf" commands. */ | |
9419 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
9420 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
9421 | ||
7c8ff89e | 9422 | |
718e3744 | 9423 | install_default (OSPF_NODE); |
9424 | ||
9425 | /* "ospf router-id" commands. */ | |
9426 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
747e489c | 9427 | install_element (OSPF_NODE, &ospf_router_id_old_cmd); |
718e3744 | 9428 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
718e3744 | 9429 | |
9430 | /* "passive-interface" commands. */ | |
a2c62831 | 9431 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
a2c62831 | 9432 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
718e3744 | 9433 | |
9434 | /* "ospf abr-type" commands. */ | |
9435 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
9436 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
9437 | ||
d7e60dd7 AS |
9438 | /* "ospf log-adjacency-changes" commands. */ |
9439 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
9440 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
9441 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
9442 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
9443 | ||
718e3744 | 9444 | /* "ospf rfc1583-compatible" commands. */ |
718e3744 | 9445 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
9446 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
7a7be519 | 9447 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
9448 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
718e3744 | 9449 | |
9450 | /* "network area" commands. */ | |
a2c62831 | 9451 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
9452 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 9453 | |
9454 | /* "area authentication" commands. */ | |
a2c62831 | 9455 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
9456 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
9457 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 9458 | |
9459 | /* "area range" commands. */ | |
a2c62831 | 9460 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
7a7be519 | 9461 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
a2c62831 | 9462 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
9463 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
a2c62831 | 9464 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
9465 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 9466 | |
9467 | /* "area virtual-link" commands. */ | |
a2c62831 | 9468 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
7a7be519 | 9469 | install_element (OSPF_NODE, &ospf_area_vlink_intervals_cmd); |
a2c62831 | 9470 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
7a7be519 | 9471 | install_element (OSPF_NODE, &no_ospf_area_vlink_intervals_cmd); |
718e3744 | 9472 | |
718e3744 | 9473 | |
718e3744 | 9474 | |
718e3744 | 9475 | |
718e3744 | 9476 | |
718e3744 | 9477 | |
718e3744 | 9478 | |
718e3744 | 9479 | |
718e3744 | 9480 | |
718e3744 | 9481 | |
9482 | /* "area stub" commands. */ | |
a2c62831 | 9483 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
9484 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
9485 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
9486 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 9487 | |
718e3744 | 9488 | /* "area nssa" commands. */ |
a2c62831 | 9489 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
9490 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
9491 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
9492 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
9493 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
718e3744 | 9494 | |
a2c62831 | 9495 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
9496 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 9497 | |
a2c62831 | 9498 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
9499 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 9500 | |
a2c62831 | 9501 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
9502 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 9503 | |
a2c62831 | 9504 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
9505 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 9506 | |
a2c62831 | 9507 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
9508 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 9509 | |
9510 | /* SPF timer commands */ | |
d24f6e2a | 9511 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
9512 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
9513 | ||
b6927875 | 9514 | /* LSA timers commands */ |
ac7424f9 MR |
9515 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
9516 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
9517 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); | |
9518 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
b6927875 DS |
9519 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
9520 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
b6927875 | 9521 | |
88d6cf37 | 9522 | /* refresh timer commands */ |
a2c62831 | 9523 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
9524 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
718e3744 | 9525 | |
88d6cf37 | 9526 | /* max-metric commands */ |
9527 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
9528 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
9529 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
9530 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
9531 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
9532 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
9533 | ||
9534 | /* reference bandwidth commands */ | |
a2c62831 | 9535 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
9536 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
718e3744 | 9537 | |
9538 | /* "neighbor" commands. */ | |
a2c62831 | 9539 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
a2c62831 | 9540 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
a2c62831 | 9541 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
7a7be519 | 9542 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_cmd); |
718e3744 | 9543 | |
2f8f370e DS |
9544 | /* write multiplier commands */ |
9545 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
7a7be519 | 9546 | install_element (OSPF_NODE, &write_multiplier_cmd); |
2f8f370e | 9547 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); |
7a7be519 | 9548 | install_element (OSPF_NODE, &no_write_multiplier_cmd); |
2f8f370e | 9549 | |
718e3744 | 9550 | /* Init interface related vty commands. */ |
9551 | ospf_vty_if_init (); | |
9552 | ||
9553 | /* Init zebra related vty commands. */ | |
9554 | ospf_vty_zebra_init (); | |
9555 | } |