]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPF VTY interface. |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 Toshiaki Takada |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #include <zebra.h> | |
91756b38 | 24 | #include <lib/json.h> |
7ec4159b | 25 | #include <string.h> |
718e3744 | 26 | |
27 | #include "memory.h" | |
28 | #include "thread.h" | |
29 | #include "prefix.h" | |
30 | #include "table.h" | |
31 | #include "vty.h" | |
32 | #include "command.h" | |
33 | #include "plist.h" | |
34 | #include "log.h" | |
35 | #include "zclient.h" | |
8efe88ea | 36 | #include "defaults.h" |
718e3744 | 37 | |
38 | #include "ospfd/ospfd.h" | |
39 | #include "ospfd/ospf_asbr.h" | |
40 | #include "ospfd/ospf_lsa.h" | |
41 | #include "ospfd/ospf_lsdb.h" | |
42 | #include "ospfd/ospf_ism.h" | |
43 | #include "ospfd/ospf_interface.h" | |
44 | #include "ospfd/ospf_nsm.h" | |
45 | #include "ospfd/ospf_neighbor.h" | |
46 | #include "ospfd/ospf_flood.h" | |
47 | #include "ospfd/ospf_abr.h" | |
48 | #include "ospfd/ospf_spf.h" | |
49 | #include "ospfd/ospf_route.h" | |
50 | #include "ospfd/ospf_zebra.h" | |
51 | /*#include "ospfd/ospf_routemap.h" */ | |
52 | #include "ospfd/ospf_vty.h" | |
53 | #include "ospfd/ospf_dump.h" | |
7f342629 | 54 | #include "ospfd/ospf_bfd.h" |
718e3744 | 55 | |
30a2231a | 56 | static const char *ospf_network_type_str[] = |
718e3744 | 57 | { |
58 | "Null", | |
59 | "POINTOPOINT", | |
60 | "BROADCAST", | |
61 | "NBMA", | |
62 | "POINTOMULTIPOINT", | |
63 | "VIRTUALLINK", | |
64 | "LOOPBACK" | |
65 | }; | |
66 | ||
718e3744 | 67 | /* Utility functions. */ |
16f1b9ee | 68 | int |
6c835671 | 69 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
718e3744 | 70 | { |
71 | char *endptr = NULL; | |
72 | unsigned long ret; | |
73 | ||
74 | /* match "A.B.C.D". */ | |
75 | if (strchr (str, '.') != NULL) | |
76 | { | |
77 | ret = inet_aton (str, area_id); | |
78 | if (!ret) | |
79 | return -1; | |
80 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; | |
81 | } | |
82 | /* match "<0-4294967295>". */ | |
83 | else | |
84 | { | |
664711c1 UW |
85 | if (*str == '-') |
86 | return -1; | |
87 | errno = 0; | |
718e3744 | 88 | ret = strtoul (str, &endptr, 10); |
664711c1 | 89 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
718e3744 | 90 | return -1; |
91 | ||
92 | area_id->s_addr = htonl (ret); | |
93 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; | |
94 | } | |
95 | ||
96 | return 0; | |
97 | } | |
98 | ||
6b0655a2 | 99 | |
4dadc291 | 100 | static int |
6c835671 | 101 | str2metric (const char *str, int *metric) |
718e3744 | 102 | { |
103 | /* Sanity check. */ | |
104 | if (str == NULL) | |
105 | return 0; | |
106 | ||
107 | *metric = strtol (str, NULL, 10); | |
108 | if (*metric < 0 && *metric > 16777214) | |
109 | { | |
110 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
111 | return 0; | |
112 | } | |
113 | ||
114 | return 1; | |
115 | } | |
116 | ||
4dadc291 | 117 | static int |
6c835671 | 118 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 119 | { |
120 | /* Sanity check. */ | |
121 | if (str == NULL) | |
122 | return 0; | |
123 | ||
124 | if (strncmp (str, "1", 1) == 0) | |
125 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
126 | else if (strncmp (str, "2", 1) == 0) | |
127 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
128 | else | |
129 | return 0; | |
130 | ||
131 | return 1; | |
132 | } | |
133 | ||
134 | int | |
135 | ospf_oi_count (struct interface *ifp) | |
136 | { | |
137 | struct route_node *rn; | |
138 | int i = 0; | |
139 | ||
140 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
141 | if (rn->info) | |
142 | i++; | |
143 | ||
144 | return i; | |
145 | } | |
146 | ||
6b0655a2 | 147 | |
718e3744 | 148 | DEFUN (router_ospf, |
149 | router_ospf_cmd, | |
150 | "router ospf", | |
151 | "Enable a routing process\n" | |
152 | "Start OSPF configuration\n") | |
153 | { | |
7c8ff89e DS |
154 | struct ospf *ospf; |
155 | u_short instance = 0; | |
156 | ||
157 | ospf = ospf_lookup(); | |
158 | if (!ospf) | |
159 | { | |
160 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
161 | return CMD_WARNING; | |
162 | } | |
163 | ||
718e3744 | 164 | vty->node = OSPF_NODE; |
7c8ff89e DS |
165 | |
166 | if (argc) | |
167 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
168 | ||
169 | /* The following logic to set the vty->index is in place to be able | |
170 | to ignore the commands which dont belong to this instance. */ | |
171 | if (ospf->instance != instance) | |
172 | vty->index = NULL; | |
173 | else | |
0bad4851 DS |
174 | { |
175 | if (IS_DEBUG_OSPF_EVENT) | |
176 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
177 | ospf->oi_running = 1; | |
178 | vty->index = ospf; | |
179 | ospf_router_id_update (ospf); | |
180 | } | |
718e3744 | 181 | |
182 | return CMD_SUCCESS; | |
183 | } | |
184 | ||
7c8ff89e DS |
185 | ALIAS (router_ospf, |
186 | router_ospf_instance_cmd, | |
187 | "router ospf <1-65535>", | |
188 | "Enable a routing process\n" | |
189 | "Start OSPF configuration\n" | |
190 | "Instance ID\n") | |
191 | ||
718e3744 | 192 | DEFUN (no_router_ospf, |
193 | no_router_ospf_cmd, | |
194 | "no router ospf", | |
195 | NO_STR | |
196 | "Enable a routing process\n" | |
197 | "Start OSPF configuration\n") | |
198 | { | |
020709f9 | 199 | struct ospf *ospf; |
7c8ff89e | 200 | u_short instance = 0; |
020709f9 | 201 | |
7c8ff89e DS |
202 | if (argc) |
203 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
204 | ||
205 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
206 | return CMD_SUCCESS; | |
718e3744 | 207 | |
020709f9 | 208 | ospf_finish (ospf); |
718e3744 | 209 | |
210 | return CMD_SUCCESS; | |
211 | } | |
212 | ||
7c8ff89e DS |
213 | ALIAS (no_router_ospf, |
214 | no_router_ospf_instance_cmd, | |
215 | "no router ospf <1-65535>", | |
216 | NO_STR | |
217 | "Enable a routing process\n" | |
218 | "Start OSPF configuration\n" | |
219 | "Instance ID\n") | |
220 | ||
718e3744 | 221 | DEFUN (ospf_router_id, |
222 | ospf_router_id_cmd, | |
223 | "ospf router-id A.B.C.D", | |
224 | "OSPF specific commands\n" | |
225 | "router-id for the OSPF process\n" | |
226 | "OSPF router-id in IP address format\n") | |
227 | { | |
68980084 | 228 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
229 | struct listnode *node; |
230 | struct ospf_area *area; | |
718e3744 | 231 | struct in_addr router_id; |
68980084 | 232 | int ret; |
718e3744 | 233 | |
7c8ff89e DS |
234 | if (!ospf) |
235 | return CMD_SUCCESS; | |
236 | ||
718e3744 | 237 | ret = inet_aton (argv[0], &router_id); |
238 | if (!ret) | |
239 | { | |
240 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
241 | return CMD_WARNING; | |
242 | } | |
243 | ||
68980084 | 244 | ospf->router_id_static = router_id; |
2c19a6ec DS |
245 | |
246 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
247 | if (area->full_nbrs) | |
248 | { | |
249 | vty_out (vty, "For this router-id change to take effect," | |
250 | " save config and restart ospfd%s", VTY_NEWLINE); | |
251 | return CMD_SUCCESS; | |
252 | } | |
253 | ||
b29800a6 | 254 | ospf_router_id_update (ospf); |
255 | ||
718e3744 | 256 | return CMD_SUCCESS; |
257 | } | |
258 | ||
747e489c DW |
259 | ALIAS_HIDDEN (ospf_router_id, |
260 | ospf_router_id_old_cmd, | |
261 | "router-id A.B.C.D", | |
262 | "router-id for the OSPF process\n" | |
263 | "OSPF router-id in IP address format\n") | |
264 | ||
718e3744 | 265 | DEFUN (no_ospf_router_id, |
266 | no_ospf_router_id_cmd, | |
267 | "no ospf router-id", | |
268 | NO_STR | |
269 | "OSPF specific commands\n" | |
270 | "router-id for the OSPF process\n") | |
271 | { | |
68980084 | 272 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
273 | struct listnode *node; |
274 | struct ospf_area *area; | |
68980084 | 275 | |
7c8ff89e DS |
276 | if (!ospf) |
277 | return CMD_SUCCESS; | |
278 | ||
68980084 | 279 | ospf->router_id_static.s_addr = 0; |
718e3744 | 280 | |
2c19a6ec DS |
281 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
282 | if (area->full_nbrs) | |
283 | { | |
284 | vty_out (vty, "For this router-id change to take effect," | |
285 | " save config and restart ospfd%s", VTY_NEWLINE); | |
286 | return CMD_SUCCESS; | |
287 | } | |
288 | ||
68980084 | 289 | ospf_router_id_update (ospf); |
718e3744 | 290 | |
291 | return CMD_SUCCESS; | |
292 | } | |
293 | ||
294 | ALIAS (no_ospf_router_id, | |
12fde75b DW |
295 | no_ospf_router_id_val_cmd, |
296 | "no ospf router-id A.B.C.D", | |
718e3744 | 297 | NO_STR |
12fde75b DW |
298 | "OSPF specific commands\n" |
299 | "router-id for the OSPF process\n" | |
300 | "OSPF router-id in IP address format\n") | |
718e3744 | 301 | |
7ffa8fa2 | 302 | static void |
43540886 | 303 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
304 | { |
305 | struct listnode *ln; | |
306 | struct interface *ifp; | |
307 | struct ospf_interface *oi; | |
308 | ||
43540886 AS |
309 | ospf->passive_interface_default = newval; |
310 | ||
7ffa8fa2 PJ |
311 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
312 | { | |
313 | if (ifp && | |
314 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
315 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
316 | } | |
317 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
318 | { | |
319 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
320 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
321 | /* update multicast memberships */ |
322 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
323 | } |
324 | } | |
325 | ||
326 | static void | |
f842f166 PJ |
327 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
328 | struct ospf_if_params *params, u_char value, | |
329 | struct in_addr addr) | |
7ffa8fa2 PJ |
330 | { |
331 | u_char dflt; | |
332 | ||
333 | params->passive_interface = value; | |
334 | if (params != IF_DEF_PARAMS (ifp)) | |
335 | { | |
336 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
337 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
338 | else | |
339 | dflt = ospf->passive_interface_default; | |
340 | ||
341 | if (value != dflt) | |
342 | SET_IF_PARAM (params, passive_interface); | |
343 | else | |
344 | UNSET_IF_PARAM (params, passive_interface); | |
345 | ||
346 | ospf_free_if_params (ifp, addr); | |
347 | ospf_if_update_params (ifp, addr); | |
348 | } | |
f842f166 PJ |
349 | } |
350 | ||
351 | static void | |
352 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
353 | struct ospf_if_params *params, u_char value) | |
354 | { | |
355 | params->passive_interface = value; | |
356 | if (params == IF_DEF_PARAMS (ifp)) | |
7ffa8fa2 PJ |
357 | { |
358 | if (value != ospf->passive_interface_default) | |
359 | SET_IF_PARAM (params, passive_interface); | |
360 | else | |
361 | UNSET_IF_PARAM (params, passive_interface); | |
362 | } | |
363 | } | |
364 | ||
a2c62831 | 365 | DEFUN (ospf_passive_interface, |
366 | ospf_passive_interface_addr_cmd, | |
718e3744 | 367 | "passive-interface IFNAME A.B.C.D", |
368 | "Suppress routing updates on an interface\n" | |
369 | "Interface's name\n") | |
370 | { | |
7ffa8fa2 | 371 | struct interface *ifp; |
cb2af5d0 | 372 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
7ffa8fa2 PJ |
373 | int ret; |
374 | struct ospf_if_params *params; | |
375 | struct route_node *rn; | |
376 | struct ospf *ospf = vty->index; | |
718e3744 | 377 | |
7c8ff89e DS |
378 | if (!ospf) |
379 | return CMD_SUCCESS; | |
380 | ||
43540886 AS |
381 | if (argc == 0) |
382 | { | |
383 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
384 | return CMD_SUCCESS; | |
385 | } | |
386 | ||
7ffa8fa2 | 387 | ifp = if_get_by_name (argv[0]); |
718e3744 | 388 | |
389 | params = IF_DEF_PARAMS (ifp); | |
390 | ||
43540886 | 391 | if (argc == 2) |
718e3744 | 392 | { |
43540886 AS |
393 | ret = inet_aton(argv[1], &addr); |
394 | if (!ret) | |
395 | { | |
396 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
397 | VTY_NEWLINE); | |
398 | return CMD_WARNING; | |
399 | } | |
400 | ||
401 | params = ospf_get_if_params (ifp, addr); | |
402 | ospf_if_update_params (ifp, addr); | |
f842f166 PJ |
403 | ospf_passive_interface_update_addr (ospf, ifp, params, |
404 | OSPF_IF_PASSIVE, addr); | |
7ffa8fa2 | 405 | } |
f842f166 PJ |
406 | |
407 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); | |
43540886 | 408 | |
ba6454ec | 409 | /* XXX We should call ospf_if_set_multicast on exactly those |
410 | * interfaces for which the passive property changed. It is too much | |
411 | * work to determine this set, so we do this for every interface. | |
412 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
413 | * record of joined groups to avoid systems calls if the desired | |
414 | * memberships match the current memership. | |
415 | */ | |
7ffa8fa2 | 416 | |
ba6454ec | 417 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
418 | { | |
419 | struct ospf_interface *oi = rn->info; | |
420 | ||
421 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 422 | ospf_if_set_multicast(oi); |
ba6454ec | 423 | } |
424 | /* | |
425 | * XXX It is not clear what state transitions the interface needs to | |
426 | * undergo when going from active to passive. Fixing this will | |
427 | * require precise identification of interfaces having such a | |
428 | * transition. | |
429 | */ | |
430 | ||
718e3744 | 431 | return CMD_SUCCESS; |
432 | } | |
433 | ||
a2c62831 | 434 | ALIAS (ospf_passive_interface, |
435 | ospf_passive_interface_cmd, | |
718e3744 | 436 | "passive-interface IFNAME", |
437 | "Suppress routing updates on an interface\n" | |
438 | "Interface's name\n") | |
439 | ||
7ffa8fa2 PJ |
440 | ALIAS (ospf_passive_interface, |
441 | ospf_passive_interface_default_cmd, | |
442 | "passive-interface default", | |
443 | "Suppress routing updates on an interface\n" | |
444 | "Suppress routing updates on interfaces by default\n") | |
445 | ||
a2c62831 | 446 | DEFUN (no_ospf_passive_interface, |
447 | no_ospf_passive_interface_addr_cmd, | |
718e3744 | 448 | "no passive-interface IFNAME A.B.C.D", |
449 | NO_STR | |
450 | "Allow routing updates on an interface\n" | |
451 | "Interface's name\n") | |
452 | { | |
453 | struct interface *ifp; | |
cb2af5d0 | 454 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
718e3744 | 455 | struct ospf_if_params *params; |
456 | int ret; | |
ba6454ec | 457 | struct route_node *rn; |
7ffa8fa2 | 458 | struct ospf *ospf = vty->index; |
43540886 | 459 | |
7c8ff89e DS |
460 | if (!ospf) |
461 | return CMD_SUCCESS; | |
462 | ||
43540886 AS |
463 | if (argc == 0) |
464 | { | |
465 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
466 | return CMD_SUCCESS; | |
467 | } | |
718e3744 | 468 | |
6e72cb6a | 469 | ifp = if_get_by_name (argv[0]); |
718e3744 | 470 | |
471 | params = IF_DEF_PARAMS (ifp); | |
472 | ||
43540886 | 473 | if (argc == 2) |
718e3744 | 474 | { |
43540886 AS |
475 | ret = inet_aton(argv[1], &addr); |
476 | if (!ret) | |
477 | { | |
478 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
479 | VTY_NEWLINE); | |
480 | return CMD_WARNING; | |
481 | } | |
482 | ||
483 | params = ospf_lookup_if_params (ifp, addr); | |
484 | if (params == NULL) | |
485 | return CMD_SUCCESS; | |
f842f166 PJ |
486 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
487 | addr); | |
718e3744 | 488 | } |
f842f166 PJ |
489 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
490 | ||
ba6454ec | 491 | /* XXX We should call ospf_if_set_multicast on exactly those |
492 | * interfaces for which the passive property changed. It is too much | |
493 | * work to determine this set, so we do this for every interface. | |
494 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
495 | * record of joined groups to avoid systems calls if the desired | |
496 | * memberships match the current memership. | |
497 | */ | |
498 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
499 | { | |
500 | struct ospf_interface *oi = rn->info; | |
501 | ||
502 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
503 | ospf_if_set_multicast(oi); | |
504 | } | |
505 | ||
718e3744 | 506 | return CMD_SUCCESS; |
507 | } | |
508 | ||
a2c62831 | 509 | ALIAS (no_ospf_passive_interface, |
510 | no_ospf_passive_interface_cmd, | |
718e3744 | 511 | "no passive-interface IFNAME", |
512 | NO_STR | |
513 | "Allow routing updates on an interface\n" | |
514 | "Interface's name\n") | |
515 | ||
7ffa8fa2 PJ |
516 | ALIAS (no_ospf_passive_interface, |
517 | no_ospf_passive_interface_default_cmd, | |
518 | "no passive-interface default", | |
519 | NO_STR | |
520 | "Allow routing updates on an interface\n" | |
521 | "Allow routing updates on interfaces by default\n") | |
522 | ||
a2c62831 | 523 | DEFUN (ospf_network_area, |
524 | ospf_network_area_cmd, | |
718e3744 | 525 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
526 | "Enable routing on an IP network\n" | |
527 | "OSPF network prefix\n" | |
528 | "Set the OSPF area ID\n" | |
529 | "OSPF area ID in IP address format\n" | |
530 | "OSPF area ID as a decimal value\n") | |
531 | { | |
532 | struct ospf *ospf= vty->index; | |
533 | struct prefix_ipv4 p; | |
534 | struct in_addr area_id; | |
535 | int ret, format; | |
536 | ||
7c8ff89e DS |
537 | if (!ospf) |
538 | return CMD_SUCCESS; | |
539 | ||
540 | if (ospf->instance) | |
541 | { | |
542 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
543 | VTY_NEWLINE); | |
544 | return CMD_WARNING; | |
545 | } | |
546 | ||
953cde65 JT |
547 | if (ospf->if_ospf_cli_count > 0) |
548 | { | |
549 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
550 | VTY_NEWLINE); | |
551 | return CMD_WARNING; | |
552 | } | |
553 | ||
718e3744 | 554 | /* Get network prefix and Area ID. */ |
555 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
556 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
557 | ||
558 | ret = ospf_network_set (ospf, &p, area_id); | |
559 | if (ret == 0) | |
560 | { | |
561 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
562 | return CMD_WARNING; | |
563 | } | |
564 | ||
565 | return CMD_SUCCESS; | |
566 | } | |
567 | ||
a2c62831 | 568 | DEFUN (no_ospf_network_area, |
569 | no_ospf_network_area_cmd, | |
718e3744 | 570 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
571 | NO_STR | |
572 | "Enable routing on an IP network\n" | |
573 | "OSPF network prefix\n" | |
574 | "Set the OSPF area ID\n" | |
575 | "OSPF area ID in IP address format\n" | |
576 | "OSPF area ID as a decimal value\n") | |
577 | { | |
578 | struct ospf *ospf = (struct ospf *) vty->index; | |
579 | struct prefix_ipv4 p; | |
580 | struct in_addr area_id; | |
581 | int ret, format; | |
582 | ||
7c8ff89e DS |
583 | if (!ospf) |
584 | return CMD_SUCCESS; | |
585 | ||
586 | if (ospf->instance) | |
587 | { | |
588 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
589 | VTY_NEWLINE); | |
590 | return CMD_WARNING; | |
591 | } | |
592 | ||
718e3744 | 593 | /* Get network prefix and Area ID. */ |
594 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
595 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
596 | ||
597 | ret = ospf_network_unset (ospf, &p, area_id); | |
598 | if (ret == 0) | |
599 | { | |
600 | vty_out (vty, "Can't find specified network area configuration.%s", | |
601 | VTY_NEWLINE); | |
602 | return CMD_WARNING; | |
603 | } | |
604 | ||
605 | return CMD_SUCCESS; | |
606 | } | |
607 | ||
6b0655a2 | 608 | |
a2c62831 | 609 | DEFUN (ospf_area_range, |
610 | ospf_area_range_cmd, | |
718e3744 | 611 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
612 | "OSPF area parameters\n" | |
613 | "OSPF area ID in IP address format\n" | |
614 | "OSPF area ID as a decimal value\n" | |
615 | "Summarize routes matching address/mask (border routers only)\n" | |
616 | "Area range prefix\n") | |
617 | { | |
618 | struct ospf *ospf = vty->index; | |
619 | struct prefix_ipv4 p; | |
620 | struct in_addr area_id; | |
621 | int format; | |
622 | u_int32_t cost; | |
623 | ||
7c8ff89e DS |
624 | if (!ospf) |
625 | return CMD_SUCCESS; | |
626 | ||
718e3744 | 627 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
628 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
629 | ||
630 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
631 | if (argc > 2) | |
632 | { | |
4dadc291 | 633 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
718e3744 | 634 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
635 | } | |
636 | ||
637 | return CMD_SUCCESS; | |
638 | } | |
639 | ||
a2c62831 | 640 | ALIAS (ospf_area_range, |
641 | ospf_area_range_advertise_cmd, | |
718e3744 | 642 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
643 | "OSPF area parameters\n" | |
644 | "OSPF area ID in IP address format\n" | |
645 | "OSPF area ID as a decimal value\n" | |
646 | "OSPF area range for route advertise (default)\n" | |
647 | "Area range prefix\n" | |
648 | "Advertise this range (default)\n") | |
649 | ||
a2c62831 | 650 | ALIAS (ospf_area_range, |
651 | ospf_area_range_cost_cmd, | |
718e3744 | 652 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
653 | "OSPF area parameters\n" | |
654 | "OSPF area ID in IP address format\n" | |
655 | "OSPF area ID as a decimal value\n" | |
656 | "Summarize routes matching address/mask (border routers only)\n" | |
657 | "Area range prefix\n" | |
658 | "User specified metric for this range\n" | |
659 | "Advertised metric for this range\n") | |
660 | ||
a2c62831 | 661 | ALIAS (ospf_area_range, |
662 | ospf_area_range_advertise_cost_cmd, | |
718e3744 | 663 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
664 | "OSPF area parameters\n" | |
665 | "OSPF area ID in IP address format\n" | |
666 | "OSPF area ID as a decimal value\n" | |
667 | "Summarize routes matching address/mask (border routers only)\n" | |
668 | "Area range prefix\n" | |
669 | "Advertise this range (default)\n" | |
670 | "User specified metric for this range\n" | |
671 | "Advertised metric for this range\n") | |
672 | ||
a2c62831 | 673 | DEFUN (ospf_area_range_not_advertise, |
674 | ospf_area_range_not_advertise_cmd, | |
718e3744 | 675 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
676 | "OSPF area parameters\n" | |
677 | "OSPF area ID in IP address format\n" | |
678 | "OSPF area ID as a decimal value\n" | |
679 | "Summarize routes matching address/mask (border routers only)\n" | |
680 | "Area range prefix\n" | |
681 | "DoNotAdvertise this range\n") | |
682 | { | |
683 | struct ospf *ospf = vty->index; | |
684 | struct prefix_ipv4 p; | |
685 | struct in_addr area_id; | |
686 | int format; | |
687 | ||
7c8ff89e DS |
688 | if (!ospf) |
689 | return CMD_SUCCESS; | |
690 | ||
718e3744 | 691 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
692 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
693 | ||
694 | ospf_area_range_set (ospf, area_id, &p, 0); | |
695 | ||
696 | return CMD_SUCCESS; | |
697 | } | |
698 | ||
a2c62831 | 699 | DEFUN (no_ospf_area_range, |
700 | no_ospf_area_range_cmd, | |
718e3744 | 701 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
702 | NO_STR | |
703 | "OSPF area parameters\n" | |
704 | "OSPF area ID in IP address format\n" | |
705 | "OSPF area ID as a decimal value\n" | |
706 | "Summarize routes matching address/mask (border routers only)\n" | |
707 | "Area range prefix\n") | |
708 | { | |
709 | struct ospf *ospf = vty->index; | |
710 | struct prefix_ipv4 p; | |
711 | struct in_addr area_id; | |
712 | int format; | |
713 | ||
7c8ff89e DS |
714 | if (!ospf) |
715 | return CMD_SUCCESS; | |
716 | ||
718e3744 | 717 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
718 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
719 | ||
720 | ospf_area_range_unset (ospf, area_id, &p); | |
721 | ||
722 | return CMD_SUCCESS; | |
723 | } | |
724 | ||
a2c62831 | 725 | ALIAS (no_ospf_area_range, |
726 | no_ospf_area_range_advertise_cmd, | |
718e3744 | 727 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
728 | NO_STR | |
729 | "OSPF area parameters\n" | |
730 | "OSPF area ID in IP address format\n" | |
731 | "OSPF area ID as a decimal value\n" | |
732 | "Summarize routes matching address/mask (border routers only)\n" | |
733 | "Area range prefix\n" | |
734 | "Advertise this range (default)\n" | |
735 | "DoNotAdvertise this range\n") | |
736 | ||
a2c62831 | 737 | ALIAS (no_ospf_area_range, |
738 | no_ospf_area_range_cost_cmd, | |
718e3744 | 739 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
740 | NO_STR | |
741 | "OSPF area parameters\n" | |
742 | "OSPF area ID in IP address format\n" | |
743 | "OSPF area ID as a decimal value\n" | |
744 | "Summarize routes matching address/mask (border routers only)\n" | |
745 | "Area range prefix\n" | |
746 | "User specified metric for this range\n" | |
747 | "Advertised metric for this range\n") | |
748 | ||
a2c62831 | 749 | ALIAS (no_ospf_area_range, |
750 | no_ospf_area_range_advertise_cost_cmd, | |
718e3744 | 751 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
752 | NO_STR | |
753 | "OSPF area parameters\n" | |
754 | "OSPF area ID in IP address format\n" | |
755 | "OSPF area ID as a decimal value\n" | |
756 | "Summarize routes matching address/mask (border routers only)\n" | |
757 | "Area range prefix\n" | |
758 | "Advertise this range (default)\n" | |
759 | "User specified metric for this range\n" | |
760 | "Advertised metric for this range\n") | |
6b0655a2 | 761 | |
a2c62831 | 762 | DEFUN (ospf_area_range_substitute, |
763 | ospf_area_range_substitute_cmd, | |
718e3744 | 764 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
765 | "OSPF area parameters\n" | |
766 | "OSPF area ID in IP address format\n" | |
767 | "OSPF area ID as a decimal value\n" | |
768 | "Summarize routes matching address/mask (border routers only)\n" | |
769 | "Area range prefix\n" | |
770 | "Announce area range as another prefix\n" | |
771 | "Network prefix to be announced instead of range\n") | |
772 | { | |
773 | struct ospf *ospf = vty->index; | |
774 | struct prefix_ipv4 p, s; | |
775 | struct in_addr area_id; | |
776 | int format; | |
777 | ||
7c8ff89e DS |
778 | if (!ospf) |
779 | return CMD_SUCCESS; | |
780 | ||
718e3744 | 781 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
782 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
783 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
784 | ||
785 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
786 | ||
787 | return CMD_SUCCESS; | |
788 | } | |
789 | ||
a2c62831 | 790 | DEFUN (no_ospf_area_range_substitute, |
791 | no_ospf_area_range_substitute_cmd, | |
718e3744 | 792 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
793 | NO_STR | |
794 | "OSPF area parameters\n" | |
795 | "OSPF area ID in IP address format\n" | |
796 | "OSPF area ID as a decimal value\n" | |
797 | "Summarize routes matching address/mask (border routers only)\n" | |
798 | "Area range prefix\n" | |
799 | "Announce area range as another prefix\n" | |
800 | "Network prefix to be announced instead of range\n") | |
801 | { | |
802 | struct ospf *ospf = vty->index; | |
803 | struct prefix_ipv4 p, s; | |
804 | struct in_addr area_id; | |
805 | int format; | |
806 | ||
7c8ff89e DS |
807 | if (!ospf) |
808 | return CMD_SUCCESS; | |
809 | ||
718e3744 | 810 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
811 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
812 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
813 | ||
814 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
815 | ||
816 | return CMD_SUCCESS; | |
817 | } | |
818 | ||
6b0655a2 | 819 | |
718e3744 | 820 | /* Command Handler Logic in VLink stuff is delicate!! |
821 | ||
822 | ALTER AT YOUR OWN RISK!!!! | |
823 | ||
824 | Various dummy values are used to represent 'NoChange' state for | |
825 | VLink configuration NOT being changed by a VLink command, and | |
826 | special syntax is used within the command strings so that the | |
827 | typed in command verbs can be seen in the configuration command | |
828 | bacckend handler. This is to drastically reduce the verbeage | |
829 | required to coe up with a reasonably compatible Cisco VLink command | |
830 | ||
831 | - Matthew Grant <grantma@anathoth.gen.nz> | |
832 | Wed, 21 Feb 2001 15:13:52 +1300 | |
833 | */ | |
834 | ||
835 | ||
836 | /* Configuration data for virtual links | |
837 | */ | |
838 | struct ospf_vl_config_data { | |
839 | struct vty *vty; /* vty stuff */ | |
840 | struct in_addr area_id; /* area ID from command line */ | |
841 | int format; /* command line area ID format */ | |
842 | struct in_addr vl_peer; /* command line vl_peer */ | |
843 | int auth_type; /* Authehntication type, if given */ | |
844 | char *auth_key; /* simple password if present */ | |
845 | int crypto_key_id; /* Cryptographic key ID */ | |
846 | char *md5_key; /* MD5 authentication key */ | |
847 | int hello_interval; /* Obvious what these are... */ | |
848 | int retransmit_interval; | |
849 | int transmit_delay; | |
850 | int dead_interval; | |
851 | }; | |
852 | ||
4dadc291 | 853 | static void |
718e3744 | 854 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
855 | struct vty *vty) | |
856 | { | |
857 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
858 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
859 | vl_config->vty = vty; | |
860 | } | |
861 | ||
4dadc291 | 862 | static struct ospf_vl_data * |
68980084 | 863 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 864 | { |
865 | struct ospf_area *area; | |
866 | struct ospf_vl_data *vl_data; | |
867 | struct vty *vty; | |
868 | struct in_addr area_id; | |
869 | ||
870 | vty = vl_config->vty; | |
871 | area_id = vl_config->area_id; | |
872 | ||
873 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
874 | { | |
875 | vty_out (vty, | |
876 | "Configuring VLs over the backbone is not allowed%s", | |
877 | VTY_NEWLINE); | |
878 | return NULL; | |
879 | } | |
68980084 | 880 | area = ospf_area_get (ospf, area_id, vl_config->format); |
718e3744 | 881 | |
882 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
883 | { | |
884 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
885 | vty_out (vty, "Area %s is %s%s", | |
886 | inet_ntoa (area_id), | |
718e3744 | 887 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 888 | VTY_NEWLINE); |
889 | else | |
890 | vty_out (vty, "Area %ld is %s%s", | |
891 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 892 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 893 | VTY_NEWLINE); |
894 | return NULL; | |
895 | } | |
896 | ||
9c27ef9b | 897 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 898 | { |
899 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
900 | if (vl_data->vl_oi == NULL) | |
901 | { | |
68980084 | 902 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
903 | ospf_vl_add (ospf, vl_data); | |
d3a9c768 | 904 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 905 | } |
906 | } | |
907 | return vl_data; | |
908 | } | |
909 | ||
910 | ||
4dadc291 | 911 | static int |
718e3744 | 912 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
913 | struct ospf_vl_config_data *vl_config) | |
914 | { | |
915 | struct crypt_key *ck; | |
916 | struct vty *vty; | |
917 | struct interface *ifp = vl_data->vl_oi->ifp; | |
918 | ||
919 | vty = vl_config->vty; | |
920 | ||
921 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
922 | { | |
923 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
924 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
925 | } | |
926 | ||
927 | if (vl_config->auth_key) | |
928 | { | |
929 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 930 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 931 | OSPF_AUTH_SIMPLE_SIZE); |
932 | } | |
933 | else if (vl_config->md5_key) | |
934 | { | |
935 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
936 | != NULL) | |
937 | { | |
938 | vty_out (vty, "OSPF: Key %d already exists%s", | |
939 | vl_config->crypto_key_id, VTY_NEWLINE); | |
940 | return CMD_WARNING; | |
941 | } | |
942 | ck = ospf_crypt_key_new (); | |
943 | ck->key_id = vl_config->crypto_key_id; | |
944 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 945 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 946 | |
947 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
948 | } | |
949 | else if (vl_config->crypto_key_id != 0) | |
950 | { | |
951 | /* Delete a key */ | |
952 | ||
953 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
954 | vl_config->crypto_key_id) == NULL) | |
955 | { | |
956 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
957 | vl_config->crypto_key_id, VTY_NEWLINE); | |
958 | return CMD_WARNING; | |
959 | } | |
960 | ||
961 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
962 | ||
963 | } | |
964 | ||
965 | return CMD_SUCCESS; | |
966 | } | |
967 | ||
4dadc291 | 968 | static int |
718e3744 | 969 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
970 | struct ospf_vl_config_data *vl_config) | |
971 | { | |
c8cdf5c7 | 972 | struct interface *ifp = vl_data->vl_oi->ifp; |
718e3744 | 973 | /* Virtual Link data initialised to defaults, so only set |
974 | if a value given */ | |
975 | if (vl_config->hello_interval) | |
976 | { | |
977 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
978 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
979 | } | |
980 | ||
981 | if (vl_config->dead_interval) | |
982 | { | |
983 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
984 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
985 | } | |
986 | ||
987 | if (vl_config->retransmit_interval) | |
988 | { | |
989 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
990 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
991 | } | |
992 | ||
993 | if (vl_config->transmit_delay) | |
994 | { | |
995 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
996 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
997 | } | |
998 | ||
999 | return CMD_SUCCESS; | |
1000 | } | |
1001 | ||
1002 | ||
1003 | ||
1004 | /* The business end of all of the above */ | |
4dadc291 | 1005 | static int |
68980084 | 1006 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 1007 | { |
1008 | struct ospf_vl_data *vl_data; | |
1009 | int ret; | |
1010 | ||
68980084 | 1011 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 1012 | if (!vl_data) |
1013 | return CMD_WARNING; | |
1014 | ||
1015 | /* Process this one first as it can have a fatal result, which can | |
1016 | only logically occur if the virtual link exists already | |
1017 | Thus a command error does not result in a change to the | |
1018 | running configuration such as unexpectedly altered timer | |
1019 | values etc.*/ | |
1020 | ret = ospf_vl_set_security (vl_data, vl_config); | |
1021 | if (ret != CMD_SUCCESS) | |
1022 | return ret; | |
1023 | ||
1024 | /* Set any time based parameters, these area already range checked */ | |
1025 | ||
1026 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
1027 | if (ret != CMD_SUCCESS) | |
1028 | return ret; | |
1029 | ||
1030 | return CMD_SUCCESS; | |
1031 | ||
1032 | } | |
1033 | ||
1034 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1035 | */ | |
1036 | #define VLINK_HELPSTR_IPADDR \ | |
1037 | "OSPF area parameters\n" \ | |
1038 | "OSPF area ID in IP address format\n" \ | |
1039 | "OSPF area ID as a decimal value\n" \ | |
1040 | "Configure a virtual link\n" \ | |
1041 | "Router ID of the remote ABR\n" | |
1042 | ||
1043 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1044 | "Enable authentication on this virtual link\n" \ | |
1045 | "dummy string \n" | |
1046 | ||
1047 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1048 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1049 | "Use null authentication\n" \ | |
1050 | "Use message-digest authentication\n" | |
1051 | ||
1052 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1053 | "Time between HELLO packets\n" \ | |
1054 | "Time between retransmitting lost link state advertisements\n" \ | |
1055 | "Link state transmit delay\n" \ | |
1056 | "Interval after which a neighbor is declared dead\n" | |
1057 | ||
1058 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1059 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1060 | "Seconds\n" | |
1061 | ||
1062 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1063 | "Authentication password (key)\n" \ | |
1064 | "The OSPF password (key)" | |
1065 | ||
1066 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1067 | "Message digest authentication password (key)\n" \ | |
1068 | "dummy string \n" \ | |
1069 | "Key ID\n" \ | |
1070 | "Use MD5 algorithm\n" \ | |
1071 | "The OSPF password (key)" | |
1072 | ||
a2c62831 | 1073 | DEFUN (ospf_area_vlink, |
1074 | ospf_area_vlink_cmd, | |
718e3744 | 1075 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1076 | VLINK_HELPSTR_IPADDR) | |
1077 | { | |
68980084 | 1078 | struct ospf *ospf = vty->index; |
718e3744 | 1079 | struct ospf_vl_config_data vl_config; |
1080 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1081 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1082 | int i; | |
1083 | int ret; | |
1084 | ||
7c8ff89e DS |
1085 | if (!ospf) |
1086 | return CMD_SUCCESS; | |
1087 | ||
718e3744 | 1088 | ospf_vl_config_data_init(&vl_config, vty); |
1089 | ||
1090 | /* Read off first 2 parameters and check them */ | |
1091 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); | |
1092 | if (ret < 0) | |
1093 | { | |
1094 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1095 | return CMD_WARNING; | |
1096 | } | |
1097 | ||
1098 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1099 | if (! ret) | |
1100 | { | |
1101 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1102 | VTY_NEWLINE); | |
1103 | return CMD_WARNING; | |
1104 | } | |
1105 | ||
1106 | if (argc <=2) | |
1107 | { | |
1108 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1109 | ||
68980084 | 1110 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1111 | } |
1112 | ||
1113 | /* Deal with other parameters */ | |
1114 | for (i=2; i < argc; i++) | |
1115 | { | |
1116 | ||
1117 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ | |
1118 | ||
1119 | switch (argv[i][0]) | |
1120 | { | |
1121 | ||
1122 | case 'a': | |
1123 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1124 | { | |
1125 | /* authentication-key - this option can occur anywhere on | |
1126 | command line. At start of command line | |
1127 | must check for authentication option. */ | |
1128 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1129 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); | |
1130 | vl_config.auth_key = auth_key; | |
1131 | i++; | |
1132 | } | |
1133 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1134 | { | |
1135 | /* authentication - this option can only occur at start | |
1136 | of command line */ | |
1137 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1138 | if ((i+1) < argc) | |
1139 | { | |
1140 | if (strncmp (argv[i+1], "n", 1) == 0) | |
1141 | { | |
1142 | /* "authentication null" */ | |
1143 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1144 | i++; | |
1145 | } | |
1146 | else if (strncmp (argv[i+1], "m", 1) == 0 | |
1147 | && strcmp (argv[i+1], "message-digest-") != 0) | |
1148 | { | |
1149 | /* "authentication message-digest" */ | |
1150 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1151 | i++; | |
1152 | } | |
1153 | } | |
1154 | } | |
1155 | break; | |
1156 | ||
1157 | case 'm': | |
1158 | /* message-digest-key */ | |
1159 | i++; | |
1160 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1161 | if (vl_config.crypto_key_id < 0) | |
1162 | return CMD_WARNING; | |
1163 | i++; | |
1164 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1165 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); | |
1166 | vl_config.md5_key = md5_key; | |
1167 | break; | |
1168 | ||
1169 | case 'h': | |
1170 | /* Hello interval */ | |
1171 | i++; | |
1172 | vl_config.hello_interval = strtol (argv[i], NULL, 10); | |
1173 | if (vl_config.hello_interval < 0) | |
1174 | return CMD_WARNING; | |
1175 | break; | |
1176 | ||
1177 | case 'r': | |
1178 | /* Retransmit Interval */ | |
1179 | i++; | |
1180 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); | |
1181 | if (vl_config.retransmit_interval < 0) | |
1182 | return CMD_WARNING; | |
1183 | break; | |
1184 | ||
1185 | case 't': | |
1186 | /* Transmit Delay */ | |
1187 | i++; | |
1188 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); | |
1189 | if (vl_config.transmit_delay < 0) | |
1190 | return CMD_WARNING; | |
1191 | break; | |
1192 | ||
1193 | case 'd': | |
1194 | /* Dead Interval */ | |
1195 | i++; | |
1196 | vl_config.dead_interval = strtol (argv[i], NULL, 10); | |
1197 | if (vl_config.dead_interval < 0) | |
1198 | return CMD_WARNING; | |
1199 | break; | |
1200 | } | |
1201 | } | |
1202 | ||
1203 | ||
1204 | /* Action configuration */ | |
1205 | ||
68980084 | 1206 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1207 | |
1208 | } | |
1209 | ||
a2c62831 | 1210 | DEFUN (no_ospf_area_vlink, |
1211 | no_ospf_area_vlink_cmd, | |
718e3744 | 1212 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1213 | NO_STR | |
1214 | VLINK_HELPSTR_IPADDR) | |
1215 | { | |
68980084 | 1216 | struct ospf *ospf = vty->index; |
718e3744 | 1217 | struct ospf_area *area; |
1218 | struct ospf_vl_config_data vl_config; | |
1219 | struct ospf_vl_data *vl_data = NULL; | |
1220 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1221 | int i; | |
1222 | int ret, format; | |
1223 | ||
7c8ff89e DS |
1224 | if (!ospf) |
1225 | return CMD_SUCCESS; | |
1226 | ||
718e3744 | 1227 | ospf_vl_config_data_init(&vl_config, vty); |
1228 | ||
1229 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); | |
1230 | if (ret < 0) | |
1231 | { | |
1232 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1233 | return CMD_WARNING; | |
1234 | } | |
1235 | ||
68980084 | 1236 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1237 | if (!area) |
1238 | { | |
1239 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1240 | return CMD_WARNING; | |
1241 | } | |
1242 | ||
1243 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1244 | if (! ret) | |
1245 | { | |
1246 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1247 | VTY_NEWLINE); | |
1248 | return CMD_WARNING; | |
1249 | } | |
1250 | ||
1251 | if (argc <=2) | |
1252 | { | |
1253 | /* Basic VLink no command */ | |
1254 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1255 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1256 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1257 | |
68980084 | 1258 | ospf_area_check_free (ospf, vl_config.area_id); |
718e3744 | 1259 | |
1260 | return CMD_SUCCESS; | |
1261 | } | |
1262 | ||
1263 | /* If we are down here, we are reseting parameters */ | |
1264 | ||
1265 | /* Deal with other parameters */ | |
1266 | for (i=2; i < argc; i++) | |
1267 | { | |
718e3744 | 1268 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1269 | ||
1270 | switch (argv[i][0]) | |
1271 | { | |
1272 | ||
1273 | case 'a': | |
1274 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1275 | { | |
1276 | /* authentication-key - this option can occur anywhere on | |
1277 | command line. At start of command line | |
1278 | must check for authentication option. */ | |
1279 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1280 | vl_config.auth_key = auth_key; | |
1281 | } | |
1282 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1283 | { | |
1284 | /* authentication - this option can only occur at start | |
1285 | of command line */ | |
1286 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1287 | } | |
1288 | break; | |
1289 | ||
1290 | case 'm': | |
1291 | /* message-digest-key */ | |
1292 | /* Delete one key */ | |
1293 | i++; | |
36da0665 DS |
1294 | if (i < argc) |
1295 | { | |
1296 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1297 | if (vl_config.crypto_key_id < 0) | |
1298 | return CMD_WARNING; | |
1299 | vl_config.md5_key = NULL; | |
1300 | } | |
1301 | else | |
718e3744 | 1302 | return CMD_WARNING; |
718e3744 | 1303 | break; |
1304 | ||
1305 | case 'h': | |
1306 | /* Hello interval */ | |
1307 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1308 | break; | |
1309 | ||
1310 | case 'r': | |
1311 | /* Retransmit Interval */ | |
1312 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1313 | break; | |
1314 | ||
1315 | case 't': | |
1316 | /* Transmit Delay */ | |
1317 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1318 | break; | |
1319 | ||
1320 | case 'd': | |
1321 | /* Dead Interval */ | |
1322 | i++; | |
1323 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
1324 | break; | |
1325 | } | |
1326 | } | |
1327 | ||
1328 | ||
1329 | /* Action configuration */ | |
1330 | ||
68980084 | 1331 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1332 | } |
1333 | ||
a2c62831 | 1334 | ALIAS (ospf_area_vlink, |
1335 | ospf_area_vlink_param1_cmd, | |
718e3744 | 1336 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1337 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1338 | VLINK_HELPSTR_IPADDR | |
1339 | VLINK_HELPSTR_TIME_PARAM) | |
1340 | ||
a2c62831 | 1341 | ALIAS (no_ospf_area_vlink, |
1342 | no_ospf_area_vlink_param1_cmd, | |
718e3744 | 1343 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 | 1344 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
718e3744 | 1345 | NO_STR |
1346 | VLINK_HELPSTR_IPADDR | |
1347 | VLINK_HELPSTR_TIME_PARAM) | |
1348 | ||
a2c62831 | 1349 | ALIAS (ospf_area_vlink, |
1350 | ospf_area_vlink_param2_cmd, | |
718e3744 | 1351 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1352 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1353 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1354 | VLINK_HELPSTR_IPADDR | |
1355 | VLINK_HELPSTR_TIME_PARAM | |
1356 | VLINK_HELPSTR_TIME_PARAM) | |
1357 | ||
a2c62831 | 1358 | ALIAS (no_ospf_area_vlink, |
1359 | no_ospf_area_vlink_param2_cmd, | |
718e3744 | 1360 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 DW |
1361 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
1362 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
718e3744 | 1363 | NO_STR |
1364 | VLINK_HELPSTR_IPADDR | |
1365 | VLINK_HELPSTR_TIME_PARAM | |
1366 | VLINK_HELPSTR_TIME_PARAM) | |
1367 | ||
a2c62831 | 1368 | ALIAS (ospf_area_vlink, |
1369 | ospf_area_vlink_param3_cmd, | |
718e3744 | 1370 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1371 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1372 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1373 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1374 | VLINK_HELPSTR_IPADDR | |
1375 | VLINK_HELPSTR_TIME_PARAM | |
1376 | VLINK_HELPSTR_TIME_PARAM | |
1377 | VLINK_HELPSTR_TIME_PARAM) | |
1378 | ||
a2c62831 | 1379 | ALIAS (no_ospf_area_vlink, |
1380 | no_ospf_area_vlink_param3_cmd, | |
718e3744 | 1381 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 DW |
1382 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
1383 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1384 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
718e3744 | 1385 | NO_STR |
1386 | VLINK_HELPSTR_IPADDR | |
1387 | VLINK_HELPSTR_TIME_PARAM | |
1388 | VLINK_HELPSTR_TIME_PARAM | |
1389 | VLINK_HELPSTR_TIME_PARAM) | |
1390 | ||
a2c62831 | 1391 | ALIAS (ospf_area_vlink, |
1392 | ospf_area_vlink_param4_cmd, | |
718e3744 | 1393 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1394 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1395 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1396 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1397 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1398 | VLINK_HELPSTR_IPADDR | |
1399 | VLINK_HELPSTR_TIME_PARAM | |
1400 | VLINK_HELPSTR_TIME_PARAM | |
1401 | VLINK_HELPSTR_TIME_PARAM | |
1402 | VLINK_HELPSTR_TIME_PARAM) | |
1403 | ||
a2c62831 | 1404 | ALIAS (no_ospf_area_vlink, |
1405 | no_ospf_area_vlink_param4_cmd, | |
718e3744 | 1406 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 DW |
1407 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
1408 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1409 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1410 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
718e3744 | 1411 | NO_STR |
1412 | VLINK_HELPSTR_IPADDR | |
1413 | VLINK_HELPSTR_TIME_PARAM | |
1414 | VLINK_HELPSTR_TIME_PARAM | |
1415 | VLINK_HELPSTR_TIME_PARAM | |
1416 | VLINK_HELPSTR_TIME_PARAM) | |
1417 | ||
a2c62831 | 1418 | ALIAS (ospf_area_vlink, |
1419 | ospf_area_vlink_authtype_args_cmd, | |
718e3744 | 1420 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1421 | "(authentication|) (message-digest|null)", | |
1422 | VLINK_HELPSTR_IPADDR | |
1423 | VLINK_HELPSTR_AUTHTYPE_ALL) | |
1424 | ||
813d4307 DW |
1425 | ALIAS (no_ospf_area_vlink, |
1426 | no_ospf_area_vlink_authtype_args_cmd, | |
1427 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1428 | "(authentication|) (message-digest|null)", | |
1429 | NO_STR | |
1430 | VLINK_HELPSTR_IPADDR | |
1431 | VLINK_HELPSTR_AUTHTYPE_ALL) | |
1432 | ||
a2c62831 | 1433 | ALIAS (ospf_area_vlink, |
1434 | ospf_area_vlink_authtype_cmd, | |
718e3744 | 1435 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1436 | "(authentication|)", | |
1437 | VLINK_HELPSTR_IPADDR | |
1438 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1439 | ||
a2c62831 | 1440 | ALIAS (no_ospf_area_vlink, |
1441 | no_ospf_area_vlink_authtype_cmd, | |
718e3744 | 1442 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1443 | "(authentication|)", | |
1444 | NO_STR | |
1445 | VLINK_HELPSTR_IPADDR | |
1446 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1447 | ||
a2c62831 | 1448 | ALIAS (ospf_area_vlink, |
1449 | ospf_area_vlink_md5_cmd, | |
718e3744 | 1450 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1451 | "(message-digest-key|) <1-255> md5 KEY", | |
1452 | VLINK_HELPSTR_IPADDR | |
1453 | VLINK_HELPSTR_AUTH_MD5) | |
1454 | ||
a2c62831 | 1455 | ALIAS (no_ospf_area_vlink, |
1456 | no_ospf_area_vlink_md5_cmd, | |
718e3744 | 1457 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 | 1458 | "(message-digest-key|) <1-255> md5 KEY", |
718e3744 | 1459 | NO_STR |
1460 | VLINK_HELPSTR_IPADDR | |
1461 | VLINK_HELPSTR_AUTH_MD5) | |
1462 | ||
a2c62831 | 1463 | ALIAS (ospf_area_vlink, |
1464 | ospf_area_vlink_authkey_cmd, | |
718e3744 | 1465 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1466 | "(authentication-key|) AUTH_KEY", | |
1467 | VLINK_HELPSTR_IPADDR | |
1468 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1469 | ||
a2c62831 | 1470 | ALIAS (no_ospf_area_vlink, |
1471 | no_ospf_area_vlink_authkey_cmd, | |
718e3744 | 1472 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 | 1473 | "(authentication-key|) AUTH_KEY", |
718e3744 | 1474 | NO_STR |
1475 | VLINK_HELPSTR_IPADDR | |
1476 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1477 | ||
a2c62831 | 1478 | ALIAS (ospf_area_vlink, |
1479 | ospf_area_vlink_authtype_args_authkey_cmd, | |
718e3744 | 1480 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1481 | "(authentication|) (message-digest|null) " | |
1482 | "(authentication-key|) AUTH_KEY", | |
1483 | VLINK_HELPSTR_IPADDR | |
1484 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1485 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1486 | ||
813d4307 DW |
1487 | ALIAS (no_ospf_area_vlink, |
1488 | no_ospf_area_vlink_authtype_args_authkey_cmd, | |
1489 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1490 | "(authentication|) (message-digest|null) " | |
1491 | "(authentication-key|) AUTH_KEY", | |
1492 | NO_STR | |
1493 | VLINK_HELPSTR_IPADDR | |
1494 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1495 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1496 | ||
a2c62831 | 1497 | ALIAS (ospf_area_vlink, |
1498 | ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1499 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1500 | "(authentication|) " | |
1501 | "(authentication-key|) AUTH_KEY", | |
1502 | VLINK_HELPSTR_IPADDR | |
1503 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1504 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1505 | ||
a2c62831 | 1506 | ALIAS (no_ospf_area_vlink, |
1507 | no_ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1508 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1509 | "(authentication|) " | |
813d4307 | 1510 | "(authentication-key|) AUTH_KEY", |
718e3744 | 1511 | NO_STR |
1512 | VLINK_HELPSTR_IPADDR | |
1513 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1514 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1515 | ||
a2c62831 | 1516 | ALIAS (ospf_area_vlink, |
1517 | ospf_area_vlink_authtype_args_md5_cmd, | |
718e3744 | 1518 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1519 | "(authentication|) (message-digest|null) " | |
1520 | "(message-digest-key|) <1-255> md5 KEY", | |
1521 | VLINK_HELPSTR_IPADDR | |
1522 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1523 | VLINK_HELPSTR_AUTH_MD5) | |
1524 | ||
813d4307 DW |
1525 | ALIAS (no_ospf_area_vlink, |
1526 | no_ospf_area_vlink_authtype_args_md5_cmd, | |
1527 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1528 | "(authentication|) (message-digest|null) " | |
1529 | "(message-digest-key|) <1-255> md5 KEY", | |
1530 | NO_STR | |
1531 | VLINK_HELPSTR_IPADDR | |
1532 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1533 | VLINK_HELPSTR_AUTH_MD5) | |
1534 | ||
a2c62831 | 1535 | ALIAS (ospf_area_vlink, |
1536 | ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1537 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1538 | "(authentication|) " | |
1539 | "(message-digest-key|) <1-255> md5 KEY", | |
1540 | VLINK_HELPSTR_IPADDR | |
1541 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1542 | VLINK_HELPSTR_AUTH_MD5) | |
1543 | ||
a2c62831 | 1544 | ALIAS (no_ospf_area_vlink, |
1545 | no_ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1546 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1547 | "(authentication|) " | |
813d4307 | 1548 | "(message-digest-key|) <1-255> md5 KEY", |
718e3744 | 1549 | NO_STR |
1550 | VLINK_HELPSTR_IPADDR | |
1551 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1552 | VLINK_HELPSTR_AUTH_MD5) | |
1553 | ||
6b0655a2 | 1554 | |
a2c62831 | 1555 | DEFUN (ospf_area_shortcut, |
1556 | ospf_area_shortcut_cmd, | |
718e3744 | 1557 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
1558 | "OSPF area parameters\n" | |
1559 | "OSPF area ID in IP address format\n" | |
1560 | "OSPF area ID as a decimal value\n" | |
1561 | "Configure the area's shortcutting mode\n" | |
1562 | "Set default shortcutting behavior\n" | |
1563 | "Enable shortcutting through the area\n" | |
1564 | "Disable shortcutting through the area\n") | |
1565 | { | |
68980084 | 1566 | struct ospf *ospf = vty->index; |
718e3744 | 1567 | struct ospf_area *area; |
1568 | struct in_addr area_id; | |
1569 | int mode; | |
1570 | int format; | |
1571 | ||
7c8ff89e DS |
1572 | if (!ospf) |
1573 | return CMD_SUCCESS; | |
1574 | ||
718e3744 | 1575 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1576 | ||
68980084 | 1577 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1578 | |
1579 | if (strncmp (argv[1], "de", 2) == 0) | |
1580 | mode = OSPF_SHORTCUT_DEFAULT; | |
1581 | else if (strncmp (argv[1], "di", 2) == 0) | |
1582 | mode = OSPF_SHORTCUT_DISABLE; | |
1583 | else if (strncmp (argv[1], "e", 1) == 0) | |
1584 | mode = OSPF_SHORTCUT_ENABLE; | |
1585 | else | |
1586 | return CMD_WARNING; | |
1587 | ||
68980084 | 1588 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1589 | |
68980084 | 1590 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1591 | vty_out (vty, "Shortcut area setting will take effect " |
1592 | "only when the router is configured as Shortcut ABR%s", | |
1593 | VTY_NEWLINE); | |
1594 | ||
1595 | return CMD_SUCCESS; | |
1596 | } | |
1597 | ||
a2c62831 | 1598 | DEFUN (no_ospf_area_shortcut, |
1599 | no_ospf_area_shortcut_cmd, | |
718e3744 | 1600 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
1601 | NO_STR | |
1602 | "OSPF area parameters\n" | |
1603 | "OSPF area ID in IP address format\n" | |
1604 | "OSPF area ID as a decimal value\n" | |
1605 | "Deconfigure the area's shortcutting mode\n" | |
1606 | "Deconfigure enabled shortcutting through the area\n" | |
1607 | "Deconfigure disabled shortcutting through the area\n") | |
1608 | { | |
68980084 | 1609 | struct ospf *ospf = vty->index; |
718e3744 | 1610 | struct ospf_area *area; |
1611 | struct in_addr area_id; | |
1612 | int format; | |
1613 | ||
7c8ff89e DS |
1614 | if (!ospf) |
1615 | return CMD_SUCCESS; | |
1616 | ||
718e3744 | 1617 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1618 | ||
68980084 | 1619 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1620 | if (!area) |
1621 | return CMD_SUCCESS; | |
1622 | ||
68980084 | 1623 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1624 | |
1625 | return CMD_SUCCESS; | |
1626 | } | |
1627 | ||
6b0655a2 | 1628 | |
a2c62831 | 1629 | DEFUN (ospf_area_stub, |
1630 | ospf_area_stub_cmd, | |
718e3744 | 1631 | "area (A.B.C.D|<0-4294967295>) stub", |
1632 | "OSPF area parameters\n" | |
1633 | "OSPF area ID in IP address format\n" | |
1634 | "OSPF area ID as a decimal value\n" | |
1635 | "Configure OSPF area as stub\n") | |
1636 | { | |
1637 | struct ospf *ospf = vty->index; | |
1638 | struct in_addr area_id; | |
1639 | int ret, format; | |
1640 | ||
7c8ff89e DS |
1641 | if (!ospf) |
1642 | return CMD_SUCCESS; | |
1643 | ||
718e3744 | 1644 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1645 | ||
1646 | ret = ospf_area_stub_set (ospf, area_id); | |
1647 | if (ret == 0) | |
1648 | { | |
1649 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1650 | VTY_NEWLINE); | |
1651 | return CMD_WARNING; | |
1652 | } | |
1653 | ||
1654 | ospf_area_no_summary_unset (ospf, area_id); | |
1655 | ||
1656 | return CMD_SUCCESS; | |
1657 | } | |
1658 | ||
a2c62831 | 1659 | DEFUN (ospf_area_stub_no_summary, |
1660 | ospf_area_stub_no_summary_cmd, | |
718e3744 | 1661 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
1662 | "OSPF stub parameters\n" | |
1663 | "OSPF area ID in IP address format\n" | |
1664 | "OSPF area ID as a decimal value\n" | |
1665 | "Configure OSPF area as stub\n" | |
1666 | "Do not inject inter-area routes into stub\n") | |
1667 | { | |
1668 | struct ospf *ospf = vty->index; | |
1669 | struct in_addr area_id; | |
1670 | int ret, format; | |
1671 | ||
7c8ff89e DS |
1672 | if (!ospf) |
1673 | return CMD_SUCCESS; | |
1674 | ||
718e3744 | 1675 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1676 | ||
1677 | ret = ospf_area_stub_set (ospf, area_id); | |
1678 | if (ret == 0) | |
1679 | { | |
b0a053be | 1680 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1681 | VTY_NEWLINE); |
1682 | return CMD_WARNING; | |
1683 | } | |
1684 | ||
1685 | ospf_area_no_summary_set (ospf, area_id); | |
1686 | ||
1687 | return CMD_SUCCESS; | |
1688 | } | |
1689 | ||
a2c62831 | 1690 | DEFUN (no_ospf_area_stub, |
1691 | no_ospf_area_stub_cmd, | |
718e3744 | 1692 | "no area (A.B.C.D|<0-4294967295>) stub", |
1693 | NO_STR | |
1694 | "OSPF area parameters\n" | |
1695 | "OSPF area ID in IP address format\n" | |
1696 | "OSPF area ID as a decimal value\n" | |
1697 | "Configure OSPF area as stub\n") | |
1698 | { | |
1699 | struct ospf *ospf = vty->index; | |
1700 | struct in_addr area_id; | |
1701 | int format; | |
1702 | ||
7c8ff89e DS |
1703 | if (!ospf) |
1704 | return CMD_SUCCESS; | |
1705 | ||
718e3744 | 1706 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1707 | ||
1708 | ospf_area_stub_unset (ospf, area_id); | |
1709 | ospf_area_no_summary_unset (ospf, area_id); | |
1710 | ||
1711 | return CMD_SUCCESS; | |
1712 | } | |
1713 | ||
a2c62831 | 1714 | DEFUN (no_ospf_area_stub_no_summary, |
1715 | no_ospf_area_stub_no_summary_cmd, | |
718e3744 | 1716 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
1717 | NO_STR | |
1718 | "OSPF area parameters\n" | |
1719 | "OSPF area ID in IP address format\n" | |
1720 | "OSPF area ID as a decimal value\n" | |
1721 | "Configure OSPF area as stub\n" | |
1722 | "Do not inject inter-area routes into area\n") | |
1723 | { | |
1724 | struct ospf *ospf = vty->index; | |
1725 | struct in_addr area_id; | |
1726 | int format; | |
1727 | ||
7c8ff89e DS |
1728 | if (!ospf) |
1729 | return CMD_SUCCESS; | |
1730 | ||
718e3744 | 1731 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1732 | ospf_area_no_summary_unset (ospf, area_id); | |
1733 | ||
1734 | return CMD_SUCCESS; | |
1735 | } | |
1736 | ||
4dadc291 | 1737 | static int |
6c835671 | 1738 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
1739 | int nosum) | |
718e3744 | 1740 | { |
1741 | struct ospf *ospf = vty->index; | |
1742 | struct in_addr area_id; | |
1743 | int ret, format; | |
1744 | ||
7c8ff89e DS |
1745 | if (!ospf) |
1746 | return CMD_SUCCESS; | |
1747 | ||
718e3744 | 1748 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1749 | ||
1750 | ret = ospf_area_nssa_set (ospf, area_id); | |
1751 | if (ret == 0) | |
1752 | { | |
1753 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1754 | VTY_NEWLINE); | |
1755 | return CMD_WARNING; | |
1756 | } | |
1757 | ||
1758 | if (argc > 1) | |
1759 | { | |
1760 | if (strncmp (argv[1], "translate-c", 11) == 0) | |
b0a053be | 1761 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1762 | OSPF_NSSA_ROLE_CANDIDATE); |
1763 | else if (strncmp (argv[1], "translate-n", 11) == 0) | |
b0a053be | 1764 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1765 | OSPF_NSSA_ROLE_NEVER); |
1766 | else if (strncmp (argv[1], "translate-a", 11) == 0) | |
b0a053be | 1767 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1768 | OSPF_NSSA_ROLE_ALWAYS); |
1769 | } | |
b0a053be | 1770 | else |
1771 | { | |
1772 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1773 | OSPF_NSSA_ROLE_CANDIDATE); | |
1774 | } | |
718e3744 | 1775 | |
b0a053be | 1776 | if (nosum) |
718e3744 | 1777 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1778 | else |
1779 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1780 | |
b0a053be | 1781 | ospf_schedule_abr_task (ospf); |
1782 | ||
718e3744 | 1783 | return CMD_SUCCESS; |
1784 | } | |
1785 | ||
b0a053be | 1786 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1787 | ospf_area_nssa_translate_no_summary_cmd, |
b0a053be | 1788 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", |
718e3744 | 1789 | "OSPF area parameters\n" |
1790 | "OSPF area ID in IP address format\n" | |
1791 | "OSPF area ID as a decimal value\n" | |
1792 | "Configure OSPF area as nssa\n" | |
1793 | "Configure NSSA-ABR for translate election (default)\n" | |
1794 | "Configure NSSA-ABR to never translate\n" | |
1795 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1796 | "Do not inject inter-area routes into nssa\n") |
1797 | { | |
1798 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1799 | } | |
718e3744 | 1800 | |
b0a053be | 1801 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1802 | ospf_area_nssa_translate_cmd, |
718e3744 | 1803 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
1804 | "OSPF area parameters\n" | |
1805 | "OSPF area ID in IP address format\n" | |
1806 | "OSPF area ID as a decimal value\n" | |
1807 | "Configure OSPF area as nssa\n" | |
1808 | "Configure NSSA-ABR for translate election (default)\n" | |
1809 | "Configure NSSA-ABR to never translate\n" | |
1810 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1811 | { |
1812 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1813 | } | |
1814 | ||
1815 | DEFUN (ospf_area_nssa, | |
1816 | ospf_area_nssa_cmd, | |
1817 | "area (A.B.C.D|<0-4294967295>) nssa", | |
1818 | "OSPF area parameters\n" | |
1819 | "OSPF area ID in IP address format\n" | |
1820 | "OSPF area ID as a decimal value\n" | |
1821 | "Configure OSPF area as nssa\n") | |
1822 | { | |
1823 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1824 | } | |
718e3744 | 1825 | |
a2c62831 | 1826 | DEFUN (ospf_area_nssa_no_summary, |
1827 | ospf_area_nssa_no_summary_cmd, | |
718e3744 | 1828 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
1829 | "OSPF area parameters\n" | |
1830 | "OSPF area ID in IP address format\n" | |
1831 | "OSPF area ID as a decimal value\n" | |
1832 | "Configure OSPF area as nssa\n" | |
1833 | "Do not inject inter-area routes into nssa\n") | |
1834 | { | |
b0a053be | 1835 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1836 | } |
1837 | ||
a2c62831 | 1838 | DEFUN (no_ospf_area_nssa, |
1839 | no_ospf_area_nssa_cmd, | |
718e3744 | 1840 | "no area (A.B.C.D|<0-4294967295>) nssa", |
1841 | NO_STR | |
1842 | "OSPF area parameters\n" | |
1843 | "OSPF area ID in IP address format\n" | |
1844 | "OSPF area ID as a decimal value\n" | |
1845 | "Configure OSPF area as nssa\n") | |
1846 | { | |
1847 | struct ospf *ospf = vty->index; | |
1848 | struct in_addr area_id; | |
1849 | int format; | |
1850 | ||
7c8ff89e DS |
1851 | if (!ospf) |
1852 | return CMD_SUCCESS; | |
1853 | ||
718e3744 | 1854 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1855 | ||
1856 | ospf_area_nssa_unset (ospf, area_id); | |
1857 | ospf_area_no_summary_unset (ospf, area_id); | |
1858 | ||
b0a053be | 1859 | ospf_schedule_abr_task (ospf); |
1860 | ||
718e3744 | 1861 | return CMD_SUCCESS; |
1862 | } | |
1863 | ||
813d4307 | 1864 | ALIAS (no_ospf_area_nssa, |
a2c62831 | 1865 | no_ospf_area_nssa_no_summary_cmd, |
813d4307 | 1866 | "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}", |
718e3744 | 1867 | NO_STR |
1868 | "OSPF area parameters\n" | |
1869 | "OSPF area ID in IP address format\n" | |
1870 | "OSPF area ID as a decimal value\n" | |
1871 | "Configure OSPF area as nssa\n" | |
813d4307 DW |
1872 | "Configure NSSA-ABR for translate election (default)\n" |
1873 | "Configure NSSA-ABR to never translate\n" | |
1874 | "Configure NSSA-ABR to always translate\n" | |
718e3744 | 1875 | "Do not inject inter-area routes into nssa\n") |
718e3744 | 1876 | |
a2c62831 | 1877 | DEFUN (ospf_area_default_cost, |
1878 | ospf_area_default_cost_cmd, | |
718e3744 | 1879 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1880 | "OSPF area parameters\n" | |
1881 | "OSPF area ID in IP address format\n" | |
1882 | "OSPF area ID as a decimal value\n" | |
1883 | "Set the summary-default cost of a NSSA or stub area\n" | |
1884 | "Stub's advertised default summary cost\n") | |
1885 | { | |
68980084 | 1886 | struct ospf *ospf = vty->index; |
718e3744 | 1887 | struct ospf_area *area; |
1888 | struct in_addr area_id; | |
1889 | u_int32_t cost; | |
1890 | int format; | |
ba682537 | 1891 | struct prefix_ipv4 p; |
718e3744 | 1892 | |
7c8ff89e DS |
1893 | if (!ospf) |
1894 | return CMD_SUCCESS; | |
1895 | ||
718e3744 | 1896 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
1897 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); | |
1898 | ||
68980084 | 1899 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1900 | |
1901 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1902 | { | |
1903 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1904 | return CMD_WARNING; | |
1905 | } | |
1906 | ||
1907 | area->default_cost = cost; | |
1908 | ||
ba682537 | 1909 | p.family = AF_INET; |
1910 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1911 | p.prefixlen = 0; | |
1912 | if (IS_DEBUG_OSPF_EVENT) | |
1913 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1914 | "announcing 0.0.0.0/0 to area %s", | |
1915 | inet_ntoa (area->area_id)); | |
1916 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1917 | ||
718e3744 | 1918 | return CMD_SUCCESS; |
1919 | } | |
1920 | ||
a2c62831 | 1921 | DEFUN (no_ospf_area_default_cost, |
1922 | no_ospf_area_default_cost_cmd, | |
718e3744 | 1923 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1924 | NO_STR | |
1925 | "OSPF area parameters\n" | |
1926 | "OSPF area ID in IP address format\n" | |
1927 | "OSPF area ID as a decimal value\n" | |
1928 | "Set the summary-default cost of a NSSA or stub area\n" | |
1929 | "Stub's advertised default summary cost\n") | |
1930 | { | |
68980084 | 1931 | struct ospf *ospf = vty->index; |
718e3744 | 1932 | struct ospf_area *area; |
1933 | struct in_addr area_id; | |
718e3744 | 1934 | int format; |
ba682537 | 1935 | struct prefix_ipv4 p; |
718e3744 | 1936 | |
7c8ff89e DS |
1937 | if (!ospf) |
1938 | return CMD_SUCCESS; | |
1939 | ||
718e3744 | 1940 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
0798cee3 | 1941 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
718e3744 | 1942 | |
68980084 | 1943 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1944 | if (area == NULL) |
1945 | return CMD_SUCCESS; | |
1946 | ||
1947 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1948 | { | |
1949 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1950 | return CMD_WARNING; | |
1951 | } | |
1952 | ||
1953 | area->default_cost = 1; | |
1954 | ||
ba682537 | 1955 | p.family = AF_INET; |
1956 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1957 | p.prefixlen = 0; | |
1958 | if (IS_DEBUG_OSPF_EVENT) | |
1959 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1960 | "announcing 0.0.0.0/0 to area %s", | |
1961 | inet_ntoa (area->area_id)); | |
1962 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1963 | ||
1964 | ||
68980084 | 1965 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1966 | |
1967 | return CMD_SUCCESS; | |
1968 | } | |
1969 | ||
a2c62831 | 1970 | DEFUN (ospf_area_export_list, |
1971 | ospf_area_export_list_cmd, | |
718e3744 | 1972 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
1973 | "OSPF area parameters\n" | |
1974 | "OSPF area ID in IP address format\n" | |
1975 | "OSPF area ID as a decimal value\n" | |
1976 | "Set the filter for networks announced to other areas\n" | |
1977 | "Name of the access-list\n") | |
1978 | { | |
68980084 | 1979 | struct ospf *ospf = vty->index; |
718e3744 | 1980 | struct ospf_area *area; |
1981 | struct in_addr area_id; | |
1982 | int format; | |
1983 | ||
7c8ff89e DS |
1984 | if (!ospf) |
1985 | return CMD_SUCCESS; | |
1986 | ||
52930766 | 1987 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
1988 | ||
68980084 | 1989 | area = ospf_area_get (ospf, area_id, format); |
1990 | ospf_area_export_list_set (ospf, area, argv[1]); | |
718e3744 | 1991 | |
1992 | return CMD_SUCCESS; | |
1993 | } | |
1994 | ||
a2c62831 | 1995 | DEFUN (no_ospf_area_export_list, |
1996 | no_ospf_area_export_list_cmd, | |
718e3744 | 1997 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
1998 | NO_STR | |
1999 | "OSPF area parameters\n" | |
2000 | "OSPF area ID in IP address format\n" | |
2001 | "OSPF area ID as a decimal value\n" | |
2002 | "Unset the filter for networks announced to other areas\n" | |
2003 | "Name of the access-list\n") | |
2004 | { | |
68980084 | 2005 | struct ospf *ospf = vty->index; |
718e3744 | 2006 | struct ospf_area *area; |
2007 | struct in_addr area_id; | |
2008 | int format; | |
2009 | ||
7c8ff89e DS |
2010 | if (!ospf) |
2011 | return CMD_SUCCESS; | |
2012 | ||
52930766 | 2013 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2014 | ||
68980084 | 2015 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2016 | if (area == NULL) |
2017 | return CMD_SUCCESS; | |
2018 | ||
68980084 | 2019 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 2020 | |
2021 | return CMD_SUCCESS; | |
2022 | } | |
2023 | ||
2024 | ||
a2c62831 | 2025 | DEFUN (ospf_area_import_list, |
2026 | ospf_area_import_list_cmd, | |
718e3744 | 2027 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
2028 | "OSPF area parameters\n" | |
2029 | "OSPF area ID in IP address format\n" | |
2030 | "OSPF area ID as a decimal value\n" | |
2031 | "Set the filter for networks from other areas announced to the specified one\n" | |
2032 | "Name of the access-list\n") | |
2033 | { | |
68980084 | 2034 | struct ospf *ospf = vty->index; |
718e3744 | 2035 | struct ospf_area *area; |
2036 | struct in_addr area_id; | |
2037 | int format; | |
2038 | ||
7c8ff89e DS |
2039 | if (!ospf) |
2040 | return CMD_SUCCESS; | |
2041 | ||
52930766 | 2042 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2043 | ||
68980084 | 2044 | area = ospf_area_get (ospf, area_id, format); |
2045 | ospf_area_import_list_set (ospf, area, argv[1]); | |
718e3744 | 2046 | |
2047 | return CMD_SUCCESS; | |
2048 | } | |
2049 | ||
a2c62831 | 2050 | DEFUN (no_ospf_area_import_list, |
2051 | no_ospf_area_import_list_cmd, | |
718e3744 | 2052 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
2053 | NO_STR | |
2054 | "OSPF area parameters\n" | |
2055 | "OSPF area ID in IP address format\n" | |
2056 | "OSPF area ID as a decimal value\n" | |
2057 | "Unset the filter for networks announced to other areas\n" | |
2058 | "Name of the access-list\n") | |
2059 | { | |
68980084 | 2060 | struct ospf *ospf = vty->index; |
718e3744 | 2061 | struct ospf_area *area; |
2062 | struct in_addr area_id; | |
2063 | int format; | |
2064 | ||
7c8ff89e DS |
2065 | if (!ospf) |
2066 | return CMD_SUCCESS; | |
2067 | ||
52930766 | 2068 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2069 | ||
68980084 | 2070 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2071 | if (area == NULL) |
2072 | return CMD_SUCCESS; | |
2073 | ||
68980084 | 2074 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 2075 | |
2076 | return CMD_SUCCESS; | |
2077 | } | |
2078 | ||
a2c62831 | 2079 | DEFUN (ospf_area_filter_list, |
2080 | ospf_area_filter_list_cmd, | |
718e3744 | 2081 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2082 | "OSPF area parameters\n" | |
2083 | "OSPF area ID in IP address format\n" | |
2084 | "OSPF area ID as a decimal value\n" | |
2085 | "Filter networks between OSPF areas\n" | |
2086 | "Filter prefixes between OSPF areas\n" | |
2087 | "Name of an IP prefix-list\n" | |
2088 | "Filter networks sent to this area\n" | |
2089 | "Filter networks sent from this area\n") | |
2090 | { | |
68980084 | 2091 | struct ospf *ospf = vty->index; |
718e3744 | 2092 | struct ospf_area *area; |
2093 | struct in_addr area_id; | |
2094 | struct prefix_list *plist; | |
2095 | int format; | |
2096 | ||
7c8ff89e DS |
2097 | if (!ospf) |
2098 | return CMD_SUCCESS; | |
2099 | ||
718e3744 | 2100 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2101 | ||
68980084 | 2102 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2103 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
2104 | if (strncmp (argv[2], "in", 2) == 0) | |
2105 | { | |
2106 | PREFIX_LIST_IN (area) = plist; | |
2107 | if (PREFIX_NAME_IN (area)) | |
2108 | free (PREFIX_NAME_IN (area)); | |
2109 | ||
2110 | PREFIX_NAME_IN (area) = strdup (argv[1]); | |
68980084 | 2111 | ospf_schedule_abr_task (ospf); |
718e3744 | 2112 | } |
2113 | else | |
2114 | { | |
2115 | PREFIX_LIST_OUT (area) = plist; | |
2116 | if (PREFIX_NAME_OUT (area)) | |
2117 | free (PREFIX_NAME_OUT (area)); | |
2118 | ||
2119 | PREFIX_NAME_OUT (area) = strdup (argv[1]); | |
68980084 | 2120 | ospf_schedule_abr_task (ospf); |
718e3744 | 2121 | } |
2122 | ||
2123 | return CMD_SUCCESS; | |
2124 | } | |
2125 | ||
a2c62831 | 2126 | DEFUN (no_ospf_area_filter_list, |
2127 | no_ospf_area_filter_list_cmd, | |
718e3744 | 2128 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2129 | NO_STR | |
2130 | "OSPF area parameters\n" | |
2131 | "OSPF area ID in IP address format\n" | |
2132 | "OSPF area ID as a decimal value\n" | |
2133 | "Filter networks between OSPF areas\n" | |
2134 | "Filter prefixes between OSPF areas\n" | |
2135 | "Name of an IP prefix-list\n" | |
2136 | "Filter networks sent to this area\n" | |
2137 | "Filter networks sent from this area\n") | |
2138 | { | |
68980084 | 2139 | struct ospf *ospf = vty->index; |
718e3744 | 2140 | struct ospf_area *area; |
2141 | struct in_addr area_id; | |
718e3744 | 2142 | int format; |
2143 | ||
7c8ff89e DS |
2144 | if (!ospf) |
2145 | return CMD_SUCCESS; | |
2146 | ||
718e3744 | 2147 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2148 | ||
1a8ec2b9 PJ |
2149 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
2150 | return CMD_SUCCESS; | |
2151 | ||
718e3744 | 2152 | if (strncmp (argv[2], "in", 2) == 0) |
2153 | { | |
2154 | if (PREFIX_NAME_IN (area)) | |
2155 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) | |
2156 | return CMD_SUCCESS; | |
2157 | ||
2158 | PREFIX_LIST_IN (area) = NULL; | |
2159 | if (PREFIX_NAME_IN (area)) | |
2160 | free (PREFIX_NAME_IN (area)); | |
2161 | ||
2162 | PREFIX_NAME_IN (area) = NULL; | |
2163 | ||
68980084 | 2164 | ospf_schedule_abr_task (ospf); |
718e3744 | 2165 | } |
2166 | else | |
2167 | { | |
2168 | if (PREFIX_NAME_OUT (area)) | |
2169 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) | |
2170 | return CMD_SUCCESS; | |
2171 | ||
2172 | PREFIX_LIST_OUT (area) = NULL; | |
2173 | if (PREFIX_NAME_OUT (area)) | |
2174 | free (PREFIX_NAME_OUT (area)); | |
2175 | ||
2176 | PREFIX_NAME_OUT (area) = NULL; | |
2177 | ||
68980084 | 2178 | ospf_schedule_abr_task (ospf); |
718e3744 | 2179 | } |
2180 | ||
2181 | return CMD_SUCCESS; | |
2182 | } | |
2183 | ||
6b0655a2 | 2184 | |
a2c62831 | 2185 | DEFUN (ospf_area_authentication_message_digest, |
2186 | ospf_area_authentication_message_digest_cmd, | |
718e3744 | 2187 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
2188 | "OSPF area parameters\n" | |
2b00515a CF |
2189 | "OSPF area ID in IP address format\n" |
2190 | "OSPF area ID as a decimal value\n" | |
718e3744 | 2191 | "Enable authentication\n" |
2192 | "Use message-digest authentication\n") | |
2193 | { | |
68980084 | 2194 | struct ospf *ospf = vty->index; |
718e3744 | 2195 | struct ospf_area *area; |
2196 | struct in_addr area_id; | |
2197 | int format; | |
2198 | ||
7c8ff89e DS |
2199 | if (!ospf) |
2200 | return CMD_SUCCESS; | |
2201 | ||
718e3744 | 2202 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2203 | ||
68980084 | 2204 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2205 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
2206 | ||
2207 | return CMD_SUCCESS; | |
2208 | } | |
2209 | ||
a2c62831 | 2210 | DEFUN (ospf_area_authentication, |
2211 | ospf_area_authentication_cmd, | |
718e3744 | 2212 | "area (A.B.C.D|<0-4294967295>) authentication", |
2213 | "OSPF area parameters\n" | |
2214 | "OSPF area ID in IP address format\n" | |
2215 | "OSPF area ID as a decimal value\n" | |
2216 | "Enable authentication\n") | |
2217 | { | |
68980084 | 2218 | struct ospf *ospf = vty->index; |
718e3744 | 2219 | struct ospf_area *area; |
2220 | struct in_addr area_id; | |
2221 | int format; | |
2222 | ||
7c8ff89e DS |
2223 | if (!ospf) |
2224 | return CMD_SUCCESS; | |
2225 | ||
718e3744 | 2226 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2227 | ||
68980084 | 2228 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2229 | area->auth_type = OSPF_AUTH_SIMPLE; |
2230 | ||
2231 | return CMD_SUCCESS; | |
2232 | } | |
2233 | ||
a2c62831 | 2234 | DEFUN (no_ospf_area_authentication, |
2235 | no_ospf_area_authentication_cmd, | |
718e3744 | 2236 | "no area (A.B.C.D|<0-4294967295>) authentication", |
2237 | NO_STR | |
2238 | "OSPF area parameters\n" | |
2239 | "OSPF area ID in IP address format\n" | |
2240 | "OSPF area ID as a decimal value\n" | |
2241 | "Enable authentication\n") | |
2242 | { | |
68980084 | 2243 | struct ospf *ospf = vty->index; |
718e3744 | 2244 | struct ospf_area *area; |
2245 | struct in_addr area_id; | |
2246 | int format; | |
2247 | ||
7c8ff89e DS |
2248 | if (!ospf) |
2249 | return CMD_SUCCESS; | |
2250 | ||
718e3744 | 2251 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2252 | ||
68980084 | 2253 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2254 | if (area == NULL) |
2255 | return CMD_SUCCESS; | |
2256 | ||
2257 | area->auth_type = OSPF_AUTH_NULL; | |
2258 | ||
68980084 | 2259 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2260 | |
2261 | return CMD_SUCCESS; | |
2262 | } | |
2263 | ||
6b0655a2 | 2264 | |
718e3744 | 2265 | DEFUN (ospf_abr_type, |
2266 | ospf_abr_type_cmd, | |
2267 | "ospf abr-type (cisco|ibm|shortcut|standard)", | |
2268 | "OSPF specific commands\n" | |
2269 | "Set OSPF ABR type\n" | |
2270 | "Alternative ABR, cisco implementation\n" | |
2271 | "Alternative ABR, IBM implementation\n" | |
2272 | "Shortcut ABR\n" | |
2273 | "Standard behavior (RFC2328)\n") | |
2274 | { | |
68980084 | 2275 | struct ospf *ospf = vty->index; |
718e3744 | 2276 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2277 | ||
7c8ff89e DS |
2278 | if (!ospf) |
2279 | return CMD_SUCCESS; | |
2280 | ||
718e3744 | 2281 | if (strncmp (argv[0], "c", 1) == 0) |
2282 | abr_type = OSPF_ABR_CISCO; | |
2283 | else if (strncmp (argv[0], "i", 1) == 0) | |
2284 | abr_type = OSPF_ABR_IBM; | |
2285 | else if (strncmp (argv[0], "sh", 2) == 0) | |
2286 | abr_type = OSPF_ABR_SHORTCUT; | |
2287 | else if (strncmp (argv[0], "st", 2) == 0) | |
2288 | abr_type = OSPF_ABR_STAND; | |
2289 | else | |
2290 | return CMD_WARNING; | |
2291 | ||
2292 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2293 | if (ospf->abr_type != abr_type) |
718e3744 | 2294 | { |
68980084 | 2295 | ospf->abr_type = abr_type; |
2296 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2297 | } |
2298 | ||
2299 | return CMD_SUCCESS; | |
2300 | } | |
2301 | ||
2302 | DEFUN (no_ospf_abr_type, | |
2303 | no_ospf_abr_type_cmd, | |
d57834f6 | 2304 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
718e3744 | 2305 | NO_STR |
2306 | "OSPF specific commands\n" | |
2307 | "Set OSPF ABR type\n" | |
2308 | "Alternative ABR, cisco implementation\n" | |
2309 | "Alternative ABR, IBM implementation\n" | |
2310 | "Shortcut ABR\n") | |
2311 | { | |
68980084 | 2312 | struct ospf *ospf = vty->index; |
718e3744 | 2313 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2314 | ||
7c8ff89e DS |
2315 | if (!ospf) |
2316 | return CMD_SUCCESS; | |
2317 | ||
718e3744 | 2318 | if (strncmp (argv[0], "c", 1) == 0) |
2319 | abr_type = OSPF_ABR_CISCO; | |
2320 | else if (strncmp (argv[0], "i", 1) == 0) | |
2321 | abr_type = OSPF_ABR_IBM; | |
04d23314 | 2322 | else if (strncmp (argv[0], "sh", 2) == 0) |
718e3744 | 2323 | abr_type = OSPF_ABR_SHORTCUT; |
04d23314 FD |
2324 | else if (strncmp (argv[0], "st", 2) == 0) |
2325 | abr_type = OSPF_ABR_STAND; | |
718e3744 | 2326 | else |
2327 | return CMD_WARNING; | |
2328 | ||
2329 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2330 | if (ospf->abr_type == abr_type) |
718e3744 | 2331 | { |
d57834f6 | 2332 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2333 | ospf_schedule_abr_task (ospf); |
718e3744 | 2334 | } |
2335 | ||
2336 | return CMD_SUCCESS; | |
2337 | } | |
2338 | ||
d7e60dd7 AS |
2339 | DEFUN (ospf_log_adjacency_changes, |
2340 | ospf_log_adjacency_changes_cmd, | |
2341 | "log-adjacency-changes", | |
2342 | "Log changes in adjacency state\n") | |
2343 | { | |
2344 | struct ospf *ospf = vty->index; | |
2345 | ||
7c8ff89e DS |
2346 | if (!ospf) |
2347 | return CMD_SUCCESS; | |
2348 | ||
d7e60dd7 | 2349 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
692c7954 | 2350 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
d7e60dd7 AS |
2351 | return CMD_SUCCESS; |
2352 | } | |
2353 | ||
2354 | DEFUN (ospf_log_adjacency_changes_detail, | |
2355 | ospf_log_adjacency_changes_detail_cmd, | |
2356 | "log-adjacency-changes detail", | |
2357 | "Log changes in adjacency state\n" | |
2358 | "Log all state changes\n") | |
2359 | { | |
2360 | struct ospf *ospf = vty->index; | |
2361 | ||
7c8ff89e DS |
2362 | if (!ospf) |
2363 | return CMD_SUCCESS; | |
2364 | ||
d7e60dd7 AS |
2365 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2366 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2367 | return CMD_SUCCESS; | |
2368 | } | |
2369 | ||
2370 | DEFUN (no_ospf_log_adjacency_changes, | |
2371 | no_ospf_log_adjacency_changes_cmd, | |
2372 | "no log-adjacency-changes", | |
2373 | NO_STR | |
2374 | "Log changes in adjacency state\n") | |
2375 | { | |
2376 | struct ospf *ospf = vty->index; | |
2377 | ||
7c8ff89e DS |
2378 | if (!ospf) |
2379 | return CMD_SUCCESS; | |
2380 | ||
d7e60dd7 AS |
2381 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2382 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2383 | return CMD_SUCCESS; | |
2384 | } | |
2385 | ||
2386 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2387 | no_ospf_log_adjacency_changes_detail_cmd, | |
2388 | "no log-adjacency-changes detail", | |
2389 | NO_STR | |
2390 | "Log changes in adjacency state\n" | |
2391 | "Log all state changes\n") | |
2392 | { | |
2393 | struct ospf *ospf = vty->index; | |
2394 | ||
7c8ff89e DS |
2395 | if (!ospf) |
2396 | return CMD_SUCCESS; | |
2397 | ||
692c7954 | 2398 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
d7e60dd7 AS |
2399 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2400 | return CMD_SUCCESS; | |
2401 | } | |
2402 | ||
718e3744 | 2403 | DEFUN (ospf_compatible_rfc1583, |
2404 | ospf_compatible_rfc1583_cmd, | |
2405 | "compatible rfc1583", | |
2406 | "OSPF compatibility list\n" | |
2407 | "compatible with RFC 1583\n") | |
2408 | { | |
2409 | struct ospf *ospf = vty->index; | |
2410 | ||
7c8ff89e DS |
2411 | if (!ospf) |
2412 | return CMD_SUCCESS; | |
2413 | ||
718e3744 | 2414 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2415 | { | |
2416 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2417 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2418 | } |
2419 | return CMD_SUCCESS; | |
2420 | } | |
2421 | ||
2422 | DEFUN (no_ospf_compatible_rfc1583, | |
2423 | no_ospf_compatible_rfc1583_cmd, | |
2424 | "no compatible rfc1583", | |
2425 | NO_STR | |
2426 | "OSPF compatibility list\n" | |
2427 | "compatible with RFC 1583\n") | |
2428 | { | |
2429 | struct ospf *ospf = vty->index; | |
2430 | ||
7c8ff89e DS |
2431 | if (!ospf) |
2432 | return CMD_SUCCESS; | |
2433 | ||
718e3744 | 2434 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2435 | { | |
2436 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2437 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2438 | } |
2439 | return CMD_SUCCESS; | |
2440 | } | |
2441 | ||
2442 | ALIAS (ospf_compatible_rfc1583, | |
2443 | ospf_rfc1583_flag_cmd, | |
2444 | "ospf rfc1583compatibility", | |
2445 | "OSPF specific commands\n" | |
2446 | "Enable the RFC1583Compatibility flag\n") | |
2447 | ||
2448 | ALIAS (no_ospf_compatible_rfc1583, | |
2449 | no_ospf_rfc1583_flag_cmd, | |
2450 | "no ospf rfc1583compatibility", | |
2451 | NO_STR | |
2452 | "OSPF specific commands\n" | |
2453 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2454 | |
d24f6e2a | 2455 | static int |
2456 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2457 | unsigned int hold, | |
2458 | unsigned int max) | |
2459 | { | |
2460 | struct ospf *ospf = vty->index; | |
2461 | ||
7c8ff89e DS |
2462 | if (!ospf) |
2463 | return CMD_SUCCESS; | |
2464 | ||
d24f6e2a | 2465 | ospf->spf_delay = delay; |
2466 | ospf->spf_holdtime = hold; | |
2467 | ospf->spf_max_holdtime = max; | |
2468 | ||
2469 | return CMD_SUCCESS; | |
2470 | } | |
718e3744 | 2471 | |
ac7424f9 MR |
2472 | DEFUN (ospf_timers_min_ls_interval, |
2473 | ospf_timers_min_ls_interval_cmd, | |
2474 | "timers throttle lsa all <0-5000>", | |
2475 | "Adjust routing timers\n" | |
2476 | "Throttling adaptive timer\n" | |
2477 | "LSA delay between transmissions\n" | |
813d4307 | 2478 | "All LSA types\n" |
ac7424f9 MR |
2479 | "Delay (msec) between sending LSAs\n") |
2480 | { | |
2481 | struct ospf *ospf = vty->index; | |
2482 | unsigned int interval; | |
2483 | ||
d8f70b86 DS |
2484 | if (!ospf) |
2485 | return CMD_SUCCESS; | |
2486 | ||
ac7424f9 MR |
2487 | if (argc != 1) |
2488 | { | |
2489 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2490 | return CMD_WARNING; | |
2491 | } | |
2492 | ||
2493 | VTY_GET_INTEGER ("LSA interval", interval, argv[0]); | |
2494 | ||
2495 | ospf->min_ls_interval = interval; | |
2496 | ||
2497 | return CMD_SUCCESS; | |
2498 | } | |
2499 | ||
2500 | DEFUN (no_ospf_timers_min_ls_interval, | |
2501 | no_ospf_timers_min_ls_interval_cmd, | |
2502 | "no timers throttle lsa all", | |
2503 | NO_STR | |
2504 | "Adjust routing timers\n" | |
2505 | "Throttling adaptive timer\n" | |
813d4307 DW |
2506 | "LSA delay between transmissions\n" |
2507 | "All LSA types\n") | |
ac7424f9 MR |
2508 | { |
2509 | struct ospf *ospf = vty->index; | |
2510 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; | |
2511 | ||
2512 | return CMD_SUCCESS; | |
2513 | } | |
2514 | ||
813d4307 DW |
2515 | ALIAS (no_ospf_timers_min_ls_interval, |
2516 | no_ospf_timers_min_ls_interval_val_cmd, | |
2517 | "no timers throttle lsa all <0-5000>", | |
2518 | NO_STR | |
2519 | "Adjust routing timers\n" | |
2520 | "Throttling adaptive timer\n" | |
2521 | "LSA delay between transmissions\n" | |
2522 | "All LSA types\n" | |
2523 | "Delay (msec) between sending LSAs\n") | |
2524 | ||
ac7424f9 MR |
2525 | DEFUN (ospf_timers_min_ls_arrival, |
2526 | ospf_timers_min_ls_arrival_cmd, | |
2527 | "timers lsa arrival <0-1000>", | |
2528 | "Adjust routing timers\n" | |
2529 | "Throttling link state advertisement delays\n" | |
2530 | "OSPF minimum arrival interval delay\n" | |
2531 | "Delay (msec) between accepted LSAs\n") | |
2532 | { | |
2533 | struct ospf *ospf = vty->index; | |
2534 | unsigned int arrival; | |
2535 | ||
d8f70b86 DS |
2536 | if (!ospf) |
2537 | return CMD_SUCCESS; | |
2538 | ||
ac7424f9 MR |
2539 | if (argc != 1) |
2540 | { | |
2541 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2542 | return CMD_WARNING; | |
2543 | } | |
2544 | ||
2545 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); | |
2546 | ||
2547 | ospf->min_ls_arrival = arrival; | |
2548 | ||
2549 | return CMD_SUCCESS; | |
2550 | } | |
2551 | ||
2552 | DEFUN (no_ospf_timers_min_ls_arrival, | |
2553 | no_ospf_timers_min_ls_arrival_cmd, | |
2554 | "no timers lsa arrival", | |
2555 | NO_STR | |
2556 | "Adjust routing timers\n" | |
2557 | "Throttling link state advertisement delays\n" | |
2558 | "OSPF minimum arrival interval delay\n") | |
2559 | { | |
2560 | struct ospf *ospf = vty->index; | |
d8f70b86 DS |
2561 | |
2562 | if (!ospf) | |
2563 | return CMD_SUCCESS; | |
2564 | ||
ac7424f9 MR |
2565 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
2566 | ||
2567 | return CMD_SUCCESS; | |
2568 | } | |
2569 | ||
813d4307 DW |
2570 | ALIAS (no_ospf_timers_min_ls_arrival, |
2571 | no_ospf_timers_min_ls_arrival_val_cmd, | |
2572 | "no timers lsa arrival <0-1000>", | |
2573 | NO_STR | |
2574 | "Adjust routing timers\n" | |
2575 | "Throttling link state advertisement delays\n" | |
2576 | "OSPF minimum arrival interval delay\n" | |
2577 | "Delay (msec) between accepted LSAs\n") | |
2578 | ||
d24f6e2a | 2579 | DEFUN (ospf_timers_throttle_spf, |
2580 | ospf_timers_throttle_spf_cmd, | |
2581 | "timers throttle spf <0-600000> <0-600000> <0-600000>", | |
2582 | "Adjust routing timers\n" | |
2583 | "Throttling adaptive timer\n" | |
2584 | "OSPF SPF timers\n" | |
2585 | "Delay (msec) from first change received till SPF calculation\n" | |
2586 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2587 | "Maximum hold time (msec)\n") | |
2588 | { | |
2589 | unsigned int delay, hold, max; | |
2590 | ||
2591 | if (argc != 3) | |
2592 | { | |
2593 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2594 | return CMD_WARNING; | |
2595 | } | |
2596 | ||
2597 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); | |
2598 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); | |
2599 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); | |
2600 | ||
2601 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2602 | } | |
2603 | ||
d24f6e2a | 2604 | DEFUN (no_ospf_timers_throttle_spf, |
2605 | no_ospf_timers_throttle_spf_cmd, | |
2606 | "no timers throttle spf", | |
718e3744 | 2607 | NO_STR |
2608 | "Adjust routing timers\n" | |
d24f6e2a | 2609 | "Throttling adaptive timer\n" |
718e3744 | 2610 | "OSPF SPF timers\n") |
2611 | { | |
d24f6e2a | 2612 | return ospf_timers_spf_set (vty, |
2613 | OSPF_SPF_DELAY_DEFAULT, | |
2614 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2615 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2616 | } |
2617 | ||
b4a039bf DS |
2618 | ALIAS (no_ospf_timers_throttle_spf, |
2619 | no_ospf_timers_throttle_spf_val_cmd, | |
813d4307 | 2620 | "no timers throttle spf <0-600000> <0-600000> <0-600000>", |
b4a039bf DS |
2621 | NO_STR |
2622 | "Adjust routing timers\n" | |
2623 | "Throttling adaptive timer\n" | |
2624 | "OSPF SPF timers\n" | |
2625 | "Delay (msec) from first change received till SPF calculation\n" | |
2626 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2627 | "Maximum hold time (msec)\n") | |
2628 | ||
b6927875 DS |
2629 | DEFUN (ospf_timers_lsa, |
2630 | ospf_timers_lsa_cmd, | |
2631 | "timers lsa min-arrival <0-600000>", | |
2632 | "Adjust routing timers\n" | |
2633 | "OSPF LSA timers\n" | |
2634 | "Minimum delay in receiving new version of a LSA\n" | |
2635 | "Delay in milliseconds\n") | |
2636 | { | |
2637 | unsigned int minarrival; | |
2638 | struct ospf *ospf = vty->index; | |
2639 | ||
2640 | if (!ospf) | |
2641 | return CMD_SUCCESS; | |
2642 | ||
2643 | if (argc != 1) | |
2644 | { | |
2645 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2646 | return CMD_WARNING; | |
2647 | } | |
2648 | ||
2649 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2650 | ||
ac7424f9 | 2651 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2652 | |
2653 | return CMD_SUCCESS; | |
2654 | } | |
2655 | ||
2656 | DEFUN (no_ospf_timers_lsa, | |
2657 | no_ospf_timers_lsa_cmd, | |
2658 | "no timers lsa min-arrival", | |
2659 | NO_STR | |
2660 | "Adjust routing timers\n" | |
2661 | "OSPF LSA timers\n" | |
2662 | "Minimum delay in receiving new version of a LSA\n") | |
2663 | { | |
2664 | unsigned int minarrival; | |
2665 | struct ospf *ospf = vty->index; | |
2666 | ||
2667 | if (!ospf) | |
2668 | return CMD_SUCCESS; | |
2669 | ||
2670 | if (argc) | |
2671 | { | |
2672 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2673 | ||
ac7424f9 | 2674 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2675 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2676 | return CMD_SUCCESS; | |
2677 | } | |
2678 | ||
ac7424f9 | 2679 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2680 | |
2681 | return CMD_SUCCESS; | |
2682 | } | |
2683 | ||
2684 | ALIAS (no_ospf_timers_lsa, | |
2685 | no_ospf_timers_lsa_val_cmd, | |
2686 | "no timers lsa min-arrival <0-600000>", | |
2687 | NO_STR | |
2688 | "Adjust routing timers\n" | |
2689 | "OSPF LSA timers\n" | |
2690 | "Minimum delay in receiving new version of a LSA\n" | |
2691 | "Delay in milliseconds\n") | |
2692 | ||
2693 | ||
a2c62831 | 2694 | DEFUN (ospf_neighbor, |
2695 | ospf_neighbor_cmd, | |
718e3744 | 2696 | "neighbor A.B.C.D", |
2697 | NEIGHBOR_STR | |
2698 | "Neighbor IP address\n") | |
2699 | { | |
2700 | struct ospf *ospf = vty->index; | |
2701 | struct in_addr nbr_addr; | |
eb1ce605 | 2702 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2703 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2704 | |
7c8ff89e DS |
2705 | if (!ospf) |
2706 | return CMD_SUCCESS; | |
2707 | ||
718e3744 | 2708 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2709 | ||
2710 | if (argc > 1) | |
2711 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); | |
2712 | ||
2713 | if (argc > 2) | |
2714 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); | |
2715 | ||
2716 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2717 | if (argc > 1) | |
2718 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2719 | if (argc > 2) | |
1a61ad10 | 2720 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2721 | |
2722 | return CMD_SUCCESS; | |
2723 | } | |
2724 | ||
a2c62831 | 2725 | ALIAS (ospf_neighbor, |
2726 | ospf_neighbor_priority_poll_interval_cmd, | |
718e3744 | 2727 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2728 | NEIGHBOR_STR | |
2729 | "Neighbor IP address\n" | |
2730 | "Neighbor Priority\n" | |
2731 | "Priority\n" | |
2732 | "Dead Neighbor Polling interval\n" | |
2733 | "Seconds\n") | |
2734 | ||
a2c62831 | 2735 | ALIAS (ospf_neighbor, |
2736 | ospf_neighbor_priority_cmd, | |
718e3744 | 2737 | "neighbor A.B.C.D priority <0-255>", |
2738 | NEIGHBOR_STR | |
2739 | "Neighbor IP address\n" | |
2740 | "Neighbor Priority\n" | |
2741 | "Seconds\n") | |
2742 | ||
a2c62831 | 2743 | DEFUN (ospf_neighbor_poll_interval, |
2744 | ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2745 | "neighbor A.B.C.D poll-interval <1-65535>", |
2746 | NEIGHBOR_STR | |
2747 | "Neighbor IP address\n" | |
2748 | "Dead Neighbor Polling interval\n" | |
2749 | "Seconds\n") | |
2750 | { | |
2751 | struct ospf *ospf = vty->index; | |
2752 | struct in_addr nbr_addr; | |
eb1ce605 | 2753 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2754 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2755 | |
7c8ff89e DS |
2756 | if (!ospf) |
2757 | return CMD_SUCCESS; | |
2758 | ||
718e3744 | 2759 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2760 | ||
2761 | if (argc > 1) | |
2762 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); | |
2763 | ||
2764 | if (argc > 2) | |
2765 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); | |
2766 | ||
2767 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2768 | if (argc > 1) | |
2769 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); | |
2770 | if (argc > 2) | |
2771 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2772 | ||
2773 | return CMD_SUCCESS; | |
2774 | } | |
2775 | ||
a2c62831 | 2776 | ALIAS (ospf_neighbor_poll_interval, |
2777 | ospf_neighbor_poll_interval_priority_cmd, | |
718e3744 | 2778 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
2779 | NEIGHBOR_STR | |
2780 | "Neighbor address\n" | |
2781 | "OSPF dead-router polling interval\n" | |
2782 | "Seconds\n" | |
2783 | "OSPF priority of non-broadcast neighbor\n" | |
2784 | "Priority\n") | |
2785 | ||
a2c62831 | 2786 | DEFUN (no_ospf_neighbor, |
2787 | no_ospf_neighbor_cmd, | |
718e3744 | 2788 | "no neighbor A.B.C.D", |
2789 | NO_STR | |
2790 | NEIGHBOR_STR | |
2791 | "Neighbor IP address\n") | |
2792 | { | |
2793 | struct ospf *ospf = vty->index; | |
2794 | struct in_addr nbr_addr; | |
718e3744 | 2795 | |
7c8ff89e DS |
2796 | if (!ospf) |
2797 | return CMD_SUCCESS; | |
2798 | ||
718e3744 | 2799 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2800 | ||
0798cee3 | 2801 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2802 | |
2803 | return CMD_SUCCESS; | |
2804 | } | |
2805 | ||
a2c62831 | 2806 | ALIAS (no_ospf_neighbor, |
2807 | no_ospf_neighbor_priority_cmd, | |
718e3744 | 2808 | "no neighbor A.B.C.D priority <0-255>", |
2809 | NO_STR | |
2810 | NEIGHBOR_STR | |
2811 | "Neighbor IP address\n" | |
2812 | "Neighbor Priority\n" | |
2813 | "Priority\n") | |
2814 | ||
a2c62831 | 2815 | ALIAS (no_ospf_neighbor, |
2816 | no_ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2817 | "no neighbor A.B.C.D poll-interval <1-65535>", |
2818 | NO_STR | |
2819 | NEIGHBOR_STR | |
2820 | "Neighbor IP address\n" | |
2821 | "Dead Neighbor Polling interval\n" | |
2822 | "Seconds\n") | |
2823 | ||
813d4307 DW |
2824 | ALIAS (no_ospf_neighbor, |
2825 | no_ospf_neighbor_poll_interval_priority_cmd, | |
2826 | "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", | |
2827 | NO_STR | |
2828 | NEIGHBOR_STR | |
2829 | "Neighbor IP address\n" | |
2830 | "Dead Neighbor Polling interval\n" | |
2831 | "Seconds\n" | |
2832 | "OSPF priority of non-broadcast neighbor\n" | |
2833 | "Priority\n") | |
2834 | ||
a2c62831 | 2835 | ALIAS (no_ospf_neighbor, |
2836 | no_ospf_neighbor_priority_pollinterval_cmd, | |
718e3744 | 2837 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2838 | NO_STR | |
2839 | NEIGHBOR_STR | |
2840 | "Neighbor IP address\n" | |
2841 | "Neighbor Priority\n" | |
2842 | "Priority\n" | |
2843 | "Dead Neighbor Polling interval\n" | |
2844 | "Seconds\n") | |
2845 | ||
a2c62831 | 2846 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
718e3744 | 2847 | "refresh timer <10-1800>", |
2848 | "Adjust refresh parameters\n" | |
2849 | "Set refresh timer\n" | |
2850 | "Timer value in seconds\n") | |
2851 | { | |
2852 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2853 | unsigned int interval; |
718e3744 | 2854 | |
7c8ff89e DS |
2855 | if (!ospf) |
2856 | return CMD_SUCCESS; | |
2857 | ||
718e3744 | 2858 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
535c84b1 | 2859 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; |
718e3744 | 2860 | |
2861 | ospf_timers_refresh_set (ospf, interval); | |
2862 | ||
2863 | return CMD_SUCCESS; | |
2864 | } | |
2865 | ||
a2c62831 | 2866 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
718e3744 | 2867 | "no refresh timer <10-1800>", |
2868 | "Adjust refresh parameters\n" | |
2869 | "Unset refresh timer\n" | |
2870 | "Timer value in seconds\n") | |
2871 | { | |
2872 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2873 | unsigned int interval; |
718e3744 | 2874 | |
7c8ff89e DS |
2875 | if (!ospf) |
2876 | return CMD_SUCCESS; | |
2877 | ||
718e3744 | 2878 | if (argc == 1) |
2879 | { | |
2880 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); | |
2881 | ||
2882 | if (ospf->lsa_refresh_interval != interval || | |
2883 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2884 | return CMD_SUCCESS; | |
2885 | } | |
2886 | ||
2887 | ospf_timers_refresh_unset (ospf); | |
2888 | ||
2889 | return CMD_SUCCESS; | |
2890 | } | |
2891 | ||
a2c62831 | 2892 | ALIAS (no_ospf_refresh_timer, |
2893 | no_ospf_refresh_timer_cmd, | |
718e3744 | 2894 | "no refresh timer", |
2895 | "Adjust refresh parameters\n" | |
2896 | "Unset refresh timer\n") | |
2897 | ||
a2c62831 | 2898 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2899 | ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2900 | "auto-cost reference-bandwidth <1-4294967>", |
2901 | "Calculate OSPF interface cost according to bandwidth\n" | |
2902 | "Use reference bandwidth method to assign OSPF cost\n" | |
2903 | "The reference bandwidth in terms of Mbits per second\n") | |
2904 | { | |
68980084 | 2905 | struct ospf *ospf = vty->index; |
718e3744 | 2906 | u_int32_t refbw; |
52dc7ee6 | 2907 | struct listnode *node; |
1eb8ef25 | 2908 | struct interface *ifp; |
718e3744 | 2909 | |
7c8ff89e DS |
2910 | if (!ospf) |
2911 | return CMD_SUCCESS; | |
2912 | ||
718e3744 | 2913 | refbw = strtol (argv[0], NULL, 10); |
2914 | if (refbw < 1 || refbw > 4294967) | |
2915 | { | |
2916 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2917 | return CMD_WARNING; | |
2918 | } | |
2919 | ||
2920 | /* If reference bandwidth is changed. */ | |
70bd3c43 | 2921 | if ((refbw) == ospf->ref_bandwidth) |
718e3744 | 2922 | return CMD_SUCCESS; |
2923 | ||
70bd3c43 | 2924 | ospf->ref_bandwidth = refbw; |
1eb8ef25 | 2925 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2926 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2927 | |
2928 | return CMD_SUCCESS; | |
2929 | } | |
2930 | ||
a2c62831 | 2931 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2932 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2933 | "no auto-cost reference-bandwidth", |
2934 | NO_STR | |
2935 | "Calculate OSPF interface cost according to bandwidth\n" | |
2936 | "Use reference bandwidth method to assign OSPF cost\n") | |
2937 | { | |
68980084 | 2938 | struct ospf *ospf = vty->index; |
1eb8ef25 | 2939 | struct listnode *node, *nnode; |
2940 | struct interface *ifp; | |
718e3744 | 2941 | |
7c8ff89e DS |
2942 | if (!ospf) |
2943 | return CMD_SUCCESS; | |
2944 | ||
68980084 | 2945 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2946 | return CMD_SUCCESS; |
2947 | ||
68980084 | 2948 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2949 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2950 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2951 | ||
1eb8ef25 | 2952 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2953 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2954 | |
2955 | return CMD_SUCCESS; | |
2956 | } | |
2957 | ||
813d4307 DW |
2958 | ALIAS (no_ospf_auto_cost_reference_bandwidth, |
2959 | no_ospf_auto_cost_reference_bandwidth_val_cmd, | |
2960 | "no auto-cost reference-bandwidth <1-4294967>", | |
2961 | NO_STR | |
2962 | "Calculate OSPF interface cost according to bandwidth\n" | |
2963 | "Use reference bandwidth method to assign OSPF cost\n" | |
2964 | "The reference bandwidth in terms of Mbits per second\n") | |
2965 | ||
2f8f370e DS |
2966 | DEFUN (ospf_write_multiplier, |
2967 | ospf_write_multiplier_cmd, | |
e8f45e82 DS |
2968 | "ospf write-multiplier <1-100>", |
2969 | "OSPF specific commands\n" | |
2970 | "Write multiplier\n" | |
2971 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2972 | { |
2973 | struct ospf *ospf = vty->index; | |
e8f45e82 | 2974 | u_int32_t write_oi_count; |
2f8f370e | 2975 | |
7c8ff89e DS |
2976 | if (!ospf) |
2977 | return CMD_SUCCESS; | |
2978 | ||
e8f45e82 DS |
2979 | write_oi_count = strtol (argv[0], NULL, 10); |
2980 | if (write_oi_count < 1 || write_oi_count > 100) | |
2f8f370e DS |
2981 | { |
2982 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2983 | return CMD_WARNING; | |
2984 | } | |
2985 | ||
e8f45e82 | 2986 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2987 | return CMD_SUCCESS; |
2988 | } | |
2989 | ||
e8f45e82 DS |
2990 | ALIAS (ospf_write_multiplier, |
2991 | write_multiplier_cmd, | |
2992 | "write-multiplier <1-100>", | |
2993 | "Write multiplier\n" | |
2994 | "Maximum number of interface serviced per write\n") | |
2995 | ||
2f8f370e DS |
2996 | DEFUN (no_ospf_write_multiplier, |
2997 | no_ospf_write_multiplier_cmd, | |
813d4307 | 2998 | "no ospf write-multiplier <1-100>", |
2f8f370e | 2999 | NO_STR |
e8f45e82 | 3000 | "OSPF specific commands\n" |
813d4307 DW |
3001 | "Write multiplier\n" |
3002 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
3003 | { |
3004 | struct ospf *ospf = vty->index; | |
3005 | ||
7c8ff89e DS |
3006 | if (!ospf) |
3007 | return CMD_SUCCESS; | |
3008 | ||
e8f45e82 | 3009 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
3010 | return CMD_SUCCESS; |
3011 | } | |
3012 | ||
e8f45e82 DS |
3013 | ALIAS (no_ospf_write_multiplier, |
3014 | no_write_multiplier_cmd, | |
3015 | "no write-multiplier", | |
3016 | NO_STR | |
3017 | "Write multiplier\n") | |
3018 | ||
813d4307 DW |
3019 | ALIAS (no_ospf_write_multiplier, |
3020 | no_write_multiplier_val_cmd, | |
3021 | "no write-multiplier <1-100>", | |
3022 | NO_STR | |
3023 | "Write multiplier\n" | |
3024 | "Maximum number of interface serviced per write\n") | |
3025 | ||
eb1ce605 | 3026 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 3027 | { |
3028 | "Unknown", | |
3029 | "Standard (RFC2328)", | |
3030 | "Alternative IBM", | |
3031 | "Alternative Cisco", | |
3032 | "Alternative Shortcut" | |
3033 | }; | |
3034 | ||
eb1ce605 | 3035 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 3036 | { |
3037 | "Default", | |
3038 | "Enabled", | |
3039 | "Disabled" | |
3040 | }; | |
3041 | ||
4dadc291 | 3042 | static void |
ca08c43d | 3043 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 3044 | { |
ca08c43d DS |
3045 | json_object *json_area = NULL; |
3046 | ||
3047 | if (use_json) | |
3048 | json_area = json_object_new_object(); | |
3049 | ||
718e3744 | 3050 | /* Show Area ID. */ |
ca08c43d DS |
3051 | if (!use_json) |
3052 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 3053 | |
3054 | /* Show Area type/mode. */ | |
3055 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
3056 | { |
3057 | if (use_json) | |
3058 | json_object_boolean_true_add(json_area, "backbone"); | |
3059 | else | |
3060 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
3061 | } | |
718e3744 | 3062 | else |
3063 | { | |
ca08c43d DS |
3064 | if (use_json) |
3065 | { | |
3066 | if (area->external_routing == OSPF_AREA_STUB) | |
3067 | { | |
3068 | if (area->no_summary) | |
3069 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
3070 | if (area->shortcut_configured) | |
3071 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
3072 | } | |
3073 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3074 | { | |
3075 | if (area->no_summary) | |
3076 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
3077 | if (area->shortcut_configured) | |
3078 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
3079 | } | |
3080 | ||
3081 | json_object_string_add(json_area,"shortcuttingMode", | |
3082 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3083 | if (area->shortcut_capability) | |
3084 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
3085 | } | |
3086 | else | |
3087 | { | |
3088 | if (area->external_routing == OSPF_AREA_STUB) | |
3089 | vty_out (vty, " (Stub%s%s)", | |
3090 | area->no_summary ? ", no summary" : "", | |
3091 | area->shortcut_configured ? "; " : ""); | |
3092 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3093 | vty_out (vty, " (NSSA%s%s)", | |
3094 | area->no_summary ? ", no summary" : "", | |
3095 | area->shortcut_configured ? "; " : ""); | |
3096 | ||
3097 | vty_out (vty, "%s", VTY_NEWLINE); | |
3098 | vty_out (vty, " Shortcutting mode: %s", | |
3099 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3100 | vty_out (vty, ", S-bit consensus: %s%s", | |
3101 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); | |
3102 | } | |
3103 | } | |
3104 | ||
3105 | /* Show number of interfaces */ | |
3106 | if (use_json) | |
3107 | { | |
3ac237f8 MS |
3108 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
3109 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 3110 | } |
ca08c43d DS |
3111 | else |
3112 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
3113 | "Active: %d%s", listcount (area->oiflist), | |
3114 | area->act_ints, VTY_NEWLINE); | |
718e3744 | 3115 | |
718e3744 | 3116 | if (area->external_routing == OSPF_AREA_NSSA) |
3117 | { | |
ca08c43d DS |
3118 | if (use_json) |
3119 | { | |
3120 | json_object_boolean_true_add(json_area, "nssa"); | |
3121 | if (! IS_OSPF_ABR (area->ospf)) | |
3122 | json_object_boolean_false_add(json_area, "abr"); | |
3123 | else if (area->NSSATranslatorState) | |
3124 | { | |
3125 | json_object_boolean_true_add(json_area, "abr"); | |
3126 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3127 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
3128 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3129 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
3130 | } | |
3131 | else | |
3132 | { | |
3133 | json_object_boolean_true_add(json_area, "abr"); | |
3134 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3135 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
3136 | else | |
3137 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
3138 | } | |
3139 | } | |
718e3744 | 3140 | else |
ca08c43d DS |
3141 | { |
3142 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
3143 | if (! IS_OSPF_ABR (area->ospf)) | |
3144 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
3145 | VTY_NEWLINE); | |
3146 | else if (area->NSSATranslatorState) | |
3147 | { | |
3148 | vty_out (vty, " We are an ABR and "); | |
3149 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3150 | vty_out (vty, "the NSSA Elected Translator. %s", | |
3151 | VTY_NEWLINE); | |
3152 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3153 | vty_out (vty, "always an NSSA Translator. %s", | |
3154 | VTY_NEWLINE); | |
3155 | } | |
3156 | else | |
3157 | { | |
3158 | vty_out (vty, " We are an ABR, but "); | |
3159 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3160 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
3161 | VTY_NEWLINE); | |
3162 | else | |
3163 | vty_out (vty, "never an NSSA Translator. %s", | |
3164 | VTY_NEWLINE); | |
3165 | } | |
3166 | } | |
718e3744 | 3167 | } |
ca08c43d | 3168 | |
88d6cf37 | 3169 | /* Stub-router state for this area */ |
3170 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
3171 | { | |
649654ab | 3172 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3173 | |
3174 | if (use_json) | |
3175 | { | |
3176 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
3177 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3178 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
3179 | if (area->t_stub_router) | |
3180 | { | |
3181 | struct timeval result; | |
3182 | unsigned long time_store = 0; | |
3183 | result = tv_sub (area->t_stub_router->u.sands, recent_relative_time()); | |
3184 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3185 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); | |
3186 | } | |
3187 | } | |
3188 | else | |
3189 | { | |
3190 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
3191 | VTY_NEWLINE); | |
3192 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3193 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
3194 | VTY_NEWLINE); | |
3195 | if (area->t_stub_router) | |
3196 | vty_out (vty, " Active from startup, %s remaining%s", | |
3197 | ospf_timer_dump (area->t_stub_router, timebuf, | |
3198 | sizeof(timebuf)), VTY_NEWLINE); | |
3199 | } | |
3200 | } | |
3201 | ||
3202 | if (use_json) | |
3203 | { | |
3204 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 3205 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
3206 | |
3207 | /* Show authentication type. */ | |
3208 | if (area->auth_type == OSPF_AUTH_NULL) | |
3209 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
3210 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3211 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
3212 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3213 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
3214 | ||
3215 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 3216 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
3217 | |
3218 | /* Show SPF calculation times. */ | |
3ac237f8 | 3219 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
3220 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
3221 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
3222 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
3223 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
3224 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
3225 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
3226 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
3227 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3228 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3229 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
3230 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 3231 | } |
ca08c43d DS |
3232 | else |
3233 | { | |
3234 | /* Show number of fully adjacent neighbors. */ | |
3235 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
3236 | " %d%s", area->full_nbrs, VTY_NEWLINE); | |
3237 | ||
3238 | /* Show authentication type. */ | |
3239 | vty_out (vty, " Area has "); | |
3240 | if (area->auth_type == OSPF_AUTH_NULL) | |
3241 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
3242 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3243 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
3244 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3245 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
3246 | ||
3247 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3248 | vty_out (vty, " Number of full virtual adjacencies going through" | |
3249 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
3250 | ||
3251 | /* Show SPF calculation times. */ | |
3252 | vty_out (vty, " SPF algorithm executed %d times%s", | |
3253 | area->spf_calculation, VTY_NEWLINE); | |
3254 | ||
3255 | /* Show number of LSA. */ | |
3256 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
3257 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", | |
3258 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
3259 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
3260 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
3261 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
3262 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
3263 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
3264 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
3265 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
3266 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
3267 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
3268 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
3269 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
3270 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
3271 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
3272 | } | |
3273 | ||
ca08c43d DS |
3274 | if (use_json) |
3275 | { | |
3276 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3277 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3278 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3279 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3280 | } | |
3281 | else | |
3282 | { | |
3283 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
3284 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
3285 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
3286 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
3287 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
3288 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
3289 | } | |
ca08c43d DS |
3290 | |
3291 | if (use_json) | |
3292 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
3293 | else | |
3294 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 3295 | } |
3296 | ||
7c8ff89e | 3297 | static int |
ca08c43d | 3298 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3299 | { |
1eb8ef25 | 3300 | struct listnode *node, *nnode; |
718e3744 | 3301 | struct ospf_area * area; |
d24f6e2a | 3302 | struct timeval result; |
649654ab | 3303 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3304 | json_object *json = NULL; |
3305 | json_object *json_areas = NULL; | |
3306 | ||
3307 | if (use_json) | |
0cad6e26 DS |
3308 | { |
3309 | json = json_object_new_object(); | |
3310 | json_areas = json_object_new_object(); | |
3311 | } | |
718e3744 | 3312 | |
7c8ff89e | 3313 | if (ospf->instance) |
ca08c43d DS |
3314 | { |
3315 | if (use_json) | |
3316 | { | |
3317 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3318 | } | |
3319 | else | |
3320 | { | |
3321 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3322 | VTY_NEWLINE, VTY_NEWLINE); | |
3323 | } | |
3324 | } | |
718e3744 | 3325 | |
3326 | /* Show Router ID. */ | |
ca08c43d DS |
3327 | if (use_json) |
3328 | { | |
3329 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
3330 | } | |
3331 | else | |
3332 | { | |
3333 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
3334 | inet_ntoa (ospf->router_id), | |
3335 | VTY_NEWLINE); | |
3336 | } | |
7c8ff89e | 3337 | |
88d6cf37 | 3338 | /* Graceful shutdown */ |
c9c93d50 | 3339 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
3340 | { |
3341 | if (use_json) | |
3342 | { | |
3343 | unsigned long time_store = 0; | |
3344 | result = tv_sub (ospf->t_deferred_shutdown->u.sands, recent_relative_time()); | |
3345 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3346 | json_object_int_add(json, "deferredShutdownMsecs", time_store); | |
3347 | } | |
3348 | else | |
3349 | { | |
3350 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
3351 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
3352 | timebuf, sizeof (timebuf)), VTY_NEWLINE); | |
3353 | } | |
3354 | } | |
3355 | ||
718e3744 | 3356 | /* Show capability. */ |
ca08c43d DS |
3357 | if (use_json) |
3358 | { | |
3359 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
3360 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
3361 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
3362 | { | |
3363 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
3364 | } | |
3365 | } | |
3366 | else | |
3367 | { | |
3368 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
3369 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
3370 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
3371 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
3372 | "enabled" : "disabled", VTY_NEWLINE); | |
3373 | } | |
3374 | ||
ca08c43d DS |
3375 | if (use_json) |
3376 | { | |
3377 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
3378 | { | |
3379 | json_object_boolean_true_add(json, "opaqueCapable"); | |
3380 | } | |
ca08c43d DS |
3381 | } |
3382 | else | |
3383 | { | |
801e0e14 | 3384 | vty_out (vty, " OpaqueCapability flag is %s%s", |
ca08c43d | 3385 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", |
ca08c43d DS |
3386 | VTY_NEWLINE); |
3387 | } | |
ca08c43d | 3388 | |
88d6cf37 | 3389 | /* Show stub-router configuration */ |
3390 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3391 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3392 | { | |
ca08c43d DS |
3393 | if (use_json) |
3394 | { | |
3395 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3396 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3397 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3398 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3399 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3400 | } | |
3401 | else | |
3402 | { | |
3403 | vty_out (vty, " Stub router advertisement is configured%s", | |
3404 | VTY_NEWLINE); | |
3405 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3406 | vty_out (vty, " Enabled for %us after start-up%s", | |
3407 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3408 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3409 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3410 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3411 | } | |
88d6cf37 | 3412 | } |
ca08c43d | 3413 | |
718e3744 | 3414 | /* Show SPF timers. */ |
ca08c43d DS |
3415 | if (use_json) |
3416 | { | |
3417 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3418 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3419 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3420 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3421 | } |
3422 | else | |
ca08c43d DS |
3423 | { |
3424 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3425 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3426 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3427 | " Hold time multiplier is currently %d%s", | |
3428 | ospf->spf_delay, VTY_NEWLINE, | |
3429 | ospf->spf_holdtime, VTY_NEWLINE, | |
3430 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3431 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
3432 | } | |
b6927875 | 3433 | |
ca08c43d DS |
3434 | if (use_json) |
3435 | { | |
3436 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3437 | { | |
3438 | unsigned long time_store = 0; | |
3439 | ||
3440 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3441 | result = tv_sub (result, recent_relative_time()); | |
3442 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3443 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); | |
3444 | ||
3445 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3446 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3447 | } | |
3448 | else | |
3449 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3450 | } | |
3451 | else | |
3452 | { | |
3453 | vty_out (vty, " SPF algorithm "); | |
3454 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3455 | { | |
3456 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3457 | vty_out (vty, "last executed %s ago%s", | |
3458 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3459 | VTY_NEWLINE); | |
3460 | vty_out (vty, " Last SPF duration %s%s", | |
3461 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3462 | VTY_NEWLINE); | |
3463 | } | |
3464 | else | |
3465 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
3466 | } | |
3467 | ||
3468 | if (use_json) | |
3469 | { | |
3470 | struct timeval temp_time; | |
3471 | unsigned long time_store = 0; | |
3472 | ||
3473 | if (ospf->t_spf_calc) | |
3474 | { | |
3475 | temp_time = tv_sub (ospf->t_spf_calc->u.sands, recent_relative_time()); | |
3476 | time_store = (1000 * temp_time.tv_sec) + (temp_time.tv_usec / 1000); | |
3477 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); | |
3478 | } | |
3479 | ||
ac7424f9 MR |
3480 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3481 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3482 | /* Show write multiplier values */ |
3483 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3484 | /* Show refresh parameters. */ | |
54b7214f | 3485 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000); |
ca08c43d DS |
3486 | } |
3487 | else | |
3488 | { | |
3489 | vty_out (vty, " SPF timer %s%s%s", | |
3490 | (ospf->t_spf_calc ? "due in " : "is "), | |
3491 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3492 | VTY_NEWLINE); | |
3493 | ||
ac7424f9 MR |
3494 | vty_out (vty, " LSA minimum interval %d msecs%s", |
3495 | ospf->min_ls_interval, VTY_NEWLINE); | |
ca08c43d | 3496 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
ac7424f9 | 3497 | ospf->min_ls_arrival, VTY_NEWLINE); |
ca08c43d DS |
3498 | |
3499 | /* Show write multiplier values */ | |
3500 | vty_out (vty, " Write Multiplier set to %d %s", | |
3501 | ospf->write_oi_count, VTY_NEWLINE); | |
3502 | ||
3503 | /* Show refresh parameters. */ | |
3504 | vty_out (vty, " Refresh timer %d secs%s", | |
3505 | ospf->lsa_refresh_interval, VTY_NEWLINE); | |
3506 | } | |
2f8f370e | 3507 | |
718e3744 | 3508 | /* Show ABR/ASBR flags. */ |
68980084 | 3509 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3510 | { |
3511 | if (use_json) | |
3512 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3513 | else | |
3514 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
3515 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); | |
3516 | } | |
68980084 | 3517 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3518 | { |
3519 | if (use_json) | |
3520 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3521 | else | |
3522 | vty_out (vty, " This router is an ASBR " | |
3523 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3524 | } | |
718e3744 | 3525 | |
3526 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3527 | if (use_json) |
3528 | { | |
3ac237f8 | 3529 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3530 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3531 | json_object_int_add(json, "lsaExternalChecksum", | |
3532 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3533 | } | |
3534 | else | |
3535 | { | |
3536 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3537 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3538 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3539 | } | |
3540 | ||
ca08c43d DS |
3541 | if (use_json) |
3542 | { | |
3ac237f8 | 3543 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3544 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3545 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3546 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3547 | } | |
3548 | else | |
3549 | { | |
3550 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3551 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3552 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3553 | } | |
ca08c43d | 3554 | |
718e3744 | 3555 | /* Show number of areas attached. */ |
ca08c43d | 3556 | if (use_json) |
3ac237f8 | 3557 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3558 | else |
3559 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
3560 | listcount (ospf->areas), VTY_NEWLINE); | |
d7e60dd7 AS |
3561 | |
3562 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3563 | { | |
3564 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3565 | { |
3566 | if (use_json) | |
3567 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3568 | else | |
3569 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3570 | } | |
d7e60dd7 | 3571 | else |
ca08c43d DS |
3572 | { |
3573 | if (use_json) | |
3574 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3575 | else | |
3576 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3577 | } | |
d7e60dd7 | 3578 | } |
718e3744 | 3579 | /* Show each area status. */ |
1eb8ef25 | 3580 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3581 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3582 | ||
3583 | if (use_json) | |
3584 | { | |
3585 | json_object_object_add(json, "areas", json_areas); | |
2aac5767 | 3586 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
ca08c43d DS |
3587 | json_object_free(json); |
3588 | } | |
3589 | else | |
3590 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3591 | |
3592 | return CMD_SUCCESS; | |
3593 | } | |
3594 | ||
7c8ff89e DS |
3595 | DEFUN (show_ip_ospf, |
3596 | show_ip_ospf_cmd, | |
ca08c43d | 3597 | "show ip ospf {json}", |
7c8ff89e DS |
3598 | SHOW_STR |
3599 | IP_STR | |
ca08c43d DS |
3600 | "OSPF information\n" |
3601 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3602 | { |
3603 | struct ospf *ospf; | |
db7c8528 | 3604 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3605 | |
0bad4851 | 3606 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3607 | return CMD_SUCCESS; |
3608 | ||
db7c8528 | 3609 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3610 | } |
3611 | ||
3612 | DEFUN (show_ip_ospf_instance, | |
3613 | show_ip_ospf_instance_cmd, | |
ca08c43d | 3614 | "show ip ospf <1-65535> {json}", |
7c8ff89e DS |
3615 | SHOW_STR |
3616 | IP_STR | |
3617 | "OSPF information\n" | |
ca08c43d DS |
3618 | "Instance ID\n" |
3619 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3620 | { |
3621 | struct ospf *ospf; | |
3622 | u_short instance = 0; | |
db7c8528 | 3623 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
3624 | |
3625 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3626 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3627 | return CMD_SUCCESS; |
3628 | ||
db7c8528 | 3629 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3630 | } |
3631 | ||
fd651fa6 | 3632 | static void |
7ec4159b DS |
3633 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3634 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3635 | { |
fd651fa6 | 3636 | int is_up; |
718e3744 | 3637 | struct ospf_neighbor *nbr; |
718e3744 | 3638 | struct route_node *rn; |
718e3744 | 3639 | |
718e3744 | 3640 | /* Is interface up? */ |
7ec4159b DS |
3641 | if (use_json) |
3642 | { | |
3643 | is_up = if_is_operative(ifp); | |
3644 | if (is_up) | |
3645 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3646 | else | |
3647 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3648 | ||
3649 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3650 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
70bd3c43 | 3651 | json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth); |
7ec4159b DS |
3652 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); |
3653 | } | |
3654 | else | |
3655 | { | |
3656 | vty_out (vty, "%s is %s%s", ifp->name, | |
3657 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
70bd3c43 | 3658 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s", |
7ec4159b DS |
3659 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
3660 | VTY_NEWLINE); | |
3661 | } | |
718e3744 | 3662 | |
3663 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3664 | if (use_json) |
718e3744 | 3665 | { |
7ec4159b DS |
3666 | if (ospf_oi_count(ifp) == 0) |
3667 | { | |
3668 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3669 | return; | |
3670 | } | |
3671 | else if (!is_up) | |
3672 | { | |
3673 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3674 | return; | |
3675 | } | |
3676 | else | |
3677 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3678 | } |
7ec4159b | 3679 | else |
fd651fa6 | 3680 | { |
7ec4159b DS |
3681 | if (ospf_oi_count(ifp) == 0) |
3682 | { | |
3683 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3684 | return; | |
3685 | } | |
3686 | else if (!is_up) | |
3687 | { | |
3688 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3689 | VTY_NEWLINE); | |
3690 | return; | |
3691 | } | |
fd651fa6 | 3692 | } |
3693 | ||
718e3744 | 3694 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3695 | { | |
3696 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3697 | |
718e3744 | 3698 | if (oi == NULL) |
7ec4159b DS |
3699 | continue; |
3700 | ||
525c1839 DS |
3701 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3702 | { | |
7ec4159b DS |
3703 | if (use_json) |
3704 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3705 | else | |
3706 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3707 | } |
3708 | else | |
9c27ef9b | 3709 | { |
525c1839 | 3710 | /* Show OSPF interface information. */ |
7ec4159b DS |
3711 | if (use_json) |
3712 | { | |
3713 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3714 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3715 | } | |
3716 | else | |
3717 | vty_out (vty, " Internet Address %s/%d,", | |
3718 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3719 | |
3720 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3721 | { | |
3722 | struct in_addr *dest; | |
3723 | const char *dstr; | |
3724 | ||
3725 | if (CONNECTED_PEER(oi->connected) | |
3726 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3727 | dstr = "Peer"; | |
3728 | else | |
3729 | dstr = "Broadcast"; | |
3730 | ||
3731 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3732 | * * * * * informative than the local interface that is being used |
3733 | * * * * */ | |
525c1839 DS |
3734 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3735 | dest = &oi->vl_data->peer_addr; | |
3736 | else | |
3737 | dest = &oi->connected->destination->u.prefix4; | |
3738 | ||
7ec4159b DS |
3739 | if (use_json) |
3740 | { | |
3741 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3742 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3743 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3744 | else | |
3745 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3746 | } | |
3747 | else | |
3748 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3749 | } |
9c27ef9b | 3750 | } |
7ec4159b DS |
3751 | if (use_json) |
3752 | { | |
3753 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3754 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3755 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3756 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3757 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3758 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3759 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
3760 | json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state)); | |
3761 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); | |
3762 | } | |
3763 | else | |
3764 | { | |
3765 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), | |
3766 | VTY_NEWLINE); | |
3fb9cd6e | 3767 | |
7ec4159b DS |
3768 | vty_out (vty, " MTU mismatch detection:%s%s", |
3769 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
ba682537 | 3770 | |
7ec4159b DS |
3771 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
3772 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3773 | oi->output_cost, VTY_NEWLINE); | |
718e3744 | 3774 | |
7ec4159b DS |
3775 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
3776 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3777 | PRIORITY (oi), VTY_NEWLINE); | |
3778 | } | |
718e3744 | 3779 | |
3780 | /* Show DR information. */ | |
3781 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3782 | { |
3783 | if (!use_json) | |
3784 | vty_out (vty, " No backup designated router on this network%s", | |
3785 | VTY_NEWLINE); | |
3786 | } | |
718e3744 | 3787 | else |
7ec4159b DS |
3788 | { |
3789 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3790 | if (nbr == NULL) | |
3791 | { | |
3792 | if (!use_json) | |
3793 | vty_out (vty, " No backup designated router on this network%s", | |
3794 | VTY_NEWLINE); | |
3795 | } | |
3796 | else | |
3797 | { | |
3798 | if (use_json) | |
3799 | { | |
3800 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3801 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3802 | } | |
3803 | else | |
3804 | { | |
3805 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3806 | inet_ntoa (nbr->router_id)); | |
3807 | vty_out (vty, " Interface Address %s%s", | |
3808 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3809 | } | |
3810 | } | |
3811 | } | |
525c1839 | 3812 | |
7eb5b47e | 3813 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3814 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3815 | { |
7ec4159b DS |
3816 | if (use_json) |
3817 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3818 | else | |
3819 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3820 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3821 | } | |
3822 | ||
3823 | if (use_json) | |
3824 | { | |
3825 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3826 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3827 | { | |
3828 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3829 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3830 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3831 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3832 | } | |
429ac78c PJ |
3833 | } |
3834 | else | |
7ec4159b DS |
3835 | { |
3836 | vty_out (vty, " Multicast group memberships:"); | |
3837 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3838 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3839 | { | |
3840 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3841 | vty_out (vty, " OSPFAllRouters"); | |
3842 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3843 | vty_out (vty, " OSPFDesignatedRouters"); | |
3844 | } | |
3845 | else | |
3846 | vty_out (vty, " <None>"); | |
3847 | vty_out (vty, "%s", VTY_NEWLINE); | |
3848 | } | |
ba6454ec | 3849 | |
7ec4159b DS |
3850 | if (use_json) |
3851 | { | |
3852 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3853 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3854 | else | |
3855 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3856 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3857 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3858 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3859 | } | |
f9ad937f | 3860 | else |
7ec4159b DS |
3861 | { |
3862 | vty_out (vty, " Timer intervals configured,"); | |
3863 | vty_out (vty, " Hello "); | |
3864 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3865 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3866 | else | |
3867 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3868 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3869 | OSPF_IF_PARAM (oi, v_wait), | |
3870 | OSPF_IF_PARAM (oi, v_wait), | |
3871 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3872 | VTY_NEWLINE); | |
3873 | } | |
3874 | ||
7ffa8fa2 | 3875 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3876 | { |
7ec4159b DS |
3877 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3878 | if (use_json) | |
3879 | { | |
3880 | struct timeval result; | |
3881 | unsigned long time_store = 0; | |
b8dfa544 DS |
3882 | if (oi->t_hello) |
3883 | result = tv_sub (oi->t_hello->u.sands, recent_relative_time()); | |
3884 | else | |
3885 | { | |
3886 | result.tv_sec = 0; | |
3887 | result.tv_usec = 0; | |
3888 | } | |
7ec4159b DS |
3889 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); |
3890 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); | |
3891 | } | |
3892 | else | |
3893 | vty_out (vty, " Hello due in %s%s", | |
3894 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
3895 | VTY_NEWLINE); | |
f9ad937f | 3896 | } |
7ffa8fa2 | 3897 | else /* passive-interface is set */ |
7ec4159b DS |
3898 | { |
3899 | if (use_json) | |
3900 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3901 | else | |
3902 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); | |
3903 | } | |
3904 | ||
3905 | if (use_json) | |
3906 | { | |
3907 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3908 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3909 | } | |
3910 | else | |
3911 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3912 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
3913 | VTY_NEWLINE); | |
68fe91d6 | 3914 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3915 | } |
3916 | } | |
3917 | ||
7c8ff89e | 3918 | static int |
7ec4159b DS |
3919 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
3920 | const char **argv, int iface_argv, u_char use_json) | |
718e3744 | 3921 | { |
3922 | struct interface *ifp; | |
52dc7ee6 | 3923 | struct listnode *node; |
7ec4159b DS |
3924 | json_object *json = NULL; |
3925 | json_object *json_interface_sub = NULL; | |
3926 | ||
3927 | if (use_json) | |
3928 | { | |
3929 | json = json_object_new_object(); | |
3930 | json_interface_sub = json_object_new_object(); | |
3931 | } | |
718e3744 | 3932 | |
7c8ff89e | 3933 | if (ospf->instance) |
7ec4159b DS |
3934 | { |
3935 | if (use_json) | |
3936 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3937 | else | |
3938 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3939 | VTY_NEWLINE, VTY_NEWLINE); | |
3940 | } | |
7c8ff89e | 3941 | |
7ec4159b DS |
3942 | if (argc == (iface_argv + 1)) |
3943 | { | |
3944 | /* Show All Interfaces.*/ | |
b2d7c082 | 3945 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3946 | { |
3947 | if (ospf_oi_count(ifp)) | |
3948 | { | |
3949 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3950 | if (use_json) |
3951 | json_object_object_add (json, ifp->name, json_interface_sub); | |
7ec4159b DS |
3952 | } |
3953 | } | |
3954 | } | |
3955 | else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0) | |
cac3b5c4 | 3956 | { |
b8dfa544 DS |
3957 | if (!use_json) |
3958 | { | |
3959 | json = json_object_new_object(); | |
3960 | json_interface_sub = json_object_new_object (); | |
3961 | use_json = 1; | |
3962 | } | |
7c8ff89e | 3963 | /* Show All Interfaces. */ |
b2d7c082 | 3964 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3965 | { |
3966 | if (ospf_oi_count(ifp)) | |
3967 | { | |
3968 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3969 | if (use_json) |
3970 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3971 | } | |
3972 | } | |
cac3b5c4 | 3973 | } |
718e3744 | 3974 | else |
3975 | { | |
7c8ff89e | 3976 | /* Interface name is specified. */ |
7ec4159b DS |
3977 | if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL) |
3978 | { | |
3979 | if (use_json) | |
3980 | json_object_boolean_true_add(json, "noSuchIface"); | |
3981 | else | |
3982 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
3983 | } | |
718e3744 | 3984 | else |
7ec4159b DS |
3985 | { |
3986 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3987 | if (use_json) | |
3988 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3989 | } | |
718e3744 | 3990 | } |
3991 | ||
7ec4159b DS |
3992 | if (use_json) |
3993 | { | |
2aac5767 | 3994 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
7ec4159b DS |
3995 | json_object_free(json); |
3996 | } | |
3997 | else | |
3998 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3999 | |
718e3744 | 4000 | return CMD_SUCCESS; |
4001 | } | |
4002 | ||
7c8ff89e DS |
4003 | DEFUN (show_ip_ospf_interface, |
4004 | show_ip_ospf_interface_cmd, | |
7ec4159b | 4005 | "show ip ospf interface [INTERFACE] {json}", |
7c8ff89e DS |
4006 | SHOW_STR |
4007 | IP_STR | |
4008 | "OSPF information\n" | |
4009 | "Interface information\n" | |
7ec4159b DS |
4010 | "Interface name\n" |
4011 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4012 | { |
4013 | struct ospf *ospf; | |
db7c8528 | 4014 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4015 | |
0bad4851 | 4016 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4017 | return CMD_SUCCESS; |
4018 | ||
db7c8528 | 4019 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj); |
7c8ff89e DS |
4020 | } |
4021 | ||
4022 | DEFUN (show_ip_ospf_instance_interface, | |
4023 | show_ip_ospf_instance_interface_cmd, | |
7ec4159b | 4024 | "show ip ospf <1-65535> interface [INTERFACE] {json}", |
7c8ff89e DS |
4025 | SHOW_STR |
4026 | IP_STR | |
4027 | "OSPF information\n" | |
4028 | "Instance ID\n" | |
4029 | "Interface information\n" | |
7ec4159b DS |
4030 | "Interface name\n" |
4031 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4032 | { |
4033 | struct ospf *ospf; | |
4034 | u_short instance = 0; | |
db7c8528 | 4035 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4036 | |
4037 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4038 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4039 | return CMD_SUCCESS; |
4040 | ||
db7c8528 | 4041 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj); |
7c8ff89e DS |
4042 | } |
4043 | ||
d24f6e2a | 4044 | static void |
4045 | show_ip_ospf_neighbour_header (struct vty *vty) | |
4046 | { | |
490578f3 | 4047 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 4048 | VTY_NEWLINE, |
4049 | "Neighbor ID", "Pri", "State", "Dead Time", | |
4050 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
4051 | VTY_NEWLINE); | |
4052 | } | |
4053 | ||
4dadc291 | 4054 | static void |
91756b38 | 4055 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 4056 | { |
4057 | struct route_node *rn; | |
4058 | struct ospf_neighbor *nbr; | |
4059 | char msgbuf[16]; | |
649654ab | 4060 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 4061 | json_object *json_neighbor = NULL; |
718e3744 | 4062 | |
4063 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
4064 | { |
4065 | if ((nbr = rn->info)) | |
4066 | { | |
4067 | /* Do not show myself. */ | |
4068 | if (nbr != oi->nbr_self) | |
4069 | { | |
4070 | /* Down state is not shown. */ | |
4071 | if (nbr->state != NSM_Down) | |
4072 | { | |
4073 | if (use_json) | |
4074 | { | |
4075 | json_neighbor = json_object_new_object(); | |
4076 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4077 | ||
4078 | struct timeval result; | |
4079 | unsigned long time_store = 0; | |
4080 | ||
4081 | result = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time()); | |
4082 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
4083 | ||
4084 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
4085 | json_object_string_add (json_neighbor, "state", msgbuf); | |
4086 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
4087 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
4088 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4089 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
4090 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
4091 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
4092 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
4093 | json_object_object_add(json, "neighbor", json_neighbor); | |
4094 | else | |
4095 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
4096 | } | |
4097 | else | |
4098 | { | |
4099 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4100 | ||
4101 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4102 | vty_out (vty, "%-15s %3d %-15s ", | |
4103 | "-", nbr->priority, | |
4104 | msgbuf); | |
4105 | else | |
4106 | vty_out (vty, "%-15s %3d %-15s ", | |
4107 | inet_ntoa (nbr->router_id), nbr->priority, | |
4108 | msgbuf); | |
4109 | ||
4110 | vty_out (vty, "%9s ", | |
4111 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
4112 | sizeof(timebuf))); | |
4113 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
4114 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
4115 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
4116 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
4117 | VTY_NEWLINE); | |
4118 | } | |
4119 | } | |
4120 | } | |
4121 | } | |
4122 | } | |
718e3744 | 4123 | } |
4124 | ||
7c8ff89e | 4125 | static int |
91756b38 | 4126 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 4127 | { |
1eb8ef25 | 4128 | struct ospf_interface *oi; |
52dc7ee6 | 4129 | struct listnode *node; |
91756b38 | 4130 | json_object *json = NULL; |
718e3744 | 4131 | |
91756b38 DS |
4132 | if (use_json) |
4133 | json = json_object_new_object(); | |
4134 | else | |
4135 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 4136 | |
91756b38 DS |
4137 | if (ospf->instance) |
4138 | { | |
4139 | if (use_json) | |
4140 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4141 | else | |
4142 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4143 | VTY_NEWLINE, VTY_NEWLINE); | |
4144 | } | |
718e3744 | 4145 | |
1eb8ef25 | 4146 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 4147 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4148 | |
91756b38 DS |
4149 | if (use_json) |
4150 | { | |
2aac5767 | 4151 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
4152 | json_object_free(json); |
4153 | } | |
4154 | else | |
4155 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4156 | |
718e3744 | 4157 | return CMD_SUCCESS; |
4158 | } | |
4159 | ||
7c8ff89e DS |
4160 | DEFUN (show_ip_ospf_neighbor, |
4161 | show_ip_ospf_neighbor_cmd, | |
91756b38 | 4162 | "show ip ospf neighbor {json}", |
718e3744 | 4163 | SHOW_STR |
4164 | IP_STR | |
4165 | "OSPF information\n" | |
91756b38 DS |
4166 | "Neighbor list\n" |
4167 | "JavaScript Object Notation\n") | |
718e3744 | 4168 | { |
7c8ff89e | 4169 | struct ospf *ospf; |
db7c8528 | 4170 | u_char uj = use_json(argc, argv); |
718e3744 | 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_common(vty, ospf, uj); |
7c8ff89e DS |
4176 | } |
4177 | ||
4178 | ||
4179 | DEFUN (show_ip_ospf_instance_neighbor, | |
4180 | show_ip_ospf_instance_neighbor_cmd, | |
91756b38 | 4181 | "show ip ospf <1-65535> neighbor {json}", |
7c8ff89e DS |
4182 | SHOW_STR |
4183 | IP_STR | |
4184 | "OSPF information\n" | |
4185 | "Instance ID\n" | |
91756b38 DS |
4186 | "Neighbor list\n" |
4187 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4188 | { |
4189 | struct ospf *ospf; | |
4190 | u_short instance = 0; | |
db7c8528 | 4191 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4192 | |
4193 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4194 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4195 | return CMD_SUCCESS; |
4196 | ||
db7c8528 | 4197 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
4198 | } |
4199 | ||
4200 | static int | |
91756b38 | 4201 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
4202 | { |
4203 | struct listnode *node; | |
4204 | struct ospf_interface *oi; | |
91756b38 DS |
4205 | json_object *json = NULL; |
4206 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 4207 | |
91756b38 DS |
4208 | if (use_json) |
4209 | { | |
4210 | json = json_object_new_object(); | |
4211 | json_neighbor_sub = json_object_new_object(); | |
4212 | } | |
4213 | else | |
4214 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 4215 | |
91756b38 DS |
4216 | if (ospf->instance) |
4217 | { | |
4218 | if (use_json) | |
4219 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4220 | else | |
4221 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4222 | VTY_NEWLINE, VTY_NEWLINE); | |
4223 | } | |
7c8ff89e DS |
4224 | |
4225 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
4226 | { | |
52dc7ee6 | 4227 | struct listnode *nbr_node; |
1eb8ef25 | 4228 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4229 | |
91756b38 | 4230 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4231 | |
91756b38 DS |
4232 | /* print Down neighbor status */ |
4233 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
4234 | { | |
4235 | if (nbr_nbma->nbr == NULL | |
4236 | || nbr_nbma->nbr->state == NSM_Down) | |
4237 | { | |
4238 | if (use_json) | |
4239 | { | |
4240 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
4241 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
4242 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4243 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
4244 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
4245 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
4246 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
4247 | } | |
4248 | else | |
4249 | { | |
4250 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
4251 | "-", nbr_nbma->priority, "Down", "-"); | |
4252 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
4253 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
4254 | 0, 0, 0, VTY_NEWLINE); | |
4255 | } | |
4256 | } | |
4257 | } | |
718e3744 | 4258 | } |
4259 | ||
91756b38 DS |
4260 | if (use_json) |
4261 | { | |
2aac5767 | 4262 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
4263 | json_object_free(json); |
4264 | } | |
4265 | else | |
4266 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4267 | |
718e3744 | 4268 | return CMD_SUCCESS; |
4269 | } | |
4270 | ||
7c8ff89e DS |
4271 | DEFUN (show_ip_ospf_neighbor_all, |
4272 | show_ip_ospf_neighbor_all_cmd, | |
91756b38 | 4273 | "show ip ospf neighbor all {json}", |
718e3744 | 4274 | SHOW_STR |
4275 | IP_STR | |
4276 | "OSPF information\n" | |
4277 | "Neighbor list\n" | |
91756b38 DS |
4278 | "include down status neighbor\n" |
4279 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4280 | { |
4281 | struct ospf *ospf; | |
db7c8528 | 4282 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4283 | |
0bad4851 | 4284 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4285 | return CMD_SUCCESS; |
4286 | ||
db7c8528 | 4287 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4288 | } |
4289 | ||
4290 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
4291 | show_ip_ospf_instance_neighbor_all_cmd, | |
91756b38 | 4292 | "show ip ospf <1-65535> neighbor all {json}", |
7c8ff89e DS |
4293 | SHOW_STR |
4294 | IP_STR | |
4295 | "OSPF information\n" | |
4296 | "Instance ID\n" | |
4297 | "Neighbor list\n" | |
91756b38 DS |
4298 | "include down status neighbor\n" |
4299 | "JavaScript Object Notation\n") | |
718e3744 | 4300 | { |
020709f9 | 4301 | struct ospf *ospf; |
7c8ff89e | 4302 | u_short instance = 0; |
db7c8528 | 4303 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4304 | |
4305 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4306 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4307 | return CMD_SUCCESS; |
4308 | ||
db7c8528 | 4309 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4310 | } |
4311 | ||
4312 | static int | |
4313 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
91756b38 | 4314 | const char **argv, u_char use_json) |
7c8ff89e | 4315 | { |
bb5b7552 | 4316 | struct interface *ifp; |
4317 | struct route_node *rn; | |
91756b38 DS |
4318 | json_object *json = NULL; |
4319 | ||
4320 | if (use_json) | |
4321 | json = json_object_new_object(); | |
4322 | else | |
4323 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
4324 | |
4325 | if (ospf->instance) | |
91756b38 DS |
4326 | { |
4327 | if (use_json) | |
4328 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4329 | else | |
4330 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4331 | VTY_NEWLINE, VTY_NEWLINE); | |
4332 | } | |
7c8ff89e | 4333 | |
91756b38 | 4334 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4335 | if (!ifp) |
718e3744 | 4336 | { |
91756b38 DS |
4337 | if (use_json) |
4338 | json_object_boolean_true_add(json, "noSuchIface"); | |
4339 | else | |
4340 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4341 | return CMD_WARNING; |
4342 | } | |
d24f6e2a | 4343 | |
bb5b7552 | 4344 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 4345 | { |
bb5b7552 | 4346 | struct ospf_interface *oi = rn->info; |
4347 | ||
4348 | if (oi == NULL) | |
91756b38 | 4349 | continue; |
bb5b7552 | 4350 | |
91756b38 | 4351 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4352 | } |
4353 | ||
91756b38 DS |
4354 | if (use_json) |
4355 | { | |
2aac5767 | 4356 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
4357 | json_object_free(json); |
4358 | } | |
4359 | else | |
4360 | vty_out (vty, "%s", VTY_NEWLINE); | |
4361 | ||
718e3744 | 4362 | return CMD_SUCCESS; |
4363 | } | |
4364 | ||
7c8ff89e DS |
4365 | DEFUN (show_ip_ospf_neighbor_int, |
4366 | show_ip_ospf_neighbor_int_cmd, | |
91756b38 | 4367 | "show ip ospf neighbor IFNAME {json}", |
7c8ff89e DS |
4368 | SHOW_STR |
4369 | IP_STR | |
4370 | "OSPF information\n" | |
4371 | "Neighbor list\n" | |
91756b38 DS |
4372 | "Interface name\n" |
4373 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4374 | { |
4375 | struct ospf *ospf; | |
db7c8528 | 4376 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4377 | |
0bad4851 | 4378 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4379 | return CMD_SUCCESS; |
4380 | ||
db7c8528 | 4381 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4382 | } |
4383 | ||
4384 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
4385 | show_ip_ospf_instance_neighbor_int_cmd, | |
91756b38 | 4386 | "show ip ospf <1-65535> neighbor IFNAME {json}", |
7c8ff89e DS |
4387 | SHOW_STR |
4388 | IP_STR | |
4389 | "OSPF information\n" | |
4390 | "Instance ID\n" | |
4391 | "Neighbor list\n" | |
91756b38 DS |
4392 | "Interface name\n" |
4393 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4394 | { |
4395 | struct ospf *ospf; | |
4396 | u_short instance = 0; | |
db7c8528 | 4397 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4398 | |
4399 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4400 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4401 | return CMD_SUCCESS; |
4402 | ||
db7c8528 | 4403 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4404 | } |
4405 | ||
4dadc291 | 4406 | static void |
3ac237f8 MS |
4407 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4408 | u_char use_json, json_object *json) | |
718e3744 | 4409 | { |
649654ab | 4410 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4411 | json_object *json_sub = NULL; |
718e3744 | 4412 | |
3ac237f8 MS |
4413 | if (use_json) |
4414 | json_sub = json_object_new_object(); | |
4415 | else /* Show neighbor ID. */ | |
4416 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4417 | |
4418 | /* Show interface address. */ | |
3ac237f8 MS |
4419 | if (use_json) |
4420 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4421 | else | |
4422 | vty_out (vty, " interface address %s%s", | |
4423 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
4424 | ||
718e3744 | 4425 | /* Show Area ID. */ |
3ac237f8 MS |
4426 | if (use_json) |
4427 | { | |
4428 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4429 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4430 | } | |
4431 | else | |
4432 | vty_out (vty, " In the area %s via interface %s%s", | |
4433 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
4434 | ||
718e3744 | 4435 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4436 | if (use_json) |
4437 | { | |
4438 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4439 | json_object_string_add(json_sub, "nbrState", "down"); | |
4440 | } | |
4441 | else | |
4442 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4443 | nbr_nbma->priority, "Down"); | |
4444 | ||
718e3744 | 4445 | /* Show state changes. */ |
3ac237f8 MS |
4446 | if (use_json) |
4447 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4448 | else | |
4449 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
718e3744 | 4450 | |
4451 | /* Show PollInterval */ | |
3ac237f8 MS |
4452 | if (use_json) |
4453 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4454 | else | |
4455 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
718e3744 | 4456 | |
4457 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4458 | if (use_json) |
4459 | { | |
4460 | struct timeval res = tv_sub (nbr_nbma->t_poll->u.sands, recent_relative_time ()); | |
4461 | unsigned long time_store = 0; | |
4462 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4463 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); | |
4464 | } | |
4465 | else | |
4466 | vty_out (vty, " Poll timer due in %s%s", | |
4467 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
4468 | VTY_NEWLINE); | |
718e3744 | 4469 | |
4470 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4471 | if (use_json) |
4472 | { | |
4473 | if (nbr_nbma->t_poll != NULL) | |
4474 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4475 | } | |
4476 | else | |
4477 | vty_out (vty, " Thread Poll Timer %s%s", | |
4478 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
4479 | ||
4480 | if (use_json) | |
4481 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4482 | } |
4483 | ||
4dadc291 | 4484 | static void |
718e3744 | 4485 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4486 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4487 | { |
649654ab | 4488 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4489 | json_object *json_sub = NULL; |
718e3744 | 4490 | |
3ac237f8 MS |
4491 | if (use_json) |
4492 | json_sub = json_object_new_object(); | |
718e3744 | 4493 | else |
3ac237f8 MS |
4494 | { |
4495 | /* Show neighbor ID. */ | |
4496 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4497 | vty_out (vty, " Neighbor %s,", "-"); | |
4498 | else | |
4499 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4500 | } | |
718e3744 | 4501 | |
4502 | /* Show interface address. */ | |
3ac237f8 MS |
4503 | if (use_json) |
4504 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4505 | else | |
4506 | vty_out (vty, " interface address %s%s", | |
4507 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
4508 | ||
718e3744 | 4509 | /* Show Area ID. */ |
3ac237f8 MS |
4510 | if (use_json) |
4511 | { | |
4512 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4513 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4514 | } | |
4515 | else | |
4516 | vty_out (vty, " In the area %s via interface %s%s", | |
4517 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
4518 | ||
718e3744 | 4519 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4520 | if (use_json) |
4521 | { | |
4522 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4523 | json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4524 | } | |
4525 | else | |
4526 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4527 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4528 | ||
718e3744 | 4529 | /* Show state changes. */ |
3ac237f8 MS |
4530 | if (use_json) |
4531 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4532 | else | |
4533 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
4534 | ||
3fed4160 | 4535 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4536 | { |
3ac237f8 MS |
4537 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
4538 | if (use_json) | |
4539 | { | |
4540 | unsigned long time_store = 0; | |
4541 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4542 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store); | |
4543 | } | |
4544 | else | |
4545 | { | |
4546 | vty_out (vty, " Most recent state change statistics:%s", | |
4547 | VTY_NEWLINE); | |
4548 | vty_out (vty, " Progressive change %s ago%s", | |
4549 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4550 | VTY_NEWLINE); | |
4551 | } | |
3fed4160 | 4552 | } |
3ac237f8 | 4553 | |
3fed4160 PJ |
4554 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4555 | { | |
3ac237f8 MS |
4556 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
4557 | if (use_json) | |
4558 | { | |
4559 | unsigned long time_store = 0; | |
4560 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4561 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); | |
4562 | if (nbr->last_regress_str) | |
4563 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4564 | } | |
4565 | else | |
4566 | { | |
4567 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4568 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4569 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
4570 | VTY_NEWLINE); | |
4571 | } | |
90c33177 | 4572 | } |
3ac237f8 | 4573 | |
718e3744 | 4574 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4575 | if (use_json) |
4576 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4577 | else | |
4578 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4579 | ||
718e3744 | 4580 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4581 | if (use_json) |
4582 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4583 | else | |
4584 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
4585 | ||
718e3744 | 4586 | /* Show options. */ |
3ac237f8 MS |
4587 | if (use_json) |
4588 | { | |
4589 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4590 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4591 | } | |
4592 | else | |
4593 | vty_out (vty, " Options %d %s%s", nbr->options, | |
4594 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
4595 | ||
718e3744 | 4596 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4597 | if (use_json) |
4598 | { | |
45d430e8 DS |
4599 | if (nbr->t_inactivity) |
4600 | { | |
4601 | struct timeval res = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time ()); | |
4602 | unsigned long time_store = 0; | |
4603 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4604 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); | |
4605 | } | |
4606 | else | |
4607 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", -1); | |
3ac237f8 MS |
4608 | } |
4609 | else | |
4610 | vty_out (vty, " Dead timer due in %s%s", | |
4611 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
4612 | VTY_NEWLINE); | |
4613 | ||
718e3744 | 4614 | /* Show Database Summary list. */ |
3ac237f8 MS |
4615 | if (use_json) |
4616 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4617 | else | |
4618 | vty_out (vty, " Database Summary List %d%s", | |
4619 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
4620 | ||
718e3744 | 4621 | /* Show Link State Request list. */ |
3ac237f8 MS |
4622 | if (use_json) |
4623 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4624 | else | |
4625 | vty_out (vty, " Link State Request List %ld%s", | |
4626 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
4627 | ||
718e3744 | 4628 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4629 | if (use_json) |
4630 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4631 | else | |
4632 | vty_out (vty, " Link State Retransmission List %ld%s", | |
4633 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
4634 | ||
718e3744 | 4635 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4636 | if (use_json) |
4637 | { | |
4638 | if (nbr->t_inactivity != NULL) | |
4639 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4640 | } | |
4641 | else | |
4642 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
4643 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
4644 | ||
718e3744 | 4645 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4646 | if (use_json) |
4647 | { | |
4648 | if (nbr->t_db_desc != NULL) | |
4649 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4650 | } | |
4651 | else | |
4652 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
4653 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
4654 | ||
718e3744 | 4655 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4656 | if (use_json) |
4657 | { | |
4658 | if (nbr->t_ls_req != NULL) | |
4659 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4660 | } | |
4661 | else | |
4662 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
4663 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
4664 | ||
718e3744 | 4665 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4666 | if (use_json) |
4667 | { | |
4668 | if (nbr->t_ls_upd != NULL) | |
4669 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4670 | } | |
4671 | else | |
4672 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
4673 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
4674 | ||
4675 | if (use_json) | |
4676 | { | |
4677 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4678 | json_object_object_add(json, "noNbrId", json_sub); | |
4679 | else | |
4680 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4681 | } | |
68fe91d6 | 4682 | |
4683 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4684 | } |
4685 | ||
7c8ff89e DS |
4686 | static int |
4687 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4688 | int arg_base, const char **argv, u_char use_json) |
718e3744 | 4689 | { |
52dc7ee6 | 4690 | struct listnode *node; |
718e3744 | 4691 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4692 | struct ospf_interface *oi; |
718e3744 | 4693 | struct in_addr router_id; |
4694 | int ret; | |
3ac237f8 MS |
4695 | json_object *json = NULL; |
4696 | ||
4697 | if (use_json) | |
4698 | json = json_object_new_object(); | |
718e3744 | 4699 | |
7c8ff89e | 4700 | if (ospf->instance) |
3ac237f8 MS |
4701 | { |
4702 | if (use_json) | |
4703 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4704 | else | |
4705 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4706 | VTY_NEWLINE, VTY_NEWLINE); | |
4707 | } | |
7c8ff89e | 4708 | |
3ac237f8 | 4709 | ret = inet_aton (argv[arg_base], &router_id); |
718e3744 | 4710 | if (!ret) |
4711 | { | |
3ac237f8 MS |
4712 | if (!use_json) |
4713 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
718e3744 | 4714 | return CMD_WARNING; |
4715 | } | |
4716 | ||
1eb8ef25 | 4717 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4718 | { |
4719 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4720 | { | |
4721 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4722 | } | |
4723 | } | |
4724 | ||
4725 | if (use_json) | |
4726 | { | |
2aac5767 | 4727 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4728 | json_object_free(json); |
4729 | } | |
4730 | else | |
4731 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4732 | |
718e3744 | 4733 | return CMD_SUCCESS; |
4734 | } | |
4735 | ||
7c8ff89e DS |
4736 | DEFUN (show_ip_ospf_neighbor_id, |
4737 | show_ip_ospf_neighbor_id_cmd, | |
3ac237f8 | 4738 | "show ip ospf neighbor A.B.C.D {json}", |
718e3744 | 4739 | SHOW_STR |
4740 | IP_STR | |
4741 | "OSPF information\n" | |
4742 | "Neighbor list\n" | |
3ac237f8 MS |
4743 | "Neighbor ID\n" |
4744 | "JavaScript Object Notation\n") | |
718e3744 | 4745 | { |
020709f9 | 4746 | struct ospf *ospf; |
db7c8528 | 4747 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4748 | |
0bad4851 | 4749 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4750 | return CMD_SUCCESS; |
4751 | ||
db7c8528 | 4752 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4753 | } |
4754 | ||
4755 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4756 | show_ip_ospf_instance_neighbor_id_cmd, | |
3ac237f8 | 4757 | "show ip ospf <1-65535> neighbor A.B.C.D {json}", |
7c8ff89e DS |
4758 | SHOW_STR |
4759 | IP_STR | |
4760 | "OSPF information\n" | |
4761 | "Instance ID\n" | |
4762 | "Neighbor list\n" | |
3ac237f8 MS |
4763 | "Neighbor ID\n" |
4764 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4765 | { |
4766 | struct ospf *ospf; | |
4767 | u_short instance = 0; | |
db7c8528 | 4768 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4769 | |
4770 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4771 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4772 | return CMD_SUCCESS; |
4773 | ||
db7c8528 | 4774 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4775 | } |
4776 | ||
4777 | static int | |
3ac237f8 | 4778 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4779 | { |
1eb8ef25 | 4780 | struct ospf_interface *oi; |
52dc7ee6 | 4781 | struct listnode *node; |
3ac237f8 MS |
4782 | json_object *json = NULL; |
4783 | ||
4784 | if (use_json) | |
4785 | json = json_object_new_object(); | |
718e3744 | 4786 | |
7c8ff89e | 4787 | if (ospf->instance) |
3ac237f8 MS |
4788 | { |
4789 | if (use_json) | |
4790 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4791 | else | |
4792 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4793 | VTY_NEWLINE, VTY_NEWLINE); | |
4794 | } | |
718e3744 | 4795 | |
1eb8ef25 | 4796 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4797 | { |
718e3744 | 4798 | struct route_node *rn; |
4799 | struct ospf_neighbor *nbr; | |
4800 | ||
4801 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4802 | { |
4803 | if ((nbr = rn->info)) | |
4804 | { | |
4805 | if (nbr != oi->nbr_self) | |
4806 | { | |
4807 | if (nbr->state != NSM_Down) | |
4808 | { | |
4809 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4810 | } | |
4811 | } | |
4812 | } | |
4813 | } | |
718e3744 | 4814 | } |
4815 | ||
3ac237f8 MS |
4816 | if (use_json) |
4817 | { | |
2aac5767 | 4818 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4819 | json_object_free(json); |
4820 | } | |
4821 | else | |
4822 | vty_out (vty, "%s", VTY_NEWLINE); | |
4823 | ||
718e3744 | 4824 | return CMD_SUCCESS; |
4825 | } | |
4826 | ||
7c8ff89e DS |
4827 | DEFUN (show_ip_ospf_neighbor_detail, |
4828 | show_ip_ospf_neighbor_detail_cmd, | |
3ac237f8 | 4829 | "show ip ospf neighbor detail {json}", |
718e3744 | 4830 | SHOW_STR |
4831 | IP_STR | |
4832 | "OSPF information\n" | |
4833 | "Neighbor list\n" | |
3ac237f8 MS |
4834 | "detail of all neighbors\n" |
4835 | "JavaScript Object Notation\n") | |
718e3744 | 4836 | { |
020709f9 | 4837 | struct ospf *ospf; |
db7c8528 | 4838 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4839 | |
0bad4851 | 4840 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4841 | return CMD_SUCCESS; |
4842 | ||
db7c8528 | 4843 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4844 | } |
4845 | ||
4846 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4847 | show_ip_ospf_instance_neighbor_detail_cmd, | |
3ac237f8 | 4848 | "show ip ospf <1-65535> neighbor detail {json}", |
7c8ff89e DS |
4849 | SHOW_STR |
4850 | IP_STR | |
4851 | "OSPF information\n" | |
4852 | "Instance ID\n" | |
4853 | "Neighbor list\n" | |
3ac237f8 MS |
4854 | "detail of all neighbors\n" |
4855 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4856 | { |
4857 | struct ospf *ospf; | |
4858 | u_short instance = 0; | |
db7c8528 | 4859 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4860 | |
4861 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4862 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4863 | return CMD_SUCCESS; |
4864 | ||
db7c8528 | 4865 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4866 | } |
4867 | ||
4868 | static int | |
3ac237f8 | 4869 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4870 | { |
52dc7ee6 | 4871 | struct listnode *node; |
1eb8ef25 | 4872 | struct ospf_interface *oi; |
3ac237f8 MS |
4873 | json_object *json = NULL; |
4874 | ||
4875 | if (use_json) | |
4876 | json = json_object_new_object(); | |
718e3744 | 4877 | |
7c8ff89e | 4878 | if (ospf->instance) |
3ac237f8 MS |
4879 | { |
4880 | if (use_json) | |
4881 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4882 | else | |
4883 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4884 | VTY_NEWLINE, VTY_NEWLINE); | |
4885 | } | |
718e3744 | 4886 | |
1eb8ef25 | 4887 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4888 | { |
718e3744 | 4889 | struct route_node *rn; |
4890 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4891 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4892 | |
4893 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4894 | if ((nbr = rn->info)) | |
4895 | if (nbr != oi->nbr_self) | |
a452df33 | 4896 | if (nbr->state != NSM_Down) |
3ac237f8 | 4897 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4898 | |
4899 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4900 | { |
4901 | struct listnode *nd; | |
718e3744 | 4902 | |
3ac237f8 MS |
4903 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4904 | { | |
4905 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4906 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4907 | } | |
4908 | } | |
4909 | } | |
4910 | ||
4911 | if (use_json) | |
4912 | { | |
2aac5767 | 4913 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4914 | json_object_free(json); |
4915 | } | |
4916 | else | |
4917 | { | |
4918 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4919 | } |
4920 | ||
4921 | return CMD_SUCCESS; | |
4922 | } | |
4923 | ||
7c8ff89e DS |
4924 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4925 | show_ip_ospf_neighbor_detail_all_cmd, | |
3ac237f8 | 4926 | "show ip ospf neighbor detail all {json}", |
718e3744 | 4927 | SHOW_STR |
4928 | IP_STR | |
4929 | "OSPF information\n" | |
4930 | "Neighbor list\n" | |
7c8ff89e | 4931 | "detail of all neighbors\n" |
3ac237f8 MS |
4932 | "include down status neighbor\n" |
4933 | "JavaScript Object Notation\n") | |
718e3744 | 4934 | { |
020709f9 | 4935 | struct ospf *ospf; |
db7c8528 | 4936 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4937 | |
0bad4851 | 4938 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4939 | return CMD_SUCCESS; |
4940 | ||
db7c8528 | 4941 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4942 | } |
4943 | ||
4944 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4945 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
3ac237f8 | 4946 | "show ip ospf <1-65535> neighbor detail all {json}", |
7c8ff89e DS |
4947 | SHOW_STR |
4948 | IP_STR | |
4949 | "OSPF information\n" | |
4950 | "Instance ID\n" | |
4951 | "Neighbor list\n" | |
4952 | "detail of all neighbors\n" | |
3ac237f8 MS |
4953 | "include down status neighbor\n" |
4954 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4955 | { |
4956 | struct ospf *ospf; | |
4957 | u_short instance = 0; | |
db7c8528 | 4958 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4959 | |
4960 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4961 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4962 | return CMD_SUCCESS; |
4963 | ||
db7c8528 | 4964 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4965 | } |
4966 | ||
4967 | static int | |
4968 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4969 | int arg_base, const char **argv, u_char use_json) |
7c8ff89e | 4970 | { |
718e3744 | 4971 | struct ospf_interface *oi; |
bb5b7552 | 4972 | struct interface *ifp; |
4973 | struct route_node *rn, *nrn; | |
4974 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4975 | json_object *json = NULL; |
4976 | ||
4977 | if (use_json) | |
4978 | json = json_object_new_object(); | |
bb5b7552 | 4979 | |
7c8ff89e | 4980 | if (ospf->instance) |
3ac237f8 MS |
4981 | { |
4982 | if (use_json) | |
4983 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4984 | else | |
4985 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4986 | VTY_NEWLINE, VTY_NEWLINE); | |
4987 | } | |
7c8ff89e | 4988 | |
3ac237f8 | 4989 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4990 | if (!ifp) |
718e3744 | 4991 | { |
3ac237f8 MS |
4992 | if (!use_json) |
4993 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4994 | return CMD_WARNING; |
4995 | } | |
4996 | ||
bb5b7552 | 4997 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
4998 | { |
4999 | if ((oi = rn->info)) | |
5000 | { | |
5001 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
5002 | { | |
5003 | if ((nbr = nrn->info)) | |
5004 | { | |
5005 | if (nbr != oi->nbr_self) | |
5006 | { | |
5007 | if (nbr->state != NSM_Down) | |
5008 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
5009 | } | |
5010 | } | |
5011 | } | |
5012 | } | |
5013 | } | |
5014 | ||
5015 | if (use_json) | |
5016 | { | |
2aac5767 | 5017 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
5018 | json_object_free(json); |
5019 | } | |
5020 | else | |
5021 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5022 | |
5023 | return CMD_SUCCESS; | |
5024 | } | |
5025 | ||
7c8ff89e DS |
5026 | DEFUN (show_ip_ospf_neighbor_int_detail, |
5027 | show_ip_ospf_neighbor_int_detail_cmd, | |
3ac237f8 | 5028 | "show ip ospf neighbor IFNAME detail {json}", |
7c8ff89e DS |
5029 | SHOW_STR |
5030 | IP_STR | |
5031 | "OSPF information\n" | |
5032 | "Neighbor list\n" | |
5033 | "Interface name\n" | |
3ac237f8 MS |
5034 | "detail of all neighbors\n" |
5035 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5036 | { |
5037 | struct ospf *ospf; | |
db7c8528 | 5038 | u_char uj = use_json(argc, argv); |
7c8ff89e | 5039 | |
0bad4851 | 5040 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5041 | return CMD_SUCCESS; |
5042 | ||
db7c8528 | 5043 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
5044 | } |
5045 | ||
5046 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
5047 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
3ac237f8 | 5048 | "show ip ospf <1-65535> neighbor IFNAME detail {json}", |
7c8ff89e DS |
5049 | SHOW_STR |
5050 | IP_STR | |
5051 | "OSPF information\n" | |
5052 | "Instance ID\n" | |
5053 | "Neighbor list\n" | |
5054 | "Interface name\n" | |
3ac237f8 MS |
5055 | "detail of all neighbors\n" |
5056 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5057 | { |
5058 | struct ospf *ospf; | |
5059 | u_short instance = 0; | |
db7c8528 | 5060 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
5061 | |
5062 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 5063 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5064 | return CMD_SUCCESS; |
5065 | ||
db7c8528 | 5066 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); |
7c8ff89e | 5067 | } |
6b0655a2 | 5068 | |
718e3744 | 5069 | /* Show functions */ |
4dadc291 | 5070 | static int |
020709f9 | 5071 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 5072 | { |
718e3744 | 5073 | struct router_lsa *rl; |
5074 | struct summary_lsa *sl; | |
5075 | struct as_external_lsa *asel; | |
5076 | struct prefix_ipv4 p; | |
5077 | ||
5078 | if (lsa != NULL) | |
5079 | /* If self option is set, check LSA self flag. */ | |
5080 | if (self == 0 || IS_LSA_SELF (lsa)) | |
5081 | { | |
5082 | /* LSA common part show. */ | |
5083 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
5084 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
5085 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
5086 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
5087 | /* LSA specific part show. */ | |
5088 | switch (lsa->data->type) | |
5089 | { | |
5090 | case OSPF_ROUTER_LSA: | |
5091 | rl = (struct router_lsa *) lsa->data; | |
5092 | vty_out (vty, " %-d", ntohs (rl->links)); | |
5093 | break; | |
5094 | case OSPF_SUMMARY_LSA: | |
5095 | sl = (struct summary_lsa *) lsa->data; | |
5096 | ||
5097 | p.family = AF_INET; | |
5098 | p.prefix = sl->header.id; | |
5099 | p.prefixlen = ip_masklen (sl->mask); | |
5100 | apply_mask_ipv4 (&p); | |
5101 | ||
5102 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
5103 | break; | |
5104 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 5105 | case OSPF_AS_NSSA_LSA: |
718e3744 | 5106 | asel = (struct as_external_lsa *) lsa->data; |
5107 | ||
5108 | p.family = AF_INET; | |
5109 | p.prefix = asel->header.id; | |
5110 | p.prefixlen = ip_masklen (asel->mask); | |
5111 | apply_mask_ipv4 (&p); | |
5112 | ||
5113 | vty_out (vty, " %s %s/%d [0x%lx]", | |
5114 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
5115 | inet_ntoa (p.prefix), p.prefixlen, | |
5116 | (u_long)ntohl (asel->e[0].route_tag)); | |
5117 | break; | |
5118 | case OSPF_NETWORK_LSA: | |
5119 | case OSPF_ASBR_SUMMARY_LSA: | |
718e3744 | 5120 | case OSPF_OPAQUE_LINK_LSA: |
5121 | case OSPF_OPAQUE_AREA_LSA: | |
5122 | case OSPF_OPAQUE_AS_LSA: | |
718e3744 | 5123 | default: |
5124 | break; | |
5125 | } | |
5126 | vty_out (vty, VTY_NEWLINE); | |
5127 | } | |
5128 | ||
5129 | return 0; | |
5130 | } | |
5131 | ||
8b6a15b2 | 5132 | static const char *show_database_desc[] = |
718e3744 | 5133 | { |
5134 | "unknown", | |
5135 | "Router Link States", | |
5136 | "Net Link States", | |
5137 | "Summary Link States", | |
5138 | "ASBR-Summary Link States", | |
5139 | "AS External Link States", | |
718e3744 | 5140 | "Group Membership LSA", |
5141 | "NSSA-external Link States", | |
718e3744 | 5142 | "Type-8 LSA", |
5143 | "Link-Local Opaque-LSA", | |
5144 | "Area-Local Opaque-LSA", | |
5145 | "AS-external Opaque-LSA", | |
718e3744 | 5146 | }; |
5147 | ||
8b6a15b2 | 5148 | static const char *show_database_header[] = |
718e3744 | 5149 | { |
5150 | "", | |
5151 | "Link ID ADV Router Age Seq# CkSum Link count", | |
5152 | "Link ID ADV Router Age Seq# CkSum", | |
5153 | "Link ID ADV Router Age Seq# CkSum Route", | |
5154 | "Link ID ADV Router Age Seq# CkSum", | |
5155 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5156 | " --- header for Group Member ----", |
5157 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5158 | " --- type-8 ---", |
5159 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5160 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5161 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
718e3744 | 5162 | }; |
5163 | ||
4dadc291 | 5164 | static void |
718e3744 | 5165 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
5166 | { | |
5167 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 5168 | |
718e3744 | 5169 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 5170 | vty_out (vty, " Options: 0x%-2x : %s%s", |
5171 | lsa->data->options, | |
5172 | ospf_options_dump(lsa->data->options), | |
5173 | VTY_NEWLINE); | |
5174 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 5175 | lsa->flags, |
4957f494 | 5176 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
5177 | VTY_NEWLINE); | |
718e3744 | 5178 | |
5179 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
5180 | { | |
5181 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
5182 | ||
5183 | if (rlsa->flags) | |
5184 | vty_out (vty, " :%s%s%s%s", | |
5185 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
5186 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
5187 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
5188 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
5189 | ||
5190 | vty_out (vty, "%s", VTY_NEWLINE); | |
5191 | } | |
5192 | vty_out (vty, " LS Type: %s%s", | |
5193 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
5194 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
5195 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
5196 | vty_out (vty, " Advertising Router: %s%s", | |
5197 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5198 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
5199 | VTY_NEWLINE); | |
5200 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
5201 | VTY_NEWLINE); | |
5202 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
5203 | } | |
5204 | ||
eb1ce605 | 5205 | const char *link_type_desc[] = |
718e3744 | 5206 | { |
5207 | "(null)", | |
5208 | "another Router (point-to-point)", | |
5209 | "a Transit Network", | |
5210 | "Stub Network", | |
5211 | "a Virtual Link", | |
5212 | }; | |
5213 | ||
eb1ce605 | 5214 | const char *link_id_desc[] = |
718e3744 | 5215 | { |
5216 | "(null)", | |
5217 | "Neighboring Router ID", | |
5218 | "Designated Router address", | |
68980084 | 5219 | "Net", |
718e3744 | 5220 | "Neighboring Router ID", |
5221 | }; | |
5222 | ||
eb1ce605 | 5223 | const char *link_data_desc[] = |
718e3744 | 5224 | { |
5225 | "(null)", | |
5226 | "Router Interface address", | |
5227 | "Router Interface address", | |
5228 | "Network Mask", | |
5229 | "Router Interface address", | |
5230 | }; | |
5231 | ||
5232 | /* Show router-LSA each Link information. */ | |
4dadc291 | 5233 | static void |
718e3744 | 5234 | show_ip_ospf_database_router_links (struct vty *vty, |
5235 | struct router_lsa *rl) | |
5236 | { | |
b07c4cb3 DS |
5237 | int len, type; |
5238 | unsigned int i; | |
718e3744 | 5239 | |
5240 | len = ntohs (rl->header.length) - 4; | |
5241 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
5242 | { | |
5243 | type = rl->link[i].type; | |
5244 | ||
5245 | vty_out (vty, " Link connected to: %s%s", | |
5246 | link_type_desc[type], VTY_NEWLINE); | |
5247 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
5248 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
5249 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
5250 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
5251 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
5252 | vty_out (vty, " TOS 0 Metric: %d%s", | |
5253 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
5254 | vty_out (vty, "%s", VTY_NEWLINE); | |
5255 | } | |
5256 | } | |
5257 | ||
5258 | /* Show router-LSA detail information. */ | |
4dadc291 | 5259 | static int |
718e3744 | 5260 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5261 | { | |
5262 | if (lsa != NULL) | |
5263 | { | |
5264 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
5265 | ||
5266 | show_ip_ospf_database_header (vty, lsa); | |
5267 | ||
5268 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
5269 | VTY_NEWLINE, VTY_NEWLINE); | |
5270 | ||
5271 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 5272 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5273 | } |
5274 | ||
5275 | return 0; | |
5276 | } | |
5277 | ||
5278 | /* Show network-LSA detail information. */ | |
4dadc291 | 5279 | static int |
718e3744 | 5280 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5281 | { | |
5282 | int length, i; | |
5283 | ||
5284 | if (lsa != NULL) | |
5285 | { | |
5286 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
5287 | ||
5288 | show_ip_ospf_database_header (vty, lsa); | |
5289 | ||
5290 | vty_out (vty, " Network Mask: /%d%s", | |
5291 | ip_masklen (nl->mask), VTY_NEWLINE); | |
5292 | ||
5293 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
5294 | ||
5295 | for (i = 0; length > 0; i++, length -= 4) | |
5296 | vty_out (vty, " Attached Router: %s%s", | |
5297 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
5298 | ||
5299 | vty_out (vty, "%s", VTY_NEWLINE); | |
5300 | } | |
5301 | ||
5302 | return 0; | |
5303 | } | |
5304 | ||
5305 | /* Show summary-LSA detail information. */ | |
4dadc291 | 5306 | static int |
718e3744 | 5307 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5308 | { | |
5309 | if (lsa != NULL) | |
5310 | { | |
5311 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5312 | ||
5313 | show_ip_ospf_database_header (vty, lsa); | |
5314 | ||
5315 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
5316 | VTY_NEWLINE); | |
5317 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5318 | VTY_NEWLINE); | |
b0a053be | 5319 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5320 | } |
5321 | ||
5322 | return 0; | |
5323 | } | |
5324 | ||
5325 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 5326 | static int |
718e3744 | 5327 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5328 | { | |
5329 | if (lsa != NULL) | |
5330 | { | |
5331 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5332 | ||
5333 | show_ip_ospf_database_header (vty, lsa); | |
5334 | ||
5335 | vty_out (vty, " Network Mask: /%d%s", | |
5336 | ip_masklen (sl->mask), VTY_NEWLINE); | |
5337 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5338 | VTY_NEWLINE); | |
b0a053be | 5339 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5340 | } |
5341 | ||
5342 | return 0; | |
5343 | } | |
5344 | ||
5345 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 5346 | static int |
718e3744 | 5347 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5348 | { | |
5349 | if (lsa != NULL) | |
5350 | { | |
5351 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5352 | ||
5353 | show_ip_ospf_database_header (vty, lsa); | |
5354 | ||
5355 | vty_out (vty, " Network Mask: /%d%s", | |
5356 | ip_masklen (al->mask), VTY_NEWLINE); | |
5357 | vty_out (vty, " Metric Type: %s%s", | |
5358 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5359 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5360 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5361 | vty_out (vty, " Metric: %d%s", | |
5362 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5363 | vty_out (vty, " Forward Address: %s%s", | |
5364 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5365 | ||
dc9ffce8 CF |
5366 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5367 | (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 5368 | } |
5369 | ||
5370 | return 0; | |
5371 | } | |
5372 | ||
075e12f5 | 5373 | #if 0 |
4dadc291 | 5374 | static int |
718e3744 | 5375 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
5376 | { | |
5377 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5378 | ||
5379 | /* show_ip_ospf_database_header (vty, lsa); */ | |
5380 | ||
2a42e285 | 5381 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 5382 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5383 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5384 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5385 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5386 | zlog_debug( " TOS: 0%s", "\n"); |
5387 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5388 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5389 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5390 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5391 | ||
dc9ffce8 CF |
5392 | zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5393 | (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n"); | |
718e3744 | 5394 | |
5395 | return 0; | |
5396 | } | |
075e12f5 | 5397 | #endif |
718e3744 | 5398 | |
5399 | /* Show AS-NSSA-LSA detail information. */ | |
4dadc291 | 5400 | static int |
718e3744 | 5401 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5402 | { | |
5403 | if (lsa != NULL) | |
5404 | { | |
5405 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5406 | ||
5407 | show_ip_ospf_database_header (vty, lsa); | |
5408 | ||
5409 | vty_out (vty, " Network Mask: /%d%s", | |
5410 | ip_masklen (al->mask), VTY_NEWLINE); | |
5411 | vty_out (vty, " Metric Type: %s%s", | |
5412 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5413 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5414 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5415 | vty_out (vty, " Metric: %d%s", | |
5416 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5417 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
5418 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5419 | ||
dc9ffce8 CF |
5420 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5421 | (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 5422 | } |
5423 | ||
5424 | return 0; | |
5425 | } | |
5426 | ||
4dadc291 | 5427 | static int |
718e3744 | 5428 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5429 | { | |
5430 | return 0; | |
5431 | } | |
5432 | ||
4dadc291 | 5433 | static int |
718e3744 | 5434 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5435 | { | |
5436 | if (lsa != NULL) | |
5437 | { | |
5438 | show_ip_ospf_database_header (vty, lsa); | |
5439 | show_opaque_info_detail (vty, lsa); | |
5440 | ||
5441 | vty_out (vty, "%s", VTY_NEWLINE); | |
5442 | } | |
5443 | return 0; | |
5444 | } | |
718e3744 | 5445 | |
5446 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5447 | { | |
5448 | NULL, | |
5449 | show_router_lsa_detail, | |
5450 | show_network_lsa_detail, | |
5451 | show_summary_lsa_detail, | |
5452 | show_summary_asbr_lsa_detail, | |
5453 | show_as_external_lsa_detail, | |
718e3744 | 5454 | show_func_dummy, |
5455 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5456 | NULL, /* type-8 */ |
5457 | show_opaque_lsa_detail, | |
5458 | show_opaque_lsa_detail, | |
5459 | show_opaque_lsa_detail, | |
718e3744 | 5460 | }; |
5461 | ||
4dadc291 | 5462 | static void |
718e3744 | 5463 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5464 | struct in_addr *adv_router) | |
5465 | { | |
5466 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5467 | lp->family = 0; | |
5468 | if (id == NULL) | |
5469 | lp->prefixlen = 0; | |
5470 | else if (adv_router == NULL) | |
5471 | { | |
5472 | lp->prefixlen = 32; | |
5473 | lp->id = *id; | |
5474 | } | |
5475 | else | |
5476 | { | |
5477 | lp->prefixlen = 64; | |
5478 | lp->id = *id; | |
5479 | lp->adv_router = *adv_router; | |
5480 | } | |
5481 | } | |
5482 | ||
4dadc291 | 5483 | static void |
718e3744 | 5484 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5485 | struct in_addr *id, struct in_addr *adv_router) | |
5486 | { | |
5487 | struct prefix_ls lp; | |
5488 | struct route_node *rn, *start; | |
5489 | struct ospf_lsa *lsa; | |
5490 | ||
5491 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5492 | start = route_node_get (rt, (struct prefix *) &lp); | |
5493 | if (start) | |
5494 | { | |
5495 | route_lock_node (start); | |
5496 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5497 | if ((lsa = rn->info)) | |
5498 | { | |
718e3744 | 5499 | if (show_function[lsa->data->type] != NULL) |
5500 | show_function[lsa->data->type] (vty, lsa); | |
5501 | } | |
5502 | route_unlock_node (start); | |
5503 | } | |
5504 | } | |
5505 | ||
5506 | /* Show detail LSA information | |
5507 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5508 | static void |
020709f9 | 5509 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5510 | struct in_addr *id, struct in_addr *adv_router) |
5511 | { | |
52dc7ee6 | 5512 | struct listnode *node; |
1eb8ef25 | 5513 | struct ospf_area *area; |
5514 | ||
718e3744 | 5515 | switch (type) |
5516 | { | |
5517 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5518 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5519 | vty_out (vty, " %s %s%s", |
5520 | show_database_desc[type], | |
5521 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5522 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5523 | break; |
5524 | default: | |
1eb8ef25 | 5525 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5526 | { |
718e3744 | 5527 | vty_out (vty, "%s %s (Area %s)%s%s", |
5528 | VTY_NEWLINE, show_database_desc[type], | |
5529 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5530 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
5531 | } | |
5532 | break; | |
5533 | } | |
5534 | } | |
5535 | ||
4dadc291 | 5536 | static void |
718e3744 | 5537 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5538 | struct in_addr *adv_router) | |
5539 | { | |
5540 | struct route_node *rn; | |
5541 | struct ospf_lsa *lsa; | |
5542 | ||
5543 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5544 | if ((lsa = rn->info)) | |
5545 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5546 | { | |
718e3744 | 5547 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5548 | continue; | |
718e3744 | 5549 | if (show_function[lsa->data->type] != NULL) |
5550 | show_function[lsa->data->type] (vty, lsa); | |
5551 | } | |
5552 | } | |
5553 | ||
5554 | /* Show detail LSA information. */ | |
4dadc291 | 5555 | static void |
020709f9 | 5556 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5557 | struct in_addr *adv_router) |
5558 | { | |
52dc7ee6 | 5559 | struct listnode *node; |
1eb8ef25 | 5560 | struct ospf_area *area; |
718e3744 | 5561 | |
5562 | switch (type) | |
5563 | { | |
5564 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5565 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5566 | vty_out (vty, " %s %s%s", |
5567 | show_database_desc[type], | |
5568 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5569 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5570 | adv_router); |
5571 | break; | |
5572 | default: | |
1eb8ef25 | 5573 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5574 | { |
718e3744 | 5575 | vty_out (vty, "%s %s (Area %s)%s%s", |
5576 | VTY_NEWLINE, show_database_desc[type], | |
5577 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5578 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
5579 | adv_router); | |
5580 | } | |
5581 | break; | |
5582 | } | |
5583 | } | |
5584 | ||
4dadc291 | 5585 | static void |
020709f9 | 5586 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5587 | { |
020709f9 | 5588 | struct ospf_lsa *lsa; |
5589 | struct route_node *rn; | |
1eb8ef25 | 5590 | struct ospf_area *area; |
52dc7ee6 | 5591 | struct listnode *node; |
718e3744 | 5592 | int type; |
5593 | ||
1eb8ef25 | 5594 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5595 | { |
718e3744 | 5596 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5597 | { | |
5598 | switch (type) | |
5599 | { | |
5600 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5601 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5602 | continue; |
5603 | default: | |
5604 | break; | |
5605 | } | |
5606 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5607 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5608 | { | |
5609 | vty_out (vty, " %s (Area %s)%s%s", | |
5610 | show_database_desc[type], | |
5611 | ospf_area_desc_string (area), | |
5612 | VTY_NEWLINE, VTY_NEWLINE); | |
5613 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
5614 | ||
020709f9 | 5615 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5616 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5617 | |
5618 | vty_out (vty, "%s", VTY_NEWLINE); | |
5619 | } | |
5620 | } | |
5621 | } | |
5622 | ||
5623 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5624 | { | |
5625 | switch (type) | |
5626 | { | |
5627 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5628 | case OSPF_OPAQUE_AS_LSA: |
e8e1946e | 5629 | break; |
718e3744 | 5630 | default: |
5631 | continue; | |
5632 | } | |
68980084 | 5633 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5634 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5635 | { |
5636 | vty_out (vty, " %s%s%s", | |
5637 | show_database_desc[type], | |
5638 | VTY_NEWLINE, VTY_NEWLINE); | |
5639 | vty_out (vty, "%s%s", show_database_header[type], | |
5640 | VTY_NEWLINE); | |
020709f9 | 5641 | |
5642 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5643 | show_lsa_summary (vty, lsa, self); | |
5644 | ||
718e3744 | 5645 | vty_out (vty, "%s", VTY_NEWLINE); |
5646 | } | |
5647 | } | |
5648 | ||
5649 | vty_out (vty, "%s", VTY_NEWLINE); | |
5650 | } | |
5651 | ||
4dadc291 | 5652 | static void |
020709f9 | 5653 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5654 | { |
91e6a0e5 | 5655 | struct route_node *rn; |
718e3744 | 5656 | |
5657 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
5658 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
5659 | ||
91e6a0e5 | 5660 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5661 | { |
91e6a0e5 DD |
5662 | struct ospf_lsa *lsa; |
5663 | ||
5664 | if ((lsa = rn->info) != NULL) | |
5665 | { | |
5666 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
5667 | vty_out (vty, "Link State ID: %s%s", | |
5668 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
5669 | vty_out (vty, "Advertising Router: %s%s", | |
5670 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5671 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
5672 | vty_out (vty, "%s", VTY_NEWLINE); | |
5673 | } | |
1eb8ef25 | 5674 | } |
718e3744 | 5675 | } |
5676 | ||
718e3744 | 5677 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5678 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5679 | |
718e3744 | 5680 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
5681 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
5682 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
5683 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
718e3744 | 5684 | |
5685 | #define OSPF_LSA_TYPES_CMD_STR \ | |
5686 | "asbr-summary|external|network|router|summary" \ | |
5687 | OSPF_LSA_TYPE_NSSA_CMD_STR \ | |
5688 | OSPF_LSA_TYPE_OPAQUE_CMD_STR | |
5689 | ||
5690 | #define OSPF_LSA_TYPES_DESC \ | |
5691 | "ASBR summary link states\n" \ | |
5692 | "External link states\n" \ | |
5693 | "Network link states\n" \ | |
5694 | "Router link states\n" \ | |
5695 | "Network summary link states\n" \ | |
5696 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5697 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5698 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5699 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5700 | ||
7c8ff89e DS |
5701 | static int |
5702 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
5703 | int arg_base, int argc, const char **argv) | |
718e3744 | 5704 | { |
5705 | int type, ret; | |
5706 | struct in_addr id, adv_router; | |
5707 | ||
7c8ff89e DS |
5708 | if (ospf->instance) |
5709 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5710 | VTY_NEWLINE); | |
718e3744 | 5711 | |
5712 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5713 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5714 | |
5715 | /* Show all LSA. */ | |
7c8ff89e | 5716 | if (argc == arg_base + 0) |
718e3744 | 5717 | { |
020709f9 | 5718 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5719 | return CMD_SUCCESS; |
5720 | } | |
5721 | ||
5722 | /* Set database type to show. */ | |
7c8ff89e | 5723 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5724 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5725 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5726 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5727 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5728 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5729 | else if (strncmp (argv[arg_base + 0], "su", 2) == 0) |
718e3744 | 5730 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5731 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5732 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5733 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5734 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 5735 | else if (strncmp (argv[arg_base + 0], "se", 2) == 0) |
718e3744 | 5736 | { |
020709f9 | 5737 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5738 | return CMD_SUCCESS; |
5739 | } | |
7c8ff89e | 5740 | else if (strncmp (argv[arg_base + 0], "m", 1) == 0) |
718e3744 | 5741 | { |
020709f9 | 5742 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5743 | return CMD_SUCCESS; |
5744 | } | |
7c8ff89e | 5745 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5746 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5747 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5748 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5749 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5750 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5751 | else |
5752 | return CMD_WARNING; | |
5753 | ||
5754 | /* `show ip ospf database LSA'. */ | |
7c8ff89e | 5755 | if (argc == arg_base + 1) |
020709f9 | 5756 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7c8ff89e | 5757 | else if (argc >= arg_base + 2) |
718e3744 | 5758 | { |
7c8ff89e | 5759 | ret = inet_aton (argv[arg_base + 1], &id); |
718e3744 | 5760 | if (!ret) |
5761 | return CMD_WARNING; | |
5762 | ||
5763 | /* `show ip ospf database LSA ID'. */ | |
7c8ff89e | 5764 | if (argc == arg_base + 2) |
020709f9 | 5765 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5766 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7c8ff89e | 5767 | else if (argc == arg_base + 3) |
718e3744 | 5768 | { |
7c8ff89e | 5769 | if (strncmp (argv[arg_base + 2], "s", 1) == 0) |
68980084 | 5770 | adv_router = ospf->router_id; |
718e3744 | 5771 | else |
5772 | { | |
7c8ff89e | 5773 | ret = inet_aton (argv[arg_base + 2], &adv_router); |
718e3744 | 5774 | if (!ret) |
5775 | return CMD_WARNING; | |
5776 | } | |
020709f9 | 5777 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5778 | } |
5779 | } | |
5780 | ||
5781 | return CMD_SUCCESS; | |
5782 | } | |
5783 | ||
7c8ff89e DS |
5784 | DEFUN (show_ip_ospf_database, |
5785 | show_ip_ospf_database_cmd, | |
5786 | "show ip ospf database", | |
5787 | SHOW_STR | |
5788 | IP_STR | |
5789 | "OSPF information\n" | |
5790 | "Database summary\n") | |
5791 | { | |
5792 | struct ospf *ospf; | |
5793 | ||
0bad4851 | 5794 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5795 | return CMD_SUCCESS; |
5796 | ||
5797 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); | |
5798 | } | |
5799 | ||
718e3744 | 5800 | ALIAS (show_ip_ospf_database, |
5801 | show_ip_ospf_database_type_cmd, | |
5802 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5803 | SHOW_STR | |
5804 | IP_STR | |
5805 | "OSPF information\n" | |
5806 | "Database summary\n" | |
5807 | OSPF_LSA_TYPES_DESC | |
5808 | "LSAs in MaxAge list\n" | |
5809 | "Self-originated link states\n") | |
5810 | ||
5811 | ALIAS (show_ip_ospf_database, | |
5812 | show_ip_ospf_database_type_id_cmd, | |
5813 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5814 | SHOW_STR | |
5815 | IP_STR | |
5816 | "OSPF information\n" | |
5817 | "Database summary\n" | |
5818 | OSPF_LSA_TYPES_DESC | |
5819 | "Link State ID (as an IP address)\n") | |
5820 | ||
5821 | ALIAS (show_ip_ospf_database, | |
5822 | show_ip_ospf_database_type_id_adv_router_cmd, | |
5823 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5824 | SHOW_STR | |
5825 | IP_STR | |
5826 | "OSPF information\n" | |
5827 | "Database summary\n" | |
5828 | OSPF_LSA_TYPES_DESC | |
5829 | "Link State ID (as an IP address)\n" | |
5830 | "Advertising Router link states\n" | |
5831 | "Advertising Router (as an IP address)\n") | |
5832 | ||
5833 | ALIAS (show_ip_ospf_database, | |
5834 | show_ip_ospf_database_type_id_self_cmd, | |
5835 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5836 | SHOW_STR | |
5837 | IP_STR | |
5838 | "OSPF information\n" | |
5839 | "Database summary\n" | |
5840 | OSPF_LSA_TYPES_DESC | |
5841 | "Link State ID (as an IP address)\n" | |
5842 | "Self-originated link states\n" | |
5843 | "\n") | |
5844 | ||
7c8ff89e DS |
5845 | DEFUN (show_ip_ospf_instance_database, |
5846 | show_ip_ospf_instance_database_cmd, | |
5847 | "show ip ospf <1-65535> database", | |
718e3744 | 5848 | SHOW_STR |
5849 | IP_STR | |
5850 | "OSPF information\n" | |
7c8ff89e DS |
5851 | "Instance ID\n" |
5852 | "Database summary\n") | |
5853 | { | |
5854 | struct ospf *ospf; | |
5855 | u_short instance = 0; | |
5856 | ||
5857 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
5858 | ||
0bad4851 | 5859 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5860 | return CMD_SUCCESS; |
5861 | ||
5862 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); | |
5863 | } | |
5864 | ||
5865 | ALIAS (show_ip_ospf_instance_database, | |
5866 | show_ip_ospf_instance_database_type_cmd, | |
5867 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5868 | SHOW_STR | |
5869 | IP_STR | |
5870 | "OSPF information\n" | |
5871 | "Instance ID\n" | |
5872 | "Database summary\n" | |
5873 | OSPF_LSA_TYPES_DESC | |
5874 | "LSAs in MaxAge list\n" | |
5875 | "Self-originated link states\n") | |
5876 | ||
5877 | ALIAS (show_ip_ospf_instance_database, | |
5878 | show_ip_ospf_instance_database_type_id_cmd, | |
5879 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5880 | SHOW_STR | |
5881 | IP_STR | |
5882 | "OSPF information\n" | |
5883 | "Instance ID\n" | |
5884 | "Database summary\n" | |
5885 | OSPF_LSA_TYPES_DESC | |
5886 | "Link State ID (as an IP address)\n") | |
5887 | ||
5888 | ALIAS (show_ip_ospf_instance_database, | |
5889 | show_ip_ospf_instance_database_type_id_adv_router_cmd, | |
5890 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5891 | SHOW_STR | |
5892 | IP_STR | |
5893 | "OSPF information\n" | |
5894 | "Instance ID\n" | |
718e3744 | 5895 | "Database summary\n" |
5896 | OSPF_LSA_TYPES_DESC | |
7c8ff89e | 5897 | "Link State ID (as an IP address)\n" |
718e3744 | 5898 | "Advertising Router link states\n" |
5899 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
5900 | |
5901 | ALIAS (show_ip_ospf_instance_database, | |
5902 | show_ip_ospf_instance_database_type_id_self_cmd, | |
5903 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5904 | SHOW_STR | |
5905 | IP_STR | |
5906 | "OSPF information\n" | |
5907 | "Instance ID\n" | |
5908 | "Database summary\n" | |
5909 | OSPF_LSA_TYPES_DESC | |
5910 | "Link State ID (as an IP address)\n" | |
5911 | "Self-originated link states\n" | |
5912 | "\n") | |
5913 | ||
5914 | ||
5915 | static int | |
5916 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
5917 | int arg_base, int argc, const char **argv) | |
718e3744 | 5918 | { |
5919 | int type, ret; | |
5920 | struct in_addr adv_router; | |
5921 | ||
7c8ff89e DS |
5922 | if (ospf->instance) |
5923 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5924 | VTY_NEWLINE); | |
718e3744 | 5925 | |
5926 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5927 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5928 | |
7c8ff89e | 5929 | if (argc != arg_base + 2) |
718e3744 | 5930 | return CMD_WARNING; |
5931 | ||
5932 | /* Set database type to show. */ | |
7c8ff89e | 5933 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5934 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5935 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5936 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5937 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5938 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5939 | else if (strncmp (argv[arg_base + 0], "s", 1) == 0) |
718e3744 | 5940 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5941 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5942 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5943 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5944 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 5945 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5946 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5947 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5948 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5949 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5950 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5951 | else |
5952 | return CMD_WARNING; | |
5953 | ||
7c8ff89e DS |
5954 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
5955 | if (strncmp (argv[arg_base + 1], "s", 1) == 0) | |
5956 | adv_router = ospf->router_id; | |
5957 | else | |
5958 | { | |
5959 | ret = inet_aton (argv[arg_base + 1], &adv_router); | |
5960 | if (!ret) | |
5961 | return CMD_WARNING; | |
5962 | } | |
5963 | ||
5964 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5965 | ||
5966 | return CMD_SUCCESS; | |
5967 | } | |
5968 | ||
5969 | DEFUN (show_ip_ospf_database_type_adv_router, | |
5970 | show_ip_ospf_database_type_adv_router_cmd, | |
5971 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
5972 | SHOW_STR | |
5973 | IP_STR | |
5974 | "OSPF information\n" | |
5975 | "Database summary\n" | |
5976 | OSPF_LSA_TYPES_DESC | |
5977 | "Advertising Router link states\n" | |
5978 | "Advertising Router (as an IP address)\n") | |
5979 | { | |
5980 | struct ospf *ospf; | |
5981 | ||
0bad4851 | 5982 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5983 | return CMD_SUCCESS; |
5984 | ||
5985 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
5986 | } | |
5987 | ||
5988 | ALIAS (show_ip_ospf_database_type_adv_router, | |
5989 | show_ip_ospf_database_type_self_cmd, | |
5990 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
5991 | SHOW_STR | |
5992 | IP_STR | |
5993 | "OSPF information\n" | |
5994 | "Database summary\n" | |
5995 | OSPF_LSA_TYPES_DESC | |
5996 | "Self-originated link states\n") | |
5997 | ||
5998 | DEFUN (show_ip_ospf_instance_database_type_adv_router, | |
5999 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
6000 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
6001 | SHOW_STR | |
6002 | IP_STR | |
6003 | "OSPF information\n" | |
6004 | "Instance ID\n" | |
6005 | "Database summary\n" | |
6006 | OSPF_LSA_TYPES_DESC | |
6007 | "Advertising Router link states\n" | |
6008 | "Advertising Router (as an IP address)\n") | |
6009 | { | |
6010 | struct ospf *ospf; | |
6011 | u_short instance = 0; | |
6012 | ||
6013 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
718e3744 | 6014 | |
0bad4851 | 6015 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 6016 | return CMD_SUCCESS; |
718e3744 | 6017 | |
7c8ff89e | 6018 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 6019 | } |
6020 | ||
7c8ff89e DS |
6021 | ALIAS (show_ip_ospf_instance_database_type_adv_router, |
6022 | show_ip_ospf_instance_database_type_self_cmd, | |
6023 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
718e3744 | 6024 | SHOW_STR |
6025 | IP_STR | |
6026 | "OSPF information\n" | |
7c8ff89e | 6027 | "Instance ID\n" |
718e3744 | 6028 | "Database summary\n" |
6029 | OSPF_LSA_TYPES_DESC | |
6030 | "Self-originated link states\n") | |
6031 | ||
718e3744 | 6032 | DEFUN (ip_ospf_authentication_args, |
6033 | ip_ospf_authentication_args_addr_cmd, | |
6034 | "ip ospf authentication (null|message-digest) A.B.C.D", | |
6035 | "IP Information\n" | |
6036 | "OSPF interface commands\n" | |
6037 | "Enable authentication on this interface\n" | |
6038 | "Use null authentication\n" | |
6039 | "Use message-digest authentication\n" | |
6040 | "Address of interface") | |
6041 | { | |
6042 | struct interface *ifp; | |
6043 | struct in_addr addr; | |
6044 | int ret; | |
6045 | struct ospf_if_params *params; | |
6046 | ||
6047 | ifp = vty->index; | |
6048 | params = IF_DEF_PARAMS (ifp); | |
6049 | ||
6050 | if (argc == 2) | |
6051 | { | |
6052 | ret = inet_aton(argv[1], &addr); | |
6053 | if (!ret) | |
6054 | { | |
6055 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6056 | VTY_NEWLINE); | |
6057 | return CMD_WARNING; | |
6058 | } | |
6059 | ||
6060 | params = ospf_get_if_params (ifp, addr); | |
6061 | ospf_if_update_params (ifp, addr); | |
6062 | } | |
6063 | ||
6064 | /* Handle null authentication */ | |
6065 | if ( argv[0][0] == 'n' ) | |
6066 | { | |
6067 | SET_IF_PARAM (params, auth_type); | |
6068 | params->auth_type = OSPF_AUTH_NULL; | |
6069 | return CMD_SUCCESS; | |
6070 | } | |
6071 | ||
6072 | /* Handle message-digest authentication */ | |
6073 | if ( argv[0][0] == 'm' ) | |
6074 | { | |
6075 | SET_IF_PARAM (params, auth_type); | |
6076 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6077 | return CMD_SUCCESS; | |
6078 | } | |
6079 | ||
6080 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
6081 | return CMD_WARNING; | |
6082 | } | |
6083 | ||
6084 | ALIAS (ip_ospf_authentication_args, | |
6085 | ip_ospf_authentication_args_cmd, | |
6086 | "ip ospf authentication (null|message-digest)", | |
6087 | "IP Information\n" | |
6088 | "OSPF interface commands\n" | |
6089 | "Enable authentication on this interface\n" | |
6090 | "Use null authentication\n" | |
6091 | "Use message-digest authentication\n") | |
6092 | ||
6093 | DEFUN (ip_ospf_authentication, | |
6094 | ip_ospf_authentication_addr_cmd, | |
6095 | "ip ospf authentication A.B.C.D", | |
6096 | "IP Information\n" | |
6097 | "OSPF interface commands\n" | |
6098 | "Enable authentication on this interface\n" | |
6099 | "Address of interface") | |
6100 | { | |
6101 | struct interface *ifp; | |
6102 | struct in_addr addr; | |
6103 | int ret; | |
6104 | struct ospf_if_params *params; | |
6105 | ||
6106 | ifp = vty->index; | |
6107 | params = IF_DEF_PARAMS (ifp); | |
6108 | ||
6109 | if (argc == 1) | |
6110 | { | |
5dcf71df | 6111 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6112 | if (!ret) |
6113 | { | |
6114 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6115 | VTY_NEWLINE); | |
6116 | return CMD_WARNING; | |
6117 | } | |
6118 | ||
6119 | params = ospf_get_if_params (ifp, addr); | |
6120 | ospf_if_update_params (ifp, addr); | |
6121 | } | |
6122 | ||
6123 | SET_IF_PARAM (params, auth_type); | |
6124 | params->auth_type = OSPF_AUTH_SIMPLE; | |
6125 | ||
6126 | return CMD_SUCCESS; | |
6127 | } | |
6128 | ||
6129 | ALIAS (ip_ospf_authentication, | |
6130 | ip_ospf_authentication_cmd, | |
6131 | "ip ospf authentication", | |
6132 | "IP Information\n" | |
6133 | "OSPF interface commands\n" | |
6134 | "Enable authentication on this interface\n") | |
6135 | ||
b4a039bf DS |
6136 | DEFUN (no_ip_ospf_authentication_args, |
6137 | no_ip_ospf_authentication_args_addr_cmd, | |
6138 | "no ip ospf authentication (null|message-digest) A.B.C.D", | |
6139 | NO_STR | |
6140 | "IP Information\n" | |
6141 | "OSPF interface commands\n" | |
6142 | "Enable authentication on this interface\n" | |
6143 | "Use null authentication\n" | |
6144 | "Use message-digest authentication\n" | |
6145 | "Address of interface") | |
6146 | { | |
6147 | struct interface *ifp; | |
6148 | struct in_addr addr; | |
6149 | int ret; | |
6150 | struct ospf_if_params *params; | |
6151 | struct route_node *rn; | |
6152 | int auth_type; | |
6153 | ||
6154 | ifp = vty->index; | |
6155 | params = IF_DEF_PARAMS (ifp); | |
6156 | ||
6157 | if (argc == 2) | |
6158 | { | |
6159 | ret = inet_aton(argv[1], &addr); | |
6160 | if (!ret) | |
6161 | { | |
6162 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6163 | VTY_NEWLINE); | |
6164 | return CMD_WARNING; | |
6165 | } | |
6166 | ||
6167 | params = ospf_lookup_if_params (ifp, addr); | |
6168 | if (params == NULL) | |
6169 | { | |
6170 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6171 | return CMD_WARNING; | |
6172 | } | |
6173 | params->auth_type = OSPF_AUTH_NOTSET; | |
6174 | UNSET_IF_PARAM (params, auth_type); | |
6175 | if (params != IF_DEF_PARAMS (ifp)) | |
6176 | { | |
6177 | ospf_free_if_params (ifp, addr); | |
6178 | ospf_if_update_params (ifp, addr); | |
6179 | } | |
6180 | } | |
6181 | else | |
6182 | { | |
6183 | if ( argv[0][0] == 'n' ) | |
6184 | { | |
6185 | auth_type = OSPF_AUTH_NULL; | |
6186 | } | |
6187 | else if ( argv[0][0] == 'm' ) | |
6188 | { | |
6189 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6190 | } | |
6191 | else | |
6192 | { | |
6193 | vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE); | |
6194 | return CMD_WARNING; | |
6195 | } | |
6196 | /* | |
6197 | * Here we have a case where the user has entered | |
6198 | * 'no ip ospf authentication (null | message_digest )' | |
6199 | * we need to find if we have any ip addresses underneath it that | |
6200 | * correspond to the associated type. | |
6201 | */ | |
813d4307 DW |
6202 | if (params->auth_type == auth_type) |
6203 | { | |
6204 | params->auth_type = OSPF_AUTH_NOTSET; | |
6205 | UNSET_IF_PARAM (params, auth_type); | |
6206 | } | |
6207 | ||
b4a039bf DS |
6208 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6209 | { | |
6210 | if ((params = rn->info)) | |
6211 | { | |
6212 | if (params->auth_type == auth_type) | |
6213 | { | |
6214 | params->auth_type = OSPF_AUTH_NOTSET; | |
6215 | UNSET_IF_PARAM (params, auth_type); | |
6216 | if (params != IF_DEF_PARAMS (ifp)) | |
6217 | { | |
6218 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6219 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6220 | } | |
6221 | } | |
6222 | } | |
6223 | } | |
6224 | } | |
6225 | ||
6226 | return CMD_SUCCESS; | |
6227 | } | |
6228 | ||
6229 | ALIAS (no_ip_ospf_authentication_args, | |
6230 | no_ip_ospf_authentication_args_cmd, | |
6231 | "no ip ospf authentication (null|message-digest)", | |
6232 | NO_STR | |
6233 | "IP Information\n" | |
6234 | "OSPF interface commands\n" | |
6235 | "Enable authentication on this interface\n" | |
6236 | "Use null authentication\n" | |
6237 | "Use message-digest authentication\n") | |
6238 | ||
718e3744 | 6239 | DEFUN (no_ip_ospf_authentication, |
6240 | no_ip_ospf_authentication_addr_cmd, | |
6241 | "no ip ospf authentication A.B.C.D", | |
6242 | NO_STR | |
6243 | "IP Information\n" | |
6244 | "OSPF interface commands\n" | |
6245 | "Enable authentication on this interface\n" | |
6246 | "Address of interface") | |
6247 | { | |
6248 | struct interface *ifp; | |
6249 | struct in_addr addr; | |
6250 | int ret; | |
6251 | struct ospf_if_params *params; | |
b4a039bf DS |
6252 | struct route_node *rn; |
6253 | ||
718e3744 | 6254 | ifp = vty->index; |
6255 | params = IF_DEF_PARAMS (ifp); | |
6256 | ||
6257 | if (argc == 1) | |
6258 | { | |
5dcf71df | 6259 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6260 | if (!ret) |
6261 | { | |
6262 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6263 | VTY_NEWLINE); | |
6264 | return CMD_WARNING; | |
6265 | } | |
6266 | ||
6267 | params = ospf_lookup_if_params (ifp, addr); | |
6268 | if (params == NULL) | |
b4a039bf DS |
6269 | { |
6270 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6271 | return CMD_WARNING; | |
6272 | } | |
718e3744 | 6273 | |
b4a039bf DS |
6274 | params->auth_type = OSPF_AUTH_NOTSET; |
6275 | UNSET_IF_PARAM (params, auth_type); | |
6276 | if (params != IF_DEF_PARAMS (ifp)) | |
6277 | { | |
6278 | ospf_free_if_params (ifp, addr); | |
6279 | ospf_if_update_params (ifp, addr); | |
6280 | } | |
6281 | } | |
6282 | else | |
718e3744 | 6283 | { |
b4a039bf DS |
6284 | /* |
6285 | * When a user enters 'no ip ospf authentication' | |
6286 | * We should remove all authentication types from | |
6287 | * the interface. | |
6288 | */ | |
813d4307 DW |
6289 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6290 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6291 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6292 | { | |
6293 | params->auth_type = OSPF_AUTH_NOTSET; | |
6294 | UNSET_IF_PARAM (params, auth_type); | |
6295 | } | |
6296 | ||
b4a039bf DS |
6297 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6298 | { | |
6299 | if ((params = rn->info)) | |
6300 | { | |
813d4307 | 6301 | |
b4a039bf DS |
6302 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6303 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6304 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6305 | { | |
6306 | params->auth_type = OSPF_AUTH_NOTSET; | |
6307 | UNSET_IF_PARAM (params, auth_type); | |
6308 | if (params != IF_DEF_PARAMS (ifp)) | |
6309 | { | |
6310 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6311 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6312 | } | |
6313 | } | |
6314 | } | |
6315 | } | |
718e3744 | 6316 | } |
6317 | ||
6318 | return CMD_SUCCESS; | |
6319 | } | |
6320 | ||
6321 | ALIAS (no_ip_ospf_authentication, | |
6322 | no_ip_ospf_authentication_cmd, | |
6323 | "no ip ospf authentication", | |
6324 | NO_STR | |
6325 | "IP Information\n" | |
6326 | "OSPF interface commands\n" | |
6327 | "Enable authentication on this interface\n") | |
6328 | ||
6329 | DEFUN (ip_ospf_authentication_key, | |
6330 | ip_ospf_authentication_key_addr_cmd, | |
6331 | "ip ospf authentication-key AUTH_KEY A.B.C.D", | |
6332 | "IP Information\n" | |
6333 | "OSPF interface commands\n" | |
6334 | "Authentication password (key)\n" | |
6335 | "The OSPF password (key)\n" | |
6336 | "Address of interface") | |
6337 | { | |
6338 | struct interface *ifp; | |
6339 | struct in_addr addr; | |
6340 | int ret; | |
6341 | struct ospf_if_params *params; | |
6342 | ||
6343 | ifp = vty->index; | |
6344 | params = IF_DEF_PARAMS (ifp); | |
6345 | ||
6346 | if (argc == 2) | |
6347 | { | |
6348 | ret = inet_aton(argv[1], &addr); | |
6349 | if (!ret) | |
6350 | { | |
6351 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6352 | VTY_NEWLINE); | |
6353 | return CMD_WARNING; | |
6354 | } | |
6355 | ||
6356 | params = ospf_get_if_params (ifp, addr); | |
6357 | ospf_if_update_params (ifp, addr); | |
6358 | } | |
6359 | ||
718e3744 | 6360 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
c9e52be3 | 6361 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 6362 | SET_IF_PARAM (params, auth_simple); |
6363 | ||
6364 | return CMD_SUCCESS; | |
6365 | } | |
6366 | ||
6367 | ALIAS (ip_ospf_authentication_key, | |
6368 | ip_ospf_authentication_key_cmd, | |
6369 | "ip ospf authentication-key AUTH_KEY", | |
6370 | "IP Information\n" | |
6371 | "OSPF interface commands\n" | |
6372 | "Authentication password (key)\n" | |
6373 | "The OSPF password (key)") | |
6374 | ||
747e489c DW |
6375 | ALIAS_HIDDEN (ip_ospf_authentication_key, |
6376 | ospf_authentication_key_cmd, | |
6377 | "ospf authentication-key AUTH_KEY", | |
6378 | "OSPF interface commands\n" | |
6379 | "Authentication password (key)\n" | |
6380 | "The OSPF password (key)") | |
718e3744 | 6381 | |
6382 | DEFUN (no_ip_ospf_authentication_key, | |
813d4307 DW |
6383 | no_ip_ospf_authentication_key_authkey_addr_cmd, |
6384 | "no ip ospf authentication-key AUTH_KEY A.B.C.D", | |
718e3744 | 6385 | NO_STR |
6386 | "IP Information\n" | |
6387 | "OSPF interface commands\n" | |
6388 | "Authentication password (key)\n" | |
813d4307 | 6389 | "The OSPF password (key)") |
718e3744 | 6390 | { |
6391 | struct interface *ifp; | |
6392 | struct in_addr addr; | |
718e3744 | 6393 | struct ospf_if_params *params; |
813d4307 | 6394 | int ret; |
718e3744 | 6395 | |
6396 | ifp = vty->index; | |
6397 | params = IF_DEF_PARAMS (ifp); | |
6398 | ||
813d4307 | 6399 | if (argc == 2) |
718e3744 | 6400 | { |
813d4307 | 6401 | ret = inet_aton(argv[1], &addr); |
718e3744 | 6402 | if (!ret) |
6403 | { | |
6404 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6405 | VTY_NEWLINE); | |
6406 | return CMD_WARNING; | |
6407 | } | |
6408 | ||
6409 | params = ospf_lookup_if_params (ifp, addr); | |
6410 | if (params == NULL) | |
6411 | return CMD_SUCCESS; | |
6412 | } | |
6413 | ||
6414 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); | |
6415 | UNSET_IF_PARAM (params, auth_simple); | |
6416 | ||
6417 | if (params != IF_DEF_PARAMS (ifp)) | |
6418 | { | |
6419 | ospf_free_if_params (ifp, addr); | |
6420 | ospf_if_update_params (ifp, addr); | |
6421 | } | |
6422 | ||
6423 | return CMD_SUCCESS; | |
6424 | } | |
6425 | ||
813d4307 DW |
6426 | ALIAS (no_ip_ospf_authentication_key, |
6427 | no_ip_ospf_authentication_key_authkey_cmd, | |
6428 | "no ip ospf authentication-key AUTH_KEY", | |
6429 | NO_STR | |
6430 | "IP Information\n" | |
6431 | "OSPF interface commands\n" | |
6432 | "Authentication password (key)\n") | |
6433 | ||
718e3744 | 6434 | ALIAS (no_ip_ospf_authentication_key, |
6435 | no_ip_ospf_authentication_key_cmd, | |
6436 | "no ip ospf authentication-key", | |
6437 | NO_STR | |
6438 | "IP Information\n" | |
6439 | "OSPF interface commands\n" | |
6440 | "Authentication password (key)\n") | |
6441 | ||
6442 | ALIAS (no_ip_ospf_authentication_key, | |
6443 | no_ospf_authentication_key_cmd, | |
6444 | "no ospf authentication-key", | |
6445 | NO_STR | |
6446 | "OSPF interface commands\n" | |
6447 | "Authentication password (key)\n") | |
6448 | ||
813d4307 DW |
6449 | ALIAS (no_ip_ospf_authentication_key, |
6450 | no_ospf_authentication_key_authkey_cmd, | |
6451 | "no ospf authentication-key AUTH_KEY", | |
6452 | NO_STR | |
6453 | "OSPF interface commands\n" | |
6454 | "Authentication password (key)\n" | |
6455 | "The OSPF password (key)\n") | |
6456 | ||
6457 | ALIAS (no_ip_ospf_authentication_key, | |
6458 | no_ospf_authentication_key_authkey_ip_cmd, | |
6459 | "no ospf authentication-key AUTH_KEY A.B.C.D", | |
6460 | NO_STR | |
6461 | "OSPF interface commands\n" | |
6462 | "Authentication password (key)\n" | |
6463 | "The OSPF password (key)\n" | |
6464 | "Address of interface") | |
6465 | ||
718e3744 | 6466 | DEFUN (ip_ospf_message_digest_key, |
6467 | ip_ospf_message_digest_key_addr_cmd, | |
6468 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", | |
6469 | "IP Information\n" | |
6470 | "OSPF interface commands\n" | |
6471 | "Message digest authentication password (key)\n" | |
6472 | "Key ID\n" | |
6473 | "Use MD5 algorithm\n" | |
6474 | "The OSPF password (key)" | |
6475 | "Address of interface") | |
6476 | { | |
6477 | struct interface *ifp; | |
6478 | struct crypt_key *ck; | |
6479 | u_char key_id; | |
6480 | struct in_addr addr; | |
6481 | int ret; | |
6482 | struct ospf_if_params *params; | |
6483 | ||
6484 | ifp = vty->index; | |
6485 | params = IF_DEF_PARAMS (ifp); | |
6486 | ||
6487 | if (argc == 3) | |
6488 | { | |
6489 | ret = inet_aton(argv[2], &addr); | |
6490 | if (!ret) | |
6491 | { | |
6492 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6493 | VTY_NEWLINE); | |
6494 | return CMD_WARNING; | |
6495 | } | |
6496 | ||
6497 | params = ospf_get_if_params (ifp, addr); | |
6498 | ospf_if_update_params (ifp, addr); | |
6499 | } | |
6500 | ||
6501 | key_id = strtol (argv[0], NULL, 10); | |
6502 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) | |
6503 | { | |
6504 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
6505 | return CMD_WARNING; | |
6506 | } | |
6507 | ||
6508 | ck = ospf_crypt_key_new (); | |
6509 | ck->key_id = (u_char) key_id; | |
6510 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 6511 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
718e3744 | 6512 | |
6513 | ospf_crypt_key_add (params->auth_crypt, ck); | |
6514 | SET_IF_PARAM (params, auth_crypt); | |
6515 | ||
6516 | return CMD_SUCCESS; | |
6517 | } | |
6518 | ||
6519 | ALIAS (ip_ospf_message_digest_key, | |
6520 | ip_ospf_message_digest_key_cmd, | |
6521 | "ip ospf message-digest-key <1-255> md5 KEY", | |
6522 | "IP Information\n" | |
6523 | "OSPF interface commands\n" | |
6524 | "Message digest authentication password (key)\n" | |
6525 | "Key ID\n" | |
6526 | "Use MD5 algorithm\n" | |
6527 | "The OSPF password (key)") | |
6528 | ||
747e489c DW |
6529 | ALIAS_HIDDEN (ip_ospf_message_digest_key, |
6530 | ospf_message_digest_key_cmd, | |
6531 | "ospf message-digest-key <1-255> md5 KEY", | |
6532 | "OSPF interface commands\n" | |
6533 | "Message digest authentication password (key)\n" | |
6534 | "Key ID\n" | |
6535 | "Use MD5 algorithm\n" | |
6536 | "The OSPF password (key)") | |
718e3744 | 6537 | |
813d4307 DW |
6538 | DEFUN (no_ip_ospf_message_digest_key_md5, |
6539 | no_ip_ospf_message_digest_key_md5_addr_cmd, | |
6540 | "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", | |
6541 | NO_STR | |
6542 | "IP Information\n" | |
6543 | "OSPF interface commands\n" | |
6544 | "Message digest authentication password (key)\n" | |
6545 | "Key ID\n" | |
6546 | "Use MD5 algorithm\n" | |
6547 | "The OSPF password (key)" | |
6548 | "Address of interface") | |
6549 | { | |
6550 | struct interface *ifp; | |
6551 | struct crypt_key *ck; | |
6552 | int key_id; | |
6553 | struct in_addr addr; | |
6554 | int ret; | |
6555 | struct ospf_if_params *params; | |
6556 | ||
6557 | ifp = vty->index; | |
6558 | params = IF_DEF_PARAMS (ifp); | |
6559 | ||
6560 | if (argc == 3) | |
6561 | { | |
6562 | ret = inet_aton(argv[2], &addr); | |
6563 | if (!ret) | |
6564 | { | |
6565 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6566 | VTY_NEWLINE); | |
6567 | return CMD_WARNING; | |
6568 | } | |
6569 | ||
6570 | params = ospf_lookup_if_params (ifp, addr); | |
6571 | if (params == NULL) | |
6572 | return CMD_SUCCESS; | |
6573 | } | |
6574 | ||
6575 | key_id = strtol (argv[0], NULL, 10); | |
6576 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); | |
6577 | if (ck == NULL) | |
6578 | { | |
6579 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6580 | return CMD_WARNING; | |
6581 | } | |
6582 | ||
6583 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6584 | ||
6585 | if (params != IF_DEF_PARAMS (ifp)) | |
6586 | { | |
6587 | ospf_free_if_params (ifp, addr); | |
6588 | ospf_if_update_params (ifp, addr); | |
6589 | } | |
6590 | ||
6591 | return CMD_SUCCESS; | |
6592 | } | |
6593 | ||
6594 | ALIAS (no_ip_ospf_message_digest_key_md5, | |
6595 | no_ip_ospf_message_digest_key_md5_cmd, | |
6596 | "no ip ospf message-digest-key <1-255> md5 KEY", | |
6597 | NO_STR | |
6598 | "IP Information\n" | |
6599 | "OSPF interface commands\n" | |
6600 | "Message digest authentication password (key)\n" | |
6601 | "Key ID\n" | |
6602 | "Use MD5 algorithm\n" | |
6603 | "The OSPF password (key)") | |
6604 | ||
718e3744 | 6605 | DEFUN (no_ip_ospf_message_digest_key, |
6606 | no_ip_ospf_message_digest_key_addr_cmd, | |
6607 | "no ip ospf message-digest-key <1-255> A.B.C.D", | |
6608 | NO_STR | |
6609 | "IP Information\n" | |
6610 | "OSPF interface commands\n" | |
6611 | "Message digest authentication password (key)\n" | |
6612 | "Key ID\n" | |
6613 | "Address of interface") | |
6614 | { | |
6615 | struct interface *ifp; | |
6616 | struct crypt_key *ck; | |
6617 | int key_id; | |
6618 | struct in_addr addr; | |
6619 | int ret; | |
6620 | struct ospf_if_params *params; | |
6621 | ||
6622 | ifp = vty->index; | |
6623 | params = IF_DEF_PARAMS (ifp); | |
6624 | ||
6625 | if (argc == 2) | |
6626 | { | |
6627 | ret = inet_aton(argv[1], &addr); | |
6628 | if (!ret) | |
6629 | { | |
6630 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6631 | VTY_NEWLINE); | |
6632 | return CMD_WARNING; | |
6633 | } | |
6634 | ||
6635 | params = ospf_lookup_if_params (ifp, addr); | |
6636 | if (params == NULL) | |
6637 | return CMD_SUCCESS; | |
6638 | } | |
6639 | ||
6640 | key_id = strtol (argv[0], NULL, 10); | |
6641 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); | |
6642 | if (ck == NULL) | |
6643 | { | |
6644 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6645 | return CMD_WARNING; | |
6646 | } | |
6647 | ||
6648 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6649 | ||
6650 | if (params != IF_DEF_PARAMS (ifp)) | |
6651 | { | |
6652 | ospf_free_if_params (ifp, addr); | |
6653 | ospf_if_update_params (ifp, addr); | |
6654 | } | |
6655 | ||
6656 | return CMD_SUCCESS; | |
6657 | } | |
6658 | ||
6659 | ALIAS (no_ip_ospf_message_digest_key, | |
6660 | no_ip_ospf_message_digest_key_cmd, | |
6661 | "no ip ospf message-digest-key <1-255>", | |
6662 | NO_STR | |
6663 | "IP Information\n" | |
6664 | "OSPF interface commands\n" | |
6665 | "Message digest authentication password (key)\n" | |
6666 | "Key ID\n") | |
6667 | ||
6668 | ALIAS (no_ip_ospf_message_digest_key, | |
6669 | no_ospf_message_digest_key_cmd, | |
6670 | "no ospf message-digest-key <1-255>", | |
6671 | NO_STR | |
6672 | "OSPF interface commands\n" | |
6673 | "Message digest authentication password (key)\n" | |
6674 | "Key ID\n") | |
6675 | ||
6676 | DEFUN (ip_ospf_cost, | |
9eff36b3 | 6677 | ip_ospf_cost_u32_inet4_cmd, |
718e3744 | 6678 | "ip ospf cost <1-65535> A.B.C.D", |
6679 | "IP Information\n" | |
6680 | "OSPF interface commands\n" | |
6681 | "Interface cost\n" | |
6682 | "Cost\n" | |
6683 | "Address of interface") | |
6684 | { | |
6685 | struct interface *ifp = vty->index; | |
6686 | u_int32_t cost; | |
6687 | struct in_addr addr; | |
6688 | int ret; | |
6689 | struct ospf_if_params *params; | |
6690 | ||
6691 | params = IF_DEF_PARAMS (ifp); | |
6692 | ||
6693 | cost = strtol (argv[0], NULL, 10); | |
6694 | ||
6695 | /* cost range is <1-65535>. */ | |
6696 | if (cost < 1 || cost > 65535) | |
6697 | { | |
6698 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6699 | return CMD_WARNING; | |
6700 | } | |
6701 | ||
6702 | if (argc == 2) | |
6703 | { | |
6704 | ret = inet_aton(argv[1], &addr); | |
6705 | if (!ret) | |
6706 | { | |
6707 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6708 | VTY_NEWLINE); | |
6709 | return CMD_WARNING; | |
6710 | } | |
6711 | ||
6712 | params = ospf_get_if_params (ifp, addr); | |
6713 | ospf_if_update_params (ifp, addr); | |
6714 | } | |
6715 | ||
6716 | SET_IF_PARAM (params, output_cost_cmd); | |
6717 | params->output_cost_cmd = cost; | |
6718 | ||
6719 | ospf_if_recalculate_output_cost (ifp); | |
6720 | ||
6721 | return CMD_SUCCESS; | |
6722 | } | |
6723 | ||
6724 | ALIAS (ip_ospf_cost, | |
9eff36b3 | 6725 | ip_ospf_cost_u32_cmd, |
718e3744 | 6726 | "ip ospf cost <1-65535>", |
6727 | "IP Information\n" | |
6728 | "OSPF interface commands\n" | |
6729 | "Interface cost\n" | |
6730 | "Cost") | |
6731 | ||
747e489c DW |
6732 | ALIAS_HIDDEN (ip_ospf_cost, |
6733 | ospf_cost_u32_cmd, | |
6734 | "ospf cost <1-65535>", | |
6735 | "OSPF interface commands\n" | |
6736 | "Interface cost\n" | |
6737 | "Cost") | |
6738 | ||
6739 | ALIAS_HIDDEN (ip_ospf_cost, | |
6740 | ospf_cost_u32_inet4_cmd, | |
6741 | "ospf cost <1-65535> A.B.C.D", | |
6742 | "OSPF interface commands\n" | |
6743 | "Interface cost\n" | |
6744 | "Cost\n" | |
6745 | "Address of interface") | |
9eff36b3 | 6746 | |
718e3744 | 6747 | DEFUN (no_ip_ospf_cost, |
9eff36b3 | 6748 | no_ip_ospf_cost_inet4_cmd, |
718e3744 | 6749 | "no ip ospf cost A.B.C.D", |
6750 | NO_STR | |
6751 | "IP Information\n" | |
6752 | "OSPF interface commands\n" | |
6753 | "Interface cost\n" | |
6754 | "Address of interface") | |
6755 | { | |
6756 | struct interface *ifp = vty->index; | |
6757 | struct in_addr addr; | |
6758 | int ret; | |
6759 | struct ospf_if_params *params; | |
6760 | ||
718e3744 | 6761 | params = IF_DEF_PARAMS (ifp); |
6762 | ||
6763 | if (argc == 1) | |
6764 | { | |
6765 | ret = inet_aton(argv[0], &addr); | |
6766 | if (!ret) | |
6767 | { | |
6768 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6769 | VTY_NEWLINE); | |
6770 | return CMD_WARNING; | |
6771 | } | |
6772 | ||
6773 | params = ospf_lookup_if_params (ifp, addr); | |
6774 | if (params == NULL) | |
6775 | return CMD_SUCCESS; | |
6776 | } | |
6777 | ||
6778 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6779 | ||
6780 | if (params != IF_DEF_PARAMS (ifp)) | |
6781 | { | |
6782 | ospf_free_if_params (ifp, addr); | |
6783 | ospf_if_update_params (ifp, addr); | |
6784 | } | |
6785 | ||
6786 | ospf_if_recalculate_output_cost (ifp); | |
6787 | ||
6788 | return CMD_SUCCESS; | |
6789 | } | |
6790 | ||
6791 | ALIAS (no_ip_ospf_cost, | |
6792 | no_ip_ospf_cost_cmd, | |
6793 | "no ip ospf cost", | |
6794 | NO_STR | |
6795 | "IP Information\n" | |
6796 | "OSPF interface commands\n" | |
6797 | "Interface cost\n") | |
6798 | ||
6799 | ALIAS (no_ip_ospf_cost, | |
6800 | no_ospf_cost_cmd, | |
6801 | "no ospf cost", | |
6802 | NO_STR | |
6803 | "OSPF interface commands\n" | |
6804 | "Interface cost\n") | |
6805 | ||
9eff36b3 DO |
6806 | ALIAS (no_ip_ospf_cost, |
6807 | no_ospf_cost_inet4_cmd, | |
6808 | "no ospf cost A.B.C.D", | |
6809 | NO_STR | |
6810 | "OSPF interface commands\n" | |
6811 | "Interface cost\n" | |
6812 | "Address of interface") | |
6813 | ||
827341b7 DO |
6814 | DEFUN (no_ip_ospf_cost2, |
6815 | no_ip_ospf_cost_u32_cmd, | |
6816 | "no ip ospf cost <1-65535>", | |
6817 | NO_STR | |
6818 | "IP Information\n" | |
6819 | "OSPF interface commands\n" | |
6820 | "Interface cost\n" | |
6821 | "Cost") | |
6822 | { | |
6823 | struct interface *ifp = vty->index; | |
6824 | struct in_addr addr; | |
6825 | u_int32_t cost; | |
6826 | int ret; | |
6827 | struct ospf_if_params *params; | |
6828 | ||
827341b7 DO |
6829 | params = IF_DEF_PARAMS (ifp); |
6830 | ||
6831 | /* According to the semantics we are mimicking "no ip ospf cost N" is | |
6832 | * always treated as "no ip ospf cost" regardless of the actual value | |
6833 | * of N already configured for the interface. Thus the first argument | |
6834 | * is always checked to be a number, but is ignored after that. | |
6835 | */ | |
6836 | cost = strtol (argv[0], NULL, 10); | |
6837 | if (cost < 1 || cost > 65535) | |
6838 | { | |
6839 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6840 | return CMD_WARNING; | |
6841 | } | |
6842 | ||
6843 | if (argc == 2) | |
6844 | { | |
6845 | ret = inet_aton(argv[1], &addr); | |
6846 | if (!ret) | |
6847 | { | |
6848 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6849 | VTY_NEWLINE); | |
6850 | return CMD_WARNING; | |
6851 | } | |
6852 | ||
6853 | params = ospf_lookup_if_params (ifp, addr); | |
6854 | if (params == NULL) | |
6855 | return CMD_SUCCESS; | |
6856 | } | |
6857 | ||
6858 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6859 | ||
6860 | if (params != IF_DEF_PARAMS (ifp)) | |
6861 | { | |
6862 | ospf_free_if_params (ifp, addr); | |
6863 | ospf_if_update_params (ifp, addr); | |
6864 | } | |
6865 | ||
6866 | ospf_if_recalculate_output_cost (ifp); | |
6867 | ||
6868 | return CMD_SUCCESS; | |
6869 | } | |
6870 | ||
6871 | ALIAS (no_ip_ospf_cost2, | |
6872 | no_ospf_cost_u32_cmd, | |
6873 | "no ospf cost <1-65535>", | |
6874 | NO_STR | |
6875 | "OSPF interface commands\n" | |
6876 | "Interface cost\n" | |
6877 | "Cost") | |
6878 | ||
6879 | ALIAS (no_ip_ospf_cost2, | |
6880 | no_ip_ospf_cost_u32_inet4_cmd, | |
6881 | "no ip ospf cost <1-65535> A.B.C.D", | |
6882 | NO_STR | |
6883 | "IP Information\n" | |
6884 | "OSPF interface commands\n" | |
6885 | "Interface cost\n" | |
6886 | "Cost\n" | |
6887 | "Address of interface") | |
6888 | ||
6889 | ALIAS (no_ip_ospf_cost2, | |
6890 | no_ospf_cost_u32_inet4_cmd, | |
6891 | "no ospf cost <1-65535> A.B.C.D", | |
6892 | NO_STR | |
6893 | "OSPF interface commands\n" | |
6894 | "Interface cost\n" | |
6895 | "Cost\n" | |
6896 | "Address of interface") | |
9eff36b3 | 6897 | |
4dadc291 | 6898 | static void |
718e3744 | 6899 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6900 | { | |
6901 | struct route_node *rn; | |
6902 | struct ospf_neighbor *nbr; | |
6903 | ||
6904 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6905 | if ((nbr = rn->info)) | |
6906 | { | |
6907 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6908 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6909 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6910 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6911 | } | |
6912 | } | |
6913 | ||
f9ad937f | 6914 | static int |
6915 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6916 | const char *nbr_str, | |
6917 | const char *fast_hello_str) | |
718e3744 | 6918 | { |
6919 | struct interface *ifp = vty->index; | |
6920 | u_int32_t seconds; | |
f9ad937f | 6921 | u_char hellomult; |
718e3744 | 6922 | struct in_addr addr; |
6923 | int ret; | |
6924 | struct ospf_if_params *params; | |
6925 | struct ospf_interface *oi; | |
6926 | struct route_node *rn; | |
6927 | ||
6928 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6929 | |
6930 | if (nbr_str) | |
718e3744 | 6931 | { |
f9ad937f | 6932 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6933 | if (!ret) |
6934 | { | |
6935 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6936 | VTY_NEWLINE); | |
6937 | return CMD_WARNING; | |
6938 | } | |
6939 | ||
6940 | params = ospf_get_if_params (ifp, addr); | |
6941 | ospf_if_update_params (ifp, addr); | |
6942 | } | |
6943 | ||
f9ad937f | 6944 | if (interval_str) |
6945 | { | |
6946 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
6947 | 1, 65535); | |
6948 | ||
6949 | /* reset fast_hello too, just to be sure */ | |
6950 | UNSET_IF_PARAM (params, fast_hello); | |
6951 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6952 | } | |
6953 | else if (fast_hello_str) | |
6954 | { | |
6955 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
6956 | 1, 10); | |
6957 | /* 1s dead-interval with sub-second hellos desired */ | |
6958 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6959 | SET_IF_PARAM (params, fast_hello); | |
6960 | params->fast_hello = hellomult; | |
6961 | } | |
6962 | else | |
6963 | { | |
6964 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
6965 | VTY_NEWLINE); | |
6966 | return CMD_WARNING; | |
6967 | } | |
6968 | ||
718e3744 | 6969 | SET_IF_PARAM (params, v_wait); |
6970 | params->v_wait = seconds; | |
6971 | ||
6972 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6973 | if (nbr_str) |
718e3744 | 6974 | { |
cac3b5c4 PJ |
6975 | struct ospf *ospf; |
6976 | if ((ospf = ospf_lookup())) | |
68980084 | 6977 | { |
6978 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6979 | if (oi) | |
6980 | ospf_nbr_timer_update (oi); | |
6981 | } | |
718e3744 | 6982 | } |
6983 | else | |
6984 | { | |
6985 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6986 | if ((oi = rn->info)) | |
6987 | ospf_nbr_timer_update (oi); | |
6988 | } | |
6989 | ||
6990 | return CMD_SUCCESS; | |
6991 | } | |
6992 | ||
f9ad937f | 6993 | |
6994 | DEFUN (ip_ospf_dead_interval, | |
6995 | ip_ospf_dead_interval_addr_cmd, | |
6996 | "ip ospf dead-interval <1-65535> A.B.C.D", | |
6997 | "IP Information\n" | |
6998 | "OSPF interface commands\n" | |
6999 | "Interval after which a neighbor is declared dead\n" | |
7000 | "Seconds\n" | |
7001 | "Address of interface\n") | |
7002 | { | |
7003 | if (argc == 2) | |
7004 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); | |
7005 | else | |
7006 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); | |
7007 | } | |
7008 | ||
718e3744 | 7009 | ALIAS (ip_ospf_dead_interval, |
7010 | ip_ospf_dead_interval_cmd, | |
7011 | "ip ospf dead-interval <1-65535>", | |
7012 | "IP Information\n" | |
7013 | "OSPF interface commands\n" | |
7014 | "Interval after which a neighbor is declared dead\n" | |
7015 | "Seconds\n") | |
7016 | ||
747e489c DW |
7017 | ALIAS_HIDDEN (ip_ospf_dead_interval, |
7018 | ospf_dead_interval_cmd, | |
7019 | "ospf dead-interval <1-65535>", | |
7020 | "OSPF interface commands\n" | |
7021 | "Interval after which a neighbor is declared dead\n" | |
7022 | "Seconds\n") | |
718e3744 | 7023 | |
f9ad937f | 7024 | DEFUN (ip_ospf_dead_interval_minimal, |
7025 | ip_ospf_dead_interval_minimal_addr_cmd, | |
7026 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
7027 | "IP Information\n" | |
7028 | "OSPF interface commands\n" | |
7029 | "Interval after which a neighbor is declared dead\n" | |
7030 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7031 | "Hello multiplier factor\n" | |
7032 | "Number of Hellos to send each second\n" | |
7033 | "Address of interface\n") | |
7034 | { | |
7035 | if (argc == 2) | |
7036 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); | |
7037 | else | |
7038 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); | |
7039 | } | |
7040 | ||
7041 | ALIAS (ip_ospf_dead_interval_minimal, | |
7042 | ip_ospf_dead_interval_minimal_cmd, | |
7043 | "ip ospf dead-interval minimal hello-multiplier <1-10>", | |
7044 | "IP Information\n" | |
7045 | "OSPF interface commands\n" | |
7046 | "Interval after which a neighbor is declared dead\n" | |
7047 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7048 | "Hello multiplier factor\n" | |
7049 | "Number of Hellos to send each second\n") | |
7050 | ||
718e3744 | 7051 | DEFUN (no_ip_ospf_dead_interval, |
7052 | no_ip_ospf_dead_interval_addr_cmd, | |
f9dfba8d | 7053 | "no ip ospf dead-interval <1-65535> A.B.C.D", |
718e3744 | 7054 | NO_STR |
7055 | "IP Information\n" | |
7056 | "OSPF interface commands\n" | |
7057 | "Interval after which a neighbor is declared dead\n" | |
f9dfba8d | 7058 | "Seconds\n" |
718e3744 | 7059 | "Address of interface") |
7060 | { | |
7061 | struct interface *ifp = vty->index; | |
7062 | struct in_addr addr; | |
7063 | int ret; | |
7064 | struct ospf_if_params *params; | |
7065 | struct ospf_interface *oi; | |
7066 | struct route_node *rn; | |
020709f9 | 7067 | |
718e3744 | 7068 | params = IF_DEF_PARAMS (ifp); |
7069 | ||
f9dfba8d | 7070 | if (argc == 2) |
718e3744 | 7071 | { |
f9dfba8d | 7072 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7073 | if (!ret) |
7074 | { | |
7075 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7076 | VTY_NEWLINE); | |
7077 | return CMD_WARNING; | |
7078 | } | |
7079 | ||
7080 | params = ospf_lookup_if_params (ifp, addr); | |
7081 | if (params == NULL) | |
7082 | return CMD_SUCCESS; | |
7083 | } | |
7084 | ||
7085 | UNSET_IF_PARAM (params, v_wait); | |
7086 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 7087 | |
7088 | UNSET_IF_PARAM (params, fast_hello); | |
7089 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
7090 | ||
718e3744 | 7091 | if (params != IF_DEF_PARAMS (ifp)) |
7092 | { | |
7093 | ospf_free_if_params (ifp, addr); | |
7094 | ospf_if_update_params (ifp, addr); | |
7095 | } | |
7096 | ||
7097 | /* Update timer values in neighbor structure. */ | |
7098 | if (argc == 1) | |
7099 | { | |
cac3b5c4 PJ |
7100 | struct ospf *ospf; |
7101 | ||
7102 | if ((ospf = ospf_lookup())) | |
68980084 | 7103 | { |
7104 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
7105 | if (oi) | |
7106 | ospf_nbr_timer_update (oi); | |
7107 | } | |
718e3744 | 7108 | } |
7109 | else | |
7110 | { | |
7111 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7112 | if ((oi = rn->info)) | |
7113 | ospf_nbr_timer_update (oi); | |
7114 | } | |
7115 | ||
7116 | return CMD_SUCCESS; | |
7117 | } | |
7118 | ||
f9dfba8d DS |
7119 | ALIAS (no_ip_ospf_dead_interval, |
7120 | no_ip_ospf_dead_interval_seconds_cmd, | |
7121 | "no ip ospf dead-interval <1-65535>", | |
7122 | NO_STR | |
7123 | "IP Information\n" | |
7124 | "OSPF interface commands\n" | |
7125 | "Interval after which a neighbor is declared dead\n" | |
7126 | "Seconds\n") | |
7127 | ||
718e3744 | 7128 | ALIAS (no_ip_ospf_dead_interval, |
7129 | no_ip_ospf_dead_interval_cmd, | |
7130 | "no ip ospf dead-interval", | |
7131 | NO_STR | |
7132 | "IP Information\n" | |
7133 | "OSPF interface commands\n" | |
7134 | "Interval after which a neighbor is declared dead\n") | |
7135 | ||
7136 | ALIAS (no_ip_ospf_dead_interval, | |
7137 | no_ospf_dead_interval_cmd, | |
7138 | "no ospf dead-interval", | |
7139 | NO_STR | |
7140 | "OSPF interface commands\n" | |
7141 | "Interval after which a neighbor is declared dead\n") | |
7142 | ||
813d4307 DW |
7143 | ALIAS (no_ip_ospf_dead_interval, |
7144 | no_ip_ospf_dead_interval_minimal_addr_cmd, | |
7145 | "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
7146 | NO_STR | |
7147 | "IP Information\n" | |
7148 | "OSPF interface commands\n" | |
7149 | "Interval after which a neighbor is declared dead\n" | |
7150 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7151 | "Hello multiplier factor\n" | |
7152 | "Number of Hellos to send each second\n" | |
7153 | "Address of interface\n") | |
7154 | ||
7155 | ALIAS (no_ip_ospf_dead_interval, | |
7156 | no_ip_ospf_dead_interval_minimal_cmd, | |
7157 | "no ip ospf dead-interval minimal hello-multiplier <1-10>", | |
7158 | NO_STR | |
7159 | "IP Information\n" | |
7160 | "OSPF interface commands\n" | |
7161 | "Interval after which a neighbor is declared dead\n" | |
7162 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7163 | "Hello multiplier factor\n" | |
7164 | "Number of Hellos to send each second\n") | |
7165 | ||
718e3744 | 7166 | DEFUN (ip_ospf_hello_interval, |
7167 | ip_ospf_hello_interval_addr_cmd, | |
7168 | "ip ospf hello-interval <1-65535> A.B.C.D", | |
7169 | "IP Information\n" | |
7170 | "OSPF interface commands\n" | |
7171 | "Time between HELLO packets\n" | |
7172 | "Seconds\n" | |
7173 | "Address of interface") | |
7174 | { | |
7175 | struct interface *ifp = vty->index; | |
7176 | u_int32_t seconds; | |
7177 | struct in_addr addr; | |
7178 | int ret; | |
7179 | struct ospf_if_params *params; | |
7180 | ||
7181 | params = IF_DEF_PARAMS (ifp); | |
7182 | ||
7183 | seconds = strtol (argv[0], NULL, 10); | |
7184 | ||
7185 | /* HelloInterval range is <1-65535>. */ | |
7186 | if (seconds < 1 || seconds > 65535) | |
7187 | { | |
7188 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); | |
7189 | return CMD_WARNING; | |
7190 | } | |
7191 | ||
7192 | if (argc == 2) | |
7193 | { | |
7194 | ret = inet_aton(argv[1], &addr); | |
7195 | if (!ret) | |
7196 | { | |
7197 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7198 | VTY_NEWLINE); | |
7199 | return CMD_WARNING; | |
7200 | } | |
7201 | ||
7202 | params = ospf_get_if_params (ifp, addr); | |
7203 | ospf_if_update_params (ifp, addr); | |
7204 | } | |
7205 | ||
f9ad937f | 7206 | SET_IF_PARAM (params, v_hello); |
718e3744 | 7207 | params->v_hello = seconds; |
7208 | ||
7209 | return CMD_SUCCESS; | |
7210 | } | |
7211 | ||
7212 | ALIAS (ip_ospf_hello_interval, | |
7213 | ip_ospf_hello_interval_cmd, | |
7214 | "ip ospf hello-interval <1-65535>", | |
7215 | "IP Information\n" | |
7216 | "OSPF interface commands\n" | |
7217 | "Time between HELLO packets\n" | |
7218 | "Seconds\n") | |
7219 | ||
747e489c DW |
7220 | ALIAS_HIDDEN (ip_ospf_hello_interval, |
7221 | ospf_hello_interval_cmd, | |
7222 | "ospf hello-interval <1-65535>", | |
7223 | "OSPF interface commands\n" | |
7224 | "Time between HELLO packets\n" | |
7225 | "Seconds\n") | |
718e3744 | 7226 | |
7227 | DEFUN (no_ip_ospf_hello_interval, | |
7228 | no_ip_ospf_hello_interval_addr_cmd, | |
f9dfba8d | 7229 | "no ip ospf hello-interval <1-65535> A.B.C.D", |
718e3744 | 7230 | NO_STR |
7231 | "IP Information\n" | |
7232 | "OSPF interface commands\n" | |
7233 | "Time between HELLO packets\n" | |
f9dfba8d | 7234 | "Seconds\n" |
718e3744 | 7235 | "Address of interface") |
7236 | { | |
7237 | struct interface *ifp = vty->index; | |
7238 | struct in_addr addr; | |
7239 | int ret; | |
7240 | struct ospf_if_params *params; | |
7241 | ||
718e3744 | 7242 | params = IF_DEF_PARAMS (ifp); |
7243 | ||
f9dfba8d | 7244 | if (argc == 2) |
718e3744 | 7245 | { |
f9dfba8d | 7246 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7247 | if (!ret) |
7248 | { | |
7249 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7250 | VTY_NEWLINE); | |
7251 | return CMD_WARNING; | |
7252 | } | |
7253 | ||
7254 | params = ospf_lookup_if_params (ifp, addr); | |
7255 | if (params == NULL) | |
7256 | return CMD_SUCCESS; | |
7257 | } | |
7258 | ||
7259 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 7260 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 7261 | |
7262 | if (params != IF_DEF_PARAMS (ifp)) | |
7263 | { | |
7264 | ospf_free_if_params (ifp, addr); | |
7265 | ospf_if_update_params (ifp, addr); | |
7266 | } | |
7267 | ||
7268 | return CMD_SUCCESS; | |
7269 | } | |
7270 | ||
f9dfba8d DS |
7271 | ALIAS (no_ip_ospf_hello_interval, |
7272 | no_ip_ospf_hello_interval_seconds_cmd, | |
7273 | "no ip ospf hello-interval <1-65535>", | |
7274 | NO_STR | |
7275 | "IP Information\n" | |
7276 | "OSPF interface commands\n" | |
7277 | "Time between HELLO packets\n" | |
7278 | "Seconds\n") | |
7279 | ||
718e3744 | 7280 | ALIAS (no_ip_ospf_hello_interval, |
7281 | no_ip_ospf_hello_interval_cmd, | |
7282 | "no ip ospf hello-interval", | |
7283 | NO_STR | |
7284 | "IP Information\n" | |
7285 | "OSPF interface commands\n" | |
7286 | "Time between HELLO packets\n") | |
7287 | ||
7288 | ALIAS (no_ip_ospf_hello_interval, | |
7289 | no_ospf_hello_interval_cmd, | |
813d4307 | 7290 | "no ospf hello-interval <1-65535>", |
718e3744 | 7291 | NO_STR |
7292 | "OSPF interface commands\n" | |
813d4307 DW |
7293 | "Time between HELLO packets\n" |
7294 | "Seconds\n") | |
718e3744 | 7295 | |
7296 | DEFUN (ip_ospf_network, | |
7297 | ip_ospf_network_cmd, | |
7298 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7299 | "IP Information\n" | |
7300 | "OSPF interface commands\n" | |
7301 | "Network type\n" | |
7302 | "Specify OSPF broadcast multi-access network\n" | |
7303 | "Specify OSPF NBMA network\n" | |
7304 | "Specify OSPF point-to-multipoint network\n" | |
7305 | "Specify OSPF point-to-point network\n") | |
7306 | { | |
7307 | struct interface *ifp = vty->index; | |
7308 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7309 | struct route_node *rn; | |
4b4bda9b CF |
7310 | |
7311 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
7312 | { | |
7313 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
7314 | return CMD_WARNING; | |
7315 | } | |
7316 | ||
718e3744 | 7317 | if (strncmp (argv[0], "b", 1) == 0) |
7318 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; | |
7319 | else if (strncmp (argv[0], "n", 1) == 0) | |
7320 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; | |
7321 | else if (strncmp (argv[0], "point-to-m", 10) == 0) | |
7322 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; | |
7323 | else if (strncmp (argv[0], "point-to-p", 10) == 0) | |
7324 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; | |
7325 | ||
7326 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7327 | return CMD_SUCCESS; | |
7328 | ||
7329 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
7330 | ||
7331 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7332 | { | |
7333 | struct ospf_interface *oi = rn->info; | |
7334 | ||
7335 | if (!oi) | |
7336 | continue; | |
7337 | ||
7338 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7339 | ||
7340 | if (oi->state > ISM_Down) | |
7341 | { | |
7342 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7343 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7344 | } | |
7345 | } | |
7346 | ||
7347 | return CMD_SUCCESS; | |
7348 | } | |
7349 | ||
747e489c DW |
7350 | ALIAS_HIDDEN (ip_ospf_network, |
7351 | ospf_network_cmd, | |
7352 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7353 | "OSPF interface commands\n" | |
7354 | "Network type\n" | |
7355 | "Specify OSPF broadcast multi-access network\n" | |
7356 | "Specify OSPF NBMA network\n" | |
7357 | "Specify OSPF point-to-multipoint network\n" | |
7358 | "Specify OSPF point-to-point network\n") | |
718e3744 | 7359 | |
7360 | DEFUN (no_ip_ospf_network, | |
7361 | no_ip_ospf_network_cmd, | |
7362 | "no ip ospf network", | |
7363 | NO_STR | |
7364 | "IP Information\n" | |
7365 | "OSPF interface commands\n" | |
7366 | "Network type\n") | |
7367 | { | |
7368 | struct interface *ifp = vty->index; | |
7369 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7370 | struct route_node *rn; | |
7371 | ||
bc18d616 | 7372 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
718e3744 | 7373 | |
7374 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7375 | return CMD_SUCCESS; | |
7376 | ||
7377 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7378 | { | |
7379 | struct ospf_interface *oi = rn->info; | |
7380 | ||
7381 | if (!oi) | |
7382 | continue; | |
7383 | ||
7384 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7385 | ||
7386 | if (oi->state > ISM_Down) | |
7387 | { | |
7388 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7389 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7390 | } | |
7391 | } | |
7392 | ||
7393 | return CMD_SUCCESS; | |
7394 | } | |
7395 | ||
813d4307 DW |
7396 | ALIAS (no_ip_ospf_network, |
7397 | no_ip_ospf_network_val_cmd, | |
7398 | "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7399 | NO_STR | |
7400 | "IP Information\n" | |
7401 | "OSPF interface commands\n" | |
7402 | "Network type\n" | |
7403 | "Specify OSPF broadcast multi-access network\n" | |
7404 | "Specify OSPF NBMA network\n" | |
7405 | "Specify OSPF point-to-multipoint network\n" | |
7406 | "Specify OSPF point-to-point network\n") | |
7407 | ||
718e3744 | 7408 | ALIAS (no_ip_ospf_network, |
7409 | no_ospf_network_cmd, | |
7410 | "no ospf network", | |
7411 | NO_STR | |
7412 | "OSPF interface commands\n" | |
7413 | "Network type\n") | |
7414 | ||
813d4307 DW |
7415 | ALIAS (no_ip_ospf_network, |
7416 | no_ospf_network_val_cmd, | |
7417 | "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7418 | NO_STR | |
7419 | "OSPF interface commands\n" | |
7420 | "Network type\n" | |
7421 | "Specify OSPF broadcast multi-access network\n" | |
7422 | "Specify OSPF NBMA network\n" | |
7423 | "Specify OSPF point-to-multipoint network\n" | |
7424 | "Specify OSPF point-to-point network\n") | |
7425 | ||
718e3744 | 7426 | DEFUN (ip_ospf_priority, |
7427 | ip_ospf_priority_addr_cmd, | |
7428 | "ip ospf priority <0-255> A.B.C.D", | |
7429 | "IP Information\n" | |
7430 | "OSPF interface commands\n" | |
7431 | "Router priority\n" | |
7432 | "Priority\n" | |
7433 | "Address of interface") | |
7434 | { | |
7435 | struct interface *ifp = vty->index; | |
0798cee3 | 7436 | long priority; |
718e3744 | 7437 | struct route_node *rn; |
7438 | struct in_addr addr; | |
7439 | int ret; | |
7440 | struct ospf_if_params *params; | |
7441 | ||
7442 | params = IF_DEF_PARAMS (ifp); | |
7443 | ||
7444 | priority = strtol (argv[0], NULL, 10); | |
7445 | ||
7446 | /* Router Priority range is <0-255>. */ | |
7447 | if (priority < 0 || priority > 255) | |
7448 | { | |
7449 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); | |
7450 | return CMD_WARNING; | |
7451 | } | |
7452 | ||
7453 | if (argc == 2) | |
7454 | { | |
7455 | ret = inet_aton(argv[1], &addr); | |
7456 | if (!ret) | |
7457 | { | |
7458 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7459 | VTY_NEWLINE); | |
7460 | return CMD_WARNING; | |
7461 | } | |
7462 | ||
7463 | params = ospf_get_if_params (ifp, addr); | |
7464 | ospf_if_update_params (ifp, addr); | |
7465 | } | |
7466 | ||
7467 | SET_IF_PARAM (params, priority); | |
7468 | params->priority = priority; | |
7469 | ||
7470 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7471 | { | |
7472 | struct ospf_interface *oi = rn->info; | |
7473 | ||
7474 | if (!oi) | |
7475 | continue; | |
7476 | ||
7477 | ||
7478 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7479 | { | |
7480 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7481 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7482 | } | |
7483 | } | |
7484 | ||
7485 | return CMD_SUCCESS; | |
7486 | } | |
7487 | ||
7488 | ALIAS (ip_ospf_priority, | |
7489 | ip_ospf_priority_cmd, | |
7490 | "ip ospf priority <0-255>", | |
7491 | "IP Information\n" | |
7492 | "OSPF interface commands\n" | |
7493 | "Router priority\n" | |
7494 | "Priority\n") | |
7495 | ||
747e489c DW |
7496 | ALIAS_HIDDEN (ip_ospf_priority, |
7497 | ospf_priority_cmd, | |
7498 | "ospf priority <0-255>", | |
7499 | "OSPF interface commands\n" | |
7500 | "Router priority\n" | |
7501 | "Priority\n") | |
718e3744 | 7502 | |
7503 | DEFUN (no_ip_ospf_priority, | |
7504 | no_ip_ospf_priority_addr_cmd, | |
813d4307 | 7505 | "no ip ospf priority <0-255> A.B.C.D", |
718e3744 | 7506 | NO_STR |
7507 | "IP Information\n" | |
7508 | "OSPF interface commands\n" | |
7509 | "Router priority\n" | |
813d4307 | 7510 | "Priority\n" |
718e3744 | 7511 | "Address of interface") |
7512 | { | |
7513 | struct interface *ifp = vty->index; | |
7514 | struct route_node *rn; | |
7515 | struct in_addr addr; | |
7516 | int ret; | |
7517 | struct ospf_if_params *params; | |
7518 | ||
718e3744 | 7519 | params = IF_DEF_PARAMS (ifp); |
7520 | ||
813d4307 | 7521 | if (argc == 2) |
718e3744 | 7522 | { |
813d4307 | 7523 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7524 | if (!ret) |
7525 | { | |
7526 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7527 | VTY_NEWLINE); | |
7528 | return CMD_WARNING; | |
7529 | } | |
7530 | ||
7531 | params = ospf_lookup_if_params (ifp, addr); | |
7532 | if (params == NULL) | |
7533 | return CMD_SUCCESS; | |
7534 | } | |
7535 | ||
7536 | UNSET_IF_PARAM (params, priority); | |
7537 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
7538 | ||
7539 | if (params != IF_DEF_PARAMS (ifp)) | |
7540 | { | |
7541 | ospf_free_if_params (ifp, addr); | |
7542 | ospf_if_update_params (ifp, addr); | |
7543 | } | |
7544 | ||
7545 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7546 | { | |
7547 | struct ospf_interface *oi = rn->info; | |
7548 | ||
7549 | if (!oi) | |
7550 | continue; | |
7551 | ||
7552 | ||
7553 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7554 | { | |
7555 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7556 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7557 | } | |
7558 | } | |
7559 | ||
7560 | return CMD_SUCCESS; | |
7561 | } | |
7562 | ||
a1afa410 DS |
7563 | ALIAS (no_ip_ospf_priority, |
7564 | no_ip_ospf_priority_no_param_cmd, | |
7565 | "no ip ospf priority", | |
7566 | NO_STR | |
7567 | "IP Information\n" | |
7568 | "OSPF interface commands\n" | |
7569 | "Router priority\n"); | |
7570 | ||
718e3744 | 7571 | ALIAS (no_ip_ospf_priority, |
7572 | no_ip_ospf_priority_cmd, | |
813d4307 | 7573 | "no ip ospf priority <0-255>", |
718e3744 | 7574 | NO_STR |
7575 | "IP Information\n" | |
7576 | "OSPF interface commands\n" | |
813d4307 DW |
7577 | "Router priority\n" |
7578 | "Priority\n") | |
718e3744 | 7579 | |
7580 | ALIAS (no_ip_ospf_priority, | |
7581 | no_ospf_priority_cmd, | |
813d4307 | 7582 | "no ospf priority <0-255>", |
718e3744 | 7583 | NO_STR |
7584 | "OSPF interface commands\n" | |
813d4307 DW |
7585 | "Router priority\n" |
7586 | "Priority\n") | |
718e3744 | 7587 | |
d5a5c8f0 | 7588 | |
718e3744 | 7589 | DEFUN (ip_ospf_retransmit_interval, |
7590 | ip_ospf_retransmit_interval_addr_cmd, | |
7591 | "ip ospf retransmit-interval <3-65535> A.B.C.D", | |
7592 | "IP Information\n" | |
7593 | "OSPF interface commands\n" | |
7594 | "Time between retransmitting lost link state advertisements\n" | |
7595 | "Seconds\n" | |
7596 | "Address of interface") | |
7597 | { | |
7598 | struct interface *ifp = vty->index; | |
7599 | u_int32_t seconds; | |
7600 | struct in_addr addr; | |
7601 | int ret; | |
7602 | struct ospf_if_params *params; | |
7603 | ||
7604 | params = IF_DEF_PARAMS (ifp); | |
7605 | seconds = strtol (argv[0], NULL, 10); | |
7606 | ||
7607 | /* Retransmit Interval range is <3-65535>. */ | |
7608 | if (seconds < 3 || seconds > 65535) | |
7609 | { | |
7610 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); | |
7611 | return CMD_WARNING; | |
7612 | } | |
7613 | ||
7614 | ||
7615 | if (argc == 2) | |
7616 | { | |
7617 | ret = inet_aton(argv[1], &addr); | |
7618 | if (!ret) | |
7619 | { | |
7620 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7621 | VTY_NEWLINE); | |
7622 | return CMD_WARNING; | |
7623 | } | |
7624 | ||
7625 | params = ospf_get_if_params (ifp, addr); | |
7626 | ospf_if_update_params (ifp, addr); | |
7627 | } | |
7628 | ||
7629 | SET_IF_PARAM (params, retransmit_interval); | |
7630 | params->retransmit_interval = seconds; | |
7631 | ||
7632 | return CMD_SUCCESS; | |
7633 | } | |
7634 | ||
7635 | ALIAS (ip_ospf_retransmit_interval, | |
7636 | ip_ospf_retransmit_interval_cmd, | |
7637 | "ip ospf retransmit-interval <3-65535>", | |
7638 | "IP Information\n" | |
7639 | "OSPF interface commands\n" | |
7640 | "Time between retransmitting lost link state advertisements\n" | |
7641 | "Seconds\n") | |
7642 | ||
747e489c DW |
7643 | ALIAS_HIDDEN (ip_ospf_retransmit_interval, |
7644 | ospf_retransmit_interval_cmd, | |
7645 | "ospf retransmit-interval <3-65535>", | |
7646 | "OSPF interface commands\n" | |
7647 | "Time between retransmitting lost link state advertisements\n" | |
7648 | "Seconds\n") | |
718e3744 | 7649 | |
7650 | DEFUN (no_ip_ospf_retransmit_interval, | |
7651 | no_ip_ospf_retransmit_interval_addr_cmd, | |
7652 | "no ip ospf retransmit-interval A.B.C.D", | |
7653 | NO_STR | |
7654 | "IP Information\n" | |
7655 | "OSPF interface commands\n" | |
7656 | "Time between retransmitting lost link state advertisements\n" | |
7657 | "Address of interface") | |
7658 | { | |
7659 | struct interface *ifp = vty->index; | |
7660 | struct in_addr addr; | |
7661 | int ret; | |
7662 | struct ospf_if_params *params; | |
813d4307 | 7663 | int addr_index; |
718e3744 | 7664 | |
718e3744 | 7665 | params = IF_DEF_PARAMS (ifp); |
7666 | ||
813d4307 | 7667 | if (argc >= 1) |
718e3744 | 7668 | { |
813d4307 DW |
7669 | if (argc == 1) |
7670 | addr_index = 0; | |
7671 | else | |
7672 | addr_index = 1; | |
7673 | ||
7674 | ret = inet_aton(argv[addr_index], &addr); | |
718e3744 | 7675 | if (!ret) |
7676 | { | |
7677 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7678 | VTY_NEWLINE); | |
7679 | return CMD_WARNING; | |
7680 | } | |
7681 | ||
7682 | params = ospf_lookup_if_params (ifp, addr); | |
7683 | if (params == NULL) | |
7684 | return CMD_SUCCESS; | |
7685 | } | |
7686 | ||
7687 | UNSET_IF_PARAM (params, retransmit_interval); | |
7688 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7689 | ||
7690 | if (params != IF_DEF_PARAMS (ifp)) | |
7691 | { | |
7692 | ospf_free_if_params (ifp, addr); | |
7693 | ospf_if_update_params (ifp, addr); | |
7694 | } | |
7695 | ||
7696 | return CMD_SUCCESS; | |
7697 | } | |
7698 | ||
813d4307 DW |
7699 | ALIAS (no_ip_ospf_retransmit_interval, |
7700 | no_ip_ospf_retransmit_interval_sec_addr_cmd, | |
7701 | "no ip ospf retransmit-interval <3-65535> A.B.C.D", | |
7702 | NO_STR | |
7703 | "IP Information\n" | |
7704 | "OSPF interface commands\n" | |
7705 | "Time between retransmitting lost link state advertisements\n" | |
7706 | "Seconds\n" | |
7707 | "Address of interface") | |
7708 | ||
718e3744 | 7709 | ALIAS (no_ip_ospf_retransmit_interval, |
7710 | no_ip_ospf_retransmit_interval_cmd, | |
7711 | "no ip ospf retransmit-interval", | |
7712 | NO_STR | |
7713 | "IP Information\n" | |
7714 | "OSPF interface commands\n" | |
7715 | "Time between retransmitting lost link state advertisements\n") | |
7716 | ||
7717 | ALIAS (no_ip_ospf_retransmit_interval, | |
7718 | no_ospf_retransmit_interval_cmd, | |
7719 | "no ospf retransmit-interval", | |
7720 | NO_STR | |
7721 | "OSPF interface commands\n" | |
7722 | "Time between retransmitting lost link state advertisements\n") | |
7723 | ||
813d4307 DW |
7724 | DEFUN (no_ip_ospf_retransmit_interval_sec, |
7725 | no_ip_ospf_retransmit_interval_sec_cmd, | |
7726 | "no ip ospf retransmit-interval <3-65535>", | |
7727 | NO_STR | |
7728 | "IP Information\n" | |
7729 | "OSPF interface commands\n" | |
7730 | "Time between retransmitting lost link state advertisements\n" | |
7731 | "Seconds\n") | |
7732 | { | |
7733 | struct interface *ifp = vty->index; | |
7734 | struct ospf_if_params *params; | |
7735 | ||
813d4307 DW |
7736 | params = IF_DEF_PARAMS (ifp); |
7737 | ||
7738 | UNSET_IF_PARAM (params, retransmit_interval); | |
7739 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7740 | ||
7741 | return CMD_SUCCESS; | |
7742 | } | |
7743 | ||
7744 | ||
718e3744 | 7745 | DEFUN (ip_ospf_transmit_delay, |
7746 | ip_ospf_transmit_delay_addr_cmd, | |
7747 | "ip ospf transmit-delay <1-65535> A.B.C.D", | |
7748 | "IP Information\n" | |
7749 | "OSPF interface commands\n" | |
7750 | "Link state transmit delay\n" | |
7751 | "Seconds\n" | |
7752 | "Address of interface") | |
7753 | { | |
7754 | struct interface *ifp = vty->index; | |
7755 | u_int32_t seconds; | |
7756 | struct in_addr addr; | |
7757 | int ret; | |
7758 | struct ospf_if_params *params; | |
7759 | ||
7760 | params = IF_DEF_PARAMS (ifp); | |
7761 | seconds = strtol (argv[0], NULL, 10); | |
7762 | ||
7763 | /* Transmit Delay range is <1-65535>. */ | |
7764 | if (seconds < 1 || seconds > 65535) | |
7765 | { | |
7766 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); | |
7767 | return CMD_WARNING; | |
7768 | } | |
7769 | ||
7770 | if (argc == 2) | |
7771 | { | |
7772 | ret = inet_aton(argv[1], &addr); | |
7773 | if (!ret) | |
7774 | { | |
7775 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7776 | VTY_NEWLINE); | |
7777 | return CMD_WARNING; | |
7778 | } | |
7779 | ||
7780 | params = ospf_get_if_params (ifp, addr); | |
7781 | ospf_if_update_params (ifp, addr); | |
7782 | } | |
7783 | ||
7784 | SET_IF_PARAM (params, transmit_delay); | |
7785 | params->transmit_delay = seconds; | |
7786 | ||
7787 | return CMD_SUCCESS; | |
7788 | } | |
7789 | ||
7790 | ALIAS (ip_ospf_transmit_delay, | |
7791 | ip_ospf_transmit_delay_cmd, | |
7792 | "ip ospf transmit-delay <1-65535>", | |
7793 | "IP Information\n" | |
7794 | "OSPF interface commands\n" | |
7795 | "Link state transmit delay\n" | |
7796 | "Seconds\n") | |
7797 | ||
747e489c DW |
7798 | ALIAS_HIDDEN (ip_ospf_transmit_delay, |
7799 | ospf_transmit_delay_cmd, | |
7800 | "ospf transmit-delay <1-65535>", | |
7801 | "OSPF interface commands\n" | |
7802 | "Link state transmit delay\n" | |
7803 | "Seconds\n") | |
718e3744 | 7804 | |
7805 | DEFUN (no_ip_ospf_transmit_delay, | |
7806 | no_ip_ospf_transmit_delay_addr_cmd, | |
7807 | "no ip ospf transmit-delay A.B.C.D", | |
7808 | NO_STR | |
7809 | "IP Information\n" | |
7810 | "OSPF interface commands\n" | |
7811 | "Link state transmit delay\n" | |
7812 | "Address of interface") | |
7813 | { | |
7814 | struct interface *ifp = vty->index; | |
7815 | struct in_addr addr; | |
7816 | int ret; | |
7817 | struct ospf_if_params *params; | |
813d4307 | 7818 | int addr_index; |
718e3744 | 7819 | |
718e3744 | 7820 | params = IF_DEF_PARAMS (ifp); |
7821 | ||
813d4307 | 7822 | if (argc >= 1) |
718e3744 | 7823 | { |
813d4307 DW |
7824 | if (argc == 1) |
7825 | addr_index = 0; | |
7826 | else | |
7827 | addr_index = 1; | |
7828 | ||
7829 | ret = inet_aton(argv[addr_index], &addr); | |
718e3744 | 7830 | if (!ret) |
7831 | { | |
7832 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7833 | VTY_NEWLINE); | |
7834 | return CMD_WARNING; | |
7835 | } | |
7836 | ||
7837 | params = ospf_lookup_if_params (ifp, addr); | |
7838 | if (params == NULL) | |
7839 | return CMD_SUCCESS; | |
7840 | } | |
7841 | ||
7842 | UNSET_IF_PARAM (params, transmit_delay); | |
7843 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7844 | ||
7845 | if (params != IF_DEF_PARAMS (ifp)) | |
7846 | { | |
7847 | ospf_free_if_params (ifp, addr); | |
7848 | ospf_if_update_params (ifp, addr); | |
7849 | } | |
7850 | ||
7851 | return CMD_SUCCESS; | |
7852 | } | |
7853 | ||
813d4307 DW |
7854 | ALIAS (no_ip_ospf_transmit_delay, |
7855 | no_ip_ospf_transmit_delay_sec_addr_cmd, | |
7856 | "no ip ospf transmit-delay <1-65535> A.B.C.D", | |
7857 | NO_STR | |
7858 | "IP Information\n" | |
7859 | "OSPF interface commands\n" | |
7860 | "Link state transmit delay\n" | |
7861 | "Seconds\n" | |
7862 | "Address of interface") | |
7863 | ||
718e3744 | 7864 | ALIAS (no_ip_ospf_transmit_delay, |
7865 | no_ip_ospf_transmit_delay_cmd, | |
7866 | "no ip ospf transmit-delay", | |
7867 | NO_STR | |
7868 | "IP Information\n" | |
7869 | "OSPF interface commands\n" | |
7870 | "Link state transmit delay\n") | |
7871 | ||
7872 | ALIAS (no_ip_ospf_transmit_delay, | |
7873 | no_ospf_transmit_delay_cmd, | |
7874 | "no ospf transmit-delay", | |
7875 | NO_STR | |
7876 | "OSPF interface commands\n" | |
7877 | "Link state transmit delay\n") | |
7878 | ||
813d4307 DW |
7879 | DEFUN (no_ip_ospf_transmit_delay_sec, |
7880 | no_ip_ospf_transmit_delay_sec_cmd, | |
7881 | "no ip ospf transmit-delay <1-65535>", | |
7882 | NO_STR | |
7883 | "IP Information\n" | |
7884 | "OSPF interface commands\n" | |
7885 | "Link state transmit delay\n" | |
7886 | "Seconds\n" | |
7887 | "Address of interface") | |
7888 | { | |
7889 | struct interface *ifp = vty->index; | |
7890 | struct ospf_if_params *params; | |
7891 | ||
813d4307 DW |
7892 | params = IF_DEF_PARAMS (ifp); |
7893 | ||
7894 | UNSET_IF_PARAM (params, transmit_delay); | |
7895 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7896 | ||
7897 | return CMD_SUCCESS; | |
7898 | } | |
7899 | ||
e723861d DS |
7900 | DEFUN (ip_ospf_area, |
7901 | ip_ospf_area_cmd, | |
7902 | "ip ospf area (A.B.C.D|<0-4294967295>)", | |
7903 | "IP Information\n" | |
7904 | "OSPF interface commands\n" | |
7905 | "Enable OSPF on this interface\n" | |
7906 | "OSPF area ID in IP address format\n" | |
7907 | "OSPF area ID as a decimal value\n") | |
7908 | { | |
7909 | struct interface *ifp = vty->index; | |
7910 | int format, ret; | |
7911 | struct in_addr area_id; | |
7912 | struct ospf *ospf; | |
7913 | struct ospf_if_params *params; | |
7914 | struct route_node *rn; | |
7c8ff89e | 7915 | u_short instance = 0; |
e723861d | 7916 | |
7c8ff89e DS |
7917 | if (argc == 2) |
7918 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
7919 | ||
7920 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
7921 | if (ospf == NULL) |
7922 | { | |
7c8ff89e DS |
7923 | params = IF_DEF_PARAMS (ifp); |
7924 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7925 | { | |
7926 | ospf_interface_unset (ifp); | |
7927 | ospf = ospf_lookup(); | |
7928 | ospf->if_ospf_cli_count--; | |
7929 | } | |
e723861d DS |
7930 | return CMD_SUCCESS; |
7931 | } | |
7932 | ||
7c8ff89e | 7933 | ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); |
e723861d DS |
7934 | if (ret < 0) |
7935 | { | |
7936 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
7937 | VTY_NEWLINE); | |
7938 | return CMD_WARNING; | |
7939 | } | |
7940 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
7941 | { | |
7942 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
7943 | return CMD_WARNING; | |
7944 | } | |
7945 | ||
7946 | params = IF_DEF_PARAMS (ifp); | |
7947 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7948 | { | |
73b9f703 VK |
7949 | vty_out (vty, |
7950 | "Must remove previous area config before changing ospf area %s", | |
7951 | VTY_NEWLINE); | |
e723861d DS |
7952 | return CMD_WARNING; |
7953 | } | |
7954 | ||
7955 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
7956 | { | |
7957 | if (rn->info != NULL) | |
7958 | { | |
7959 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
7960 | return CMD_WARNING; | |
7961 | } | |
7962 | } | |
7963 | ||
7964 | /* enable ospf on this interface with area_id */ | |
7965 | ospf_interface_set (ifp, area_id); | |
7966 | ospf->if_ospf_cli_count++; | |
7967 | ||
7968 | return CMD_SUCCESS; | |
7969 | } | |
7970 | ||
7c8ff89e DS |
7971 | ALIAS (ip_ospf_area, |
7972 | ip_ospf_instance_area_cmd, | |
7973 | "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
7974 | "IP Information\n" | |
7975 | "OSPF interface commands\n" | |
7976 | "Instance ID\n" | |
7977 | "Enable OSPF on this interface\n" | |
7978 | "OSPF area ID in IP address format\n" | |
7979 | "OSPF area ID as a decimal value\n") | |
7980 | ||
e723861d DS |
7981 | DEFUN (no_ip_ospf_area, |
7982 | no_ip_ospf_area_cmd, | |
7983 | "no ip ospf area", | |
7984 | NO_STR | |
7985 | "IP Information\n" | |
7986 | "OSPF interface commands\n" | |
7987 | "Disable OSPF on this interface\n") | |
7988 | { | |
7989 | struct interface *ifp = vty->index; | |
7990 | struct ospf *ospf; | |
7991 | struct ospf_if_params *params; | |
7c8ff89e | 7992 | u_short instance = 0; |
e723861d | 7993 | |
7c8ff89e DS |
7994 | if ((ospf = ospf_lookup_instance (instance)) == NULL) |
7995 | return CMD_SUCCESS; | |
e723861d DS |
7996 | |
7997 | params = IF_DEF_PARAMS (ifp); | |
7998 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7999 | { | |
8000 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
8001 | return CMD_WARNING; | |
8002 | } | |
8003 | ||
8004 | ospf_interface_unset (ifp); | |
8005 | ospf->if_ospf_cli_count--; | |
8006 | return CMD_SUCCESS; | |
8007 | } | |
8008 | ||
7c8ff89e | 8009 | ALIAS (no_ip_ospf_area, |
813d4307 DW |
8010 | no_ip_ospf_area_val_cmd, |
8011 | "no ip ospf area (A.B.C.D|<0-4294967295>)", | |
8012 | NO_STR | |
8013 | "IP Information\n" | |
8014 | "OSPF interface commands\n" | |
8015 | "Disable OSPF on this interface\n" | |
8016 | "OSPF area ID in IP address format\n" | |
8017 | "OSPF area ID as a decimal value\n") | |
8018 | ||
8019 | DEFUN (no_ip_ospf_instance_area, | |
7c8ff89e DS |
8020 | no_ip_ospf_instance_area_cmd, |
8021 | "no ip ospf <1-65535> area", | |
8022 | NO_STR | |
8023 | "IP Information\n" | |
8024 | "OSPF interface commands\n" | |
8025 | "Instance ID\n" | |
8026 | "Disable OSPF on this interface\n") | |
813d4307 DW |
8027 | { |
8028 | struct interface *ifp = vty->index; | |
8029 | struct ospf *ospf; | |
8030 | struct ospf_if_params *params; | |
8031 | u_short instance = 0; | |
8032 | ||
8033 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
8034 | ||
8035 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
8036 | return CMD_SUCCESS; | |
8037 | ||
8038 | params = IF_DEF_PARAMS (ifp); | |
8039 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
8040 | { | |
8041 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
8042 | return CMD_WARNING; | |
8043 | } | |
8044 | ||
8045 | ospf_interface_unset (ifp); | |
8046 | ospf->if_ospf_cli_count--; | |
8047 | return CMD_SUCCESS; | |
8048 | } | |
8049 | ||
8050 | ALIAS (no_ip_ospf_instance_area, | |
8051 | no_ip_ospf_instance_area_val_cmd, | |
8052 | "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
8053 | NO_STR | |
8054 | "IP Information\n" | |
8055 | "OSPF interface commands\n" | |
8056 | "Instance ID\n" | |
8057 | "Disable OSPF on this interface\n" | |
8058 | "OSPF area ID in IP address format\n" | |
8059 | "OSPF area ID as a decimal value\n") | |
7c8ff89e | 8060 | |
6f2a6703 CF |
8061 | DEFUN (ospf_redistribute_source, |
8062 | ospf_redistribute_source_cmd, | |
ab0181ee | 8063 | "redistribute " FRR_REDIST_STR_OSPFD |
6f2a6703 | 8064 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
d1c65c21 | 8065 | REDIST_STR |
ab0181ee | 8066 | FRR_REDIST_HELP_STR_OSPFD |
718e3744 | 8067 | "Metric for redistributed routes\n" |
8068 | "OSPF default metric\n" | |
8069 | "OSPF exterior metric type for redistributed routes\n" | |
8070 | "Set OSPF External Type 1 metrics\n" | |
8071 | "Set OSPF External Type 2 metrics\n" | |
8072 | "Route map reference\n" | |
8073 | "Pointer to route-map entries\n") | |
8074 | { | |
020709f9 | 8075 | struct ospf *ospf = vty->index; |
718e3744 | 8076 | int source; |
8077 | int type = -1; | |
8078 | int metric = -1; | |
7c8ff89e | 8079 | struct ospf_redist *red; |
718e3744 | 8080 | |
d8f70b86 DS |
8081 | if (!ospf) |
8082 | return CMD_SUCCESS; | |
8083 | ||
6f2a6703 CF |
8084 | if (argc < 4) |
8085 | return CMD_WARNING; /* should not happen */ | |
8086 | ||
7c8ff89e DS |
8087 | if (!ospf) |
8088 | return CMD_SUCCESS; | |
8089 | ||
718e3744 | 8090 | /* Get distribute source. */ |
e0ca5fde DL |
8091 | source = proto_redistnum(AFI_IP, argv[0]); |
8092 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 8093 | return CMD_WARNING; |
8094 | ||
8095 | /* Get metric value. */ | |
6f2a6703 | 8096 | if (argv[1] != NULL) |
718e3744 | 8097 | if (!str2metric (argv[1], &metric)) |
8098 | return CMD_WARNING; | |
8099 | ||
8100 | /* Get metric type. */ | |
6f2a6703 | 8101 | if (argv[2] != NULL) |
718e3744 | 8102 | if (!str2metric_type (argv[2], &type)) |
8103 | return CMD_WARNING; | |
8104 | ||
7c8ff89e DS |
8105 | red = ospf_redist_add(ospf, source, 0); |
8106 | ||
6f2a6703 | 8107 | if (argv[3] != NULL) |
7c8ff89e | 8108 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8109 | else |
7c8ff89e | 8110 | ospf_routemap_unset (red); |
718e3744 | 8111 | |
7c8ff89e | 8112 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 8113 | } |
8114 | ||
718e3744 | 8115 | DEFUN (no_ospf_redistribute_source, |
8116 | no_ospf_redistribute_source_cmd, | |
ab0181ee | 8117 | "no redistribute " FRR_REDIST_STR_OSPFD |
813d4307 | 8118 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
718e3744 | 8119 | NO_STR |
d1c65c21 | 8120 | REDIST_STR |
ab0181ee | 8121 | FRR_REDIST_HELP_STR_OSPFD |
813d4307 DW |
8122 | "Metric for redistributed routes\n" |
8123 | "OSPF default metric\n" | |
8124 | "OSPF exterior metric type for redistributed routes\n" | |
8125 | "Set OSPF External Type 1 metrics\n" | |
8126 | "Set OSPF External Type 2 metrics\n" | |
8127 | "Route map reference\n" | |
8128 | "Pointer to route-map entries\n") | |
718e3744 | 8129 | { |
020709f9 | 8130 | struct ospf *ospf = vty->index; |
718e3744 | 8131 | int source; |
7c8ff89e DS |
8132 | struct ospf_redist *red; |
8133 | if (!ospf) | |
8134 | return CMD_SUCCESS; | |
718e3744 | 8135 | |
e0ca5fde DL |
8136 | source = proto_redistnum(AFI_IP, argv[0]); |
8137 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 8138 | return CMD_WARNING; |
8139 | ||
7c8ff89e DS |
8140 | red = ospf_redist_lookup(ospf, source, 0); |
8141 | if (!red) | |
8142 | return CMD_SUCCESS; | |
8143 | ||
8144 | ospf_routemap_unset (red); | |
8145 | return ospf_redistribute_unset (ospf, source, 0); | |
8146 | } | |
8147 | ||
8148 | DEFUN (ospf_redistribute_instance_source, | |
8149 | ospf_redistribute_instance_source_cmd, | |
2d627ff5 | 8150 | "redistribute (ospf|table) <1-65535>" |
7c8ff89e DS |
8151 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
8152 | REDIST_STR | |
8153 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8154 | "Non-main Kernel Routing Table\n" |
8155 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
8156 | "Metric for redistributed routes\n" |
8157 | "OSPF default metric\n" | |
8158 | "OSPF exterior metric type for redistributed routes\n" | |
8159 | "Set OSPF External Type 1 metrics\n" | |
8160 | "Set OSPF External Type 2 metrics\n" | |
8161 | "Route map reference\n" | |
8162 | "Pointer to route-map entries\n") | |
8163 | { | |
8164 | struct ospf *ospf = vty->index; | |
8165 | int source; | |
8166 | int type = -1; | |
8167 | int metric = -1; | |
8168 | u_short instance; | |
8169 | struct ospf_redist *red; | |
8170 | ||
d8f70b86 DS |
8171 | if (!ospf) |
8172 | return CMD_SUCCESS; | |
8173 | ||
2d627ff5 DS |
8174 | if (strncmp(argv[0], "o", 1) == 0) |
8175 | source = ZEBRA_ROUTE_OSPF; | |
8176 | else | |
8177 | source = ZEBRA_ROUTE_TABLE; | |
8178 | ||
8179 | VTY_GET_INTEGER ("Instance ID", instance, argv[1]); | |
7c8ff89e DS |
8180 | |
8181 | if (!ospf) | |
8182 | return CMD_SUCCESS; | |
8183 | ||
2d627ff5 | 8184 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
8185 | { |
8186 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
8187 | VTY_NEWLINE); | |
8188 | return CMD_WARNING; | |
8189 | } | |
8190 | ||
2d627ff5 | 8191 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
8192 | { |
8193 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
8194 | VTY_NEWLINE); | |
8195 | return CMD_WARNING; | |
8196 | } | |
8197 | ||
7c8ff89e | 8198 | /* Get metric value. */ |
2d627ff5 DS |
8199 | if (argv[2] != NULL) |
8200 | if (!str2metric (argv[2], &metric)) | |
7c8ff89e DS |
8201 | return CMD_WARNING; |
8202 | ||
8203 | /* Get metric type. */ | |
2d627ff5 DS |
8204 | if (argv[3] != NULL) |
8205 | if (!str2metric_type (argv[3], &type)) | |
7c8ff89e DS |
8206 | return CMD_WARNING; |
8207 | ||
8208 | red = ospf_redist_add(ospf, source, instance); | |
2d627ff5 DS |
8209 | if (argv[4] != NULL) |
8210 | ospf_routemap_set (red, argv[4]); | |
7c8ff89e DS |
8211 | else |
8212 | ospf_routemap_unset (red); | |
8213 | ||
8214 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
8215 | } | |
8216 | ||
8217 | DEFUN (no_ospf_redistribute_instance_source, | |
8218 | no_ospf_redistribute_instance_source_cmd, | |
2d627ff5 | 8219 | "no redistribute (ospf|table) <1-65535>" |
7c8ff89e DS |
8220 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
8221 | NO_STR | |
8222 | REDIST_STR | |
8223 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8224 | "Non-main Kernel Routing Table\n" |
8225 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
8226 | "Metric for redistributed routes\n" |
8227 | "OSPF default metric\n" | |
8228 | "OSPF exterior metric type for redistributed routes\n" | |
8229 | "Set OSPF External Type 1 metrics\n" | |
8230 | "Set OSPF External Type 2 metrics\n" | |
8231 | "Route map reference\n" | |
8232 | "Pointer to route-map entries\n") | |
8233 | { | |
8234 | struct ospf *ospf = vty->index; | |
8235 | u_int instance; | |
8236 | struct ospf_redist *red; | |
8237 | int source; | |
8238 | ||
8239 | if (!ospf) | |
8240 | return CMD_SUCCESS; | |
8241 | ||
2d627ff5 DS |
8242 | if (strncmp(argv[0], "o", 1) == 0) |
8243 | source = ZEBRA_ROUTE_OSPF; | |
8244 | else | |
8245 | source = ZEBRA_ROUTE_TABLE; | |
8246 | ||
8247 | VTY_GET_INTEGER ("Instance ID", instance, argv[1]); | |
7c8ff89e | 8248 | |
2d627ff5 | 8249 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
8250 | { |
8251 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
8252 | VTY_NEWLINE); | |
8253 | return CMD_WARNING; | |
8254 | } | |
8255 | ||
2d627ff5 | 8256 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
8257 | { |
8258 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
8259 | VTY_NEWLINE); | |
8260 | return CMD_WARNING; | |
8261 | } | |
8262 | ||
7c8ff89e DS |
8263 | red = ospf_redist_lookup(ospf, source, instance); |
8264 | if (!red) | |
8265 | return CMD_SUCCESS; | |
8266 | ||
8267 | ospf_routemap_unset (red); | |
8268 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 8269 | } |
8270 | ||
8271 | DEFUN (ospf_distribute_list_out, | |
8272 | ospf_distribute_list_out_cmd, | |
ab0181ee | 8273 | "distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
718e3744 | 8274 | "Filter networks in routing updates\n" |
6f2a6703 CF |
8275 | "Access-list name\n" |
8276 | OUT_STR | |
ab0181ee | 8277 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 8278 | { |
020709f9 | 8279 | struct ospf *ospf = vty->index; |
6f2a6703 | 8280 | int source; |
718e3744 | 8281 | |
7c8ff89e DS |
8282 | if (!ospf) |
8283 | return CMD_SUCCESS; | |
8284 | ||
6f2a6703 CF |
8285 | /* Get distribute source. */ |
8286 | source = proto_redistnum(AFI_IP, argv[1]); | |
8287 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
8288 | return CMD_WARNING; | |
718e3744 | 8289 | |
6f2a6703 | 8290 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
718e3744 | 8291 | } |
8292 | ||
6f2a6703 CF |
8293 | DEFUN (no_ospf_distribute_list_out, |
8294 | no_ospf_distribute_list_out_cmd, | |
ab0181ee | 8295 | "no distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
6f2a6703 CF |
8296 | NO_STR |
8297 | "Filter networks in routing updates\n" | |
8298 | "Access-list name\n" | |
8299 | OUT_STR | |
ab0181ee | 8300 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 8301 | { |
020709f9 | 8302 | struct ospf *ospf = vty->index; |
6f2a6703 | 8303 | int source; |
020709f9 | 8304 | |
7c8ff89e DS |
8305 | if (!ospf) |
8306 | return CMD_SUCCESS; | |
8307 | ||
6f2a6703 CF |
8308 | source = proto_redistnum(AFI_IP, argv[1]); |
8309 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
8310 | return CMD_WARNING; | |
718e3744 | 8311 | |
6f2a6703 | 8312 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
718e3744 | 8313 | } |
8314 | ||
6f2a6703 CF |
8315 | /* Default information originate. */ |
8316 | DEFUN (ospf_default_information_originate, | |
8317 | ospf_default_information_originate_cmd, | |
8318 | "default-information originate " | |
8319 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 8320 | "Control distribution of default information\n" |
8321 | "Distribute a default route\n" | |
8322 | "Always advertise default route\n" | |
6f2a6703 CF |
8323 | "OSPF default metric\n" |
8324 | "OSPF metric\n" | |
718e3744 | 8325 | "OSPF metric type for default routes\n" |
8326 | "Set OSPF External Type 1 metrics\n" | |
8327 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 8328 | "Route map reference\n" |
8329 | "Pointer to route-map entries\n") | |
8330 | { | |
020709f9 | 8331 | struct ospf *ospf = vty->index; |
6f2a6703 | 8332 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 8333 | int type = -1; |
8334 | int metric = -1; | |
7c8ff89e DS |
8335 | struct ospf_redist *red; |
8336 | ||
8337 | if (!ospf) | |
8338 | return CMD_SUCCESS; | |
718e3744 | 8339 | |
6f2a6703 CF |
8340 | if (argc < 4) |
8341 | return CMD_WARNING; /* this should not happen */ | |
8342 | ||
8343 | /* Check whether "always" was specified */ | |
8344 | if (argv[0] != NULL) | |
8345 | default_originate = DEFAULT_ORIGINATE_ALWAYS; | |
718e3744 | 8346 | |
7c8ff89e DS |
8347 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
8348 | ||
718e3744 | 8349 | /* Get metric value. */ |
6f2a6703 | 8350 | if (argv[1] != NULL) |
718e3744 | 8351 | if (!str2metric (argv[1], &metric)) |
8352 | return CMD_WARNING; | |
8353 | ||
718e3744 | 8354 | /* Get metric type. */ |
6f2a6703 CF |
8355 | if (argv[2] != NULL) |
8356 | if (!str2metric_type (argv[2], &type)) | |
718e3744 | 8357 | return CMD_WARNING; |
8358 | ||
6f2a6703 | 8359 | if (argv[3] != NULL) |
7c8ff89e | 8360 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8361 | else |
7c8ff89e | 8362 | ospf_routemap_unset (red); |
718e3744 | 8363 | |
6f2a6703 CF |
8364 | return ospf_redistribute_default_set (ospf, default_originate, |
8365 | type, metric); | |
718e3744 | 8366 | } |
8367 | ||
8368 | DEFUN (no_ospf_default_information_originate, | |
8369 | no_ospf_default_information_originate_cmd, | |
813d4307 DW |
8370 | "no default-information originate" |
8371 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 8372 | NO_STR |
8373 | "Control distribution of default information\n" | |
813d4307 DW |
8374 | "Distribute a default route\n" |
8375 | "Always advertise default route\n" | |
8376 | "OSPF default metric\n" | |
8377 | "OSPF metric\n" | |
8378 | "OSPF metric type for default routes\n" | |
8379 | "Set OSPF External Type 1 metrics\n" | |
8380 | "Set OSPF External Type 2 metrics\n" | |
8381 | "Route map reference\n" | |
8382 | "Pointer to route-map entries\n") | |
718e3744 | 8383 | { |
68980084 | 8384 | struct ospf *ospf = vty->index; |
718e3744 | 8385 | struct prefix_ipv4 p; |
7c8ff89e DS |
8386 | struct ospf_external *ext; |
8387 | struct ospf_redist *red; | |
718e3744 | 8388 | |
7c8ff89e DS |
8389 | if (!ospf) |
8390 | return CMD_SUCCESS; | |
8391 | ||
718e3744 | 8392 | p.family = AF_INET; |
8393 | p.prefix.s_addr = 0; | |
8394 | p.prefixlen = 0; | |
8395 | ||
5339cfdb | 8396 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 8397 | |
7c8ff89e DS |
8398 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
8399 | EXTERNAL_INFO (ext)) { | |
8400 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
8401 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 8402 | } |
8403 | ||
7c8ff89e DS |
8404 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8405 | if (!red) | |
8406 | return CMD_SUCCESS; | |
8407 | ||
8408 | ospf_routemap_unset (red); | |
020709f9 | 8409 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 8410 | } |
8411 | ||
8412 | DEFUN (ospf_default_metric, | |
8413 | ospf_default_metric_cmd, | |
8414 | "default-metric <0-16777214>", | |
8415 | "Set metric of redistributed routes\n" | |
8416 | "Default metric\n") | |
8417 | { | |
68980084 | 8418 | struct ospf *ospf = vty->index; |
718e3744 | 8419 | int metric = -1; |
8420 | ||
7c8ff89e DS |
8421 | if (!ospf) |
8422 | return CMD_SUCCESS; | |
8423 | ||
718e3744 | 8424 | if (!str2metric (argv[0], &metric)) |
8425 | return CMD_WARNING; | |
8426 | ||
68980084 | 8427 | ospf->default_metric = metric; |
718e3744 | 8428 | |
8429 | return CMD_SUCCESS; | |
8430 | } | |
8431 | ||
8432 | DEFUN (no_ospf_default_metric, | |
8433 | no_ospf_default_metric_cmd, | |
8434 | "no default-metric", | |
8435 | NO_STR | |
8436 | "Set metric of redistributed routes\n") | |
8437 | { | |
68980084 | 8438 | struct ospf *ospf = vty->index; |
8439 | ||
7c8ff89e DS |
8440 | if (!ospf) |
8441 | return CMD_SUCCESS; | |
8442 | ||
68980084 | 8443 | ospf->default_metric = -1; |
8444 | ||
718e3744 | 8445 | return CMD_SUCCESS; |
8446 | } | |
8447 | ||
8448 | ALIAS (no_ospf_default_metric, | |
8449 | no_ospf_default_metric_val_cmd, | |
8450 | "no default-metric <0-16777214>", | |
8451 | NO_STR | |
8452 | "Set metric of redistributed routes\n" | |
8453 | "Default metric\n") | |
8454 | ||
8455 | DEFUN (ospf_distance, | |
8456 | ospf_distance_cmd, | |
8457 | "distance <1-255>", | |
8458 | "Define an administrative distance\n" | |
8459 | "OSPF Administrative distance\n") | |
8460 | { | |
68980084 | 8461 | struct ospf *ospf = vty->index; |
8462 | ||
7c8ff89e DS |
8463 | if (!ospf) |
8464 | return CMD_SUCCESS; | |
8465 | ||
68980084 | 8466 | ospf->distance_all = atoi (argv[0]); |
8467 | ||
718e3744 | 8468 | return CMD_SUCCESS; |
8469 | } | |
8470 | ||
8471 | DEFUN (no_ospf_distance, | |
8472 | no_ospf_distance_cmd, | |
8473 | "no distance <1-255>", | |
8474 | NO_STR | |
8475 | "Define an administrative distance\n" | |
8476 | "OSPF Administrative distance\n") | |
8477 | { | |
68980084 | 8478 | struct ospf *ospf = vty->index; |
8479 | ||
7c8ff89e DS |
8480 | if (!ospf) |
8481 | return CMD_SUCCESS; | |
8482 | ||
68980084 | 8483 | ospf->distance_all = 0; |
8484 | ||
718e3744 | 8485 | return CMD_SUCCESS; |
8486 | } | |
8487 | ||
8488 | DEFUN (no_ospf_distance_ospf, | |
8489 | no_ospf_distance_ospf_cmd, | |
813d4307 | 8490 | "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
718e3744 | 8491 | NO_STR |
8492 | "Define an administrative distance\n" | |
8493 | "OSPF Administrative distance\n" | |
718e3744 | 8494 | "Intra-area routes\n" |
813d4307 | 8495 | "Distance for intra-area routes\n" |
718e3744 | 8496 | "Inter-area routes\n" |
813d4307 DW |
8497 | "Distance for inter-area routes\n" |
8498 | "External routes\n" | |
8499 | "Distance for external routes\n") | |
718e3744 | 8500 | { |
68980084 | 8501 | struct ospf *ospf = vty->index; |
8502 | ||
d8f70b86 DS |
8503 | if (!ospf) |
8504 | return CMD_SUCCESS; | |
8505 | ||
6f2a6703 CF |
8506 | if (argc < 3) |
8507 | return CMD_WARNING; | |
718e3744 | 8508 | |
7c8ff89e DS |
8509 | if (!ospf) |
8510 | return CMD_SUCCESS; | |
8511 | ||
6f2a6703 CF |
8512 | if (argv[0] != NULL) |
8513 | ospf->distance_intra = 0; | |
68980084 | 8514 | |
6f2a6703 CF |
8515 | if (argv[1] != NULL) |
8516 | ospf->distance_inter = 0; | |
68980084 | 8517 | |
6f2a6703 CF |
8518 | if (argv[2] != NULL) |
8519 | ospf->distance_external = 0; | |
718e3744 | 8520 | |
6f2a6703 CF |
8521 | if (argv[0] || argv[1] || argv[2]) |
8522 | return CMD_SUCCESS; | |
68980084 | 8523 | |
6f2a6703 CF |
8524 | /* If no arguments are given, clear all distance information */ |
8525 | ospf->distance_intra = 0; | |
8526 | ospf->distance_inter = 0; | |
8527 | ospf->distance_external = 0; | |
68980084 | 8528 | |
718e3744 | 8529 | return CMD_SUCCESS; |
8530 | } | |
8531 | ||
6f2a6703 CF |
8532 | DEFUN (ospf_distance_ospf, |
8533 | ospf_distance_ospf_cmd, | |
8534 | "distance ospf " | |
2b053042 | 8535 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
718e3744 | 8536 | "Define an administrative distance\n" |
8537 | "OSPF Administrative distance\n" | |
718e3744 | 8538 | "Intra-area routes\n" |
8539 | "Distance for intra-area routes\n" | |
718e3744 | 8540 | "Inter-area routes\n" |
8541 | "Distance for inter-area routes\n" | |
8542 | "External routes\n" | |
718e3744 | 8543 | "Distance for external routes\n") |
8544 | { | |
68980084 | 8545 | struct ospf *ospf = vty->index; |
8546 | ||
d8f70b86 DS |
8547 | if (!ospf) |
8548 | return CMD_SUCCESS; | |
8549 | ||
6f2a6703 CF |
8550 | if (argc < 3) /* should not happen */ |
8551 | return CMD_WARNING; | |
68980084 | 8552 | |
6f2a6703 CF |
8553 | if (!argv[0] && !argv[1] && !argv[2]) |
8554 | { | |
8555 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", | |
8556 | VTY_NEWLINE); | |
8557 | return CMD_WARNING; | |
8558 | } | |
68980084 | 8559 | |
6f2a6703 CF |
8560 | if (argv[0] != NULL) |
8561 | ospf->distance_intra = atoi(argv[0]); | |
718e3744 | 8562 | |
6f2a6703 CF |
8563 | if (argv[1] != NULL) |
8564 | ospf->distance_inter = atoi(argv[1]); | |
68980084 | 8565 | |
6f2a6703 CF |
8566 | if (argv[2] != NULL) |
8567 | ospf->distance_external = atoi(argv[2]); | |
68980084 | 8568 | |
718e3744 | 8569 | return CMD_SUCCESS; |
8570 | } | |
8571 | ||
8572 | DEFUN (ospf_distance_source, | |
8573 | ospf_distance_source_cmd, | |
8574 | "distance <1-255> A.B.C.D/M", | |
8575 | "Administrative distance\n" | |
8576 | "Distance value\n" | |
8577 | "IP source prefix\n") | |
8578 | { | |
020709f9 | 8579 | struct ospf *ospf = vty->index; |
8580 | ||
7c8ff89e DS |
8581 | if (!ospf) |
8582 | return CMD_SUCCESS; | |
8583 | ||
020709f9 | 8584 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
68980084 | 8585 | |
718e3744 | 8586 | return CMD_SUCCESS; |
8587 | } | |
8588 | ||
8589 | DEFUN (no_ospf_distance_source, | |
8590 | no_ospf_distance_source_cmd, | |
8591 | "no distance <1-255> A.B.C.D/M", | |
8592 | NO_STR | |
8593 | "Administrative distance\n" | |
8594 | "Distance value\n" | |
8595 | "IP source prefix\n") | |
8596 | { | |
020709f9 | 8597 | struct ospf *ospf = vty->index; |
8598 | ||
7c8ff89e DS |
8599 | if (!ospf) |
8600 | return CMD_SUCCESS; | |
8601 | ||
020709f9 | 8602 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
8603 | ||
718e3744 | 8604 | return CMD_SUCCESS; |
8605 | } | |
8606 | ||
8607 | DEFUN (ospf_distance_source_access_list, | |
8608 | ospf_distance_source_access_list_cmd, | |
8609 | "distance <1-255> A.B.C.D/M WORD", | |
8610 | "Administrative distance\n" | |
8611 | "Distance value\n" | |
8612 | "IP source prefix\n" | |
8613 | "Access list name\n") | |
8614 | { | |
020709f9 | 8615 | struct ospf *ospf = vty->index; |
8616 | ||
7c8ff89e DS |
8617 | if (!ospf) |
8618 | return CMD_SUCCESS; | |
8619 | ||
020709f9 | 8620 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
8621 | ||
718e3744 | 8622 | return CMD_SUCCESS; |
8623 | } | |
8624 | ||
8625 | DEFUN (no_ospf_distance_source_access_list, | |
8626 | no_ospf_distance_source_access_list_cmd, | |
8627 | "no distance <1-255> A.B.C.D/M WORD", | |
8628 | NO_STR | |
8629 | "Administrative distance\n" | |
8630 | "Distance value\n" | |
8631 | "IP source prefix\n" | |
8632 | "Access list name\n") | |
8633 | { | |
020709f9 | 8634 | struct ospf *ospf = vty->index; |
8635 | ||
7c8ff89e DS |
8636 | if (!ospf) |
8637 | return CMD_SUCCESS; | |
8638 | ||
020709f9 | 8639 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
8640 | ||
718e3744 | 8641 | return CMD_SUCCESS; |
8642 | } | |
8643 | ||
ba682537 | 8644 | DEFUN (ip_ospf_mtu_ignore, |
8645 | ip_ospf_mtu_ignore_addr_cmd, | |
8646 | "ip ospf mtu-ignore A.B.C.D", | |
8647 | "IP Information\n" | |
8648 | "OSPF interface commands\n" | |
8649 | "Disable mtu mismatch detection\n" | |
8650 | "Address of interface") | |
8651 | { | |
8652 | struct interface *ifp = vty->index; | |
8653 | struct in_addr addr; | |
8654 | int ret; | |
8655 | ||
8656 | struct ospf_if_params *params; | |
8657 | params = IF_DEF_PARAMS (ifp); | |
8658 | ||
8659 | if (argc == 1) | |
8660 | { | |
8661 | ret = inet_aton(argv[0], &addr); | |
8662 | if (!ret) | |
8663 | { | |
8664 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8665 | VTY_NEWLINE); | |
8666 | return CMD_WARNING; | |
8667 | } | |
8668 | params = ospf_get_if_params (ifp, addr); | |
8669 | ospf_if_update_params (ifp, addr); | |
8670 | } | |
8671 | params->mtu_ignore = 1; | |
8672 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8673 | SET_IF_PARAM (params, mtu_ignore); | |
8674 | else | |
8675 | { | |
8676 | UNSET_IF_PARAM (params, mtu_ignore); | |
8677 | if (params != IF_DEF_PARAMS (ifp)) | |
8678 | { | |
8679 | ospf_free_if_params (ifp, addr); | |
8680 | ospf_if_update_params (ifp, addr); | |
8681 | } | |
8682 | } | |
8683 | return CMD_SUCCESS; | |
8684 | } | |
8685 | ||
8686 | ALIAS (ip_ospf_mtu_ignore, | |
8687 | ip_ospf_mtu_ignore_cmd, | |
8688 | "ip ospf mtu-ignore", | |
8689 | "IP Information\n" | |
8690 | "OSPF interface commands\n" | |
8691 | "Disable mtu mismatch detection\n") | |
8692 | ||
8693 | ||
8694 | DEFUN (no_ip_ospf_mtu_ignore, | |
8695 | no_ip_ospf_mtu_ignore_addr_cmd, | |
8696 | "no ip ospf mtu-ignore A.B.C.D", | |
8697 | "IP Information\n" | |
8698 | "OSPF interface commands\n" | |
8699 | "Disable mtu mismatch detection\n" | |
8700 | "Address of interface") | |
8701 | { | |
8702 | struct interface *ifp = vty->index; | |
8703 | struct in_addr addr; | |
8704 | int ret; | |
8705 | ||
8706 | struct ospf_if_params *params; | |
8707 | params = IF_DEF_PARAMS (ifp); | |
8708 | ||
8709 | if (argc == 1) | |
8710 | { | |
8711 | ret = inet_aton(argv[0], &addr); | |
8712 | if (!ret) | |
8713 | { | |
8714 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8715 | VTY_NEWLINE); | |
8716 | return CMD_WARNING; | |
8717 | } | |
8718 | params = ospf_get_if_params (ifp, addr); | |
8719 | ospf_if_update_params (ifp, addr); | |
8720 | } | |
8721 | params->mtu_ignore = 0; | |
8722 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8723 | SET_IF_PARAM (params, mtu_ignore); | |
8724 | else | |
8725 | { | |
8726 | UNSET_IF_PARAM (params, mtu_ignore); | |
8727 | if (params != IF_DEF_PARAMS (ifp)) | |
8728 | { | |
8729 | ospf_free_if_params (ifp, addr); | |
8730 | ospf_if_update_params (ifp, addr); | |
8731 | } | |
8732 | } | |
8733 | return CMD_SUCCESS; | |
8734 | } | |
8735 | ||
8736 | ALIAS (no_ip_ospf_mtu_ignore, | |
8737 | no_ip_ospf_mtu_ignore_cmd, | |
8738 | "no ip ospf mtu-ignore", | |
8739 | "IP Information\n" | |
8740 | "OSPF interface commands\n" | |
8741 | "Disable mtu mismatch detection\n") | |
6b0655a2 | 8742 | |
88d6cf37 | 8743 | DEFUN (ospf_max_metric_router_lsa_admin, |
8744 | ospf_max_metric_router_lsa_admin_cmd, | |
8745 | "max-metric router-lsa administrative", | |
8746 | "OSPF maximum / infinite-distance metric\n" | |
8747 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8748 | "Administratively applied, for an indefinite period\n") | |
8749 | { | |
8750 | struct listnode *ln; | |
8751 | struct ospf_area *area; | |
8752 | struct ospf *ospf = vty->index; | |
ba682537 | 8753 | |
7c8ff89e DS |
8754 | if (!ospf) |
8755 | return CMD_SUCCESS; | |
8756 | ||
88d6cf37 | 8757 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8758 | { | |
8759 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8760 | ||
8761 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 8762 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8763 | } |
4ba4fc85 AB |
8764 | |
8765 | /* Allows for areas configured later to get the property */ | |
8766 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
8767 | ||
88d6cf37 | 8768 | return CMD_SUCCESS; |
8769 | } | |
8770 | ||
8771 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
8772 | no_ospf_max_metric_router_lsa_admin_cmd, | |
8773 | "no max-metric router-lsa administrative", | |
8774 | NO_STR | |
8775 | "OSPF maximum / infinite-distance metric\n" | |
8776 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8777 | "Administratively applied, for an indefinite period\n") | |
8778 | { | |
8779 | struct listnode *ln; | |
8780 | struct ospf_area *area; | |
8781 | struct ospf *ospf = vty->index; | |
8782 | ||
7c8ff89e DS |
8783 | if (!ospf) |
8784 | return CMD_SUCCESS; | |
8785 | ||
88d6cf37 | 8786 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8787 | { | |
8788 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8789 | ||
8790 | /* Don't trample on the start-up stub timer */ | |
8791 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
8792 | && !area->t_stub_router) | |
8793 | { | |
8794 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8795 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8796 | } |
8797 | } | |
4ba4fc85 | 8798 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 8799 | return CMD_SUCCESS; |
8800 | } | |
8801 | ||
8802 | DEFUN (ospf_max_metric_router_lsa_startup, | |
8803 | ospf_max_metric_router_lsa_startup_cmd, | |
8804 | "max-metric router-lsa on-startup <5-86400>", | |
8805 | "OSPF maximum / infinite-distance metric\n" | |
8806 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8807 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8808 | "Time (seconds) to advertise self as stub-router\n") | |
8809 | { | |
8810 | unsigned int seconds; | |
8811 | struct ospf *ospf = vty->index; | |
8812 | ||
7c8ff89e DS |
8813 | if (!ospf) |
8814 | return CMD_SUCCESS; | |
8815 | ||
88d6cf37 | 8816 | if (argc != 1) |
8817 | { | |
8818 | vty_out (vty, "%% Must supply stub-router period"); | |
8819 | return CMD_WARNING; | |
8820 | } | |
8821 | ||
8822 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); | |
8823 | ||
8824 | ospf->stub_router_startup_time = seconds; | |
8825 | ||
8826 | return CMD_SUCCESS; | |
8827 | } | |
8828 | ||
8829 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
8830 | no_ospf_max_metric_router_lsa_startup_cmd, | |
813d4307 | 8831 | "no max-metric router-lsa on-startup <5-86400>", |
88d6cf37 | 8832 | NO_STR |
8833 | "OSPF maximum / infinite-distance metric\n" | |
8834 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8835 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
8836 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 8837 | { |
8838 | struct listnode *ln; | |
8839 | struct ospf_area *area; | |
8840 | struct ospf *ospf = vty->index; | |
8841 | ||
7c8ff89e DS |
8842 | if (!ospf) |
8843 | return CMD_SUCCESS; | |
8844 | ||
88d6cf37 | 8845 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8846 | ||
8847 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8848 | { | |
8849 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
8850 | OSPF_TIMER_OFF (area->t_stub_router); | |
8851 | ||
8852 | /* Don't trample on admin stub routed */ | |
8853 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8854 | { | |
8855 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8856 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8857 | } |
8858 | } | |
8859 | return CMD_SUCCESS; | |
8860 | } | |
8861 | ||
a1afa410 DS |
8862 | ALIAS (no_ospf_max_metric_router_lsa_startup, |
8863 | no_ospf_max_metric_router_lsa_startup_no_param_cmd, | |
8864 | "no max-metric router-lsa on-startup", | |
8865 | NO_STR | |
8866 | "OSPF maximum / infinite-distance metric\n" | |
8867 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8868 | "Automatically advertise stub Router-LSA on startup of OSPF\n"); | |
8869 | ||
88d6cf37 | 8870 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
8871 | ospf_max_metric_router_lsa_shutdown_cmd, | |
804fb5c1 | 8872 | "max-metric router-lsa on-shutdown <5-100>", |
88d6cf37 | 8873 | "OSPF maximum / infinite-distance metric\n" |
8874 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8875 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
8876 | "Time (seconds) to wait till full shutdown\n") | |
8877 | { | |
8878 | unsigned int seconds; | |
8879 | struct ospf *ospf = vty->index; | |
8880 | ||
7c8ff89e DS |
8881 | if (!ospf) |
8882 | return CMD_SUCCESS; | |
8883 | ||
88d6cf37 | 8884 | if (argc != 1) |
8885 | { | |
8886 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
8887 | return CMD_WARNING; | |
8888 | } | |
8889 | ||
8890 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); | |
8891 | ||
8892 | ospf->stub_router_shutdown_time = seconds; | |
8893 | ||
8894 | return CMD_SUCCESS; | |
8895 | } | |
8896 | ||
8897 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
8898 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
813d4307 | 8899 | "no max-metric router-lsa on-shutdown <5-100>", |
88d6cf37 | 8900 | NO_STR |
8901 | "OSPF maximum / infinite-distance metric\n" | |
8902 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8903 | "Advertise stub-router prior to full shutdown of OSPF\n" |
8904 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 8905 | { |
8906 | struct ospf *ospf = vty->index; | |
8907 | ||
7c8ff89e DS |
8908 | if (!ospf) |
8909 | return CMD_SUCCESS; | |
8910 | ||
88d6cf37 | 8911 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8912 | ||
8913 | return CMD_SUCCESS; | |
8914 | } | |
8915 | ||
a1afa410 DS |
8916 | ALIAS (no_ospf_max_metric_router_lsa_shutdown, |
8917 | no_ospf_max_metric_router_lsa_shutdown_no_param_cmd, | |
8918 | "no max-metric router-lsa on-shutdown", | |
8919 | NO_STR | |
8920 | "OSPF maximum / infinite-distance metric\n" | |
8921 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8922 | "Advertise stub-router prior to full shutdown of OSPF\n"); | |
8923 | ||
88d6cf37 | 8924 | static void |
8925 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
8926 | { | |
8927 | struct listnode *ln; | |
8928 | struct ospf_area *area; | |
8929 | ||
8930 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8931 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
8932 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
8933 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8934 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
8935 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
8936 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8937 | { | |
8938 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8939 | { | |
8940 | vty_out (vty, " max-metric router-lsa administrative%s", | |
8941 | VTY_NEWLINE); | |
8942 | break; | |
8943 | } | |
8944 | } | |
8945 | return; | |
8946 | } | |
6b0655a2 | 8947 | |
4dadc291 | 8948 | static void |
718e3744 | 8949 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
8950 | { | |
8951 | struct route_node *rn; | |
8952 | struct ospf_route *or; | |
1eb8ef25 | 8953 | struct listnode *pnode, *pnnode; |
718e3744 | 8954 | struct ospf_path *path; |
8955 | ||
8956 | vty_out (vty, "============ OSPF network routing table ============%s", | |
8957 | VTY_NEWLINE); | |
8958 | ||
8959 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8960 | if ((or = rn->info) != NULL) | |
8961 | { | |
8962 | char buf1[19]; | |
8963 | snprintf (buf1, 19, "%s/%d", | |
8964 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8965 | ||
8966 | switch (or->path_type) | |
8967 | { | |
8968 | case OSPF_PATH_INTER_AREA: | |
8969 | if (or->type == OSPF_DESTINATION_NETWORK) | |
8970 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
8971 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8972 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
8973 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
8974 | break; | |
8975 | case OSPF_PATH_INTRA_AREA: | |
8976 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
8977 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8978 | break; | |
8979 | default: | |
8980 | break; | |
8981 | } | |
8982 | ||
8983 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 8984 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 8985 | { |
a8ba847f | 8986 | if (if_lookup_by_index(path->ifindex)) |
96735eea | 8987 | { |
8988 | if (path->nexthop.s_addr == 0) | |
8989 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f | 8990 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 8991 | else |
8992 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
8993 | inet_ntoa (path->nexthop), |
8994 | ifindex2ifname (path->ifindex), VTY_NEWLINE); | |
96735eea | 8995 | } |
8996 | } | |
718e3744 | 8997 | } |
8998 | vty_out (vty, "%s", VTY_NEWLINE); | |
8999 | } | |
9000 | ||
4dadc291 | 9001 | static void |
718e3744 | 9002 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
9003 | { | |
9004 | struct route_node *rn; | |
9005 | struct ospf_route *or; | |
1eb8ef25 | 9006 | struct listnode *pnode; |
9007 | struct listnode *node; | |
718e3744 | 9008 | struct ospf_path *path; |
9009 | ||
9010 | vty_out (vty, "============ OSPF router routing table =============%s", | |
9011 | VTY_NEWLINE); | |
9012 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
9013 | if (rn->info) | |
9014 | { | |
9015 | int flag = 0; | |
9016 | ||
9017 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
9018 | ||
1eb8ef25 | 9019 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
9020 | { | |
9021 | if (flag++) | |
9022 | vty_out (vty, "%24s", ""); | |
9023 | ||
9024 | /* Show path. */ | |
9025 | vty_out (vty, "%s [%d] area: %s", | |
9026 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
9027 | or->cost, inet_ntoa (or->u.std.area_id)); | |
9028 | /* Show flags. */ | |
9029 | vty_out (vty, "%s%s%s", | |
9030 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
9031 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
9032 | VTY_NEWLINE); | |
9033 | ||
9034 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
9035 | { | |
a8ba847f | 9036 | if (if_lookup_by_index(path->ifindex)) |
54bedb55 | 9037 | { |
9038 | if (path->nexthop.s_addr == 0) | |
9039 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f JT |
9040 | "", ifindex2ifname (path->ifindex), |
9041 | VTY_NEWLINE); | |
54bedb55 | 9042 | else |
9043 | vty_out (vty, "%24s via %s, %s%s", "", | |
9044 | inet_ntoa (path->nexthop), | |
a8ba847f JT |
9045 | ifindex2ifname (path->ifindex), |
9046 | VTY_NEWLINE); | |
54bedb55 | 9047 | } |
1eb8ef25 | 9048 | } |
9049 | } | |
718e3744 | 9050 | } |
9051 | vty_out (vty, "%s", VTY_NEWLINE); | |
9052 | } | |
9053 | ||
4dadc291 | 9054 | static void |
718e3744 | 9055 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
9056 | { | |
9057 | struct route_node *rn; | |
9058 | struct ospf_route *er; | |
1eb8ef25 | 9059 | struct listnode *pnode, *pnnode; |
718e3744 | 9060 | struct ospf_path *path; |
9061 | ||
9062 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
9063 | VTY_NEWLINE); | |
9064 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
9065 | if ((er = rn->info) != NULL) | |
9066 | { | |
9067 | char buf1[19]; | |
9068 | snprintf (buf1, 19, "%s/%d", | |
9069 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
9070 | ||
9071 | switch (er->path_type) | |
9072 | { | |
9073 | case OSPF_PATH_TYPE1_EXTERNAL: | |
dc9ffce8 | 9074 | vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1, |
718e3744 | 9075 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
9076 | break; | |
9077 | case OSPF_PATH_TYPE2_EXTERNAL: | |
dc9ffce8 | 9078 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost, |
718e3744 | 9079 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
9080 | break; | |
9081 | } | |
9082 | ||
1eb8ef25 | 9083 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 9084 | { |
a8ba847f | 9085 | if (if_lookup_by_index(path->ifindex)) |
718e3744 | 9086 | { |
9087 | if (path->nexthop.s_addr == 0) | |
96735eea | 9088 | vty_out (vty, "%24s directly attached to %s%s", |
a8ba847f | 9089 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 9090 | else |
9091 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
9092 | inet_ntoa (path->nexthop), |
9093 | ifindex2ifname (path->ifindex), | |
96735eea | 9094 | VTY_NEWLINE); |
718e3744 | 9095 | } |
9096 | } | |
9097 | } | |
9098 | vty_out (vty, "%s", VTY_NEWLINE); | |
9099 | } | |
9100 | ||
7c8ff89e DS |
9101 | static int |
9102 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 9103 | { |
7c8ff89e DS |
9104 | if (ospf->instance) |
9105 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
9106 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9107 | |
68980084 | 9108 | if (ospf->new_table == NULL) |
718e3744 | 9109 | { |
9110 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
9111 | return CMD_SUCCESS; | |
9112 | } | |
9113 | ||
9114 | /* Show Network routes. | |
020709f9 | 9115 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 9116 | |
9117 | /* Show Router routes. */ | |
68980084 | 9118 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 9119 | |
7c8ff89e DS |
9120 | vty_out (vty, "%s", VTY_NEWLINE); |
9121 | ||
718e3744 | 9122 | return CMD_SUCCESS; |
9123 | } | |
718e3744 | 9124 | |
7c8ff89e DS |
9125 | DEFUN (show_ip_ospf_border_routers, |
9126 | show_ip_ospf_border_routers_cmd, | |
9127 | "show ip ospf border-routers", | |
718e3744 | 9128 | SHOW_STR |
9129 | IP_STR | |
9130 | "OSPF information\n" | |
7c8ff89e | 9131 | "Show all the ABR's and ASBR's\n") |
718e3744 | 9132 | { |
020709f9 | 9133 | struct ospf *ospf; |
68980084 | 9134 | |
0bad4851 | 9135 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9136 | return CMD_SUCCESS; |
9137 | ||
9138 | return show_ip_ospf_border_routers_common(vty, ospf); | |
9139 | } | |
9140 | ||
9141 | DEFUN (show_ip_ospf_instance_border_routers, | |
9142 | show_ip_ospf_instance_border_routers_cmd, | |
9143 | "show ip ospf <1-65535> border-routers", | |
9144 | SHOW_STR | |
9145 | IP_STR | |
9146 | "OSPF information\n" | |
9147 | "Instance ID\n" | |
9148 | "Show all the ABR's and ASBR's\n") | |
9149 | { | |
9150 | struct ospf *ospf; | |
9151 | u_short instance = 0; | |
9152 | ||
9153 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 9154 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9155 | return CMD_SUCCESS; |
9156 | ||
9157 | return show_ip_ospf_border_routers_common(vty, ospf); | |
9158 | } | |
9159 | ||
9160 | static int | |
9161 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
9162 | { | |
9163 | if (ospf->instance) | |
9164 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
9165 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9166 | |
68980084 | 9167 | if (ospf->new_table == NULL) |
718e3744 | 9168 | { |
9169 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
9170 | return CMD_SUCCESS; | |
9171 | } | |
9172 | ||
9173 | /* Show Network routes. */ | |
68980084 | 9174 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 9175 | |
9176 | /* Show Router routes. */ | |
68980084 | 9177 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 9178 | |
9179 | /* Show AS External routes. */ | |
68980084 | 9180 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 9181 | |
7c8ff89e DS |
9182 | vty_out (vty, "%s", VTY_NEWLINE); |
9183 | ||
718e3744 | 9184 | return CMD_SUCCESS; |
9185 | } | |
9186 | ||
7c8ff89e DS |
9187 | DEFUN (show_ip_ospf_route, |
9188 | show_ip_ospf_route_cmd, | |
9189 | "show ip ospf route", | |
9190 | SHOW_STR | |
9191 | IP_STR | |
9192 | "OSPF information\n" | |
9193 | "OSPF routing table\n") | |
9194 | { | |
9195 | struct ospf *ospf; | |
9196 | ||
0bad4851 | 9197 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9198 | return CMD_SUCCESS; |
9199 | ||
9200 | return show_ip_ospf_route_common(vty, ospf); | |
9201 | } | |
9202 | ||
9203 | DEFUN (show_ip_ospf_instance_route, | |
9204 | show_ip_ospf_instance_route_cmd, | |
9205 | "show ip ospf <1-65535> route", | |
9206 | SHOW_STR | |
9207 | IP_STR | |
9208 | "OSPF information\n" | |
9209 | "Instance ID\n" | |
9210 | "OSPF routing table\n") | |
9211 | { | |
9212 | struct ospf *ospf; | |
9213 | u_short instance = 0; | |
9214 | ||
9215 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 9216 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9217 | return CMD_SUCCESS; |
9218 | ||
9219 | return show_ip_ospf_route_common(vty, ospf); | |
9220 | } | |
6b0655a2 | 9221 | |
eb1ce605 | 9222 | const char *ospf_abr_type_str[] = |
718e3744 | 9223 | { |
9224 | "unknown", | |
9225 | "standard", | |
9226 | "ibm", | |
9227 | "cisco", | |
9228 | "shortcut" | |
9229 | }; | |
9230 | ||
eb1ce605 | 9231 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 9232 | { |
9233 | "default", | |
9234 | "enable", | |
9235 | "disable" | |
9236 | }; | |
9237 | ||
9238 | ||
4dadc291 | 9239 | static void |
718e3744 | 9240 | area_id2str (char *buf, int length, struct ospf_area *area) |
9241 | { | |
9242 | memset (buf, 0, length); | |
9243 | ||
9244 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
9245 | strncpy (buf, inet_ntoa (area->area_id), length); | |
9246 | else | |
9247 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); | |
9248 | } | |
9249 | ||
6b0655a2 | 9250 | |
eb1ce605 | 9251 | const char *ospf_int_type_str[] = |
718e3744 | 9252 | { |
9253 | "unknown", /* should never be used. */ | |
9254 | "point-to-point", | |
9255 | "broadcast", | |
9256 | "non-broadcast", | |
9257 | "point-to-multipoint", | |
9258 | "virtual-link", /* should never be used. */ | |
9259 | "loopback" | |
9260 | }; | |
9261 | ||
9262 | /* Configuration write function for ospfd. */ | |
4dadc291 | 9263 | static int |
718e3744 | 9264 | config_write_interface (struct vty *vty) |
9265 | { | |
52dc7ee6 | 9266 | struct listnode *n1, *n2; |
718e3744 | 9267 | struct interface *ifp; |
9268 | struct crypt_key *ck; | |
9269 | int write = 0; | |
9270 | struct route_node *rn = NULL; | |
9271 | struct ospf_if_params *params; | |
7c8ff89e | 9272 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 9273 | |
b2d7c082 | 9274 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp)) |
718e3744 | 9275 | { |
718e3744 | 9276 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
9277 | continue; | |
9278 | ||
84361d61 DS |
9279 | if (ifp->ifindex == IFINDEX_DELETED) |
9280 | continue; | |
9281 | ||
718e3744 | 9282 | vty_out (vty, "!%s", VTY_NEWLINE); |
9283 | vty_out (vty, "interface %s%s", ifp->name, | |
9284 | VTY_NEWLINE); | |
9285 | if (ifp->desc) | |
9286 | vty_out (vty, " description %s%s", ifp->desc, | |
9287 | VTY_NEWLINE); | |
9288 | ||
9289 | write++; | |
9290 | ||
9291 | params = IF_DEF_PARAMS (ifp); | |
9292 | ||
9293 | do { | |
9294 | /* Interface Network print. */ | |
9295 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 9296 | params->type != OSPF_IFTYPE_LOOPBACK) |
9297 | { | |
bc18d616 | 9298 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 9299 | { |
9300 | vty_out (vty, " ip ospf network %s", | |
9301 | ospf_int_type_str[params->type]); | |
9302 | if (params != IF_DEF_PARAMS (ifp)) | |
9303 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9304 | vty_out (vty, "%s", VTY_NEWLINE); | |
9305 | } | |
718e3744 | 9306 | } |
9307 | ||
9308 | /* OSPF interface authentication print */ | |
9309 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
9310 | params->auth_type != OSPF_AUTH_NOTSET) | |
9311 | { | |
eb1ce605 | 9312 | const char *auth_str; |
718e3744 | 9313 | |
9314 | /* Translation tables are not that much help here due to syntax | |
9315 | of the simple option */ | |
9316 | switch (params->auth_type) | |
9317 | { | |
9318 | ||
9319 | case OSPF_AUTH_NULL: | |
9320 | auth_str = " null"; | |
9321 | break; | |
9322 | ||
9323 | case OSPF_AUTH_SIMPLE: | |
9324 | auth_str = ""; | |
9325 | break; | |
9326 | ||
9327 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
9328 | auth_str = " message-digest"; | |
9329 | break; | |
9330 | ||
9331 | default: | |
9332 | auth_str = ""; | |
9333 | break; | |
9334 | } | |
9335 | ||
9336 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
9337 | if (params != IF_DEF_PARAMS (ifp)) | |
9338 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9339 | vty_out (vty, "%s", VTY_NEWLINE); | |
9340 | } | |
9341 | ||
9342 | /* Simple Authentication Password print. */ | |
9343 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
9344 | params->auth_simple[0] != '\0') | |
9345 | { | |
9346 | vty_out (vty, " ip ospf authentication-key %s", | |
9347 | params->auth_simple); | |
9348 | if (params != IF_DEF_PARAMS (ifp)) | |
9349 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9350 | vty_out (vty, "%s", VTY_NEWLINE); | |
9351 | } | |
9352 | ||
9353 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 9354 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 9355 | { |
718e3744 | 9356 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 9357 | ck->key_id, ck->auth_key); |
718e3744 | 9358 | if (params != IF_DEF_PARAMS (ifp)) |
9359 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9360 | vty_out (vty, "%s", VTY_NEWLINE); | |
9361 | } | |
9362 | ||
9363 | /* Interface Output Cost print. */ | |
9364 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
9365 | { | |
9366 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
9367 | if (params != IF_DEF_PARAMS (ifp)) | |
9368 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9369 | vty_out (vty, "%s", VTY_NEWLINE); | |
9370 | } | |
9371 | ||
9372 | /* Hello Interval print. */ | |
9373 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
9374 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
9375 | { | |
9376 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
9377 | if (params != IF_DEF_PARAMS (ifp)) | |
9378 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9379 | vty_out (vty, "%s", VTY_NEWLINE); | |
9380 | } | |
9381 | ||
9382 | ||
9383 | /* Router Dead Interval print. */ | |
9384 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
9385 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
9386 | { | |
f9ad937f | 9387 | vty_out (vty, " ip ospf dead-interval "); |
9388 | ||
9389 | /* fast hello ? */ | |
9390 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
9391 | vty_out (vty, "minimal hello-multiplier %d", | |
9392 | params->fast_hello); | |
9393 | else | |
9394 | vty_out (vty, "%u", params->v_wait); | |
9395 | ||
718e3744 | 9396 | if (params != IF_DEF_PARAMS (ifp)) |
9397 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9398 | vty_out (vty, "%s", VTY_NEWLINE); | |
9399 | } | |
9400 | ||
9401 | /* Router Priority print. */ | |
9402 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
9403 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
9404 | { | |
9405 | vty_out (vty, " ip ospf priority %u", params->priority); | |
9406 | if (params != IF_DEF_PARAMS (ifp)) | |
9407 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9408 | vty_out (vty, "%s", VTY_NEWLINE); | |
9409 | } | |
9410 | ||
9411 | /* Retransmit Interval print. */ | |
9412 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
9413 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
9414 | { | |
9415 | vty_out (vty, " ip ospf retransmit-interval %u", | |
9416 | params->retransmit_interval); | |
9417 | if (params != IF_DEF_PARAMS (ifp)) | |
9418 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9419 | vty_out (vty, "%s", VTY_NEWLINE); | |
9420 | } | |
9421 | ||
9422 | /* Transmit Delay print. */ | |
9423 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
9424 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9425 | { | |
9426 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
9427 | if (params != IF_DEF_PARAMS (ifp)) | |
9428 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9429 | vty_out (vty, "%s", VTY_NEWLINE); | |
9430 | } | |
9431 | ||
953cde65 JT |
9432 | /* Area print. */ |
9433 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
9434 | { | |
9435 | if (ospf->instance) | |
9436 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
9437 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
9438 | else | |
9439 | vty_out (vty, " ip ospf area %s%s", | |
9440 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
9441 | ||
9442 | } | |
9443 | ||
d5a5c8f0 | 9444 | /* bfd print. */ |
7f342629 | 9445 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 9446 | |
ba682537 | 9447 | /* MTU ignore print. */ |
9448 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
9449 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
9450 | { | |
9451 | if (params->mtu_ignore == 0) | |
9452 | vty_out (vty, " no ip ospf mtu-ignore"); | |
9453 | else | |
9454 | vty_out (vty, " ip ospf mtu-ignore"); | |
9455 | if (params != IF_DEF_PARAMS (ifp)) | |
9456 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9457 | vty_out (vty, "%s", VTY_NEWLINE); | |
9458 | } | |
9459 | ||
9460 | ||
718e3744 | 9461 | while (1) |
9462 | { | |
9463 | if (rn == NULL) | |
9464 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
9465 | else | |
9466 | rn = route_next (rn); | |
9467 | ||
9468 | if (rn == NULL) | |
9469 | break; | |
9470 | params = rn->info; | |
9471 | if (params != NULL) | |
9472 | break; | |
9473 | } | |
9474 | } while (rn); | |
9475 | ||
718e3744 | 9476 | ospf_opaque_config_write_if (vty, ifp); |
718e3744 | 9477 | } |
9478 | ||
9479 | return write; | |
9480 | } | |
9481 | ||
4dadc291 | 9482 | static int |
68980084 | 9483 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9484 | { |
9485 | struct route_node *rn; | |
9486 | u_char buf[INET_ADDRSTRLEN]; | |
9487 | ||
9488 | /* `network area' print. */ | |
68980084 | 9489 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 9490 | if (rn->info) |
9491 | { | |
9492 | struct ospf_network *n = rn->info; | |
9493 | ||
9494 | memset (buf, 0, INET_ADDRSTRLEN); | |
9495 | ||
9496 | /* Create Area ID string by specified Area ID format. */ | |
9497 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9498 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 9499 | else |
c9e52be3 | 9500 | sprintf ((char *) buf, "%lu", |
718e3744 | 9501 | (unsigned long int) ntohl (n->area_id.s_addr)); |
9502 | ||
9503 | /* Network print. */ | |
9504 | vty_out (vty, " network %s/%d area %s%s", | |
9505 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9506 | buf, VTY_NEWLINE); | |
9507 | } | |
9508 | ||
9509 | return 0; | |
9510 | } | |
9511 | ||
4dadc291 | 9512 | static int |
68980084 | 9513 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9514 | { |
52dc7ee6 | 9515 | struct listnode *node; |
1eb8ef25 | 9516 | struct ospf_area *area; |
718e3744 | 9517 | u_char buf[INET_ADDRSTRLEN]; |
9518 | ||
9519 | /* Area configuration print. */ | |
1eb8ef25 | 9520 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 9521 | { |
718e3744 | 9522 | struct route_node *rn1; |
9523 | ||
c9e52be3 | 9524 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
718e3744 | 9525 | |
9526 | if (area->auth_type != OSPF_AUTH_NULL) | |
9527 | { | |
9528 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
9529 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
9530 | else | |
9531 | vty_out (vty, " area %s authentication message-digest%s", | |
9532 | buf, VTY_NEWLINE); | |
9533 | } | |
9534 | ||
9535 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
9536 | vty_out (vty, " area %s shortcut %s%s", buf, | |
9537 | ospf_shortcut_mode_str[area->shortcut_configured], | |
9538 | VTY_NEWLINE); | |
9539 | ||
9540 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 9541 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 9542 | ) |
9543 | { | |
b0a053be | 9544 | if (area->external_routing == OSPF_AREA_STUB) |
9545 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 9546 | else if (area->external_routing == OSPF_AREA_NSSA) |
9547 | { | |
9548 | vty_out (vty, " area %s nssa", buf); | |
9549 | switch (area->NSSATranslatorRole) | |
9550 | { | |
9551 | case OSPF_NSSA_ROLE_NEVER: | |
9552 | vty_out (vty, " translate-never"); | |
9553 | break; | |
9554 | case OSPF_NSSA_ROLE_ALWAYS: | |
9555 | vty_out (vty, " translate-always"); | |
9556 | break; | |
9557 | case OSPF_NSSA_ROLE_CANDIDATE: | |
9558 | default: | |
9559 | vty_out (vty, " translate-candidate"); | |
9560 | } | |
9561 | } | |
718e3744 | 9562 | |
9563 | if (area->no_summary) | |
9564 | vty_out (vty, " no-summary"); | |
9565 | ||
9566 | vty_out (vty, "%s", VTY_NEWLINE); | |
9567 | ||
9568 | if (area->default_cost != 1) | |
9569 | vty_out (vty, " area %s default-cost %d%s", buf, | |
9570 | area->default_cost, VTY_NEWLINE); | |
9571 | } | |
9572 | ||
9573 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
9574 | if (rn1->info) | |
9575 | { | |
9576 | struct ospf_area_range *range = rn1->info; | |
9577 | ||
9578 | vty_out (vty, " area %s range %s/%d", buf, | |
9579 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
9580 | ||
6c835671 | 9581 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 9582 | vty_out (vty, " cost %d", range->cost_config); |
9583 | ||
9584 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
9585 | vty_out (vty, " not-advertise"); | |
9586 | ||
9587 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
9588 | vty_out (vty, " substitute %s/%d", | |
9589 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
9590 | ||
9591 | vty_out (vty, "%s", VTY_NEWLINE); | |
9592 | } | |
9593 | ||
9594 | if (EXPORT_NAME (area)) | |
9595 | vty_out (vty, " area %s export-list %s%s", buf, | |
9596 | EXPORT_NAME (area), VTY_NEWLINE); | |
9597 | ||
9598 | if (IMPORT_NAME (area)) | |
9599 | vty_out (vty, " area %s import-list %s%s", buf, | |
9600 | IMPORT_NAME (area), VTY_NEWLINE); | |
9601 | ||
9602 | if (PREFIX_NAME_IN (area)) | |
9603 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
9604 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
9605 | ||
9606 | if (PREFIX_NAME_OUT (area)) | |
9607 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
9608 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
9609 | } | |
9610 | ||
9611 | return 0; | |
9612 | } | |
9613 | ||
4dadc291 | 9614 | static int |
68980084 | 9615 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 9616 | { |
9617 | struct ospf_nbr_nbma *nbr_nbma; | |
9618 | struct route_node *rn; | |
9619 | ||
9620 | /* Static Neighbor configuration print. */ | |
68980084 | 9621 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 9622 | if ((nbr_nbma = rn->info)) |
9623 | { | |
9624 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
9625 | ||
9626 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
9627 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
9628 | ||
9629 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
9630 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
9631 | ||
9632 | vty_out (vty, "%s", VTY_NEWLINE); | |
9633 | } | |
9634 | ||
9635 | return 0; | |
9636 | } | |
9637 | ||
4dadc291 | 9638 | static int |
68980084 | 9639 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 9640 | { |
52dc7ee6 | 9641 | struct listnode *node; |
1eb8ef25 | 9642 | struct ospf_vl_data *vl_data; |
718e3744 | 9643 | u_char buf[INET_ADDRSTRLEN]; |
9644 | ||
9645 | /* Virtual-Link print */ | |
1eb8ef25 | 9646 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 9647 | { |
52dc7ee6 | 9648 | struct listnode *n2; |
718e3744 | 9649 | struct crypt_key *ck; |
718e3744 | 9650 | struct ospf_interface *oi; |
9651 | ||
9652 | if (vl_data != NULL) | |
9653 | { | |
9654 | memset (buf, 0, INET_ADDRSTRLEN); | |
9655 | ||
9656 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9657 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
718e3744 | 9658 | else |
c9e52be3 | 9659 | sprintf ((char *) buf, "%lu", |
718e3744 | 9660 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
9661 | oi = vl_data->vl_oi; | |
9662 | ||
9663 | /* timers */ | |
9664 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
9665 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
9666 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
9667 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9668 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
9669 | buf, | |
9670 | inet_ntoa (vl_data->vl_peer), | |
9671 | OSPF_IF_PARAM (oi, v_hello), | |
9672 | OSPF_IF_PARAM (oi, retransmit_interval), | |
9673 | OSPF_IF_PARAM (oi, transmit_delay), | |
9674 | OSPF_IF_PARAM (oi, v_wait), | |
9675 | VTY_NEWLINE); | |
9676 | else | |
9677 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
9678 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
9679 | /* Auth key */ | |
9680 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
9681 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
9682 | buf, | |
9683 | inet_ntoa (vl_data->vl_peer), | |
9684 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
9685 | VTY_NEWLINE); | |
9686 | /* md5 keys */ | |
1eb8ef25 | 9687 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
9688 | n2, ck)) | |
9689 | vty_out (vty, " area %s virtual-link %s" | |
9690 | " message-digest-key %d md5 %s%s", | |
9691 | buf, | |
9692 | inet_ntoa (vl_data->vl_peer), | |
9693 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 9694 | |
9695 | } | |
9696 | } | |
9697 | ||
9698 | return 0; | |
9699 | } | |
9700 | ||
6b0655a2 | 9701 | |
4dadc291 | 9702 | static int |
68980084 | 9703 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9704 | { |
9705 | int type; | |
9706 | ||
9707 | /* redistribute print. */ | |
9708 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
9709 | { |
9710 | struct list *red_list; | |
9711 | struct listnode *node; | |
9712 | struct ospf_redist *red; | |
718e3744 | 9713 | |
7c8ff89e DS |
9714 | red_list = ospf->redist[type]; |
9715 | if (!red_list) | |
9716 | continue; | |
9717 | ||
9718 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
9719 | { | |
9720 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
9721 | if (red->instance) | |
9722 | vty_out (vty, " %d", red->instance); | |
9723 | ||
9724 | if (red->dmetric.value >= 0) | |
9725 | vty_out (vty, " metric %d", red->dmetric.value); | |
9726 | ||
9727 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9728 | vty_out (vty, " metric-type 1"); | |
9729 | ||
9730 | if (ROUTEMAP_NAME (red)) | |
9731 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
9732 | ||
9733 | vty_out (vty, "%s", VTY_NEWLINE); | |
9734 | } | |
9735 | } | |
718e3744 | 9736 | |
9737 | return 0; | |
9738 | } | |
9739 | ||
4dadc291 | 9740 | static int |
68980084 | 9741 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 9742 | { |
68980084 | 9743 | if (ospf->default_metric != -1) |
9744 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 9745 | VTY_NEWLINE); |
9746 | return 0; | |
9747 | } | |
9748 | ||
4dadc291 | 9749 | static int |
68980084 | 9750 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9751 | { |
9752 | int type; | |
7c8ff89e | 9753 | struct ospf_redist *red; |
718e3744 | 9754 | |
68980084 | 9755 | if (ospf) |
718e3744 | 9756 | { |
9757 | /* distribute-list print. */ | |
9758 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 9759 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 9760 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 9761 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 9762 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 9763 | |
9764 | /* default-information print. */ | |
68980084 | 9765 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 9766 | { |
c42c177d | 9767 | vty_out (vty, " default-information originate"); |
9768 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
9769 | vty_out (vty, " always"); | |
718e3744 | 9770 | |
7c8ff89e DS |
9771 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
9772 | if (red) | |
9773 | { | |
9774 | if (red->dmetric.value >= 0) | |
9775 | vty_out (vty, " metric %d", | |
9776 | red->dmetric.value); | |
9777 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9778 | vty_out (vty, " metric-type 1"); | |
9779 | ||
9780 | if (ROUTEMAP_NAME (red)) | |
9781 | vty_out (vty, " route-map %s", | |
9782 | ROUTEMAP_NAME (red)); | |
9783 | } | |
718e3744 | 9784 | |
9785 | vty_out (vty, "%s", VTY_NEWLINE); | |
9786 | } | |
9787 | ||
9788 | } | |
9789 | ||
9790 | return 0; | |
9791 | } | |
9792 | ||
4dadc291 | 9793 | static int |
68980084 | 9794 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 9795 | { |
9796 | struct route_node *rn; | |
9797 | struct ospf_distance *odistance; | |
9798 | ||
68980084 | 9799 | if (ospf->distance_all) |
9800 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 9801 | |
68980084 | 9802 | if (ospf->distance_intra |
9803 | || ospf->distance_inter | |
9804 | || ospf->distance_external) | |
718e3744 | 9805 | { |
9806 | vty_out (vty, " distance ospf"); | |
9807 | ||
68980084 | 9808 | if (ospf->distance_intra) |
9809 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
9810 | if (ospf->distance_inter) | |
9811 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
9812 | if (ospf->distance_external) | |
9813 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 9814 | |
9815 | vty_out (vty, "%s", VTY_NEWLINE); | |
9816 | } | |
9817 | ||
68980084 | 9818 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 9819 | if ((odistance = rn->info) != NULL) |
9820 | { | |
9821 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
9822 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9823 | odistance->access_list ? odistance->access_list : "", | |
9824 | VTY_NEWLINE); | |
9825 | } | |
9826 | return 0; | |
9827 | } | |
9828 | ||
9829 | /* OSPF configuration write function. */ | |
4dadc291 | 9830 | static int |
718e3744 | 9831 | ospf_config_write (struct vty *vty) |
9832 | { | |
020709f9 | 9833 | struct ospf *ospf; |
1eb8ef25 | 9834 | struct interface *ifp; |
9835 | struct ospf_interface *oi; | |
52dc7ee6 | 9836 | struct listnode *node; |
718e3744 | 9837 | int write = 0; |
9838 | ||
020709f9 | 9839 | ospf = ospf_lookup (); |
0bad4851 | 9840 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 9841 | { |
9842 | /* `router ospf' print. */ | |
7c8ff89e DS |
9843 | if (ospf->instance) |
9844 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
9845 | else | |
9846 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 9847 | |
9848 | write++; | |
9849 | ||
68980084 | 9850 | if (!ospf->networks) |
718e3744 | 9851 | return write; |
9852 | ||
9853 | /* Router ID print. */ | |
68980084 | 9854 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 9855 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 9856 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 9857 | |
9858 | /* ABR type print. */ | |
d57834f6 | 9859 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 9860 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 9861 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 9862 | |
d7e60dd7 AS |
9863 | /* log-adjacency-changes flag print. */ |
9864 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
9865 | { | |
d7e60dd7 | 9866 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
692c7954 | 9867 | vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE); |
8efe88ea DL |
9868 | else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES) |
9869 | vty_out(vty, " log-adjacency-changes%s", VTY_NEWLINE); | |
d7e60dd7 | 9870 | } |
8efe88ea | 9871 | else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) |
692c7954 DW |
9872 | { |
9873 | vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE); | |
9874 | } | |
d7e60dd7 | 9875 | |
718e3744 | 9876 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 9877 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 9878 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
9879 | ||
9880 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 9881 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 9882 | { |
9883 | vty_out (vty, "! Important: ensure reference bandwidth " | |
9884 | "is consistent across all routers%s", VTY_NEWLINE); | |
9885 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
70bd3c43 | 9886 | ospf->ref_bandwidth, VTY_NEWLINE); |
f9ad937f | 9887 | } |
718e3744 | 9888 | |
9889 | /* SPF timers print. */ | |
68980084 | 9890 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 9891 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
9892 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
9893 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 9894 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 9895 | ospf->spf_max_holdtime, VTY_NEWLINE); |
b6927875 DS |
9896 | |
9897 | /* LSA timers print. */ | |
ac7424f9 MR |
9898 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
9899 | vty_out (vty, " timers throttle lsa all %d%s", | |
9900 | ospf->min_ls_interval, VTY_NEWLINE); | |
9901 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
b6927875 | 9902 | vty_out (vty, " timers lsa min-arrival %d%s", |
ac7424f9 | 9903 | ospf->min_ls_arrival, VTY_NEWLINE); |
b6927875 | 9904 | |
2f8f370e | 9905 | /* Write multiplier print. */ |
e8f45e82 | 9906 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 9907 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 9908 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 9909 | |
88d6cf37 | 9910 | /* Max-metric router-lsa print */ |
9911 | config_write_stub_router (vty, ospf); | |
9912 | ||
718e3744 | 9913 | /* SPF refresh parameters print. */ |
68980084 | 9914 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 9915 | vty_out (vty, " refresh timer %d%s", |
68980084 | 9916 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 9917 | |
9918 | /* Redistribute information print. */ | |
68980084 | 9919 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 9920 | |
9921 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
9922 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
9923 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
9924 | ||
1eb8ef25 | 9925 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
9926 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
9927 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
9928 | ospf->passive_interface_default) | |
9929 | { | |
9930 | vty_out (vty, " %spassive-interface %s%s", | |
9931 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
9932 | ifp->name, VTY_NEWLINE); | |
9933 | } | |
1eb8ef25 | 9934 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
9935 | { |
9936 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
9937 | continue; | |
9938 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
9939 | passive_interface)) | |
9940 | { | |
9941 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
9942 | continue; | |
9943 | } | |
9944 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
9945 | continue; | |
9946 | ||
9947 | vty_out (vty, " %spassive-interface %s %s%s", | |
9948 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 9949 | oi->ifp->name, |
9950 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 9951 | } |
718e3744 | 9952 | |
9953 | /* Network area print. */ | |
68980084 | 9954 | config_write_network_area (vty, ospf); |
718e3744 | 9955 | |
9956 | /* Area config print. */ | |
68980084 | 9957 | config_write_ospf_area (vty, ospf); |
718e3744 | 9958 | |
9959 | /* static neighbor print. */ | |
68980084 | 9960 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 9961 | |
9962 | /* Virtual-Link print. */ | |
68980084 | 9963 | config_write_virtual_link (vty, ospf); |
718e3744 | 9964 | |
9965 | /* Default metric configuration. */ | |
68980084 | 9966 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 9967 | |
9968 | /* Distribute-list and default-information print. */ | |
68980084 | 9969 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 9970 | |
9971 | /* Distance configuration. */ | |
68980084 | 9972 | config_write_ospf_distance (vty, ospf); |
718e3744 | 9973 | |
68980084 | 9974 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 9975 | } |
9976 | ||
9977 | return write; | |
9978 | } | |
9979 | ||
9980 | void | |
4dadc291 | 9981 | ospf_vty_show_init (void) |
718e3744 | 9982 | { |
9983 | /* "show ip ospf" commands. */ | |
9984 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
718e3744 | 9985 | |
7c8ff89e | 9986 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
7c8ff89e | 9987 | |
718e3744 | 9988 | /* "show ip ospf database" commands. */ |
9989 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); | |
9990 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); | |
9991 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
9992 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
9993 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
9994 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); | |
9995 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); | |
718e3744 | 9996 | |
7c8ff89e DS |
9997 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd); |
9998 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
9999 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
10000 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
10001 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
10002 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
10003 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); | |
7c8ff89e | 10004 | |
718e3744 | 10005 | /* "show ip ospf interface" commands. */ |
10006 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
718e3744 | 10007 | |
7c8ff89e | 10008 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
7c8ff89e | 10009 | |
718e3744 | 10010 | /* "show ip ospf neighbor" commands. */ |
10011 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
10012 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
10013 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
10014 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
10015 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
10016 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
10017 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
718e3744 | 10018 | |
7c8ff89e DS |
10019 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
10020 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
10021 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
10022 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
10023 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
10024 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
10025 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
7c8ff89e | 10026 | |
718e3744 | 10027 | /* "show ip ospf route" commands. */ |
10028 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 10029 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
7c8ff89e DS |
10030 | |
10031 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
7c8ff89e | 10032 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); |
718e3744 | 10033 | } |
10034 | ||
6b0655a2 | 10035 | |
718e3744 | 10036 | /* ospfd's interface node. */ |
7fc626de | 10037 | static struct cmd_node interface_node = |
718e3744 | 10038 | { |
10039 | INTERFACE_NODE, | |
10040 | "%s(config-if)# ", | |
10041 | 1 | |
10042 | }; | |
10043 | ||
10044 | /* Initialization of OSPF interface. */ | |
4dadc291 | 10045 | static void |
10046 | ospf_vty_if_init (void) | |
718e3744 | 10047 | { |
10048 | /* Install interface node. */ | |
10049 | install_node (&interface_node, config_write_interface); | |
10050 | ||
10051 | install_element (CONFIG_NODE, &interface_cmd); | |
32d2463c | 10052 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 10053 | install_default (INTERFACE_NODE); |
10054 | ||
10055 | /* "description" commands. */ | |
10056 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
10057 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
10058 | ||
10059 | /* "ip ospf authentication" commands. */ | |
10060 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
10061 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); | |
10062 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); | |
10063 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); | |
b4a039bf DS |
10064 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
10065 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_cmd); | |
718e3744 | 10066 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
10067 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); | |
10068 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); | |
10069 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); | |
813d4307 DW |
10070 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); |
10071 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_cmd); | |
718e3744 | 10072 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
10073 | ||
10074 | /* "ip ospf message-digest-key" commands. */ | |
10075 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); | |
10076 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); | |
10077 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); | |
10078 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
813d4307 DW |
10079 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd); |
10080 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_cmd); | |
718e3744 | 10081 | |
10082 | /* "ip ospf cost" commands. */ | |
9eff36b3 DO |
10083 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
10084 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); | |
827341b7 DO |
10085 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
10086 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 10087 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
718e3744 | 10088 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
10089 | ||
ba682537 | 10090 | /* "ip ospf mtu-ignore" commands. */ |
10091 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
10092 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); | |
10093 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); | |
10094 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); | |
10095 | ||
718e3744 | 10096 | /* "ip ospf dead-interval" commands. */ |
10097 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); | |
10098 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); | |
f9ad937f | 10099 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
10100 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); | |
718e3744 | 10101 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
10102 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); | |
f9dfba8d | 10103 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd); |
f9ad937f | 10104 | |
718e3744 | 10105 | /* "ip ospf hello-interval" commands. */ |
10106 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); | |
10107 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); | |
10108 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); | |
10109 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
f9dfba8d | 10110 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd); |
718e3744 | 10111 | |
10112 | /* "ip ospf network" commands. */ | |
10113 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
10114 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
813d4307 | 10115 | install_element (INTERFACE_NODE, &no_ip_ospf_network_val_cmd); |
718e3744 | 10116 | |
10117 | /* "ip ospf priority" commands. */ | |
10118 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); | |
10119 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); | |
718e3744 | 10120 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
a1afa410 | 10121 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_no_param_cmd); |
813d4307 | 10122 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
718e3744 | 10123 | |
10124 | /* "ip ospf retransmit-interval" commands. */ | |
10125 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
10126 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); | |
10127 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); | |
10128 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); | |
813d4307 DW |
10129 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_addr_cmd); |
10130 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_cmd); | |
718e3744 | 10131 | |
10132 | /* "ip ospf transmit-delay" commands. */ | |
10133 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
10134 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); | |
10135 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); | |
10136 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); | |
813d4307 DW |
10137 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_addr_cmd); |
10138 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_cmd); | |
718e3744 | 10139 | |
953cde65 JT |
10140 | /* "ip ospf area" commands. */ |
10141 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
10142 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
10143 | install_element (INTERFACE_NODE, &no_ip_ospf_area_val_cmd); | |
10144 | install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd); | |
10145 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd); | |
10146 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_val_cmd); | |
10147 | ||
718e3744 | 10148 | /* These commands are compatibitliy for previous version. */ |
10149 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
10150 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); | |
813d4307 DW |
10151 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_cmd); |
10152 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_ip_cmd); | |
718e3744 | 10153 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
10154 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); | |
9eff36b3 DO |
10155 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
10156 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); | |
718e3744 | 10157 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
827341b7 DO |
10158 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
10159 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 10160 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
718e3744 | 10161 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
10162 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); | |
813d4307 DW |
10163 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_addr_cmd); |
10164 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_cmd); | |
718e3744 | 10165 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
10166 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); | |
10167 | install_element (INTERFACE_NODE, &ospf_network_cmd); | |
10168 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); | |
813d4307 | 10169 | install_element (INTERFACE_NODE, &no_ospf_network_val_cmd); |
718e3744 | 10170 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
10171 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); | |
10172 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); | |
10173 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); | |
10174 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); | |
10175 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); | |
10176 | } | |
10177 | ||
4dadc291 | 10178 | static void |
10179 | ospf_vty_zebra_init (void) | |
718e3744 | 10180 | { |
718e3744 | 10181 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 10182 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
10183 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
10184 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 10185 | |
10186 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
10187 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
10188 | ||
718e3744 | 10189 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 10190 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
10191 | ||
10192 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
10193 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
10194 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); | |
10195 | ||
10196 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
10197 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
10198 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 10199 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 10200 | #if 0 |
10201 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
10202 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
10203 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
10204 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
10205 | #endif /* 0 */ | |
10206 | } | |
10207 | ||
7fc626de | 10208 | static struct cmd_node ospf_node = |
718e3744 | 10209 | { |
10210 | OSPF_NODE, | |
10211 | "%s(config-router)# ", | |
10212 | 1 | |
10213 | }; | |
10214 | ||
09f35f8c DS |
10215 | static void |
10216 | ospf_interface_clear (struct interface *ifp) | |
10217 | { | |
10218 | if (!if_is_operative (ifp)) return; | |
10219 | ||
10220 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
10221 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); | |
10222 | ||
10223 | ospf_if_reset(ifp); | |
10224 | } | |
10225 | ||
10226 | DEFUN (clear_ip_ospf_interface, | |
10227 | clear_ip_ospf_interface_cmd, | |
10228 | "clear ip ospf interface [IFNAME]", | |
10229 | CLEAR_STR | |
10230 | IP_STR | |
10231 | "OSPF information\n" | |
10232 | "Interface information\n" | |
10233 | "Interface name\n") | |
10234 | { | |
10235 | struct interface *ifp; | |
10236 | struct listnode *node; | |
10237 | ||
10238 | if (argc == 0) /* Clear all the ospfv2 interfaces. */ | |
10239 | { | |
b2d7c082 | 10240 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
09f35f8c DS |
10241 | ospf_interface_clear(ifp); |
10242 | } | |
10243 | else /* Interface name is specified. */ | |
10244 | { | |
10245 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) | |
10246 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
10247 | else | |
10248 | ospf_interface_clear(ifp); | |
10249 | } | |
10250 | ||
10251 | return CMD_SUCCESS; | |
10252 | } | |
10253 | ||
10254 | void | |
10255 | ospf_vty_clear_init (void) | |
10256 | { | |
10257 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
10258 | } | |
10259 | ||
6b0655a2 | 10260 | |
718e3744 | 10261 | /* Install OSPF related vty commands. */ |
10262 | void | |
4dadc291 | 10263 | ospf_vty_init (void) |
718e3744 | 10264 | { |
10265 | /* Install ospf top node. */ | |
10266 | install_node (&ospf_node, ospf_config_write); | |
10267 | ||
10268 | /* "router ospf" commands. */ | |
10269 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
10270 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
10271 | ||
7c8ff89e DS |
10272 | install_element (CONFIG_NODE, &router_ospf_instance_cmd); |
10273 | install_element (CONFIG_NODE, &no_router_ospf_instance_cmd); | |
10274 | ||
718e3744 | 10275 | install_default (OSPF_NODE); |
10276 | ||
10277 | /* "ospf router-id" commands. */ | |
10278 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
747e489c | 10279 | install_element (OSPF_NODE, &ospf_router_id_old_cmd); |
718e3744 | 10280 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
12fde75b | 10281 | install_element (OSPF_NODE, &no_ospf_router_id_val_cmd); |
718e3744 | 10282 | |
10283 | /* "passive-interface" commands. */ | |
a2c62831 | 10284 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
10285 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); | |
7ffa8fa2 | 10286 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
a2c62831 | 10287 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
10288 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); | |
7ffa8fa2 | 10289 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
718e3744 | 10290 | |
10291 | /* "ospf abr-type" commands. */ | |
10292 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
10293 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
10294 | ||
d7e60dd7 AS |
10295 | /* "ospf log-adjacency-changes" commands. */ |
10296 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
10297 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
10298 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
10299 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
10300 | ||
718e3744 | 10301 | /* "ospf rfc1583-compatible" commands. */ |
10302 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); | |
10303 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
10304 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); | |
10305 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
10306 | ||
10307 | /* "network area" commands. */ | |
a2c62831 | 10308 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
10309 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 10310 | |
10311 | /* "area authentication" commands. */ | |
a2c62831 | 10312 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
10313 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
10314 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 10315 | |
10316 | /* "area range" commands. */ | |
a2c62831 | 10317 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
10318 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); | |
10319 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); | |
10320 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); | |
10321 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); | |
10322 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
10323 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); | |
10324 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); | |
10325 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); | |
10326 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); | |
10327 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 10328 | |
10329 | /* "area virtual-link" commands. */ | |
a2c62831 | 10330 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
10331 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); | |
718e3744 | 10332 | |
a2c62831 | 10333 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
10334 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); | |
718e3744 | 10335 | |
a2c62831 | 10336 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
10337 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); | |
718e3744 | 10338 | |
a2c62831 | 10339 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
10340 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); | |
718e3744 | 10341 | |
a2c62831 | 10342 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
10343 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); | |
718e3744 | 10344 | |
a2c62831 | 10345 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
813d4307 | 10346 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_cmd); |
a2c62831 | 10347 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
10348 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); | |
718e3744 | 10349 | |
a2c62831 | 10350 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
10351 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); | |
718e3744 | 10352 | |
a2c62831 | 10353 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
10354 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); | |
718e3744 | 10355 | |
a2c62831 | 10356 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
813d4307 | 10357 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_authkey_cmd); |
a2c62831 | 10358 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
10359 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); | |
718e3744 | 10360 | |
a2c62831 | 10361 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
813d4307 | 10362 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_md5_cmd); |
a2c62831 | 10363 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
10364 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); | |
718e3744 | 10365 | |
10366 | /* "area stub" commands. */ | |
a2c62831 | 10367 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
10368 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
10369 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
10370 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 10371 | |
718e3744 | 10372 | /* "area nssa" commands. */ |
a2c62831 | 10373 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
10374 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
10375 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
10376 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
10377 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
10378 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); | |
718e3744 | 10379 | |
a2c62831 | 10380 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
10381 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 10382 | |
a2c62831 | 10383 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
10384 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 10385 | |
a2c62831 | 10386 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
10387 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 10388 | |
a2c62831 | 10389 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
10390 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 10391 | |
a2c62831 | 10392 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
10393 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 10394 | |
10395 | /* SPF timer commands */ | |
d24f6e2a | 10396 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
10397 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
b4a039bf | 10398 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_val_cmd); |
d24f6e2a | 10399 | |
b6927875 | 10400 | /* LSA timers commands */ |
ac7424f9 MR |
10401 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
10402 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
813d4307 | 10403 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_val_cmd); |
ac7424f9 MR |
10404 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); |
10405 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
813d4307 | 10406 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_val_cmd); |
b6927875 DS |
10407 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
10408 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
10409 | install_element (OSPF_NODE, &no_ospf_timers_lsa_val_cmd); | |
10410 | ||
88d6cf37 | 10411 | /* refresh timer commands */ |
a2c62831 | 10412 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
10413 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
10414 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); | |
718e3744 | 10415 | |
88d6cf37 | 10416 | /* max-metric commands */ |
10417 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
10418 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
10419 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
10420 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
a1afa410 | 10421 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_no_param_cmd); |
88d6cf37 | 10422 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
10423 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
a1afa410 | 10424 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd); |
88d6cf37 | 10425 | |
10426 | /* reference bandwidth commands */ | |
a2c62831 | 10427 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
10428 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
813d4307 | 10429 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_val_cmd); |
718e3744 | 10430 | |
10431 | /* "neighbor" commands. */ | |
a2c62831 | 10432 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
10433 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); | |
10434 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); | |
10435 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); | |
10436 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); | |
10437 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); | |
10438 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); | |
10439 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); | |
813d4307 DW |
10440 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_priority_cmd); |
10441 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_pollinterval_cmd); | |
718e3744 | 10442 | |
2f8f370e DS |
10443 | /* write multiplier commands */ |
10444 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
10445 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); | |
e8f45e82 DS |
10446 | install_element (OSPF_NODE, &write_multiplier_cmd); |
10447 | install_element (OSPF_NODE, &no_write_multiplier_cmd); | |
813d4307 | 10448 | install_element (OSPF_NODE, &no_write_multiplier_val_cmd); |
2f8f370e | 10449 | |
718e3744 | 10450 | /* Init interface related vty commands. */ |
10451 | ospf_vty_if_init (); | |
10452 | ||
10453 | /* Init zebra related vty commands. */ | |
10454 | ospf_vty_zebra_init (); | |
10455 | } |