]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPF VTY interface. |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 Toshiaki Takada |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #include <zebra.h> | |
91756b38 | 24 | #include <lib/json.h> |
7ec4159b | 25 | #include <string.h> |
718e3744 | 26 | |
27 | #include "memory.h" | |
28 | #include "thread.h" | |
29 | #include "prefix.h" | |
30 | #include "table.h" | |
31 | #include "vty.h" | |
32 | #include "command.h" | |
33 | #include "plist.h" | |
34 | #include "log.h" | |
35 | #include "zclient.h" | |
36 | ||
37 | #include "ospfd/ospfd.h" | |
38 | #include "ospfd/ospf_asbr.h" | |
39 | #include "ospfd/ospf_lsa.h" | |
40 | #include "ospfd/ospf_lsdb.h" | |
41 | #include "ospfd/ospf_ism.h" | |
42 | #include "ospfd/ospf_interface.h" | |
43 | #include "ospfd/ospf_nsm.h" | |
44 | #include "ospfd/ospf_neighbor.h" | |
45 | #include "ospfd/ospf_flood.h" | |
46 | #include "ospfd/ospf_abr.h" | |
47 | #include "ospfd/ospf_spf.h" | |
48 | #include "ospfd/ospf_route.h" | |
49 | #include "ospfd/ospf_zebra.h" | |
50 | /*#include "ospfd/ospf_routemap.h" */ | |
51 | #include "ospfd/ospf_vty.h" | |
52 | #include "ospfd/ospf_dump.h" | |
7f342629 | 53 | #include "ospfd/ospf_bfd.h" |
718e3744 | 54 | |
30a2231a | 55 | static const char *ospf_network_type_str[] = |
718e3744 | 56 | { |
57 | "Null", | |
58 | "POINTOPOINT", | |
59 | "BROADCAST", | |
60 | "NBMA", | |
61 | "POINTOMULTIPOINT", | |
62 | "VIRTUALLINK", | |
63 | "LOOPBACK" | |
64 | }; | |
65 | ||
718e3744 | 66 | /* Utility functions. */ |
4dadc291 | 67 | static int |
6c835671 | 68 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
718e3744 | 69 | { |
70 | char *endptr = NULL; | |
71 | unsigned long ret; | |
72 | ||
73 | /* match "A.B.C.D". */ | |
74 | if (strchr (str, '.') != NULL) | |
75 | { | |
76 | ret = inet_aton (str, area_id); | |
77 | if (!ret) | |
78 | return -1; | |
79 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; | |
80 | } | |
81 | /* match "<0-4294967295>". */ | |
82 | else | |
83 | { | |
664711c1 UW |
84 | if (*str == '-') |
85 | return -1; | |
86 | errno = 0; | |
718e3744 | 87 | ret = strtoul (str, &endptr, 10); |
664711c1 | 88 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
718e3744 | 89 | return -1; |
90 | ||
91 | area_id->s_addr = htonl (ret); | |
92 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; | |
93 | } | |
94 | ||
95 | return 0; | |
96 | } | |
97 | ||
6b0655a2 | 98 | |
4dadc291 | 99 | static int |
6c835671 | 100 | str2metric (const char *str, int *metric) |
718e3744 | 101 | { |
102 | /* Sanity check. */ | |
103 | if (str == NULL) | |
104 | return 0; | |
105 | ||
106 | *metric = strtol (str, NULL, 10); | |
107 | if (*metric < 0 && *metric > 16777214) | |
108 | { | |
109 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
110 | return 0; | |
111 | } | |
112 | ||
113 | return 1; | |
114 | } | |
115 | ||
4dadc291 | 116 | static int |
6c835671 | 117 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 118 | { |
119 | /* Sanity check. */ | |
120 | if (str == NULL) | |
121 | return 0; | |
122 | ||
123 | if (strncmp (str, "1", 1) == 0) | |
124 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
125 | else if (strncmp (str, "2", 1) == 0) | |
126 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
127 | else | |
128 | return 0; | |
129 | ||
130 | return 1; | |
131 | } | |
132 | ||
133 | int | |
134 | ospf_oi_count (struct interface *ifp) | |
135 | { | |
136 | struct route_node *rn; | |
137 | int i = 0; | |
138 | ||
139 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
140 | if (rn->info) | |
141 | i++; | |
142 | ||
143 | return i; | |
144 | } | |
145 | ||
6b0655a2 | 146 | |
718e3744 | 147 | DEFUN (router_ospf, |
148 | router_ospf_cmd, | |
149 | "router ospf", | |
150 | "Enable a routing process\n" | |
151 | "Start OSPF configuration\n") | |
152 | { | |
7c8ff89e DS |
153 | struct ospf *ospf; |
154 | u_short instance = 0; | |
155 | ||
156 | ospf = ospf_lookup(); | |
157 | if (!ospf) | |
158 | { | |
159 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
160 | return CMD_WARNING; | |
161 | } | |
162 | ||
718e3744 | 163 | vty->node = OSPF_NODE; |
7c8ff89e DS |
164 | |
165 | if (argc) | |
166 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
167 | ||
168 | /* The following logic to set the vty->index is in place to be able | |
169 | to ignore the commands which dont belong to this instance. */ | |
170 | if (ospf->instance != instance) | |
171 | vty->index = NULL; | |
172 | else | |
0bad4851 DS |
173 | { |
174 | if (IS_DEBUG_OSPF_EVENT) | |
175 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
176 | ospf->oi_running = 1; | |
177 | vty->index = ospf; | |
178 | ospf_router_id_update (ospf); | |
179 | } | |
718e3744 | 180 | |
181 | return CMD_SUCCESS; | |
182 | } | |
183 | ||
7c8ff89e DS |
184 | ALIAS (router_ospf, |
185 | router_ospf_instance_cmd, | |
186 | "router ospf <1-65535>", | |
187 | "Enable a routing process\n" | |
188 | "Start OSPF configuration\n" | |
189 | "Instance ID\n") | |
190 | ||
718e3744 | 191 | DEFUN (no_router_ospf, |
192 | no_router_ospf_cmd, | |
193 | "no router ospf", | |
194 | NO_STR | |
195 | "Enable a routing process\n" | |
196 | "Start OSPF configuration\n") | |
197 | { | |
020709f9 | 198 | struct ospf *ospf; |
7c8ff89e | 199 | u_short instance = 0; |
020709f9 | 200 | |
7c8ff89e DS |
201 | if (argc) |
202 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
203 | ||
204 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
205 | return CMD_SUCCESS; | |
718e3744 | 206 | |
020709f9 | 207 | ospf_finish (ospf); |
718e3744 | 208 | |
209 | return CMD_SUCCESS; | |
210 | } | |
211 | ||
7c8ff89e DS |
212 | ALIAS (no_router_ospf, |
213 | no_router_ospf_instance_cmd, | |
214 | "no router ospf <1-65535>", | |
215 | NO_STR | |
216 | "Enable a routing process\n" | |
217 | "Start OSPF configuration\n" | |
218 | "Instance ID\n") | |
219 | ||
718e3744 | 220 | DEFUN (ospf_router_id, |
221 | ospf_router_id_cmd, | |
222 | "ospf router-id A.B.C.D", | |
223 | "OSPF specific commands\n" | |
224 | "router-id for the OSPF process\n" | |
225 | "OSPF router-id in IP address format\n") | |
226 | { | |
68980084 | 227 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
228 | struct listnode *node; |
229 | struct ospf_area *area; | |
718e3744 | 230 | struct in_addr router_id; |
68980084 | 231 | int ret; |
718e3744 | 232 | |
7c8ff89e DS |
233 | if (!ospf) |
234 | return CMD_SUCCESS; | |
235 | ||
718e3744 | 236 | ret = inet_aton (argv[0], &router_id); |
237 | if (!ret) | |
238 | { | |
239 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
240 | return CMD_WARNING; | |
241 | } | |
242 | ||
68980084 | 243 | ospf->router_id_static = router_id; |
2c19a6ec DS |
244 | |
245 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
246 | if (area->full_nbrs) | |
247 | { | |
248 | vty_out (vty, "For this router-id change to take effect," | |
249 | " save config and restart ospfd%s", VTY_NEWLINE); | |
250 | return CMD_SUCCESS; | |
251 | } | |
252 | ||
b29800a6 | 253 | ospf_router_id_update (ospf); |
254 | ||
718e3744 | 255 | return CMD_SUCCESS; |
256 | } | |
257 | ||
747e489c DW |
258 | ALIAS_HIDDEN (ospf_router_id, |
259 | ospf_router_id_old_cmd, | |
260 | "router-id A.B.C.D", | |
261 | "router-id for the OSPF process\n" | |
262 | "OSPF router-id in IP address format\n") | |
263 | ||
718e3744 | 264 | DEFUN (no_ospf_router_id, |
265 | no_ospf_router_id_cmd, | |
266 | "no ospf router-id", | |
267 | NO_STR | |
268 | "OSPF specific commands\n" | |
269 | "router-id for the OSPF process\n") | |
270 | { | |
68980084 | 271 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
272 | struct listnode *node; |
273 | struct ospf_area *area; | |
68980084 | 274 | |
7c8ff89e DS |
275 | if (!ospf) |
276 | return CMD_SUCCESS; | |
277 | ||
68980084 | 278 | ospf->router_id_static.s_addr = 0; |
718e3744 | 279 | |
2c19a6ec DS |
280 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
281 | if (area->full_nbrs) | |
282 | { | |
283 | vty_out (vty, "For this router-id change to take effect," | |
284 | " save config and restart ospfd%s", VTY_NEWLINE); | |
285 | return CMD_SUCCESS; | |
286 | } | |
287 | ||
68980084 | 288 | ospf_router_id_update (ospf); |
718e3744 | 289 | |
290 | return CMD_SUCCESS; | |
291 | } | |
292 | ||
293 | ALIAS (no_ospf_router_id, | |
12fde75b DW |
294 | no_ospf_router_id_val_cmd, |
295 | "no ospf router-id A.B.C.D", | |
718e3744 | 296 | NO_STR |
12fde75b DW |
297 | "OSPF specific commands\n" |
298 | "router-id for the OSPF process\n" | |
299 | "OSPF router-id in IP address format\n") | |
718e3744 | 300 | |
7ffa8fa2 | 301 | static void |
43540886 | 302 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
303 | { |
304 | struct listnode *ln; | |
305 | struct interface *ifp; | |
306 | struct ospf_interface *oi; | |
307 | ||
43540886 AS |
308 | ospf->passive_interface_default = newval; |
309 | ||
7ffa8fa2 PJ |
310 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
311 | { | |
312 | if (ifp && | |
313 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
314 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
315 | } | |
316 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
317 | { | |
318 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
319 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
320 | /* update multicast memberships */ |
321 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
322 | } |
323 | } | |
324 | ||
325 | static void | |
f842f166 PJ |
326 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
327 | struct ospf_if_params *params, u_char value, | |
328 | struct in_addr addr) | |
7ffa8fa2 PJ |
329 | { |
330 | u_char dflt; | |
331 | ||
332 | params->passive_interface = value; | |
333 | if (params != IF_DEF_PARAMS (ifp)) | |
334 | { | |
335 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
336 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
337 | else | |
338 | dflt = ospf->passive_interface_default; | |
339 | ||
340 | if (value != dflt) | |
341 | SET_IF_PARAM (params, passive_interface); | |
342 | else | |
343 | UNSET_IF_PARAM (params, passive_interface); | |
344 | ||
345 | ospf_free_if_params (ifp, addr); | |
346 | ospf_if_update_params (ifp, addr); | |
347 | } | |
f842f166 PJ |
348 | } |
349 | ||
350 | static void | |
351 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
352 | struct ospf_if_params *params, u_char value) | |
353 | { | |
354 | params->passive_interface = value; | |
355 | if (params == IF_DEF_PARAMS (ifp)) | |
7ffa8fa2 PJ |
356 | { |
357 | if (value != ospf->passive_interface_default) | |
358 | SET_IF_PARAM (params, passive_interface); | |
359 | else | |
360 | UNSET_IF_PARAM (params, passive_interface); | |
361 | } | |
362 | } | |
363 | ||
a2c62831 | 364 | DEFUN (ospf_passive_interface, |
365 | ospf_passive_interface_addr_cmd, | |
718e3744 | 366 | "passive-interface IFNAME A.B.C.D", |
367 | "Suppress routing updates on an interface\n" | |
368 | "Interface's name\n") | |
369 | { | |
7ffa8fa2 | 370 | struct interface *ifp; |
cb2af5d0 | 371 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
7ffa8fa2 PJ |
372 | int ret; |
373 | struct ospf_if_params *params; | |
374 | struct route_node *rn; | |
375 | struct ospf *ospf = vty->index; | |
718e3744 | 376 | |
7c8ff89e DS |
377 | if (!ospf) |
378 | return CMD_SUCCESS; | |
379 | ||
43540886 AS |
380 | if (argc == 0) |
381 | { | |
382 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
383 | return CMD_SUCCESS; | |
384 | } | |
385 | ||
7ffa8fa2 | 386 | ifp = if_get_by_name (argv[0]); |
718e3744 | 387 | |
388 | params = IF_DEF_PARAMS (ifp); | |
389 | ||
43540886 | 390 | if (argc == 2) |
718e3744 | 391 | { |
43540886 AS |
392 | ret = inet_aton(argv[1], &addr); |
393 | if (!ret) | |
394 | { | |
395 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
396 | VTY_NEWLINE); | |
397 | return CMD_WARNING; | |
398 | } | |
399 | ||
400 | params = ospf_get_if_params (ifp, addr); | |
401 | ospf_if_update_params (ifp, addr); | |
f842f166 PJ |
402 | ospf_passive_interface_update_addr (ospf, ifp, params, |
403 | OSPF_IF_PASSIVE, addr); | |
7ffa8fa2 | 404 | } |
f842f166 PJ |
405 | |
406 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); | |
43540886 | 407 | |
ba6454ec | 408 | /* XXX We should call ospf_if_set_multicast on exactly those |
409 | * interfaces for which the passive property changed. It is too much | |
410 | * work to determine this set, so we do this for every interface. | |
411 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
412 | * record of joined groups to avoid systems calls if the desired | |
413 | * memberships match the current memership. | |
414 | */ | |
7ffa8fa2 | 415 | |
ba6454ec | 416 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
417 | { | |
418 | struct ospf_interface *oi = rn->info; | |
419 | ||
420 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 421 | ospf_if_set_multicast(oi); |
ba6454ec | 422 | } |
423 | /* | |
424 | * XXX It is not clear what state transitions the interface needs to | |
425 | * undergo when going from active to passive. Fixing this will | |
426 | * require precise identification of interfaces having such a | |
427 | * transition. | |
428 | */ | |
429 | ||
718e3744 | 430 | return CMD_SUCCESS; |
431 | } | |
432 | ||
a2c62831 | 433 | ALIAS (ospf_passive_interface, |
434 | ospf_passive_interface_cmd, | |
718e3744 | 435 | "passive-interface IFNAME", |
436 | "Suppress routing updates on an interface\n" | |
437 | "Interface's name\n") | |
438 | ||
7ffa8fa2 PJ |
439 | ALIAS (ospf_passive_interface, |
440 | ospf_passive_interface_default_cmd, | |
441 | "passive-interface default", | |
442 | "Suppress routing updates on an interface\n" | |
443 | "Suppress routing updates on interfaces by default\n") | |
444 | ||
a2c62831 | 445 | DEFUN (no_ospf_passive_interface, |
446 | no_ospf_passive_interface_addr_cmd, | |
718e3744 | 447 | "no passive-interface IFNAME A.B.C.D", |
448 | NO_STR | |
449 | "Allow routing updates on an interface\n" | |
450 | "Interface's name\n") | |
451 | { | |
452 | struct interface *ifp; | |
cb2af5d0 | 453 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
718e3744 | 454 | struct ospf_if_params *params; |
455 | int ret; | |
ba6454ec | 456 | struct route_node *rn; |
7ffa8fa2 | 457 | struct ospf *ospf = vty->index; |
43540886 | 458 | |
7c8ff89e DS |
459 | if (!ospf) |
460 | return CMD_SUCCESS; | |
461 | ||
43540886 AS |
462 | if (argc == 0) |
463 | { | |
464 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
465 | return CMD_SUCCESS; | |
466 | } | |
718e3744 | 467 | |
6e72cb6a | 468 | ifp = if_get_by_name (argv[0]); |
718e3744 | 469 | |
470 | params = IF_DEF_PARAMS (ifp); | |
471 | ||
43540886 | 472 | if (argc == 2) |
718e3744 | 473 | { |
43540886 AS |
474 | ret = inet_aton(argv[1], &addr); |
475 | if (!ret) | |
476 | { | |
477 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
478 | VTY_NEWLINE); | |
479 | return CMD_WARNING; | |
480 | } | |
481 | ||
482 | params = ospf_lookup_if_params (ifp, addr); | |
483 | if (params == NULL) | |
484 | return CMD_SUCCESS; | |
f842f166 PJ |
485 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
486 | addr); | |
718e3744 | 487 | } |
f842f166 PJ |
488 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
489 | ||
ba6454ec | 490 | /* XXX We should call ospf_if_set_multicast on exactly those |
491 | * interfaces for which the passive property changed. It is too much | |
492 | * work to determine this set, so we do this for every interface. | |
493 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
494 | * record of joined groups to avoid systems calls if the desired | |
495 | * memberships match the current memership. | |
496 | */ | |
497 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
498 | { | |
499 | struct ospf_interface *oi = rn->info; | |
500 | ||
501 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
502 | ospf_if_set_multicast(oi); | |
503 | } | |
504 | ||
718e3744 | 505 | return CMD_SUCCESS; |
506 | } | |
507 | ||
a2c62831 | 508 | ALIAS (no_ospf_passive_interface, |
509 | no_ospf_passive_interface_cmd, | |
718e3744 | 510 | "no passive-interface IFNAME", |
511 | NO_STR | |
512 | "Allow routing updates on an interface\n" | |
513 | "Interface's name\n") | |
514 | ||
7ffa8fa2 PJ |
515 | ALIAS (no_ospf_passive_interface, |
516 | no_ospf_passive_interface_default_cmd, | |
517 | "no passive-interface default", | |
518 | NO_STR | |
519 | "Allow routing updates on an interface\n" | |
520 | "Allow routing updates on interfaces by default\n") | |
521 | ||
a2c62831 | 522 | DEFUN (ospf_network_area, |
523 | ospf_network_area_cmd, | |
718e3744 | 524 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
525 | "Enable routing on an IP network\n" | |
526 | "OSPF network prefix\n" | |
527 | "Set the OSPF area ID\n" | |
528 | "OSPF area ID in IP address format\n" | |
529 | "OSPF area ID as a decimal value\n") | |
530 | { | |
531 | struct ospf *ospf= vty->index; | |
532 | struct prefix_ipv4 p; | |
533 | struct in_addr area_id; | |
534 | int ret, format; | |
535 | ||
7c8ff89e DS |
536 | if (!ospf) |
537 | return CMD_SUCCESS; | |
538 | ||
539 | if (ospf->instance) | |
540 | { | |
541 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
542 | VTY_NEWLINE); | |
543 | return CMD_WARNING; | |
544 | } | |
545 | ||
e723861d DS |
546 | if (ospf->if_ospf_cli_count > 0) |
547 | { | |
548 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
549 | VTY_NEWLINE); | |
550 | return CMD_WARNING; | |
551 | } | |
552 | ||
718e3744 | 553 | /* Get network prefix and Area ID. */ |
554 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
555 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
556 | ||
557 | ret = ospf_network_set (ospf, &p, area_id); | |
558 | if (ret == 0) | |
559 | { | |
560 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
561 | return CMD_WARNING; | |
562 | } | |
563 | ||
564 | return CMD_SUCCESS; | |
565 | } | |
566 | ||
a2c62831 | 567 | DEFUN (no_ospf_network_area, |
568 | no_ospf_network_area_cmd, | |
718e3744 | 569 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
570 | NO_STR | |
571 | "Enable routing on an IP network\n" | |
572 | "OSPF network prefix\n" | |
573 | "Set the OSPF area ID\n" | |
574 | "OSPF area ID in IP address format\n" | |
575 | "OSPF area ID as a decimal value\n") | |
576 | { | |
577 | struct ospf *ospf = (struct ospf *) vty->index; | |
578 | struct prefix_ipv4 p; | |
579 | struct in_addr area_id; | |
580 | int ret, format; | |
581 | ||
7c8ff89e DS |
582 | if (!ospf) |
583 | return CMD_SUCCESS; | |
584 | ||
585 | if (ospf->instance) | |
586 | { | |
587 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
588 | VTY_NEWLINE); | |
589 | return CMD_WARNING; | |
590 | } | |
591 | ||
718e3744 | 592 | /* Get network prefix and Area ID. */ |
593 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); | |
594 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); | |
595 | ||
596 | ret = ospf_network_unset (ospf, &p, area_id); | |
597 | if (ret == 0) | |
598 | { | |
599 | vty_out (vty, "Can't find specified network area configuration.%s", | |
600 | VTY_NEWLINE); | |
601 | return CMD_WARNING; | |
602 | } | |
603 | ||
604 | return CMD_SUCCESS; | |
605 | } | |
606 | ||
6b0655a2 | 607 | |
a2c62831 | 608 | DEFUN (ospf_area_range, |
609 | ospf_area_range_cmd, | |
718e3744 | 610 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
611 | "OSPF area parameters\n" | |
612 | "OSPF area ID in IP address format\n" | |
613 | "OSPF area ID as a decimal value\n" | |
614 | "Summarize routes matching address/mask (border routers only)\n" | |
615 | "Area range prefix\n") | |
616 | { | |
617 | struct ospf *ospf = vty->index; | |
618 | struct prefix_ipv4 p; | |
619 | struct in_addr area_id; | |
620 | int format; | |
621 | u_int32_t cost; | |
622 | ||
7c8ff89e DS |
623 | if (!ospf) |
624 | return CMD_SUCCESS; | |
625 | ||
718e3744 | 626 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
627 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
628 | ||
629 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
630 | if (argc > 2) | |
631 | { | |
4dadc291 | 632 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
718e3744 | 633 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
634 | } | |
635 | ||
636 | return CMD_SUCCESS; | |
637 | } | |
638 | ||
a2c62831 | 639 | ALIAS (ospf_area_range, |
640 | ospf_area_range_advertise_cmd, | |
718e3744 | 641 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
642 | "OSPF area parameters\n" | |
643 | "OSPF area ID in IP address format\n" | |
644 | "OSPF area ID as a decimal value\n" | |
645 | "OSPF area range for route advertise (default)\n" | |
646 | "Area range prefix\n" | |
647 | "Advertise this range (default)\n") | |
648 | ||
a2c62831 | 649 | ALIAS (ospf_area_range, |
650 | ospf_area_range_cost_cmd, | |
718e3744 | 651 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
652 | "OSPF area parameters\n" | |
653 | "OSPF area ID in IP address format\n" | |
654 | "OSPF area ID as a decimal value\n" | |
655 | "Summarize routes matching address/mask (border routers only)\n" | |
656 | "Area range prefix\n" | |
657 | "User specified metric for this range\n" | |
658 | "Advertised metric for this range\n") | |
659 | ||
a2c62831 | 660 | ALIAS (ospf_area_range, |
661 | ospf_area_range_advertise_cost_cmd, | |
718e3744 | 662 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
663 | "OSPF area parameters\n" | |
664 | "OSPF area ID in IP address format\n" | |
665 | "OSPF area ID as a decimal value\n" | |
666 | "Summarize routes matching address/mask (border routers only)\n" | |
667 | "Area range prefix\n" | |
668 | "Advertise this range (default)\n" | |
669 | "User specified metric for this range\n" | |
670 | "Advertised metric for this range\n") | |
671 | ||
a2c62831 | 672 | DEFUN (ospf_area_range_not_advertise, |
673 | ospf_area_range_not_advertise_cmd, | |
718e3744 | 674 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
675 | "OSPF area parameters\n" | |
676 | "OSPF area ID in IP address format\n" | |
677 | "OSPF area ID as a decimal value\n" | |
678 | "Summarize routes matching address/mask (border routers only)\n" | |
679 | "Area range prefix\n" | |
680 | "DoNotAdvertise this range\n") | |
681 | { | |
682 | struct ospf *ospf = vty->index; | |
683 | struct prefix_ipv4 p; | |
684 | struct in_addr area_id; | |
685 | int format; | |
686 | ||
7c8ff89e DS |
687 | if (!ospf) |
688 | return CMD_SUCCESS; | |
689 | ||
718e3744 | 690 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
691 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
692 | ||
693 | ospf_area_range_set (ospf, area_id, &p, 0); | |
694 | ||
695 | return CMD_SUCCESS; | |
696 | } | |
697 | ||
a2c62831 | 698 | DEFUN (no_ospf_area_range, |
699 | no_ospf_area_range_cmd, | |
718e3744 | 700 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
701 | NO_STR | |
702 | "OSPF area parameters\n" | |
703 | "OSPF area ID in IP address format\n" | |
704 | "OSPF area ID as a decimal value\n" | |
705 | "Summarize routes matching address/mask (border routers only)\n" | |
706 | "Area range prefix\n") | |
707 | { | |
708 | struct ospf *ospf = vty->index; | |
709 | struct prefix_ipv4 p; | |
710 | struct in_addr area_id; | |
711 | int format; | |
712 | ||
7c8ff89e DS |
713 | if (!ospf) |
714 | return CMD_SUCCESS; | |
715 | ||
718e3744 | 716 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
717 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
718 | ||
719 | ospf_area_range_unset (ospf, area_id, &p); | |
720 | ||
721 | return CMD_SUCCESS; | |
722 | } | |
723 | ||
a2c62831 | 724 | ALIAS (no_ospf_area_range, |
725 | no_ospf_area_range_advertise_cmd, | |
718e3744 | 726 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
727 | NO_STR | |
728 | "OSPF area parameters\n" | |
729 | "OSPF area ID in IP address format\n" | |
730 | "OSPF area ID as a decimal value\n" | |
731 | "Summarize routes matching address/mask (border routers only)\n" | |
732 | "Area range prefix\n" | |
733 | "Advertise this range (default)\n" | |
734 | "DoNotAdvertise this range\n") | |
735 | ||
a2c62831 | 736 | ALIAS (no_ospf_area_range, |
737 | no_ospf_area_range_cost_cmd, | |
718e3744 | 738 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
739 | NO_STR | |
740 | "OSPF area parameters\n" | |
741 | "OSPF area ID in IP address format\n" | |
742 | "OSPF area ID as a decimal value\n" | |
743 | "Summarize routes matching address/mask (border routers only)\n" | |
744 | "Area range prefix\n" | |
745 | "User specified metric for this range\n" | |
746 | "Advertised metric for this range\n") | |
747 | ||
a2c62831 | 748 | ALIAS (no_ospf_area_range, |
749 | no_ospf_area_range_advertise_cost_cmd, | |
718e3744 | 750 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
751 | NO_STR | |
752 | "OSPF area parameters\n" | |
753 | "OSPF area ID in IP address format\n" | |
754 | "OSPF area ID as a decimal value\n" | |
755 | "Summarize routes matching address/mask (border routers only)\n" | |
756 | "Area range prefix\n" | |
757 | "Advertise this range (default)\n" | |
758 | "User specified metric for this range\n" | |
759 | "Advertised metric for this range\n") | |
6b0655a2 | 760 | |
a2c62831 | 761 | DEFUN (ospf_area_range_substitute, |
762 | ospf_area_range_substitute_cmd, | |
718e3744 | 763 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
764 | "OSPF area parameters\n" | |
765 | "OSPF area ID in IP address format\n" | |
766 | "OSPF area ID as a decimal value\n" | |
767 | "Summarize routes matching address/mask (border routers only)\n" | |
768 | "Area range prefix\n" | |
769 | "Announce area range as another prefix\n" | |
770 | "Network prefix to be announced instead of range\n") | |
771 | { | |
772 | struct ospf *ospf = vty->index; | |
773 | struct prefix_ipv4 p, s; | |
774 | struct in_addr area_id; | |
775 | int format; | |
776 | ||
7c8ff89e DS |
777 | if (!ospf) |
778 | return CMD_SUCCESS; | |
779 | ||
718e3744 | 780 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
781 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
782 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
783 | ||
784 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
785 | ||
786 | return CMD_SUCCESS; | |
787 | } | |
788 | ||
a2c62831 | 789 | DEFUN (no_ospf_area_range_substitute, |
790 | no_ospf_area_range_substitute_cmd, | |
718e3744 | 791 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
792 | NO_STR | |
793 | "OSPF area parameters\n" | |
794 | "OSPF area ID in IP address format\n" | |
795 | "OSPF area ID as a decimal value\n" | |
796 | "Summarize routes matching address/mask (border routers only)\n" | |
797 | "Area range prefix\n" | |
798 | "Announce area range as another prefix\n" | |
799 | "Network prefix to be announced instead of range\n") | |
800 | { | |
801 | struct ospf *ospf = vty->index; | |
802 | struct prefix_ipv4 p, s; | |
803 | struct in_addr area_id; | |
804 | int format; | |
805 | ||
7c8ff89e DS |
806 | if (!ospf) |
807 | return CMD_SUCCESS; | |
808 | ||
718e3744 | 809 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
810 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); | |
811 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); | |
812 | ||
813 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
814 | ||
815 | return CMD_SUCCESS; | |
816 | } | |
817 | ||
6b0655a2 | 818 | |
718e3744 | 819 | /* Command Handler Logic in VLink stuff is delicate!! |
820 | ||
821 | ALTER AT YOUR OWN RISK!!!! | |
822 | ||
823 | Various dummy values are used to represent 'NoChange' state for | |
824 | VLink configuration NOT being changed by a VLink command, and | |
825 | special syntax is used within the command strings so that the | |
826 | typed in command verbs can be seen in the configuration command | |
827 | bacckend handler. This is to drastically reduce the verbeage | |
828 | required to coe up with a reasonably compatible Cisco VLink command | |
829 | ||
830 | - Matthew Grant <grantma@anathoth.gen.nz> | |
831 | Wed, 21 Feb 2001 15:13:52 +1300 | |
832 | */ | |
833 | ||
834 | ||
835 | /* Configuration data for virtual links | |
836 | */ | |
837 | struct ospf_vl_config_data { | |
838 | struct vty *vty; /* vty stuff */ | |
839 | struct in_addr area_id; /* area ID from command line */ | |
840 | int format; /* command line area ID format */ | |
841 | struct in_addr vl_peer; /* command line vl_peer */ | |
842 | int auth_type; /* Authehntication type, if given */ | |
843 | char *auth_key; /* simple password if present */ | |
844 | int crypto_key_id; /* Cryptographic key ID */ | |
845 | char *md5_key; /* MD5 authentication key */ | |
846 | int hello_interval; /* Obvious what these are... */ | |
847 | int retransmit_interval; | |
848 | int transmit_delay; | |
849 | int dead_interval; | |
850 | }; | |
851 | ||
4dadc291 | 852 | static void |
718e3744 | 853 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
854 | struct vty *vty) | |
855 | { | |
856 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
857 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
858 | vl_config->vty = vty; | |
859 | } | |
860 | ||
4dadc291 | 861 | static struct ospf_vl_data * |
68980084 | 862 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 863 | { |
864 | struct ospf_area *area; | |
865 | struct ospf_vl_data *vl_data; | |
866 | struct vty *vty; | |
867 | struct in_addr area_id; | |
868 | ||
869 | vty = vl_config->vty; | |
870 | area_id = vl_config->area_id; | |
871 | ||
872 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
873 | { | |
874 | vty_out (vty, | |
875 | "Configuring VLs over the backbone is not allowed%s", | |
876 | VTY_NEWLINE); | |
877 | return NULL; | |
878 | } | |
68980084 | 879 | area = ospf_area_get (ospf, area_id, vl_config->format); |
718e3744 | 880 | |
881 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
882 | { | |
883 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
884 | vty_out (vty, "Area %s is %s%s", | |
885 | inet_ntoa (area_id), | |
718e3744 | 886 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 887 | VTY_NEWLINE); |
888 | else | |
889 | vty_out (vty, "Area %ld is %s%s", | |
890 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 891 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 892 | VTY_NEWLINE); |
893 | return NULL; | |
894 | } | |
895 | ||
9c27ef9b | 896 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 897 | { |
898 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
899 | if (vl_data->vl_oi == NULL) | |
900 | { | |
68980084 | 901 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
902 | ospf_vl_add (ospf, vl_data); | |
d3a9c768 | 903 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 904 | } |
905 | } | |
906 | return vl_data; | |
907 | } | |
908 | ||
909 | ||
4dadc291 | 910 | static int |
718e3744 | 911 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
912 | struct ospf_vl_config_data *vl_config) | |
913 | { | |
914 | struct crypt_key *ck; | |
915 | struct vty *vty; | |
916 | struct interface *ifp = vl_data->vl_oi->ifp; | |
917 | ||
918 | vty = vl_config->vty; | |
919 | ||
920 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
921 | { | |
922 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
923 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
924 | } | |
925 | ||
926 | if (vl_config->auth_key) | |
927 | { | |
928 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 929 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 930 | OSPF_AUTH_SIMPLE_SIZE); |
931 | } | |
932 | else if (vl_config->md5_key) | |
933 | { | |
934 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
935 | != NULL) | |
936 | { | |
937 | vty_out (vty, "OSPF: Key %d already exists%s", | |
938 | vl_config->crypto_key_id, VTY_NEWLINE); | |
939 | return CMD_WARNING; | |
940 | } | |
941 | ck = ospf_crypt_key_new (); | |
942 | ck->key_id = vl_config->crypto_key_id; | |
943 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 944 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 945 | |
946 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
947 | } | |
948 | else if (vl_config->crypto_key_id != 0) | |
949 | { | |
950 | /* Delete a key */ | |
951 | ||
952 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
953 | vl_config->crypto_key_id) == NULL) | |
954 | { | |
955 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
956 | vl_config->crypto_key_id, VTY_NEWLINE); | |
957 | return CMD_WARNING; | |
958 | } | |
959 | ||
960 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
961 | ||
962 | } | |
963 | ||
964 | return CMD_SUCCESS; | |
965 | } | |
966 | ||
4dadc291 | 967 | static int |
718e3744 | 968 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
969 | struct ospf_vl_config_data *vl_config) | |
970 | { | |
971 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; | |
972 | /* Virtual Link data initialised to defaults, so only set | |
973 | if a value given */ | |
974 | if (vl_config->hello_interval) | |
975 | { | |
976 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
977 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
978 | } | |
979 | ||
980 | if (vl_config->dead_interval) | |
981 | { | |
982 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
983 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
984 | } | |
985 | ||
986 | if (vl_config->retransmit_interval) | |
987 | { | |
988 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
989 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
990 | } | |
991 | ||
992 | if (vl_config->transmit_delay) | |
993 | { | |
994 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
995 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
996 | } | |
997 | ||
998 | return CMD_SUCCESS; | |
999 | } | |
1000 | ||
1001 | ||
1002 | ||
1003 | /* The business end of all of the above */ | |
4dadc291 | 1004 | static int |
68980084 | 1005 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 1006 | { |
1007 | struct ospf_vl_data *vl_data; | |
1008 | int ret; | |
1009 | ||
68980084 | 1010 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 1011 | if (!vl_data) |
1012 | return CMD_WARNING; | |
1013 | ||
1014 | /* Process this one first as it can have a fatal result, which can | |
1015 | only logically occur if the virtual link exists already | |
1016 | Thus a command error does not result in a change to the | |
1017 | running configuration such as unexpectedly altered timer | |
1018 | values etc.*/ | |
1019 | ret = ospf_vl_set_security (vl_data, vl_config); | |
1020 | if (ret != CMD_SUCCESS) | |
1021 | return ret; | |
1022 | ||
1023 | /* Set any time based parameters, these area already range checked */ | |
1024 | ||
1025 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
1026 | if (ret != CMD_SUCCESS) | |
1027 | return ret; | |
1028 | ||
1029 | return CMD_SUCCESS; | |
1030 | ||
1031 | } | |
1032 | ||
1033 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1034 | */ | |
1035 | #define VLINK_HELPSTR_IPADDR \ | |
1036 | "OSPF area parameters\n" \ | |
1037 | "OSPF area ID in IP address format\n" \ | |
1038 | "OSPF area ID as a decimal value\n" \ | |
1039 | "Configure a virtual link\n" \ | |
1040 | "Router ID of the remote ABR\n" | |
1041 | ||
1042 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1043 | "Enable authentication on this virtual link\n" \ | |
1044 | "dummy string \n" | |
1045 | ||
1046 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1047 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1048 | "Use null authentication\n" \ | |
1049 | "Use message-digest authentication\n" | |
1050 | ||
1051 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1052 | "Time between HELLO packets\n" \ | |
1053 | "Time between retransmitting lost link state advertisements\n" \ | |
1054 | "Link state transmit delay\n" \ | |
1055 | "Interval after which a neighbor is declared dead\n" | |
1056 | ||
1057 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1058 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1059 | "Seconds\n" | |
1060 | ||
1061 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1062 | "Authentication password (key)\n" \ | |
1063 | "The OSPF password (key)" | |
1064 | ||
1065 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1066 | "Message digest authentication password (key)\n" \ | |
1067 | "dummy string \n" \ | |
1068 | "Key ID\n" \ | |
1069 | "Use MD5 algorithm\n" \ | |
1070 | "The OSPF password (key)" | |
1071 | ||
a2c62831 | 1072 | DEFUN (ospf_area_vlink, |
1073 | ospf_area_vlink_cmd, | |
718e3744 | 1074 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1075 | VLINK_HELPSTR_IPADDR) | |
1076 | { | |
68980084 | 1077 | struct ospf *ospf = vty->index; |
718e3744 | 1078 | struct ospf_vl_config_data vl_config; |
1079 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1080 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1081 | int i; | |
1082 | int ret; | |
1083 | ||
7c8ff89e DS |
1084 | if (!ospf) |
1085 | return CMD_SUCCESS; | |
1086 | ||
718e3744 | 1087 | ospf_vl_config_data_init(&vl_config, vty); |
1088 | ||
1089 | /* Read off first 2 parameters and check them */ | |
1090 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); | |
1091 | if (ret < 0) | |
1092 | { | |
1093 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1094 | return CMD_WARNING; | |
1095 | } | |
1096 | ||
1097 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1098 | if (! ret) | |
1099 | { | |
1100 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1101 | VTY_NEWLINE); | |
1102 | return CMD_WARNING; | |
1103 | } | |
1104 | ||
1105 | if (argc <=2) | |
1106 | { | |
1107 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1108 | ||
68980084 | 1109 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1110 | } |
1111 | ||
1112 | /* Deal with other parameters */ | |
1113 | for (i=2; i < argc; i++) | |
1114 | { | |
1115 | ||
1116 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ | |
1117 | ||
1118 | switch (argv[i][0]) | |
1119 | { | |
1120 | ||
1121 | case 'a': | |
1122 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1123 | { | |
1124 | /* authentication-key - this option can occur anywhere on | |
1125 | command line. At start of command line | |
1126 | must check for authentication option. */ | |
1127 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1128 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); | |
1129 | vl_config.auth_key = auth_key; | |
1130 | i++; | |
1131 | } | |
1132 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1133 | { | |
1134 | /* authentication - this option can only occur at start | |
1135 | of command line */ | |
1136 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1137 | if ((i+1) < argc) | |
1138 | { | |
1139 | if (strncmp (argv[i+1], "n", 1) == 0) | |
1140 | { | |
1141 | /* "authentication null" */ | |
1142 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1143 | i++; | |
1144 | } | |
1145 | else if (strncmp (argv[i+1], "m", 1) == 0 | |
1146 | && strcmp (argv[i+1], "message-digest-") != 0) | |
1147 | { | |
1148 | /* "authentication message-digest" */ | |
1149 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1150 | i++; | |
1151 | } | |
1152 | } | |
1153 | } | |
1154 | break; | |
1155 | ||
1156 | case 'm': | |
1157 | /* message-digest-key */ | |
1158 | i++; | |
1159 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1160 | if (vl_config.crypto_key_id < 0) | |
1161 | return CMD_WARNING; | |
1162 | i++; | |
1163 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1164 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); | |
1165 | vl_config.md5_key = md5_key; | |
1166 | break; | |
1167 | ||
1168 | case 'h': | |
1169 | /* Hello interval */ | |
1170 | i++; | |
1171 | vl_config.hello_interval = strtol (argv[i], NULL, 10); | |
1172 | if (vl_config.hello_interval < 0) | |
1173 | return CMD_WARNING; | |
1174 | break; | |
1175 | ||
1176 | case 'r': | |
1177 | /* Retransmit Interval */ | |
1178 | i++; | |
1179 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); | |
1180 | if (vl_config.retransmit_interval < 0) | |
1181 | return CMD_WARNING; | |
1182 | break; | |
1183 | ||
1184 | case 't': | |
1185 | /* Transmit Delay */ | |
1186 | i++; | |
1187 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); | |
1188 | if (vl_config.transmit_delay < 0) | |
1189 | return CMD_WARNING; | |
1190 | break; | |
1191 | ||
1192 | case 'd': | |
1193 | /* Dead Interval */ | |
1194 | i++; | |
1195 | vl_config.dead_interval = strtol (argv[i], NULL, 10); | |
1196 | if (vl_config.dead_interval < 0) | |
1197 | return CMD_WARNING; | |
1198 | break; | |
1199 | } | |
1200 | } | |
1201 | ||
1202 | ||
1203 | /* Action configuration */ | |
1204 | ||
68980084 | 1205 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1206 | |
1207 | } | |
1208 | ||
a2c62831 | 1209 | DEFUN (no_ospf_area_vlink, |
1210 | no_ospf_area_vlink_cmd, | |
718e3744 | 1211 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
1212 | NO_STR | |
1213 | VLINK_HELPSTR_IPADDR) | |
1214 | { | |
68980084 | 1215 | struct ospf *ospf = vty->index; |
718e3744 | 1216 | struct ospf_area *area; |
1217 | struct ospf_vl_config_data vl_config; | |
1218 | struct ospf_vl_data *vl_data = NULL; | |
1219 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1220 | int i; | |
1221 | int ret, format; | |
1222 | ||
7c8ff89e DS |
1223 | if (!ospf) |
1224 | return CMD_SUCCESS; | |
1225 | ||
718e3744 | 1226 | ospf_vl_config_data_init(&vl_config, vty); |
1227 | ||
1228 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); | |
1229 | if (ret < 0) | |
1230 | { | |
1231 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1232 | return CMD_WARNING; | |
1233 | } | |
1234 | ||
68980084 | 1235 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1236 | if (!area) |
1237 | { | |
1238 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1239 | return CMD_WARNING; | |
1240 | } | |
1241 | ||
1242 | ret = inet_aton (argv[1], &vl_config.vl_peer); | |
1243 | if (! ret) | |
1244 | { | |
1245 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1246 | VTY_NEWLINE); | |
1247 | return CMD_WARNING; | |
1248 | } | |
1249 | ||
1250 | if (argc <=2) | |
1251 | { | |
1252 | /* Basic VLink no command */ | |
1253 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1254 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1255 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1256 | |
68980084 | 1257 | ospf_area_check_free (ospf, vl_config.area_id); |
718e3744 | 1258 | |
1259 | return CMD_SUCCESS; | |
1260 | } | |
1261 | ||
1262 | /* If we are down here, we are reseting parameters */ | |
1263 | ||
1264 | /* Deal with other parameters */ | |
1265 | for (i=2; i < argc; i++) | |
1266 | { | |
718e3744 | 1267 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1268 | ||
1269 | switch (argv[i][0]) | |
1270 | { | |
1271 | ||
1272 | case 'a': | |
1273 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1274 | { | |
1275 | /* authentication-key - this option can occur anywhere on | |
1276 | command line. At start of command line | |
1277 | must check for authentication option. */ | |
1278 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1279 | vl_config.auth_key = auth_key; | |
1280 | } | |
1281 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1282 | { | |
1283 | /* authentication - this option can only occur at start | |
1284 | of command line */ | |
1285 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1286 | } | |
1287 | break; | |
1288 | ||
1289 | case 'm': | |
1290 | /* message-digest-key */ | |
1291 | /* Delete one key */ | |
1292 | i++; | |
1293 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1294 | if (vl_config.crypto_key_id < 0) | |
1295 | return CMD_WARNING; | |
1296 | vl_config.md5_key = NULL; | |
1297 | break; | |
1298 | ||
1299 | case 'h': | |
1300 | /* Hello interval */ | |
1301 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1302 | break; | |
1303 | ||
1304 | case 'r': | |
1305 | /* Retransmit Interval */ | |
1306 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1307 | break; | |
1308 | ||
1309 | case 't': | |
1310 | /* Transmit Delay */ | |
1311 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1312 | break; | |
1313 | ||
1314 | case 'd': | |
1315 | /* Dead Interval */ | |
1316 | i++; | |
1317 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
1318 | break; | |
1319 | } | |
1320 | } | |
1321 | ||
1322 | ||
1323 | /* Action configuration */ | |
1324 | ||
68980084 | 1325 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1326 | } |
1327 | ||
a2c62831 | 1328 | ALIAS (ospf_area_vlink, |
1329 | ospf_area_vlink_param1_cmd, | |
718e3744 | 1330 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1331 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1332 | VLINK_HELPSTR_IPADDR | |
1333 | VLINK_HELPSTR_TIME_PARAM) | |
1334 | ||
a2c62831 | 1335 | ALIAS (no_ospf_area_vlink, |
1336 | no_ospf_area_vlink_param1_cmd, | |
718e3744 | 1337 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 | 1338 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
718e3744 | 1339 | NO_STR |
1340 | VLINK_HELPSTR_IPADDR | |
1341 | VLINK_HELPSTR_TIME_PARAM) | |
1342 | ||
a2c62831 | 1343 | ALIAS (ospf_area_vlink, |
1344 | ospf_area_vlink_param2_cmd, | |
718e3744 | 1345 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1346 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1347 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1348 | VLINK_HELPSTR_IPADDR | |
1349 | VLINK_HELPSTR_TIME_PARAM | |
1350 | VLINK_HELPSTR_TIME_PARAM) | |
1351 | ||
a2c62831 | 1352 | ALIAS (no_ospf_area_vlink, |
1353 | no_ospf_area_vlink_param2_cmd, | |
718e3744 | 1354 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 DW |
1355 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
1356 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
718e3744 | 1357 | NO_STR |
1358 | VLINK_HELPSTR_IPADDR | |
1359 | VLINK_HELPSTR_TIME_PARAM | |
1360 | VLINK_HELPSTR_TIME_PARAM) | |
1361 | ||
a2c62831 | 1362 | ALIAS (ospf_area_vlink, |
1363 | ospf_area_vlink_param3_cmd, | |
718e3744 | 1364 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1365 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1366 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1367 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1368 | VLINK_HELPSTR_IPADDR | |
1369 | VLINK_HELPSTR_TIME_PARAM | |
1370 | VLINK_HELPSTR_TIME_PARAM | |
1371 | VLINK_HELPSTR_TIME_PARAM) | |
1372 | ||
a2c62831 | 1373 | ALIAS (no_ospf_area_vlink, |
1374 | no_ospf_area_vlink_param3_cmd, | |
718e3744 | 1375 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 DW |
1376 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
1377 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1378 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
718e3744 | 1379 | NO_STR |
1380 | VLINK_HELPSTR_IPADDR | |
1381 | VLINK_HELPSTR_TIME_PARAM | |
1382 | VLINK_HELPSTR_TIME_PARAM | |
1383 | VLINK_HELPSTR_TIME_PARAM) | |
1384 | ||
a2c62831 | 1385 | ALIAS (ospf_area_vlink, |
1386 | ospf_area_vlink_param4_cmd, | |
718e3744 | 1387 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1388 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1389 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1390 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1391 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1392 | VLINK_HELPSTR_IPADDR | |
1393 | VLINK_HELPSTR_TIME_PARAM | |
1394 | VLINK_HELPSTR_TIME_PARAM | |
1395 | VLINK_HELPSTR_TIME_PARAM | |
1396 | VLINK_HELPSTR_TIME_PARAM) | |
1397 | ||
a2c62831 | 1398 | ALIAS (no_ospf_area_vlink, |
1399 | no_ospf_area_vlink_param4_cmd, | |
718e3744 | 1400 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 DW |
1401 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
1402 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1403 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1404 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
718e3744 | 1405 | NO_STR |
1406 | VLINK_HELPSTR_IPADDR | |
1407 | VLINK_HELPSTR_TIME_PARAM | |
1408 | VLINK_HELPSTR_TIME_PARAM | |
1409 | VLINK_HELPSTR_TIME_PARAM | |
1410 | VLINK_HELPSTR_TIME_PARAM) | |
1411 | ||
a2c62831 | 1412 | ALIAS (ospf_area_vlink, |
1413 | ospf_area_vlink_authtype_args_cmd, | |
718e3744 | 1414 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1415 | "(authentication|) (message-digest|null)", | |
1416 | VLINK_HELPSTR_IPADDR | |
1417 | VLINK_HELPSTR_AUTHTYPE_ALL) | |
1418 | ||
813d4307 DW |
1419 | ALIAS (no_ospf_area_vlink, |
1420 | no_ospf_area_vlink_authtype_args_cmd, | |
1421 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1422 | "(authentication|) (message-digest|null)", | |
1423 | NO_STR | |
1424 | VLINK_HELPSTR_IPADDR | |
1425 | VLINK_HELPSTR_AUTHTYPE_ALL) | |
1426 | ||
a2c62831 | 1427 | ALIAS (ospf_area_vlink, |
1428 | ospf_area_vlink_authtype_cmd, | |
718e3744 | 1429 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1430 | "(authentication|)", | |
1431 | VLINK_HELPSTR_IPADDR | |
1432 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1433 | ||
a2c62831 | 1434 | ALIAS (no_ospf_area_vlink, |
1435 | no_ospf_area_vlink_authtype_cmd, | |
718e3744 | 1436 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1437 | "(authentication|)", | |
1438 | NO_STR | |
1439 | VLINK_HELPSTR_IPADDR | |
1440 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) | |
1441 | ||
a2c62831 | 1442 | ALIAS (ospf_area_vlink, |
1443 | ospf_area_vlink_md5_cmd, | |
718e3744 | 1444 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1445 | "(message-digest-key|) <1-255> md5 KEY", | |
1446 | VLINK_HELPSTR_IPADDR | |
1447 | VLINK_HELPSTR_AUTH_MD5) | |
1448 | ||
a2c62831 | 1449 | ALIAS (no_ospf_area_vlink, |
1450 | no_ospf_area_vlink_md5_cmd, | |
718e3744 | 1451 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 | 1452 | "(message-digest-key|) <1-255> md5 KEY", |
718e3744 | 1453 | NO_STR |
1454 | VLINK_HELPSTR_IPADDR | |
1455 | VLINK_HELPSTR_AUTH_MD5) | |
1456 | ||
a2c62831 | 1457 | ALIAS (ospf_area_vlink, |
1458 | ospf_area_vlink_authkey_cmd, | |
718e3744 | 1459 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1460 | "(authentication-key|) AUTH_KEY", | |
1461 | VLINK_HELPSTR_IPADDR | |
1462 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1463 | ||
a2c62831 | 1464 | ALIAS (no_ospf_area_vlink, |
1465 | no_ospf_area_vlink_authkey_cmd, | |
718e3744 | 1466 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
813d4307 | 1467 | "(authentication-key|) AUTH_KEY", |
718e3744 | 1468 | NO_STR |
1469 | VLINK_HELPSTR_IPADDR | |
1470 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1471 | ||
a2c62831 | 1472 | ALIAS (ospf_area_vlink, |
1473 | ospf_area_vlink_authtype_args_authkey_cmd, | |
718e3744 | 1474 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1475 | "(authentication|) (message-digest|null) " | |
1476 | "(authentication-key|) AUTH_KEY", | |
1477 | VLINK_HELPSTR_IPADDR | |
1478 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1479 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1480 | ||
813d4307 DW |
1481 | ALIAS (no_ospf_area_vlink, |
1482 | no_ospf_area_vlink_authtype_args_authkey_cmd, | |
1483 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1484 | "(authentication|) (message-digest|null) " | |
1485 | "(authentication-key|) AUTH_KEY", | |
1486 | NO_STR | |
1487 | VLINK_HELPSTR_IPADDR | |
1488 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1489 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1490 | ||
a2c62831 | 1491 | ALIAS (ospf_area_vlink, |
1492 | ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1493 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1494 | "(authentication|) " | |
1495 | "(authentication-key|) AUTH_KEY", | |
1496 | VLINK_HELPSTR_IPADDR | |
1497 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1498 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1499 | ||
a2c62831 | 1500 | ALIAS (no_ospf_area_vlink, |
1501 | no_ospf_area_vlink_authtype_authkey_cmd, | |
718e3744 | 1502 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1503 | "(authentication|) " | |
813d4307 | 1504 | "(authentication-key|) AUTH_KEY", |
718e3744 | 1505 | NO_STR |
1506 | VLINK_HELPSTR_IPADDR | |
1507 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1508 | VLINK_HELPSTR_AUTH_SIMPLE) | |
1509 | ||
a2c62831 | 1510 | ALIAS (ospf_area_vlink, |
1511 | ospf_area_vlink_authtype_args_md5_cmd, | |
718e3744 | 1512 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1513 | "(authentication|) (message-digest|null) " | |
1514 | "(message-digest-key|) <1-255> md5 KEY", | |
1515 | VLINK_HELPSTR_IPADDR | |
1516 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1517 | VLINK_HELPSTR_AUTH_MD5) | |
1518 | ||
813d4307 DW |
1519 | ALIAS (no_ospf_area_vlink, |
1520 | no_ospf_area_vlink_authtype_args_md5_cmd, | |
1521 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1522 | "(authentication|) (message-digest|null) " | |
1523 | "(message-digest-key|) <1-255> md5 KEY", | |
1524 | NO_STR | |
1525 | VLINK_HELPSTR_IPADDR | |
1526 | VLINK_HELPSTR_AUTHTYPE_ALL | |
1527 | VLINK_HELPSTR_AUTH_MD5) | |
1528 | ||
a2c62831 | 1529 | ALIAS (ospf_area_vlink, |
1530 | ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1531 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1532 | "(authentication|) " | |
1533 | "(message-digest-key|) <1-255> md5 KEY", | |
1534 | VLINK_HELPSTR_IPADDR | |
1535 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1536 | VLINK_HELPSTR_AUTH_MD5) | |
1537 | ||
a2c62831 | 1538 | ALIAS (no_ospf_area_vlink, |
1539 | no_ospf_area_vlink_authtype_md5_cmd, | |
718e3744 | 1540 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
1541 | "(authentication|) " | |
813d4307 | 1542 | "(message-digest-key|) <1-255> md5 KEY", |
718e3744 | 1543 | NO_STR |
1544 | VLINK_HELPSTR_IPADDR | |
1545 | VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1546 | VLINK_HELPSTR_AUTH_MD5) | |
1547 | ||
6b0655a2 | 1548 | |
a2c62831 | 1549 | DEFUN (ospf_area_shortcut, |
1550 | ospf_area_shortcut_cmd, | |
718e3744 | 1551 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
1552 | "OSPF area parameters\n" | |
1553 | "OSPF area ID in IP address format\n" | |
1554 | "OSPF area ID as a decimal value\n" | |
1555 | "Configure the area's shortcutting mode\n" | |
1556 | "Set default shortcutting behavior\n" | |
1557 | "Enable shortcutting through the area\n" | |
1558 | "Disable shortcutting through the area\n") | |
1559 | { | |
68980084 | 1560 | struct ospf *ospf = vty->index; |
718e3744 | 1561 | struct ospf_area *area; |
1562 | struct in_addr area_id; | |
1563 | int mode; | |
1564 | int format; | |
1565 | ||
7c8ff89e DS |
1566 | if (!ospf) |
1567 | return CMD_SUCCESS; | |
1568 | ||
718e3744 | 1569 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1570 | ||
68980084 | 1571 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1572 | |
1573 | if (strncmp (argv[1], "de", 2) == 0) | |
1574 | mode = OSPF_SHORTCUT_DEFAULT; | |
1575 | else if (strncmp (argv[1], "di", 2) == 0) | |
1576 | mode = OSPF_SHORTCUT_DISABLE; | |
1577 | else if (strncmp (argv[1], "e", 1) == 0) | |
1578 | mode = OSPF_SHORTCUT_ENABLE; | |
1579 | else | |
1580 | return CMD_WARNING; | |
1581 | ||
68980084 | 1582 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1583 | |
68980084 | 1584 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1585 | vty_out (vty, "Shortcut area setting will take effect " |
1586 | "only when the router is configured as Shortcut ABR%s", | |
1587 | VTY_NEWLINE); | |
1588 | ||
1589 | return CMD_SUCCESS; | |
1590 | } | |
1591 | ||
a2c62831 | 1592 | DEFUN (no_ospf_area_shortcut, |
1593 | no_ospf_area_shortcut_cmd, | |
718e3744 | 1594 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
1595 | NO_STR | |
1596 | "OSPF area parameters\n" | |
1597 | "OSPF area ID in IP address format\n" | |
1598 | "OSPF area ID as a decimal value\n" | |
1599 | "Deconfigure the area's shortcutting mode\n" | |
1600 | "Deconfigure enabled shortcutting through the area\n" | |
1601 | "Deconfigure disabled shortcutting through the area\n") | |
1602 | { | |
68980084 | 1603 | struct ospf *ospf = vty->index; |
718e3744 | 1604 | struct ospf_area *area; |
1605 | struct in_addr area_id; | |
1606 | int format; | |
1607 | ||
7c8ff89e DS |
1608 | if (!ospf) |
1609 | return CMD_SUCCESS; | |
1610 | ||
718e3744 | 1611 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
1612 | ||
68980084 | 1613 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1614 | if (!area) |
1615 | return CMD_SUCCESS; | |
1616 | ||
68980084 | 1617 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1618 | |
1619 | return CMD_SUCCESS; | |
1620 | } | |
1621 | ||
6b0655a2 | 1622 | |
a2c62831 | 1623 | DEFUN (ospf_area_stub, |
1624 | ospf_area_stub_cmd, | |
718e3744 | 1625 | "area (A.B.C.D|<0-4294967295>) stub", |
1626 | "OSPF area parameters\n" | |
1627 | "OSPF area ID in IP address format\n" | |
1628 | "OSPF area ID as a decimal value\n" | |
1629 | "Configure OSPF area as stub\n") | |
1630 | { | |
1631 | struct ospf *ospf = vty->index; | |
1632 | struct in_addr area_id; | |
1633 | int ret, format; | |
1634 | ||
7c8ff89e DS |
1635 | if (!ospf) |
1636 | return CMD_SUCCESS; | |
1637 | ||
718e3744 | 1638 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1639 | ||
1640 | ret = ospf_area_stub_set (ospf, area_id); | |
1641 | if (ret == 0) | |
1642 | { | |
1643 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1644 | VTY_NEWLINE); | |
1645 | return CMD_WARNING; | |
1646 | } | |
1647 | ||
1648 | ospf_area_no_summary_unset (ospf, area_id); | |
1649 | ||
1650 | return CMD_SUCCESS; | |
1651 | } | |
1652 | ||
a2c62831 | 1653 | DEFUN (ospf_area_stub_no_summary, |
1654 | ospf_area_stub_no_summary_cmd, | |
718e3744 | 1655 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
1656 | "OSPF stub parameters\n" | |
1657 | "OSPF area ID in IP address format\n" | |
1658 | "OSPF area ID as a decimal value\n" | |
1659 | "Configure OSPF area as stub\n" | |
1660 | "Do not inject inter-area routes into stub\n") | |
1661 | { | |
1662 | struct ospf *ospf = vty->index; | |
1663 | struct in_addr area_id; | |
1664 | int ret, format; | |
1665 | ||
7c8ff89e DS |
1666 | if (!ospf) |
1667 | return CMD_SUCCESS; | |
1668 | ||
718e3744 | 1669 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1670 | ||
1671 | ret = ospf_area_stub_set (ospf, area_id); | |
1672 | if (ret == 0) | |
1673 | { | |
b0a053be | 1674 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1675 | VTY_NEWLINE); |
1676 | return CMD_WARNING; | |
1677 | } | |
1678 | ||
1679 | ospf_area_no_summary_set (ospf, area_id); | |
1680 | ||
1681 | return CMD_SUCCESS; | |
1682 | } | |
1683 | ||
a2c62831 | 1684 | DEFUN (no_ospf_area_stub, |
1685 | no_ospf_area_stub_cmd, | |
718e3744 | 1686 | "no area (A.B.C.D|<0-4294967295>) stub", |
1687 | NO_STR | |
1688 | "OSPF area parameters\n" | |
1689 | "OSPF area ID in IP address format\n" | |
1690 | "OSPF area ID as a decimal value\n" | |
1691 | "Configure OSPF area as stub\n") | |
1692 | { | |
1693 | struct ospf *ospf = vty->index; | |
1694 | struct in_addr area_id; | |
1695 | int format; | |
1696 | ||
7c8ff89e DS |
1697 | if (!ospf) |
1698 | return CMD_SUCCESS; | |
1699 | ||
718e3744 | 1700 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1701 | ||
1702 | ospf_area_stub_unset (ospf, area_id); | |
1703 | ospf_area_no_summary_unset (ospf, area_id); | |
1704 | ||
1705 | return CMD_SUCCESS; | |
1706 | } | |
1707 | ||
a2c62831 | 1708 | DEFUN (no_ospf_area_stub_no_summary, |
1709 | no_ospf_area_stub_no_summary_cmd, | |
718e3744 | 1710 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
1711 | NO_STR | |
1712 | "OSPF area parameters\n" | |
1713 | "OSPF area ID in IP address format\n" | |
1714 | "OSPF area ID as a decimal value\n" | |
1715 | "Configure OSPF area as stub\n" | |
1716 | "Do not inject inter-area routes into area\n") | |
1717 | { | |
1718 | struct ospf *ospf = vty->index; | |
1719 | struct in_addr area_id; | |
1720 | int format; | |
1721 | ||
7c8ff89e DS |
1722 | if (!ospf) |
1723 | return CMD_SUCCESS; | |
1724 | ||
718e3744 | 1725 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
1726 | ospf_area_no_summary_unset (ospf, area_id); | |
1727 | ||
1728 | return CMD_SUCCESS; | |
1729 | } | |
1730 | ||
4dadc291 | 1731 | static int |
6c835671 | 1732 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
1733 | int nosum) | |
718e3744 | 1734 | { |
1735 | struct ospf *ospf = vty->index; | |
1736 | struct in_addr area_id; | |
1737 | int ret, format; | |
1738 | ||
7c8ff89e DS |
1739 | if (!ospf) |
1740 | return CMD_SUCCESS; | |
1741 | ||
718e3744 | 1742 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1743 | ||
1744 | ret = ospf_area_nssa_set (ospf, area_id); | |
1745 | if (ret == 0) | |
1746 | { | |
1747 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1748 | VTY_NEWLINE); | |
1749 | return CMD_WARNING; | |
1750 | } | |
1751 | ||
1752 | if (argc > 1) | |
1753 | { | |
1754 | if (strncmp (argv[1], "translate-c", 11) == 0) | |
b0a053be | 1755 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1756 | OSPF_NSSA_ROLE_CANDIDATE); |
1757 | else if (strncmp (argv[1], "translate-n", 11) == 0) | |
b0a053be | 1758 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1759 | OSPF_NSSA_ROLE_NEVER); |
1760 | else if (strncmp (argv[1], "translate-a", 11) == 0) | |
b0a053be | 1761 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1762 | OSPF_NSSA_ROLE_ALWAYS); |
1763 | } | |
b0a053be | 1764 | else |
1765 | { | |
1766 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1767 | OSPF_NSSA_ROLE_CANDIDATE); | |
1768 | } | |
718e3744 | 1769 | |
b0a053be | 1770 | if (nosum) |
718e3744 | 1771 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1772 | else |
1773 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1774 | |
b0a053be | 1775 | ospf_schedule_abr_task (ospf); |
1776 | ||
718e3744 | 1777 | return CMD_SUCCESS; |
1778 | } | |
1779 | ||
b0a053be | 1780 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1781 | ospf_area_nssa_translate_no_summary_cmd, |
b0a053be | 1782 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", |
718e3744 | 1783 | "OSPF area parameters\n" |
1784 | "OSPF area ID in IP address format\n" | |
1785 | "OSPF area ID as a decimal value\n" | |
1786 | "Configure OSPF area as nssa\n" | |
1787 | "Configure NSSA-ABR for translate election (default)\n" | |
1788 | "Configure NSSA-ABR to never translate\n" | |
1789 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1790 | "Do not inject inter-area routes into nssa\n") |
1791 | { | |
1792 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1793 | } | |
718e3744 | 1794 | |
b0a053be | 1795 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1796 | ospf_area_nssa_translate_cmd, |
718e3744 | 1797 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
1798 | "OSPF area parameters\n" | |
1799 | "OSPF area ID in IP address format\n" | |
1800 | "OSPF area ID as a decimal value\n" | |
1801 | "Configure OSPF area as nssa\n" | |
1802 | "Configure NSSA-ABR for translate election (default)\n" | |
1803 | "Configure NSSA-ABR to never translate\n" | |
1804 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1805 | { |
1806 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1807 | } | |
1808 | ||
1809 | DEFUN (ospf_area_nssa, | |
1810 | ospf_area_nssa_cmd, | |
1811 | "area (A.B.C.D|<0-4294967295>) nssa", | |
1812 | "OSPF area parameters\n" | |
1813 | "OSPF area ID in IP address format\n" | |
1814 | "OSPF area ID as a decimal value\n" | |
1815 | "Configure OSPF area as nssa\n") | |
1816 | { | |
1817 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1818 | } | |
718e3744 | 1819 | |
a2c62831 | 1820 | DEFUN (ospf_area_nssa_no_summary, |
1821 | ospf_area_nssa_no_summary_cmd, | |
718e3744 | 1822 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
1823 | "OSPF area parameters\n" | |
1824 | "OSPF area ID in IP address format\n" | |
1825 | "OSPF area ID as a decimal value\n" | |
1826 | "Configure OSPF area as nssa\n" | |
1827 | "Do not inject inter-area routes into nssa\n") | |
1828 | { | |
b0a053be | 1829 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1830 | } |
1831 | ||
a2c62831 | 1832 | DEFUN (no_ospf_area_nssa, |
1833 | no_ospf_area_nssa_cmd, | |
718e3744 | 1834 | "no area (A.B.C.D|<0-4294967295>) nssa", |
1835 | NO_STR | |
1836 | "OSPF area parameters\n" | |
1837 | "OSPF area ID in IP address format\n" | |
1838 | "OSPF area ID as a decimal value\n" | |
1839 | "Configure OSPF area as nssa\n") | |
1840 | { | |
1841 | struct ospf *ospf = vty->index; | |
1842 | struct in_addr area_id; | |
1843 | int format; | |
1844 | ||
7c8ff89e DS |
1845 | if (!ospf) |
1846 | return CMD_SUCCESS; | |
1847 | ||
718e3744 | 1848 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1849 | ||
1850 | ospf_area_nssa_unset (ospf, area_id); | |
1851 | ospf_area_no_summary_unset (ospf, area_id); | |
1852 | ||
b0a053be | 1853 | ospf_schedule_abr_task (ospf); |
1854 | ||
718e3744 | 1855 | return CMD_SUCCESS; |
1856 | } | |
1857 | ||
813d4307 | 1858 | ALIAS (no_ospf_area_nssa, |
a2c62831 | 1859 | no_ospf_area_nssa_no_summary_cmd, |
813d4307 | 1860 | "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}", |
718e3744 | 1861 | NO_STR |
1862 | "OSPF area parameters\n" | |
1863 | "OSPF area ID in IP address format\n" | |
1864 | "OSPF area ID as a decimal value\n" | |
1865 | "Configure OSPF area as nssa\n" | |
813d4307 DW |
1866 | "Configure NSSA-ABR for translate election (default)\n" |
1867 | "Configure NSSA-ABR to never translate\n" | |
1868 | "Configure NSSA-ABR to always translate\n" | |
718e3744 | 1869 | "Do not inject inter-area routes into nssa\n") |
718e3744 | 1870 | |
a2c62831 | 1871 | DEFUN (ospf_area_default_cost, |
1872 | ospf_area_default_cost_cmd, | |
718e3744 | 1873 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1874 | "OSPF area parameters\n" | |
1875 | "OSPF area ID in IP address format\n" | |
1876 | "OSPF area ID as a decimal value\n" | |
1877 | "Set the summary-default cost of a NSSA or stub area\n" | |
1878 | "Stub's advertised default summary cost\n") | |
1879 | { | |
68980084 | 1880 | struct ospf *ospf = vty->index; |
718e3744 | 1881 | struct ospf_area *area; |
1882 | struct in_addr area_id; | |
1883 | u_int32_t cost; | |
1884 | int format; | |
ba682537 | 1885 | struct prefix_ipv4 p; |
718e3744 | 1886 | |
7c8ff89e DS |
1887 | if (!ospf) |
1888 | return CMD_SUCCESS; | |
1889 | ||
718e3744 | 1890 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
1891 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); | |
1892 | ||
68980084 | 1893 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1894 | |
1895 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1896 | { | |
1897 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1898 | return CMD_WARNING; | |
1899 | } | |
1900 | ||
1901 | area->default_cost = cost; | |
1902 | ||
ba682537 | 1903 | p.family = AF_INET; |
1904 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1905 | p.prefixlen = 0; | |
1906 | if (IS_DEBUG_OSPF_EVENT) | |
1907 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1908 | "announcing 0.0.0.0/0 to area %s", | |
1909 | inet_ntoa (area->area_id)); | |
1910 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1911 | ||
718e3744 | 1912 | return CMD_SUCCESS; |
1913 | } | |
1914 | ||
a2c62831 | 1915 | DEFUN (no_ospf_area_default_cost, |
1916 | no_ospf_area_default_cost_cmd, | |
718e3744 | 1917 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
1918 | NO_STR | |
1919 | "OSPF area parameters\n" | |
1920 | "OSPF area ID in IP address format\n" | |
1921 | "OSPF area ID as a decimal value\n" | |
1922 | "Set the summary-default cost of a NSSA or stub area\n" | |
1923 | "Stub's advertised default summary cost\n") | |
1924 | { | |
68980084 | 1925 | struct ospf *ospf = vty->index; |
718e3744 | 1926 | struct ospf_area *area; |
1927 | struct in_addr area_id; | |
718e3744 | 1928 | int format; |
ba682537 | 1929 | struct prefix_ipv4 p; |
718e3744 | 1930 | |
7c8ff89e DS |
1931 | if (!ospf) |
1932 | return CMD_SUCCESS; | |
1933 | ||
718e3744 | 1934 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
0798cee3 | 1935 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
718e3744 | 1936 | |
68980084 | 1937 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1938 | if (area == NULL) |
1939 | return CMD_SUCCESS; | |
1940 | ||
1941 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1942 | { | |
1943 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1944 | return CMD_WARNING; | |
1945 | } | |
1946 | ||
1947 | area->default_cost = 1; | |
1948 | ||
ba682537 | 1949 | p.family = AF_INET; |
1950 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1951 | p.prefixlen = 0; | |
1952 | if (IS_DEBUG_OSPF_EVENT) | |
1953 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1954 | "announcing 0.0.0.0/0 to area %s", | |
1955 | inet_ntoa (area->area_id)); | |
1956 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1957 | ||
1958 | ||
68980084 | 1959 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1960 | |
1961 | return CMD_SUCCESS; | |
1962 | } | |
1963 | ||
a2c62831 | 1964 | DEFUN (ospf_area_export_list, |
1965 | ospf_area_export_list_cmd, | |
718e3744 | 1966 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
1967 | "OSPF area parameters\n" | |
1968 | "OSPF area ID in IP address format\n" | |
1969 | "OSPF area ID as a decimal value\n" | |
1970 | "Set the filter for networks announced to other areas\n" | |
1971 | "Name of the access-list\n") | |
1972 | { | |
68980084 | 1973 | struct ospf *ospf = vty->index; |
718e3744 | 1974 | struct ospf_area *area; |
1975 | struct in_addr area_id; | |
1976 | int format; | |
1977 | ||
7c8ff89e DS |
1978 | if (!ospf) |
1979 | return CMD_SUCCESS; | |
1980 | ||
52930766 | 1981 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
1982 | ||
68980084 | 1983 | area = ospf_area_get (ospf, area_id, format); |
1984 | ospf_area_export_list_set (ospf, area, argv[1]); | |
718e3744 | 1985 | |
1986 | return CMD_SUCCESS; | |
1987 | } | |
1988 | ||
a2c62831 | 1989 | DEFUN (no_ospf_area_export_list, |
1990 | no_ospf_area_export_list_cmd, | |
718e3744 | 1991 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
1992 | NO_STR | |
1993 | "OSPF area parameters\n" | |
1994 | "OSPF area ID in IP address format\n" | |
1995 | "OSPF area ID as a decimal value\n" | |
1996 | "Unset the filter for networks announced to other areas\n" | |
1997 | "Name of the access-list\n") | |
1998 | { | |
68980084 | 1999 | struct ospf *ospf = vty->index; |
718e3744 | 2000 | struct ospf_area *area; |
2001 | struct in_addr area_id; | |
2002 | int format; | |
2003 | ||
7c8ff89e DS |
2004 | if (!ospf) |
2005 | return CMD_SUCCESS; | |
2006 | ||
52930766 | 2007 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2008 | ||
68980084 | 2009 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2010 | if (area == NULL) |
2011 | return CMD_SUCCESS; | |
2012 | ||
68980084 | 2013 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 2014 | |
2015 | return CMD_SUCCESS; | |
2016 | } | |
2017 | ||
2018 | ||
a2c62831 | 2019 | DEFUN (ospf_area_import_list, |
2020 | ospf_area_import_list_cmd, | |
718e3744 | 2021 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
2022 | "OSPF area parameters\n" | |
2023 | "OSPF area ID in IP address format\n" | |
2024 | "OSPF area ID as a decimal value\n" | |
2025 | "Set the filter for networks from other areas announced to the specified one\n" | |
2026 | "Name of the access-list\n") | |
2027 | { | |
68980084 | 2028 | struct ospf *ospf = vty->index; |
718e3744 | 2029 | struct ospf_area *area; |
2030 | struct in_addr area_id; | |
2031 | int format; | |
2032 | ||
7c8ff89e DS |
2033 | if (!ospf) |
2034 | return CMD_SUCCESS; | |
2035 | ||
52930766 | 2036 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2037 | ||
68980084 | 2038 | area = ospf_area_get (ospf, area_id, format); |
2039 | ospf_area_import_list_set (ospf, area, argv[1]); | |
718e3744 | 2040 | |
2041 | return CMD_SUCCESS; | |
2042 | } | |
2043 | ||
a2c62831 | 2044 | DEFUN (no_ospf_area_import_list, |
2045 | no_ospf_area_import_list_cmd, | |
718e3744 | 2046 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
2047 | NO_STR | |
2048 | "OSPF area parameters\n" | |
2049 | "OSPF area ID in IP address format\n" | |
2050 | "OSPF area ID as a decimal value\n" | |
2051 | "Unset the filter for networks announced to other areas\n" | |
2052 | "Name of the access-list\n") | |
2053 | { | |
68980084 | 2054 | struct ospf *ospf = vty->index; |
718e3744 | 2055 | struct ospf_area *area; |
2056 | struct in_addr area_id; | |
2057 | int format; | |
2058 | ||
7c8ff89e DS |
2059 | if (!ospf) |
2060 | return CMD_SUCCESS; | |
2061 | ||
52930766 | 2062 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2063 | ||
68980084 | 2064 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2065 | if (area == NULL) |
2066 | return CMD_SUCCESS; | |
2067 | ||
68980084 | 2068 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 2069 | |
2070 | return CMD_SUCCESS; | |
2071 | } | |
2072 | ||
a2c62831 | 2073 | DEFUN (ospf_area_filter_list, |
2074 | ospf_area_filter_list_cmd, | |
718e3744 | 2075 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2076 | "OSPF area parameters\n" | |
2077 | "OSPF area ID in IP address format\n" | |
2078 | "OSPF area ID as a decimal value\n" | |
2079 | "Filter networks between OSPF areas\n" | |
2080 | "Filter prefixes between OSPF areas\n" | |
2081 | "Name of an IP prefix-list\n" | |
2082 | "Filter networks sent to this area\n" | |
2083 | "Filter networks sent from this area\n") | |
2084 | { | |
68980084 | 2085 | struct ospf *ospf = vty->index; |
718e3744 | 2086 | struct ospf_area *area; |
2087 | struct in_addr area_id; | |
2088 | struct prefix_list *plist; | |
2089 | int format; | |
2090 | ||
7c8ff89e DS |
2091 | if (!ospf) |
2092 | return CMD_SUCCESS; | |
2093 | ||
718e3744 | 2094 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2095 | ||
68980084 | 2096 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2097 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
2098 | if (strncmp (argv[2], "in", 2) == 0) | |
2099 | { | |
2100 | PREFIX_LIST_IN (area) = plist; | |
2101 | if (PREFIX_NAME_IN (area)) | |
2102 | free (PREFIX_NAME_IN (area)); | |
2103 | ||
2104 | PREFIX_NAME_IN (area) = strdup (argv[1]); | |
68980084 | 2105 | ospf_schedule_abr_task (ospf); |
718e3744 | 2106 | } |
2107 | else | |
2108 | { | |
2109 | PREFIX_LIST_OUT (area) = plist; | |
2110 | if (PREFIX_NAME_OUT (area)) | |
2111 | free (PREFIX_NAME_OUT (area)); | |
2112 | ||
2113 | PREFIX_NAME_OUT (area) = strdup (argv[1]); | |
68980084 | 2114 | ospf_schedule_abr_task (ospf); |
718e3744 | 2115 | } |
2116 | ||
2117 | return CMD_SUCCESS; | |
2118 | } | |
2119 | ||
a2c62831 | 2120 | DEFUN (no_ospf_area_filter_list, |
2121 | no_ospf_area_filter_list_cmd, | |
718e3744 | 2122 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
2123 | NO_STR | |
2124 | "OSPF area parameters\n" | |
2125 | "OSPF area ID in IP address format\n" | |
2126 | "OSPF area ID as a decimal value\n" | |
2127 | "Filter networks between OSPF areas\n" | |
2128 | "Filter prefixes between OSPF areas\n" | |
2129 | "Name of an IP prefix-list\n" | |
2130 | "Filter networks sent to this area\n" | |
2131 | "Filter networks sent from this area\n") | |
2132 | { | |
68980084 | 2133 | struct ospf *ospf = vty->index; |
718e3744 | 2134 | struct ospf_area *area; |
2135 | struct in_addr area_id; | |
718e3744 | 2136 | int format; |
2137 | ||
7c8ff89e DS |
2138 | if (!ospf) |
2139 | return CMD_SUCCESS; | |
2140 | ||
718e3744 | 2141 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2142 | ||
1a8ec2b9 PJ |
2143 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
2144 | return CMD_SUCCESS; | |
2145 | ||
718e3744 | 2146 | if (strncmp (argv[2], "in", 2) == 0) |
2147 | { | |
2148 | if (PREFIX_NAME_IN (area)) | |
2149 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) | |
2150 | return CMD_SUCCESS; | |
2151 | ||
2152 | PREFIX_LIST_IN (area) = NULL; | |
2153 | if (PREFIX_NAME_IN (area)) | |
2154 | free (PREFIX_NAME_IN (area)); | |
2155 | ||
2156 | PREFIX_NAME_IN (area) = NULL; | |
2157 | ||
68980084 | 2158 | ospf_schedule_abr_task (ospf); |
718e3744 | 2159 | } |
2160 | else | |
2161 | { | |
2162 | if (PREFIX_NAME_OUT (area)) | |
2163 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) | |
2164 | return CMD_SUCCESS; | |
2165 | ||
2166 | PREFIX_LIST_OUT (area) = NULL; | |
2167 | if (PREFIX_NAME_OUT (area)) | |
2168 | free (PREFIX_NAME_OUT (area)); | |
2169 | ||
2170 | PREFIX_NAME_OUT (area) = NULL; | |
2171 | ||
68980084 | 2172 | ospf_schedule_abr_task (ospf); |
718e3744 | 2173 | } |
2174 | ||
2175 | return CMD_SUCCESS; | |
2176 | } | |
2177 | ||
6b0655a2 | 2178 | |
a2c62831 | 2179 | DEFUN (ospf_area_authentication_message_digest, |
2180 | ospf_area_authentication_message_digest_cmd, | |
718e3744 | 2181 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
2182 | "OSPF area parameters\n" | |
2b00515a CF |
2183 | "OSPF area ID in IP address format\n" |
2184 | "OSPF area ID as a decimal value\n" | |
718e3744 | 2185 | "Enable authentication\n" |
2186 | "Use message-digest authentication\n") | |
2187 | { | |
68980084 | 2188 | struct ospf *ospf = vty->index; |
718e3744 | 2189 | struct ospf_area *area; |
2190 | struct in_addr area_id; | |
2191 | int format; | |
2192 | ||
7c8ff89e DS |
2193 | if (!ospf) |
2194 | return CMD_SUCCESS; | |
2195 | ||
718e3744 | 2196 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2197 | ||
68980084 | 2198 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2199 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
2200 | ||
2201 | return CMD_SUCCESS; | |
2202 | } | |
2203 | ||
a2c62831 | 2204 | DEFUN (ospf_area_authentication, |
2205 | ospf_area_authentication_cmd, | |
718e3744 | 2206 | "area (A.B.C.D|<0-4294967295>) authentication", |
2207 | "OSPF area parameters\n" | |
2208 | "OSPF area ID in IP address format\n" | |
2209 | "OSPF area ID as a decimal value\n" | |
2210 | "Enable authentication\n") | |
2211 | { | |
68980084 | 2212 | struct ospf *ospf = vty->index; |
718e3744 | 2213 | struct ospf_area *area; |
2214 | struct in_addr area_id; | |
2215 | int format; | |
2216 | ||
7c8ff89e DS |
2217 | if (!ospf) |
2218 | return CMD_SUCCESS; | |
2219 | ||
718e3744 | 2220 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2221 | ||
68980084 | 2222 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2223 | area->auth_type = OSPF_AUTH_SIMPLE; |
2224 | ||
2225 | return CMD_SUCCESS; | |
2226 | } | |
2227 | ||
a2c62831 | 2228 | DEFUN (no_ospf_area_authentication, |
2229 | no_ospf_area_authentication_cmd, | |
718e3744 | 2230 | "no area (A.B.C.D|<0-4294967295>) authentication", |
2231 | NO_STR | |
2232 | "OSPF area parameters\n" | |
2233 | "OSPF area ID in IP address format\n" | |
2234 | "OSPF area ID as a decimal value\n" | |
2235 | "Enable authentication\n") | |
2236 | { | |
68980084 | 2237 | struct ospf *ospf = vty->index; |
718e3744 | 2238 | struct ospf_area *area; |
2239 | struct in_addr area_id; | |
2240 | int format; | |
2241 | ||
7c8ff89e DS |
2242 | if (!ospf) |
2243 | return CMD_SUCCESS; | |
2244 | ||
718e3744 | 2245 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
2246 | ||
68980084 | 2247 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2248 | if (area == NULL) |
2249 | return CMD_SUCCESS; | |
2250 | ||
2251 | area->auth_type = OSPF_AUTH_NULL; | |
2252 | ||
68980084 | 2253 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2254 | |
2255 | return CMD_SUCCESS; | |
2256 | } | |
2257 | ||
6b0655a2 | 2258 | |
718e3744 | 2259 | DEFUN (ospf_abr_type, |
2260 | ospf_abr_type_cmd, | |
2261 | "ospf abr-type (cisco|ibm|shortcut|standard)", | |
2262 | "OSPF specific commands\n" | |
2263 | "Set OSPF ABR type\n" | |
2264 | "Alternative ABR, cisco implementation\n" | |
2265 | "Alternative ABR, IBM implementation\n" | |
2266 | "Shortcut ABR\n" | |
2267 | "Standard behavior (RFC2328)\n") | |
2268 | { | |
68980084 | 2269 | struct ospf *ospf = vty->index; |
718e3744 | 2270 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2271 | ||
7c8ff89e DS |
2272 | if (!ospf) |
2273 | return CMD_SUCCESS; | |
2274 | ||
718e3744 | 2275 | if (strncmp (argv[0], "c", 1) == 0) |
2276 | abr_type = OSPF_ABR_CISCO; | |
2277 | else if (strncmp (argv[0], "i", 1) == 0) | |
2278 | abr_type = OSPF_ABR_IBM; | |
2279 | else if (strncmp (argv[0], "sh", 2) == 0) | |
2280 | abr_type = OSPF_ABR_SHORTCUT; | |
2281 | else if (strncmp (argv[0], "st", 2) == 0) | |
2282 | abr_type = OSPF_ABR_STAND; | |
2283 | else | |
2284 | return CMD_WARNING; | |
2285 | ||
2286 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2287 | if (ospf->abr_type != abr_type) |
718e3744 | 2288 | { |
68980084 | 2289 | ospf->abr_type = abr_type; |
2290 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2291 | } |
2292 | ||
2293 | return CMD_SUCCESS; | |
2294 | } | |
2295 | ||
2296 | DEFUN (no_ospf_abr_type, | |
2297 | no_ospf_abr_type_cmd, | |
d57834f6 | 2298 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
718e3744 | 2299 | NO_STR |
2300 | "OSPF specific commands\n" | |
2301 | "Set OSPF ABR type\n" | |
2302 | "Alternative ABR, cisco implementation\n" | |
2303 | "Alternative ABR, IBM implementation\n" | |
2304 | "Shortcut ABR\n") | |
2305 | { | |
68980084 | 2306 | struct ospf *ospf = vty->index; |
718e3744 | 2307 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2308 | ||
7c8ff89e DS |
2309 | if (!ospf) |
2310 | return CMD_SUCCESS; | |
2311 | ||
718e3744 | 2312 | if (strncmp (argv[0], "c", 1) == 0) |
2313 | abr_type = OSPF_ABR_CISCO; | |
2314 | else if (strncmp (argv[0], "i", 1) == 0) | |
2315 | abr_type = OSPF_ABR_IBM; | |
04d23314 | 2316 | else if (strncmp (argv[0], "sh", 2) == 0) |
718e3744 | 2317 | abr_type = OSPF_ABR_SHORTCUT; |
04d23314 FD |
2318 | else if (strncmp (argv[0], "st", 2) == 0) |
2319 | abr_type = OSPF_ABR_STAND; | |
718e3744 | 2320 | else |
2321 | return CMD_WARNING; | |
2322 | ||
2323 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2324 | if (ospf->abr_type == abr_type) |
718e3744 | 2325 | { |
d57834f6 | 2326 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2327 | ospf_schedule_abr_task (ospf); |
718e3744 | 2328 | } |
2329 | ||
2330 | return CMD_SUCCESS; | |
2331 | } | |
2332 | ||
d7e60dd7 AS |
2333 | DEFUN (ospf_log_adjacency_changes, |
2334 | ospf_log_adjacency_changes_cmd, | |
2335 | "log-adjacency-changes", | |
2336 | "Log changes in adjacency state\n") | |
2337 | { | |
2338 | struct ospf *ospf = vty->index; | |
2339 | ||
7c8ff89e DS |
2340 | if (!ospf) |
2341 | return CMD_SUCCESS; | |
2342 | ||
d7e60dd7 | 2343 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
692c7954 | 2344 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
d7e60dd7 AS |
2345 | return CMD_SUCCESS; |
2346 | } | |
2347 | ||
2348 | DEFUN (ospf_log_adjacency_changes_detail, | |
2349 | ospf_log_adjacency_changes_detail_cmd, | |
2350 | "log-adjacency-changes detail", | |
2351 | "Log changes in adjacency state\n" | |
2352 | "Log all state changes\n") | |
2353 | { | |
2354 | struct ospf *ospf = vty->index; | |
2355 | ||
7c8ff89e DS |
2356 | if (!ospf) |
2357 | return CMD_SUCCESS; | |
2358 | ||
d7e60dd7 AS |
2359 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2360 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2361 | return CMD_SUCCESS; | |
2362 | } | |
2363 | ||
2364 | DEFUN (no_ospf_log_adjacency_changes, | |
2365 | no_ospf_log_adjacency_changes_cmd, | |
2366 | "no log-adjacency-changes", | |
2367 | NO_STR | |
2368 | "Log changes in adjacency state\n") | |
2369 | { | |
2370 | struct ospf *ospf = vty->index; | |
2371 | ||
7c8ff89e DS |
2372 | if (!ospf) |
2373 | return CMD_SUCCESS; | |
2374 | ||
d7e60dd7 AS |
2375 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2376 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2377 | return CMD_SUCCESS; | |
2378 | } | |
2379 | ||
2380 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2381 | no_ospf_log_adjacency_changes_detail_cmd, | |
2382 | "no log-adjacency-changes detail", | |
2383 | NO_STR | |
2384 | "Log changes in adjacency state\n" | |
2385 | "Log all state changes\n") | |
2386 | { | |
2387 | struct ospf *ospf = vty->index; | |
2388 | ||
7c8ff89e DS |
2389 | if (!ospf) |
2390 | return CMD_SUCCESS; | |
2391 | ||
692c7954 | 2392 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
d7e60dd7 AS |
2393 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2394 | return CMD_SUCCESS; | |
2395 | } | |
2396 | ||
718e3744 | 2397 | DEFUN (ospf_compatible_rfc1583, |
2398 | ospf_compatible_rfc1583_cmd, | |
2399 | "compatible rfc1583", | |
2400 | "OSPF compatibility list\n" | |
2401 | "compatible with RFC 1583\n") | |
2402 | { | |
2403 | struct ospf *ospf = vty->index; | |
2404 | ||
7c8ff89e DS |
2405 | if (!ospf) |
2406 | return CMD_SUCCESS; | |
2407 | ||
718e3744 | 2408 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2409 | { | |
2410 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2411 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2412 | } |
2413 | return CMD_SUCCESS; | |
2414 | } | |
2415 | ||
2416 | DEFUN (no_ospf_compatible_rfc1583, | |
2417 | no_ospf_compatible_rfc1583_cmd, | |
2418 | "no compatible rfc1583", | |
2419 | NO_STR | |
2420 | "OSPF compatibility list\n" | |
2421 | "compatible with RFC 1583\n") | |
2422 | { | |
2423 | struct ospf *ospf = vty->index; | |
2424 | ||
7c8ff89e DS |
2425 | if (!ospf) |
2426 | return CMD_SUCCESS; | |
2427 | ||
718e3744 | 2428 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2429 | { | |
2430 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2431 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2432 | } |
2433 | return CMD_SUCCESS; | |
2434 | } | |
2435 | ||
2436 | ALIAS (ospf_compatible_rfc1583, | |
2437 | ospf_rfc1583_flag_cmd, | |
2438 | "ospf rfc1583compatibility", | |
2439 | "OSPF specific commands\n" | |
2440 | "Enable the RFC1583Compatibility flag\n") | |
2441 | ||
2442 | ALIAS (no_ospf_compatible_rfc1583, | |
2443 | no_ospf_rfc1583_flag_cmd, | |
2444 | "no ospf rfc1583compatibility", | |
2445 | NO_STR | |
2446 | "OSPF specific commands\n" | |
2447 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2448 | |
d24f6e2a | 2449 | static int |
2450 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2451 | unsigned int hold, | |
2452 | unsigned int max) | |
2453 | { | |
2454 | struct ospf *ospf = vty->index; | |
2455 | ||
7c8ff89e DS |
2456 | if (!ospf) |
2457 | return CMD_SUCCESS; | |
2458 | ||
d24f6e2a | 2459 | ospf->spf_delay = delay; |
2460 | ospf->spf_holdtime = hold; | |
2461 | ospf->spf_max_holdtime = max; | |
2462 | ||
2463 | return CMD_SUCCESS; | |
2464 | } | |
718e3744 | 2465 | |
ac7424f9 MR |
2466 | DEFUN (ospf_timers_min_ls_interval, |
2467 | ospf_timers_min_ls_interval_cmd, | |
2468 | "timers throttle lsa all <0-5000>", | |
2469 | "Adjust routing timers\n" | |
2470 | "Throttling adaptive timer\n" | |
2471 | "LSA delay between transmissions\n" | |
813d4307 | 2472 | "All LSA types\n" |
ac7424f9 MR |
2473 | "Delay (msec) between sending LSAs\n") |
2474 | { | |
2475 | struct ospf *ospf = vty->index; | |
2476 | unsigned int interval; | |
2477 | ||
d8f70b86 DS |
2478 | if (!ospf) |
2479 | return CMD_SUCCESS; | |
2480 | ||
ac7424f9 MR |
2481 | if (argc != 1) |
2482 | { | |
2483 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2484 | return CMD_WARNING; | |
2485 | } | |
2486 | ||
2487 | VTY_GET_INTEGER ("LSA interval", interval, argv[0]); | |
2488 | ||
2489 | ospf->min_ls_interval = interval; | |
2490 | ||
2491 | return CMD_SUCCESS; | |
2492 | } | |
2493 | ||
2494 | DEFUN (no_ospf_timers_min_ls_interval, | |
2495 | no_ospf_timers_min_ls_interval_cmd, | |
2496 | "no timers throttle lsa all", | |
2497 | NO_STR | |
2498 | "Adjust routing timers\n" | |
2499 | "Throttling adaptive timer\n" | |
813d4307 DW |
2500 | "LSA delay between transmissions\n" |
2501 | "All LSA types\n") | |
ac7424f9 MR |
2502 | { |
2503 | struct ospf *ospf = vty->index; | |
2504 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; | |
2505 | ||
2506 | return CMD_SUCCESS; | |
2507 | } | |
2508 | ||
813d4307 DW |
2509 | ALIAS (no_ospf_timers_min_ls_interval, |
2510 | no_ospf_timers_min_ls_interval_val_cmd, | |
2511 | "no timers throttle lsa all <0-5000>", | |
2512 | NO_STR | |
2513 | "Adjust routing timers\n" | |
2514 | "Throttling adaptive timer\n" | |
2515 | "LSA delay between transmissions\n" | |
2516 | "All LSA types\n" | |
2517 | "Delay (msec) between sending LSAs\n") | |
2518 | ||
ac7424f9 MR |
2519 | DEFUN (ospf_timers_min_ls_arrival, |
2520 | ospf_timers_min_ls_arrival_cmd, | |
2521 | "timers lsa arrival <0-1000>", | |
2522 | "Adjust routing timers\n" | |
2523 | "Throttling link state advertisement delays\n" | |
2524 | "OSPF minimum arrival interval delay\n" | |
2525 | "Delay (msec) between accepted LSAs\n") | |
2526 | { | |
2527 | struct ospf *ospf = vty->index; | |
2528 | unsigned int arrival; | |
2529 | ||
d8f70b86 DS |
2530 | if (!ospf) |
2531 | return CMD_SUCCESS; | |
2532 | ||
ac7424f9 MR |
2533 | if (argc != 1) |
2534 | { | |
2535 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2536 | return CMD_WARNING; | |
2537 | } | |
2538 | ||
2539 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); | |
2540 | ||
2541 | ospf->min_ls_arrival = arrival; | |
2542 | ||
2543 | return CMD_SUCCESS; | |
2544 | } | |
2545 | ||
2546 | DEFUN (no_ospf_timers_min_ls_arrival, | |
2547 | no_ospf_timers_min_ls_arrival_cmd, | |
2548 | "no timers lsa arrival", | |
2549 | NO_STR | |
2550 | "Adjust routing timers\n" | |
2551 | "Throttling link state advertisement delays\n" | |
2552 | "OSPF minimum arrival interval delay\n") | |
2553 | { | |
2554 | struct ospf *ospf = vty->index; | |
d8f70b86 DS |
2555 | |
2556 | if (!ospf) | |
2557 | return CMD_SUCCESS; | |
2558 | ||
ac7424f9 MR |
2559 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
2560 | ||
2561 | return CMD_SUCCESS; | |
2562 | } | |
2563 | ||
813d4307 DW |
2564 | ALIAS (no_ospf_timers_min_ls_arrival, |
2565 | no_ospf_timers_min_ls_arrival_val_cmd, | |
2566 | "no timers lsa arrival <0-1000>", | |
2567 | NO_STR | |
2568 | "Adjust routing timers\n" | |
2569 | "Throttling link state advertisement delays\n" | |
2570 | "OSPF minimum arrival interval delay\n" | |
2571 | "Delay (msec) between accepted LSAs\n") | |
2572 | ||
d24f6e2a | 2573 | DEFUN (ospf_timers_throttle_spf, |
2574 | ospf_timers_throttle_spf_cmd, | |
2575 | "timers throttle spf <0-600000> <0-600000> <0-600000>", | |
2576 | "Adjust routing timers\n" | |
2577 | "Throttling adaptive timer\n" | |
2578 | "OSPF SPF timers\n" | |
2579 | "Delay (msec) from first change received till SPF calculation\n" | |
2580 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2581 | "Maximum hold time (msec)\n") | |
2582 | { | |
2583 | unsigned int delay, hold, max; | |
2584 | ||
2585 | if (argc != 3) | |
2586 | { | |
2587 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2588 | return CMD_WARNING; | |
2589 | } | |
2590 | ||
2591 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); | |
2592 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); | |
2593 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); | |
2594 | ||
2595 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2596 | } | |
2597 | ||
d24f6e2a | 2598 | DEFUN (no_ospf_timers_throttle_spf, |
2599 | no_ospf_timers_throttle_spf_cmd, | |
2600 | "no timers throttle spf", | |
718e3744 | 2601 | NO_STR |
2602 | "Adjust routing timers\n" | |
d24f6e2a | 2603 | "Throttling adaptive timer\n" |
718e3744 | 2604 | "OSPF SPF timers\n") |
2605 | { | |
d24f6e2a | 2606 | return ospf_timers_spf_set (vty, |
2607 | OSPF_SPF_DELAY_DEFAULT, | |
2608 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2609 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2610 | } |
2611 | ||
b4a039bf DS |
2612 | ALIAS (no_ospf_timers_throttle_spf, |
2613 | no_ospf_timers_throttle_spf_val_cmd, | |
813d4307 | 2614 | "no timers throttle spf <0-600000> <0-600000> <0-600000>", |
b4a039bf DS |
2615 | NO_STR |
2616 | "Adjust routing timers\n" | |
2617 | "Throttling adaptive timer\n" | |
2618 | "OSPF SPF timers\n" | |
2619 | "Delay (msec) from first change received till SPF calculation\n" | |
2620 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2621 | "Maximum hold time (msec)\n") | |
2622 | ||
b6927875 DS |
2623 | DEFUN (ospf_timers_lsa, |
2624 | ospf_timers_lsa_cmd, | |
2625 | "timers lsa min-arrival <0-600000>", | |
2626 | "Adjust routing timers\n" | |
2627 | "OSPF LSA timers\n" | |
2628 | "Minimum delay in receiving new version of a LSA\n" | |
2629 | "Delay in milliseconds\n") | |
2630 | { | |
2631 | unsigned int minarrival; | |
2632 | struct ospf *ospf = vty->index; | |
2633 | ||
2634 | if (!ospf) | |
2635 | return CMD_SUCCESS; | |
2636 | ||
2637 | if (argc != 1) | |
2638 | { | |
2639 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2640 | return CMD_WARNING; | |
2641 | } | |
2642 | ||
2643 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2644 | ||
ac7424f9 | 2645 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2646 | |
2647 | return CMD_SUCCESS; | |
2648 | } | |
2649 | ||
2650 | DEFUN (no_ospf_timers_lsa, | |
2651 | no_ospf_timers_lsa_cmd, | |
2652 | "no timers lsa min-arrival", | |
2653 | NO_STR | |
2654 | "Adjust routing timers\n" | |
2655 | "OSPF LSA timers\n" | |
2656 | "Minimum delay in receiving new version of a LSA\n") | |
2657 | { | |
2658 | unsigned int minarrival; | |
2659 | struct ospf *ospf = vty->index; | |
2660 | ||
2661 | if (!ospf) | |
2662 | return CMD_SUCCESS; | |
2663 | ||
2664 | if (argc) | |
2665 | { | |
2666 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2667 | ||
ac7424f9 | 2668 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2669 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2670 | return CMD_SUCCESS; | |
2671 | } | |
2672 | ||
ac7424f9 | 2673 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2674 | |
2675 | return CMD_SUCCESS; | |
2676 | } | |
2677 | ||
2678 | ALIAS (no_ospf_timers_lsa, | |
2679 | no_ospf_timers_lsa_val_cmd, | |
2680 | "no timers lsa min-arrival <0-600000>", | |
2681 | NO_STR | |
2682 | "Adjust routing timers\n" | |
2683 | "OSPF LSA timers\n" | |
2684 | "Minimum delay in receiving new version of a LSA\n" | |
2685 | "Delay in milliseconds\n") | |
2686 | ||
2687 | ||
a2c62831 | 2688 | DEFUN (ospf_neighbor, |
2689 | ospf_neighbor_cmd, | |
718e3744 | 2690 | "neighbor A.B.C.D", |
2691 | NEIGHBOR_STR | |
2692 | "Neighbor IP address\n") | |
2693 | { | |
2694 | struct ospf *ospf = vty->index; | |
2695 | struct in_addr nbr_addr; | |
eb1ce605 | 2696 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2697 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2698 | |
7c8ff89e DS |
2699 | if (!ospf) |
2700 | return CMD_SUCCESS; | |
2701 | ||
718e3744 | 2702 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2703 | ||
2704 | if (argc > 1) | |
2705 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); | |
2706 | ||
2707 | if (argc > 2) | |
2708 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); | |
2709 | ||
2710 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2711 | if (argc > 1) | |
2712 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2713 | if (argc > 2) | |
1a61ad10 | 2714 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2715 | |
2716 | return CMD_SUCCESS; | |
2717 | } | |
2718 | ||
a2c62831 | 2719 | ALIAS (ospf_neighbor, |
2720 | ospf_neighbor_priority_poll_interval_cmd, | |
718e3744 | 2721 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2722 | NEIGHBOR_STR | |
2723 | "Neighbor IP address\n" | |
2724 | "Neighbor Priority\n" | |
2725 | "Priority\n" | |
2726 | "Dead Neighbor Polling interval\n" | |
2727 | "Seconds\n") | |
2728 | ||
a2c62831 | 2729 | ALIAS (ospf_neighbor, |
2730 | ospf_neighbor_priority_cmd, | |
718e3744 | 2731 | "neighbor A.B.C.D priority <0-255>", |
2732 | NEIGHBOR_STR | |
2733 | "Neighbor IP address\n" | |
2734 | "Neighbor Priority\n" | |
2735 | "Seconds\n") | |
2736 | ||
a2c62831 | 2737 | DEFUN (ospf_neighbor_poll_interval, |
2738 | ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2739 | "neighbor A.B.C.D poll-interval <1-65535>", |
2740 | NEIGHBOR_STR | |
2741 | "Neighbor IP address\n" | |
2742 | "Dead Neighbor Polling interval\n" | |
2743 | "Seconds\n") | |
2744 | { | |
2745 | struct ospf *ospf = vty->index; | |
2746 | struct in_addr nbr_addr; | |
eb1ce605 | 2747 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2748 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2749 | |
7c8ff89e DS |
2750 | if (!ospf) |
2751 | return CMD_SUCCESS; | |
2752 | ||
718e3744 | 2753 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2754 | ||
2755 | if (argc > 1) | |
2756 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); | |
2757 | ||
2758 | if (argc > 2) | |
2759 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); | |
2760 | ||
2761 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2762 | if (argc > 1) | |
2763 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); | |
2764 | if (argc > 2) | |
2765 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2766 | ||
2767 | return CMD_SUCCESS; | |
2768 | } | |
2769 | ||
a2c62831 | 2770 | ALIAS (ospf_neighbor_poll_interval, |
2771 | ospf_neighbor_poll_interval_priority_cmd, | |
718e3744 | 2772 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
2773 | NEIGHBOR_STR | |
2774 | "Neighbor address\n" | |
2775 | "OSPF dead-router polling interval\n" | |
2776 | "Seconds\n" | |
2777 | "OSPF priority of non-broadcast neighbor\n" | |
2778 | "Priority\n") | |
2779 | ||
a2c62831 | 2780 | DEFUN (no_ospf_neighbor, |
2781 | no_ospf_neighbor_cmd, | |
718e3744 | 2782 | "no neighbor A.B.C.D", |
2783 | NO_STR | |
2784 | NEIGHBOR_STR | |
2785 | "Neighbor IP address\n") | |
2786 | { | |
2787 | struct ospf *ospf = vty->index; | |
2788 | struct in_addr nbr_addr; | |
718e3744 | 2789 | |
7c8ff89e DS |
2790 | if (!ospf) |
2791 | return CMD_SUCCESS; | |
2792 | ||
718e3744 | 2793 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
2794 | ||
0798cee3 | 2795 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2796 | |
2797 | return CMD_SUCCESS; | |
2798 | } | |
2799 | ||
a2c62831 | 2800 | ALIAS (no_ospf_neighbor, |
2801 | no_ospf_neighbor_priority_cmd, | |
718e3744 | 2802 | "no neighbor A.B.C.D priority <0-255>", |
2803 | NO_STR | |
2804 | NEIGHBOR_STR | |
2805 | "Neighbor IP address\n" | |
2806 | "Neighbor Priority\n" | |
2807 | "Priority\n") | |
2808 | ||
a2c62831 | 2809 | ALIAS (no_ospf_neighbor, |
2810 | no_ospf_neighbor_poll_interval_cmd, | |
718e3744 | 2811 | "no neighbor A.B.C.D poll-interval <1-65535>", |
2812 | NO_STR | |
2813 | NEIGHBOR_STR | |
2814 | "Neighbor IP address\n" | |
2815 | "Dead Neighbor Polling interval\n" | |
2816 | "Seconds\n") | |
2817 | ||
813d4307 DW |
2818 | ALIAS (no_ospf_neighbor, |
2819 | no_ospf_neighbor_poll_interval_priority_cmd, | |
2820 | "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", | |
2821 | NO_STR | |
2822 | NEIGHBOR_STR | |
2823 | "Neighbor IP address\n" | |
2824 | "Dead Neighbor Polling interval\n" | |
2825 | "Seconds\n" | |
2826 | "OSPF priority of non-broadcast neighbor\n" | |
2827 | "Priority\n") | |
2828 | ||
a2c62831 | 2829 | ALIAS (no_ospf_neighbor, |
2830 | no_ospf_neighbor_priority_pollinterval_cmd, | |
718e3744 | 2831 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
2832 | NO_STR | |
2833 | NEIGHBOR_STR | |
2834 | "Neighbor IP address\n" | |
2835 | "Neighbor Priority\n" | |
2836 | "Priority\n" | |
2837 | "Dead Neighbor Polling interval\n" | |
2838 | "Seconds\n") | |
2839 | ||
a2c62831 | 2840 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
718e3744 | 2841 | "refresh timer <10-1800>", |
2842 | "Adjust refresh parameters\n" | |
2843 | "Set refresh timer\n" | |
2844 | "Timer value in seconds\n") | |
2845 | { | |
2846 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2847 | unsigned int interval; |
718e3744 | 2848 | |
7c8ff89e DS |
2849 | if (!ospf) |
2850 | return CMD_SUCCESS; | |
2851 | ||
718e3744 | 2852 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
535c84b1 | 2853 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; |
718e3744 | 2854 | |
2855 | ospf_timers_refresh_set (ospf, interval); | |
2856 | ||
2857 | return CMD_SUCCESS; | |
2858 | } | |
2859 | ||
a2c62831 | 2860 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
718e3744 | 2861 | "no refresh timer <10-1800>", |
2862 | "Adjust refresh parameters\n" | |
2863 | "Unset refresh timer\n" | |
2864 | "Timer value in seconds\n") | |
2865 | { | |
2866 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2867 | unsigned int interval; |
718e3744 | 2868 | |
7c8ff89e DS |
2869 | if (!ospf) |
2870 | return CMD_SUCCESS; | |
2871 | ||
718e3744 | 2872 | if (argc == 1) |
2873 | { | |
2874 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); | |
2875 | ||
2876 | if (ospf->lsa_refresh_interval != interval || | |
2877 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2878 | return CMD_SUCCESS; | |
2879 | } | |
2880 | ||
2881 | ospf_timers_refresh_unset (ospf); | |
2882 | ||
2883 | return CMD_SUCCESS; | |
2884 | } | |
2885 | ||
a2c62831 | 2886 | ALIAS (no_ospf_refresh_timer, |
2887 | no_ospf_refresh_timer_cmd, | |
718e3744 | 2888 | "no refresh timer", |
2889 | "Adjust refresh parameters\n" | |
2890 | "Unset refresh timer\n") | |
2891 | ||
a2c62831 | 2892 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2893 | ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2894 | "auto-cost reference-bandwidth <1-4294967>", |
2895 | "Calculate OSPF interface cost according to bandwidth\n" | |
2896 | "Use reference bandwidth method to assign OSPF cost\n" | |
2897 | "The reference bandwidth in terms of Mbits per second\n") | |
2898 | { | |
68980084 | 2899 | struct ospf *ospf = vty->index; |
718e3744 | 2900 | u_int32_t refbw; |
52dc7ee6 | 2901 | struct listnode *node; |
1eb8ef25 | 2902 | struct interface *ifp; |
718e3744 | 2903 | |
7c8ff89e DS |
2904 | if (!ospf) |
2905 | return CMD_SUCCESS; | |
2906 | ||
718e3744 | 2907 | refbw = strtol (argv[0], NULL, 10); |
2908 | if (refbw < 1 || refbw > 4294967) | |
2909 | { | |
2910 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2911 | return CMD_WARNING; | |
2912 | } | |
2913 | ||
2914 | /* If reference bandwidth is changed. */ | |
68980084 | 2915 | if ((refbw * 1000) == ospf->ref_bandwidth) |
718e3744 | 2916 | return CMD_SUCCESS; |
2917 | ||
68980084 | 2918 | ospf->ref_bandwidth = refbw * 1000; |
1eb8ef25 | 2919 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2920 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2921 | |
2922 | return CMD_SUCCESS; | |
2923 | } | |
2924 | ||
a2c62831 | 2925 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2926 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2927 | "no auto-cost reference-bandwidth", |
2928 | NO_STR | |
2929 | "Calculate OSPF interface cost according to bandwidth\n" | |
2930 | "Use reference bandwidth method to assign OSPF cost\n") | |
2931 | { | |
68980084 | 2932 | struct ospf *ospf = vty->index; |
1eb8ef25 | 2933 | struct listnode *node, *nnode; |
2934 | struct interface *ifp; | |
718e3744 | 2935 | |
7c8ff89e DS |
2936 | if (!ospf) |
2937 | return CMD_SUCCESS; | |
2938 | ||
68980084 | 2939 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2940 | return CMD_SUCCESS; |
2941 | ||
68980084 | 2942 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2943 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2944 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2945 | ||
1eb8ef25 | 2946 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2947 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2948 | |
2949 | return CMD_SUCCESS; | |
2950 | } | |
2951 | ||
813d4307 DW |
2952 | ALIAS (no_ospf_auto_cost_reference_bandwidth, |
2953 | no_ospf_auto_cost_reference_bandwidth_val_cmd, | |
2954 | "no auto-cost reference-bandwidth <1-4294967>", | |
2955 | NO_STR | |
2956 | "Calculate OSPF interface cost according to bandwidth\n" | |
2957 | "Use reference bandwidth method to assign OSPF cost\n" | |
2958 | "The reference bandwidth in terms of Mbits per second\n") | |
2959 | ||
2f8f370e DS |
2960 | DEFUN (ospf_write_multiplier, |
2961 | ospf_write_multiplier_cmd, | |
e8f45e82 DS |
2962 | "ospf write-multiplier <1-100>", |
2963 | "OSPF specific commands\n" | |
2964 | "Write multiplier\n" | |
2965 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2966 | { |
2967 | struct ospf *ospf = vty->index; | |
e8f45e82 | 2968 | u_int32_t write_oi_count; |
2f8f370e | 2969 | |
7c8ff89e DS |
2970 | if (!ospf) |
2971 | return CMD_SUCCESS; | |
2972 | ||
e8f45e82 DS |
2973 | write_oi_count = strtol (argv[0], NULL, 10); |
2974 | if (write_oi_count < 1 || write_oi_count > 100) | |
2f8f370e DS |
2975 | { |
2976 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2977 | return CMD_WARNING; | |
2978 | } | |
2979 | ||
e8f45e82 | 2980 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2981 | return CMD_SUCCESS; |
2982 | } | |
2983 | ||
e8f45e82 DS |
2984 | ALIAS (ospf_write_multiplier, |
2985 | write_multiplier_cmd, | |
2986 | "write-multiplier <1-100>", | |
2987 | "Write multiplier\n" | |
2988 | "Maximum number of interface serviced per write\n") | |
2989 | ||
2f8f370e DS |
2990 | DEFUN (no_ospf_write_multiplier, |
2991 | no_ospf_write_multiplier_cmd, | |
813d4307 | 2992 | "no ospf write-multiplier <1-100>", |
2f8f370e | 2993 | NO_STR |
e8f45e82 | 2994 | "OSPF specific commands\n" |
813d4307 DW |
2995 | "Write multiplier\n" |
2996 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2997 | { |
2998 | struct ospf *ospf = vty->index; | |
2999 | ||
7c8ff89e DS |
3000 | if (!ospf) |
3001 | return CMD_SUCCESS; | |
3002 | ||
e8f45e82 | 3003 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
3004 | return CMD_SUCCESS; |
3005 | } | |
3006 | ||
e8f45e82 DS |
3007 | ALIAS (no_ospf_write_multiplier, |
3008 | no_write_multiplier_cmd, | |
3009 | "no write-multiplier", | |
3010 | NO_STR | |
3011 | "Write multiplier\n") | |
3012 | ||
813d4307 DW |
3013 | ALIAS (no_ospf_write_multiplier, |
3014 | no_write_multiplier_val_cmd, | |
3015 | "no write-multiplier <1-100>", | |
3016 | NO_STR | |
3017 | "Write multiplier\n" | |
3018 | "Maximum number of interface serviced per write\n") | |
3019 | ||
eb1ce605 | 3020 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 3021 | { |
3022 | "Unknown", | |
3023 | "Standard (RFC2328)", | |
3024 | "Alternative IBM", | |
3025 | "Alternative Cisco", | |
3026 | "Alternative Shortcut" | |
3027 | }; | |
3028 | ||
eb1ce605 | 3029 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 3030 | { |
3031 | "Default", | |
3032 | "Enabled", | |
3033 | "Disabled" | |
3034 | }; | |
3035 | ||
4dadc291 | 3036 | static void |
ca08c43d | 3037 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 3038 | { |
ca08c43d DS |
3039 | json_object *json_area = NULL; |
3040 | ||
3041 | if (use_json) | |
3042 | json_area = json_object_new_object(); | |
3043 | ||
718e3744 | 3044 | /* Show Area ID. */ |
ca08c43d DS |
3045 | if (!use_json) |
3046 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 3047 | |
3048 | /* Show Area type/mode. */ | |
3049 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
3050 | { |
3051 | if (use_json) | |
3052 | json_object_boolean_true_add(json_area, "backbone"); | |
3053 | else | |
3054 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
3055 | } | |
718e3744 | 3056 | else |
3057 | { | |
ca08c43d DS |
3058 | if (use_json) |
3059 | { | |
3060 | if (area->external_routing == OSPF_AREA_STUB) | |
3061 | { | |
3062 | if (area->no_summary) | |
3063 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
3064 | if (area->shortcut_configured) | |
3065 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
3066 | } | |
3067 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3068 | { | |
3069 | if (area->no_summary) | |
3070 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
3071 | if (area->shortcut_configured) | |
3072 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
3073 | } | |
3074 | ||
3075 | json_object_string_add(json_area,"shortcuttingMode", | |
3076 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3077 | if (area->shortcut_capability) | |
3078 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
3079 | } | |
3080 | else | |
3081 | { | |
3082 | if (area->external_routing == OSPF_AREA_STUB) | |
3083 | vty_out (vty, " (Stub%s%s)", | |
3084 | area->no_summary ? ", no summary" : "", | |
3085 | area->shortcut_configured ? "; " : ""); | |
3086 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3087 | vty_out (vty, " (NSSA%s%s)", | |
3088 | area->no_summary ? ", no summary" : "", | |
3089 | area->shortcut_configured ? "; " : ""); | |
3090 | ||
3091 | vty_out (vty, "%s", VTY_NEWLINE); | |
3092 | vty_out (vty, " Shortcutting mode: %s", | |
3093 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3094 | vty_out (vty, ", S-bit consensus: %s%s", | |
3095 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); | |
3096 | } | |
3097 | } | |
3098 | ||
3099 | /* Show number of interfaces */ | |
3100 | if (use_json) | |
3101 | { | |
3ac237f8 MS |
3102 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
3103 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 3104 | } |
ca08c43d DS |
3105 | else |
3106 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
3107 | "Active: %d%s", listcount (area->oiflist), | |
3108 | area->act_ints, VTY_NEWLINE); | |
718e3744 | 3109 | |
718e3744 | 3110 | if (area->external_routing == OSPF_AREA_NSSA) |
3111 | { | |
ca08c43d DS |
3112 | if (use_json) |
3113 | { | |
3114 | json_object_boolean_true_add(json_area, "nssa"); | |
3115 | if (! IS_OSPF_ABR (area->ospf)) | |
3116 | json_object_boolean_false_add(json_area, "abr"); | |
3117 | else if (area->NSSATranslatorState) | |
3118 | { | |
3119 | json_object_boolean_true_add(json_area, "abr"); | |
3120 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3121 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
3122 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3123 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
3124 | } | |
3125 | else | |
3126 | { | |
3127 | json_object_boolean_true_add(json_area, "abr"); | |
3128 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3129 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
3130 | else | |
3131 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
3132 | } | |
3133 | } | |
718e3744 | 3134 | else |
ca08c43d DS |
3135 | { |
3136 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
3137 | if (! IS_OSPF_ABR (area->ospf)) | |
3138 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
3139 | VTY_NEWLINE); | |
3140 | else if (area->NSSATranslatorState) | |
3141 | { | |
3142 | vty_out (vty, " We are an ABR and "); | |
3143 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3144 | vty_out (vty, "the NSSA Elected Translator. %s", | |
3145 | VTY_NEWLINE); | |
3146 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3147 | vty_out (vty, "always an NSSA Translator. %s", | |
3148 | VTY_NEWLINE); | |
3149 | } | |
3150 | else | |
3151 | { | |
3152 | vty_out (vty, " We are an ABR, but "); | |
3153 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3154 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
3155 | VTY_NEWLINE); | |
3156 | else | |
3157 | vty_out (vty, "never an NSSA Translator. %s", | |
3158 | VTY_NEWLINE); | |
3159 | } | |
3160 | } | |
718e3744 | 3161 | } |
ca08c43d | 3162 | |
88d6cf37 | 3163 | /* Stub-router state for this area */ |
3164 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
3165 | { | |
649654ab | 3166 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3167 | |
3168 | if (use_json) | |
3169 | { | |
3170 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
3171 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3172 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
3173 | if (area->t_stub_router) | |
3174 | { | |
3175 | struct timeval result; | |
3176 | unsigned long time_store = 0; | |
3177 | result = tv_sub (area->t_stub_router->u.sands, recent_relative_time()); | |
3178 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3179 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); | |
3180 | } | |
3181 | } | |
3182 | else | |
3183 | { | |
3184 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
3185 | VTY_NEWLINE); | |
3186 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3187 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
3188 | VTY_NEWLINE); | |
3189 | if (area->t_stub_router) | |
3190 | vty_out (vty, " Active from startup, %s remaining%s", | |
3191 | ospf_timer_dump (area->t_stub_router, timebuf, | |
3192 | sizeof(timebuf)), VTY_NEWLINE); | |
3193 | } | |
3194 | } | |
3195 | ||
3196 | if (use_json) | |
3197 | { | |
3198 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 3199 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
3200 | |
3201 | /* Show authentication type. */ | |
3202 | if (area->auth_type == OSPF_AUTH_NULL) | |
3203 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
3204 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3205 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
3206 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3207 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
3208 | ||
3209 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 3210 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
3211 | |
3212 | /* Show SPF calculation times. */ | |
3ac237f8 | 3213 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
3214 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
3215 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
3216 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
3217 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
3218 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
3219 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
3220 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
3221 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3222 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3223 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
3224 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 3225 | } |
ca08c43d DS |
3226 | else |
3227 | { | |
3228 | /* Show number of fully adjacent neighbors. */ | |
3229 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
3230 | " %d%s", area->full_nbrs, VTY_NEWLINE); | |
3231 | ||
3232 | /* Show authentication type. */ | |
3233 | vty_out (vty, " Area has "); | |
3234 | if (area->auth_type == OSPF_AUTH_NULL) | |
3235 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
3236 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3237 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
3238 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3239 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
3240 | ||
3241 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3242 | vty_out (vty, " Number of full virtual adjacencies going through" | |
3243 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
3244 | ||
3245 | /* Show SPF calculation times. */ | |
3246 | vty_out (vty, " SPF algorithm executed %d times%s", | |
3247 | area->spf_calculation, VTY_NEWLINE); | |
3248 | ||
3249 | /* Show number of LSA. */ | |
3250 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
3251 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", | |
3252 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
3253 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
3254 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
3255 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
3256 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
3257 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
3258 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
3259 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
3260 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
3261 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
3262 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
3263 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
3264 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
3265 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
3266 | } | |
3267 | ||
fe71a97d | 3268 | #ifdef HAVE_OPAQUE_LSA |
ca08c43d DS |
3269 | if (use_json) |
3270 | { | |
3271 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3272 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3273 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3274 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3275 | } | |
3276 | else | |
3277 | { | |
3278 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
3279 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
3280 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
3281 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
3282 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
3283 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
3284 | } | |
fe71a97d | 3285 | #endif /* HAVE_OPAQUE_LSA */ |
ca08c43d DS |
3286 | |
3287 | if (use_json) | |
3288 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
3289 | else | |
3290 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 3291 | } |
3292 | ||
7c8ff89e | 3293 | static int |
ca08c43d | 3294 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3295 | { |
1eb8ef25 | 3296 | struct listnode *node, *nnode; |
718e3744 | 3297 | struct ospf_area * area; |
d24f6e2a | 3298 | struct timeval result; |
649654ab | 3299 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3300 | json_object *json = NULL; |
3301 | json_object *json_areas = NULL; | |
3302 | ||
3303 | if (use_json) | |
3304 | json = json_object_new_object(); | |
3305 | json_areas = json_object_new_object(); | |
718e3744 | 3306 | |
7c8ff89e | 3307 | if (ospf->instance) |
ca08c43d DS |
3308 | { |
3309 | if (use_json) | |
3310 | { | |
3311 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3312 | } | |
3313 | else | |
3314 | { | |
3315 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3316 | VTY_NEWLINE, VTY_NEWLINE); | |
3317 | } | |
3318 | } | |
718e3744 | 3319 | |
3320 | /* Show Router ID. */ | |
ca08c43d DS |
3321 | if (use_json) |
3322 | { | |
3323 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
3324 | } | |
3325 | else | |
3326 | { | |
3327 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
3328 | inet_ntoa (ospf->router_id), | |
3329 | VTY_NEWLINE); | |
3330 | } | |
7c8ff89e | 3331 | |
88d6cf37 | 3332 | /* Graceful shutdown */ |
c9c93d50 | 3333 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
3334 | { |
3335 | if (use_json) | |
3336 | { | |
3337 | unsigned long time_store = 0; | |
3338 | result = tv_sub (ospf->t_deferred_shutdown->u.sands, recent_relative_time()); | |
3339 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3340 | json_object_int_add(json, "deferredShutdownMsecs", time_store); | |
3341 | } | |
3342 | else | |
3343 | { | |
3344 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
3345 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
3346 | timebuf, sizeof (timebuf)), VTY_NEWLINE); | |
3347 | } | |
3348 | } | |
3349 | ||
718e3744 | 3350 | /* Show capability. */ |
ca08c43d DS |
3351 | if (use_json) |
3352 | { | |
3353 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
3354 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
3355 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
3356 | { | |
3357 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
3358 | } | |
3359 | } | |
3360 | else | |
3361 | { | |
3362 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
3363 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
3364 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
3365 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
3366 | "enabled" : "disabled", VTY_NEWLINE); | |
3367 | } | |
3368 | ||
718e3744 | 3369 | #ifdef HAVE_OPAQUE_LSA |
ca08c43d DS |
3370 | if (use_json) |
3371 | { | |
3372 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
3373 | { | |
3374 | json_object_boolean_true_add(json, "opaqueCapable"); | |
3375 | } | |
3376 | if (IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque)) | |
3377 | { | |
3378 | json_object_boolean_true_add(json, "lsaOpaqueOriginationBlocked"); | |
3379 | } | |
3380 | } | |
3381 | else | |
3382 | { | |
3383 | vty_out (vty, " OpaqueCapability flag is %s%s%s", | |
3384 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", | |
3385 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? " (origination blocked)" : "", | |
3386 | VTY_NEWLINE); | |
3387 | } | |
718e3744 | 3388 | #endif /* HAVE_OPAQUE_LSA */ |
ca08c43d | 3389 | |
88d6cf37 | 3390 | /* Show stub-router configuration */ |
3391 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3392 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3393 | { | |
ca08c43d DS |
3394 | if (use_json) |
3395 | { | |
3396 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3397 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3398 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3399 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3400 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3401 | } | |
3402 | else | |
3403 | { | |
3404 | vty_out (vty, " Stub router advertisement is configured%s", | |
3405 | VTY_NEWLINE); | |
3406 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3407 | vty_out (vty, " Enabled for %us after start-up%s", | |
3408 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3409 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3410 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3411 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3412 | } | |
88d6cf37 | 3413 | } |
ca08c43d | 3414 | |
718e3744 | 3415 | /* Show SPF timers. */ |
ca08c43d DS |
3416 | if (use_json) |
3417 | { | |
3418 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3419 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3420 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3421 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3422 | } |
3423 | else | |
ca08c43d DS |
3424 | { |
3425 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3426 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3427 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3428 | " Hold time multiplier is currently %d%s", | |
3429 | ospf->spf_delay, VTY_NEWLINE, | |
3430 | ospf->spf_holdtime, VTY_NEWLINE, | |
3431 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3432 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
3433 | } | |
b6927875 | 3434 | |
ca08c43d DS |
3435 | if (use_json) |
3436 | { | |
3437 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3438 | { | |
3439 | unsigned long time_store = 0; | |
3440 | ||
3441 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3442 | result = tv_sub (result, recent_relative_time()); | |
3443 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3444 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); | |
3445 | ||
3446 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3447 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3448 | } | |
3449 | else | |
3450 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3451 | } | |
3452 | else | |
3453 | { | |
3454 | vty_out (vty, " SPF algorithm "); | |
3455 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3456 | { | |
3457 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3458 | vty_out (vty, "last executed %s ago%s", | |
3459 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3460 | VTY_NEWLINE); | |
3461 | vty_out (vty, " Last SPF duration %s%s", | |
3462 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3463 | VTY_NEWLINE); | |
3464 | } | |
3465 | else | |
3466 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
3467 | } | |
3468 | ||
3469 | if (use_json) | |
3470 | { | |
3471 | struct timeval temp_time; | |
3472 | unsigned long time_store = 0; | |
3473 | ||
3474 | if (ospf->t_spf_calc) | |
3475 | { | |
3476 | temp_time = tv_sub (ospf->t_spf_calc->u.sands, recent_relative_time()); | |
3477 | time_store = (1000 * temp_time.tv_sec) + (temp_time.tv_usec / 1000); | |
3478 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); | |
3479 | } | |
3480 | ||
ac7424f9 MR |
3481 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3482 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3483 | /* Show write multiplier values */ |
3484 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3485 | /* Show refresh parameters. */ | |
54b7214f | 3486 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000); |
ca08c43d DS |
3487 | } |
3488 | else | |
3489 | { | |
3490 | vty_out (vty, " SPF timer %s%s%s", | |
3491 | (ospf->t_spf_calc ? "due in " : "is "), | |
3492 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3493 | VTY_NEWLINE); | |
3494 | ||
ac7424f9 MR |
3495 | vty_out (vty, " LSA minimum interval %d msecs%s", |
3496 | ospf->min_ls_interval, VTY_NEWLINE); | |
ca08c43d | 3497 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
ac7424f9 | 3498 | ospf->min_ls_arrival, VTY_NEWLINE); |
ca08c43d DS |
3499 | |
3500 | /* Show write multiplier values */ | |
3501 | vty_out (vty, " Write Multiplier set to %d %s", | |
3502 | ospf->write_oi_count, VTY_NEWLINE); | |
3503 | ||
3504 | /* Show refresh parameters. */ | |
3505 | vty_out (vty, " Refresh timer %d secs%s", | |
3506 | ospf->lsa_refresh_interval, VTY_NEWLINE); | |
3507 | } | |
2f8f370e | 3508 | |
718e3744 | 3509 | /* Show ABR/ASBR flags. */ |
68980084 | 3510 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3511 | { |
3512 | if (use_json) | |
3513 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3514 | else | |
3515 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
3516 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); | |
3517 | } | |
68980084 | 3518 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3519 | { |
3520 | if (use_json) | |
3521 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3522 | else | |
3523 | vty_out (vty, " This router is an ASBR " | |
3524 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3525 | } | |
718e3744 | 3526 | |
3527 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3528 | if (use_json) |
3529 | { | |
3ac237f8 | 3530 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3531 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3532 | json_object_int_add(json, "lsaExternalChecksum", | |
3533 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3534 | } | |
3535 | else | |
3536 | { | |
3537 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3538 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3539 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3540 | } | |
3541 | ||
fe71a97d | 3542 | #ifdef HAVE_OPAQUE_LSA |
ca08c43d DS |
3543 | if (use_json) |
3544 | { | |
3ac237f8 | 3545 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3546 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3547 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3548 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3549 | } | |
3550 | else | |
3551 | { | |
3552 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3553 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3554 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3555 | } | |
fe71a97d | 3556 | #endif /* HAVE_OPAQUE_LSA */ |
ca08c43d | 3557 | |
718e3744 | 3558 | /* Show number of areas attached. */ |
ca08c43d | 3559 | if (use_json) |
3ac237f8 | 3560 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3561 | else |
3562 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
3563 | listcount (ospf->areas), VTY_NEWLINE); | |
d7e60dd7 AS |
3564 | |
3565 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3566 | { | |
3567 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3568 | { |
3569 | if (use_json) | |
3570 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3571 | else | |
3572 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3573 | } | |
d7e60dd7 | 3574 | else |
ca08c43d DS |
3575 | { |
3576 | if (use_json) | |
3577 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3578 | else | |
3579 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3580 | } | |
d7e60dd7 | 3581 | } |
718e3744 | 3582 | /* Show each area status. */ |
1eb8ef25 | 3583 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3584 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3585 | ||
3586 | if (use_json) | |
3587 | { | |
3588 | json_object_object_add(json, "areas", json_areas); | |
3589 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
3590 | json_object_free(json); | |
3591 | } | |
3592 | else | |
3593 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3594 | |
3595 | return CMD_SUCCESS; | |
3596 | } | |
3597 | ||
7c8ff89e DS |
3598 | DEFUN (show_ip_ospf, |
3599 | show_ip_ospf_cmd, | |
ca08c43d | 3600 | "show ip ospf {json}", |
7c8ff89e DS |
3601 | SHOW_STR |
3602 | IP_STR | |
ca08c43d DS |
3603 | "OSPF information\n" |
3604 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3605 | { |
3606 | struct ospf *ospf; | |
db7c8528 | 3607 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3608 | |
0bad4851 | 3609 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3610 | return CMD_SUCCESS; |
3611 | ||
db7c8528 | 3612 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3613 | } |
3614 | ||
3615 | DEFUN (show_ip_ospf_instance, | |
3616 | show_ip_ospf_instance_cmd, | |
ca08c43d | 3617 | "show ip ospf <1-65535> {json}", |
7c8ff89e DS |
3618 | SHOW_STR |
3619 | IP_STR | |
3620 | "OSPF information\n" | |
ca08c43d DS |
3621 | "Instance ID\n" |
3622 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3623 | { |
3624 | struct ospf *ospf; | |
3625 | u_short instance = 0; | |
db7c8528 | 3626 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
3627 | |
3628 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 3629 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3630 | return CMD_SUCCESS; |
3631 | ||
db7c8528 | 3632 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3633 | } |
3634 | ||
fd651fa6 | 3635 | static void |
7ec4159b DS |
3636 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3637 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3638 | { |
fd651fa6 | 3639 | int is_up; |
718e3744 | 3640 | struct ospf_neighbor *nbr; |
718e3744 | 3641 | struct route_node *rn; |
718e3744 | 3642 | |
718e3744 | 3643 | /* Is interface up? */ |
7ec4159b DS |
3644 | if (use_json) |
3645 | { | |
3646 | is_up = if_is_operative(ifp); | |
3647 | if (is_up) | |
3648 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3649 | else | |
3650 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3651 | ||
3652 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3653 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
3654 | json_object_int_add(json_interface_sub, "bandwidthKbit", ifp->bandwidth); | |
3655 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); | |
3656 | } | |
3657 | else | |
3658 | { | |
3659 | vty_out (vty, "%s is %s%s", ifp->name, | |
3660 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
3661 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", | |
3662 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), | |
3663 | VTY_NEWLINE); | |
3664 | } | |
718e3744 | 3665 | |
3666 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3667 | if (use_json) |
718e3744 | 3668 | { |
7ec4159b DS |
3669 | if (ospf_oi_count(ifp) == 0) |
3670 | { | |
3671 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3672 | return; | |
3673 | } | |
3674 | else if (!is_up) | |
3675 | { | |
3676 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3677 | return; | |
3678 | } | |
3679 | else | |
3680 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3681 | } |
7ec4159b | 3682 | else |
fd651fa6 | 3683 | { |
7ec4159b DS |
3684 | if (ospf_oi_count(ifp) == 0) |
3685 | { | |
3686 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3687 | return; | |
3688 | } | |
3689 | else if (!is_up) | |
3690 | { | |
3691 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3692 | VTY_NEWLINE); | |
3693 | return; | |
3694 | } | |
fd651fa6 | 3695 | } |
3696 | ||
718e3744 | 3697 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3698 | { | |
3699 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3700 | |
718e3744 | 3701 | if (oi == NULL) |
7ec4159b DS |
3702 | continue; |
3703 | ||
525c1839 DS |
3704 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3705 | { | |
7ec4159b DS |
3706 | if (use_json) |
3707 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3708 | else | |
3709 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3710 | } |
3711 | else | |
9c27ef9b | 3712 | { |
525c1839 | 3713 | /* Show OSPF interface information. */ |
7ec4159b DS |
3714 | if (use_json) |
3715 | { | |
3716 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3717 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3718 | } | |
3719 | else | |
3720 | vty_out (vty, " Internet Address %s/%d,", | |
3721 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3722 | |
3723 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3724 | { | |
3725 | struct in_addr *dest; | |
3726 | const char *dstr; | |
3727 | ||
3728 | if (CONNECTED_PEER(oi->connected) | |
3729 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3730 | dstr = "Peer"; | |
3731 | else | |
3732 | dstr = "Broadcast"; | |
3733 | ||
3734 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3735 | * * * * * informative than the local interface that is being used |
3736 | * * * * */ | |
525c1839 DS |
3737 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3738 | dest = &oi->vl_data->peer_addr; | |
3739 | else | |
3740 | dest = &oi->connected->destination->u.prefix4; | |
3741 | ||
7ec4159b DS |
3742 | if (use_json) |
3743 | { | |
3744 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3745 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3746 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3747 | else | |
3748 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3749 | } | |
3750 | else | |
3751 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3752 | } |
9c27ef9b | 3753 | } |
7ec4159b DS |
3754 | if (use_json) |
3755 | { | |
3756 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3757 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3758 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3759 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3760 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3761 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3762 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
3763 | json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state)); | |
3764 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); | |
3765 | } | |
3766 | else | |
3767 | { | |
3768 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), | |
3769 | VTY_NEWLINE); | |
3fb9cd6e | 3770 | |
7ec4159b DS |
3771 | vty_out (vty, " MTU mismatch detection:%s%s", |
3772 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
ba682537 | 3773 | |
7ec4159b DS |
3774 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
3775 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3776 | oi->output_cost, VTY_NEWLINE); | |
718e3744 | 3777 | |
7ec4159b DS |
3778 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
3779 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3780 | PRIORITY (oi), VTY_NEWLINE); | |
3781 | } | |
718e3744 | 3782 | |
3783 | /* Show DR information. */ | |
3784 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3785 | { |
3786 | if (!use_json) | |
3787 | vty_out (vty, " No backup designated router on this network%s", | |
3788 | VTY_NEWLINE); | |
3789 | } | |
718e3744 | 3790 | else |
7ec4159b DS |
3791 | { |
3792 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3793 | if (nbr == NULL) | |
3794 | { | |
3795 | if (!use_json) | |
3796 | vty_out (vty, " No backup designated router on this network%s", | |
3797 | VTY_NEWLINE); | |
3798 | } | |
3799 | else | |
3800 | { | |
3801 | if (use_json) | |
3802 | { | |
3803 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3804 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3805 | } | |
3806 | else | |
3807 | { | |
3808 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3809 | inet_ntoa (nbr->router_id)); | |
3810 | vty_out (vty, " Interface Address %s%s", | |
3811 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3812 | } | |
3813 | } | |
3814 | } | |
525c1839 | 3815 | |
7eb5b47e | 3816 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3817 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3818 | { |
7ec4159b DS |
3819 | if (use_json) |
3820 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3821 | else | |
3822 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3823 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3824 | } | |
3825 | ||
3826 | if (use_json) | |
3827 | { | |
3828 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3829 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3830 | { | |
3831 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3832 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3833 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3834 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3835 | } | |
429ac78c PJ |
3836 | } |
3837 | else | |
7ec4159b DS |
3838 | { |
3839 | vty_out (vty, " Multicast group memberships:"); | |
3840 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3841 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3842 | { | |
3843 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3844 | vty_out (vty, " OSPFAllRouters"); | |
3845 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3846 | vty_out (vty, " OSPFDesignatedRouters"); | |
3847 | } | |
3848 | else | |
3849 | vty_out (vty, " <None>"); | |
3850 | vty_out (vty, "%s", VTY_NEWLINE); | |
3851 | } | |
ba6454ec | 3852 | |
7ec4159b DS |
3853 | if (use_json) |
3854 | { | |
3855 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3856 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3857 | else | |
3858 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3859 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3860 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3861 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3862 | } | |
f9ad937f | 3863 | else |
7ec4159b DS |
3864 | { |
3865 | vty_out (vty, " Timer intervals configured,"); | |
3866 | vty_out (vty, " Hello "); | |
3867 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3868 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3869 | else | |
3870 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3871 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3872 | OSPF_IF_PARAM (oi, v_wait), | |
3873 | OSPF_IF_PARAM (oi, v_wait), | |
3874 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3875 | VTY_NEWLINE); | |
3876 | } | |
3877 | ||
7ffa8fa2 | 3878 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3879 | { |
7ec4159b DS |
3880 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3881 | if (use_json) | |
3882 | { | |
3883 | struct timeval result; | |
3884 | unsigned long time_store = 0; | |
3885 | result = tv_sub (oi->t_hello->u.sands, recent_relative_time()); | |
3886 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3887 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); | |
3888 | } | |
3889 | else | |
3890 | vty_out (vty, " Hello due in %s%s", | |
3891 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
3892 | VTY_NEWLINE); | |
f9ad937f | 3893 | } |
7ffa8fa2 | 3894 | else /* passive-interface is set */ |
7ec4159b DS |
3895 | { |
3896 | if (use_json) | |
3897 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3898 | else | |
3899 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); | |
3900 | } | |
3901 | ||
3902 | if (use_json) | |
3903 | { | |
3904 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3905 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3906 | } | |
3907 | else | |
3908 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3909 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
3910 | VTY_NEWLINE); | |
68fe91d6 | 3911 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3912 | } |
3913 | } | |
3914 | ||
7c8ff89e | 3915 | static int |
7ec4159b DS |
3916 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
3917 | const char **argv, int iface_argv, u_char use_json) | |
718e3744 | 3918 | { |
3919 | struct interface *ifp; | |
52dc7ee6 | 3920 | struct listnode *node; |
7ec4159b DS |
3921 | json_object *json = NULL; |
3922 | json_object *json_interface_sub = NULL; | |
3923 | ||
3924 | if (use_json) | |
3925 | { | |
3926 | json = json_object_new_object(); | |
3927 | json_interface_sub = json_object_new_object(); | |
3928 | } | |
718e3744 | 3929 | |
7c8ff89e | 3930 | if (ospf->instance) |
7ec4159b DS |
3931 | { |
3932 | if (use_json) | |
3933 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3934 | else | |
3935 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3936 | VTY_NEWLINE, VTY_NEWLINE); | |
3937 | } | |
7c8ff89e | 3938 | |
7ec4159b DS |
3939 | if (argc == (iface_argv + 1)) |
3940 | { | |
3941 | /* Show All Interfaces.*/ | |
b2d7c082 | 3942 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3943 | { |
3944 | if (ospf_oi_count(ifp)) | |
3945 | { | |
3946 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3947 | } | |
3948 | } | |
3949 | } | |
3950 | else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0) | |
cac3b5c4 | 3951 | { |
7c8ff89e | 3952 | /* Show All Interfaces. */ |
b2d7c082 | 3953 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3954 | { |
3955 | if (ospf_oi_count(ifp)) | |
3956 | { | |
3957 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3958 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3959 | } | |
3960 | } | |
cac3b5c4 | 3961 | } |
718e3744 | 3962 | else |
3963 | { | |
7c8ff89e | 3964 | /* Interface name is specified. */ |
7ec4159b DS |
3965 | if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL) |
3966 | { | |
3967 | if (use_json) | |
3968 | json_object_boolean_true_add(json, "noSuchIface"); | |
3969 | else | |
3970 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
3971 | } | |
718e3744 | 3972 | else |
7ec4159b DS |
3973 | { |
3974 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3975 | if (use_json) | |
3976 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3977 | } | |
718e3744 | 3978 | } |
3979 | ||
7ec4159b DS |
3980 | if (use_json) |
3981 | { | |
3982 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
3983 | json_object_free(json); | |
3984 | } | |
3985 | else | |
3986 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3987 | |
718e3744 | 3988 | return CMD_SUCCESS; |
3989 | } | |
3990 | ||
7c8ff89e DS |
3991 | DEFUN (show_ip_ospf_interface, |
3992 | show_ip_ospf_interface_cmd, | |
7ec4159b | 3993 | "show ip ospf interface [INTERFACE] {json}", |
7c8ff89e DS |
3994 | SHOW_STR |
3995 | IP_STR | |
3996 | "OSPF information\n" | |
3997 | "Interface information\n" | |
7ec4159b DS |
3998 | "Interface name\n" |
3999 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4000 | { |
4001 | struct ospf *ospf; | |
db7c8528 | 4002 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4003 | |
0bad4851 | 4004 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4005 | return CMD_SUCCESS; |
4006 | ||
db7c8528 | 4007 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj); |
7c8ff89e DS |
4008 | } |
4009 | ||
4010 | DEFUN (show_ip_ospf_instance_interface, | |
4011 | show_ip_ospf_instance_interface_cmd, | |
7ec4159b | 4012 | "show ip ospf <1-65535> interface [INTERFACE] {json}", |
7c8ff89e DS |
4013 | SHOW_STR |
4014 | IP_STR | |
4015 | "OSPF information\n" | |
4016 | "Instance ID\n" | |
4017 | "Interface information\n" | |
7ec4159b DS |
4018 | "Interface name\n" |
4019 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4020 | { |
4021 | struct ospf *ospf; | |
4022 | u_short instance = 0; | |
db7c8528 | 4023 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4024 | |
4025 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4026 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4027 | return CMD_SUCCESS; |
4028 | ||
db7c8528 | 4029 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj); |
7c8ff89e DS |
4030 | } |
4031 | ||
d24f6e2a | 4032 | static void |
4033 | show_ip_ospf_neighbour_header (struct vty *vty) | |
4034 | { | |
490578f3 | 4035 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 4036 | VTY_NEWLINE, |
4037 | "Neighbor ID", "Pri", "State", "Dead Time", | |
4038 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
4039 | VTY_NEWLINE); | |
4040 | } | |
4041 | ||
4dadc291 | 4042 | static void |
91756b38 | 4043 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 4044 | { |
4045 | struct route_node *rn; | |
4046 | struct ospf_neighbor *nbr; | |
4047 | char msgbuf[16]; | |
649654ab | 4048 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 4049 | json_object *json_neighbor = NULL; |
718e3744 | 4050 | |
4051 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
4052 | { |
4053 | if ((nbr = rn->info)) | |
4054 | { | |
4055 | /* Do not show myself. */ | |
4056 | if (nbr != oi->nbr_self) | |
4057 | { | |
4058 | /* Down state is not shown. */ | |
4059 | if (nbr->state != NSM_Down) | |
4060 | { | |
4061 | if (use_json) | |
4062 | { | |
4063 | json_neighbor = json_object_new_object(); | |
4064 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4065 | ||
4066 | struct timeval result; | |
4067 | unsigned long time_store = 0; | |
4068 | ||
4069 | result = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time()); | |
4070 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
4071 | ||
4072 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
4073 | json_object_string_add (json_neighbor, "state", msgbuf); | |
4074 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
4075 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
4076 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4077 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
4078 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
4079 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
4080 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
4081 | json_object_object_add(json, "neighbor", json_neighbor); | |
4082 | else | |
4083 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
4084 | } | |
4085 | else | |
4086 | { | |
4087 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4088 | ||
4089 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4090 | vty_out (vty, "%-15s %3d %-15s ", | |
4091 | "-", nbr->priority, | |
4092 | msgbuf); | |
4093 | else | |
4094 | vty_out (vty, "%-15s %3d %-15s ", | |
4095 | inet_ntoa (nbr->router_id), nbr->priority, | |
4096 | msgbuf); | |
4097 | ||
4098 | vty_out (vty, "%9s ", | |
4099 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
4100 | sizeof(timebuf))); | |
4101 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
4102 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
4103 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
4104 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
4105 | VTY_NEWLINE); | |
4106 | } | |
4107 | } | |
4108 | } | |
4109 | } | |
4110 | } | |
718e3744 | 4111 | } |
4112 | ||
7c8ff89e | 4113 | static int |
91756b38 | 4114 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 4115 | { |
1eb8ef25 | 4116 | struct ospf_interface *oi; |
52dc7ee6 | 4117 | struct listnode *node; |
91756b38 | 4118 | json_object *json = NULL; |
718e3744 | 4119 | |
91756b38 DS |
4120 | if (use_json) |
4121 | json = json_object_new_object(); | |
4122 | else | |
4123 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 4124 | |
91756b38 DS |
4125 | if (ospf->instance) |
4126 | { | |
4127 | if (use_json) | |
4128 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4129 | else | |
4130 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4131 | VTY_NEWLINE, VTY_NEWLINE); | |
4132 | } | |
718e3744 | 4133 | |
1eb8ef25 | 4134 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 4135 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4136 | |
91756b38 DS |
4137 | if (use_json) |
4138 | { | |
4139 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4140 | json_object_free(json); | |
4141 | } | |
4142 | else | |
4143 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4144 | |
718e3744 | 4145 | return CMD_SUCCESS; |
4146 | } | |
4147 | ||
7c8ff89e DS |
4148 | DEFUN (show_ip_ospf_neighbor, |
4149 | show_ip_ospf_neighbor_cmd, | |
91756b38 | 4150 | "show ip ospf neighbor {json}", |
718e3744 | 4151 | SHOW_STR |
4152 | IP_STR | |
4153 | "OSPF information\n" | |
91756b38 DS |
4154 | "Neighbor list\n" |
4155 | "JavaScript Object Notation\n") | |
718e3744 | 4156 | { |
7c8ff89e | 4157 | struct ospf *ospf; |
db7c8528 | 4158 | u_char uj = use_json(argc, argv); |
718e3744 | 4159 | |
0bad4851 | 4160 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4161 | return CMD_SUCCESS; |
4162 | ||
db7c8528 | 4163 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
4164 | } |
4165 | ||
4166 | ||
4167 | DEFUN (show_ip_ospf_instance_neighbor, | |
4168 | show_ip_ospf_instance_neighbor_cmd, | |
91756b38 | 4169 | "show ip ospf <1-65535> neighbor {json}", |
7c8ff89e DS |
4170 | SHOW_STR |
4171 | IP_STR | |
4172 | "OSPF information\n" | |
4173 | "Instance ID\n" | |
91756b38 DS |
4174 | "Neighbor list\n" |
4175 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4176 | { |
4177 | struct ospf *ospf; | |
4178 | u_short instance = 0; | |
db7c8528 | 4179 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4180 | |
4181 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4182 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4183 | return CMD_SUCCESS; |
4184 | ||
db7c8528 | 4185 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
4186 | } |
4187 | ||
4188 | static int | |
91756b38 | 4189 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
4190 | { |
4191 | struct listnode *node; | |
4192 | struct ospf_interface *oi; | |
91756b38 DS |
4193 | json_object *json = NULL; |
4194 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 4195 | |
91756b38 DS |
4196 | if (use_json) |
4197 | { | |
4198 | json = json_object_new_object(); | |
4199 | json_neighbor_sub = json_object_new_object(); | |
4200 | } | |
4201 | else | |
4202 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 4203 | |
91756b38 DS |
4204 | if (ospf->instance) |
4205 | { | |
4206 | if (use_json) | |
4207 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4208 | else | |
4209 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4210 | VTY_NEWLINE, VTY_NEWLINE); | |
4211 | } | |
7c8ff89e DS |
4212 | |
4213 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
4214 | { | |
52dc7ee6 | 4215 | struct listnode *nbr_node; |
1eb8ef25 | 4216 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4217 | |
91756b38 | 4218 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4219 | |
91756b38 DS |
4220 | /* print Down neighbor status */ |
4221 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
4222 | { | |
4223 | if (nbr_nbma->nbr == NULL | |
4224 | || nbr_nbma->nbr->state == NSM_Down) | |
4225 | { | |
4226 | if (use_json) | |
4227 | { | |
4228 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
4229 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
4230 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4231 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
4232 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
4233 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
4234 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
4235 | } | |
4236 | else | |
4237 | { | |
4238 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
4239 | "-", nbr_nbma->priority, "Down", "-"); | |
4240 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
4241 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
4242 | 0, 0, 0, VTY_NEWLINE); | |
4243 | } | |
4244 | } | |
4245 | } | |
718e3744 | 4246 | } |
4247 | ||
91756b38 DS |
4248 | if (use_json) |
4249 | { | |
4250 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4251 | json_object_free(json); | |
4252 | } | |
4253 | else | |
4254 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4255 | |
718e3744 | 4256 | return CMD_SUCCESS; |
4257 | } | |
4258 | ||
7c8ff89e DS |
4259 | DEFUN (show_ip_ospf_neighbor_all, |
4260 | show_ip_ospf_neighbor_all_cmd, | |
91756b38 | 4261 | "show ip ospf neighbor all {json}", |
718e3744 | 4262 | SHOW_STR |
4263 | IP_STR | |
4264 | "OSPF information\n" | |
4265 | "Neighbor list\n" | |
91756b38 DS |
4266 | "include down status neighbor\n" |
4267 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4268 | { |
4269 | struct ospf *ospf; | |
db7c8528 | 4270 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4271 | |
0bad4851 | 4272 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4273 | return CMD_SUCCESS; |
4274 | ||
db7c8528 | 4275 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4276 | } |
4277 | ||
4278 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
4279 | show_ip_ospf_instance_neighbor_all_cmd, | |
91756b38 | 4280 | "show ip ospf <1-65535> neighbor all {json}", |
7c8ff89e DS |
4281 | SHOW_STR |
4282 | IP_STR | |
4283 | "OSPF information\n" | |
4284 | "Instance ID\n" | |
4285 | "Neighbor list\n" | |
91756b38 DS |
4286 | "include down status neighbor\n" |
4287 | "JavaScript Object Notation\n") | |
718e3744 | 4288 | { |
020709f9 | 4289 | struct ospf *ospf; |
7c8ff89e | 4290 | u_short instance = 0; |
db7c8528 | 4291 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4292 | |
4293 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4294 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4295 | return CMD_SUCCESS; |
4296 | ||
db7c8528 | 4297 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4298 | } |
4299 | ||
4300 | static int | |
4301 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
91756b38 | 4302 | const char **argv, u_char use_json) |
7c8ff89e | 4303 | { |
bb5b7552 | 4304 | struct interface *ifp; |
4305 | struct route_node *rn; | |
91756b38 DS |
4306 | json_object *json = NULL; |
4307 | ||
4308 | if (use_json) | |
4309 | json = json_object_new_object(); | |
4310 | else | |
4311 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
4312 | |
4313 | if (ospf->instance) | |
91756b38 DS |
4314 | { |
4315 | if (use_json) | |
4316 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4317 | else | |
4318 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4319 | VTY_NEWLINE, VTY_NEWLINE); | |
4320 | } | |
7c8ff89e | 4321 | |
91756b38 | 4322 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4323 | if (!ifp) |
718e3744 | 4324 | { |
91756b38 DS |
4325 | if (use_json) |
4326 | json_object_boolean_true_add(json, "noSuchIface"); | |
4327 | else | |
4328 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4329 | return CMD_WARNING; |
4330 | } | |
d24f6e2a | 4331 | |
bb5b7552 | 4332 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 4333 | { |
bb5b7552 | 4334 | struct ospf_interface *oi = rn->info; |
4335 | ||
4336 | if (oi == NULL) | |
91756b38 | 4337 | continue; |
bb5b7552 | 4338 | |
91756b38 | 4339 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4340 | } |
4341 | ||
91756b38 DS |
4342 | if (use_json) |
4343 | { | |
4344 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4345 | json_object_free(json); | |
4346 | } | |
4347 | else | |
4348 | vty_out (vty, "%s", VTY_NEWLINE); | |
4349 | ||
718e3744 | 4350 | return CMD_SUCCESS; |
4351 | } | |
4352 | ||
7c8ff89e DS |
4353 | DEFUN (show_ip_ospf_neighbor_int, |
4354 | show_ip_ospf_neighbor_int_cmd, | |
91756b38 | 4355 | "show ip ospf neighbor IFNAME {json}", |
7c8ff89e DS |
4356 | SHOW_STR |
4357 | IP_STR | |
4358 | "OSPF information\n" | |
4359 | "Neighbor list\n" | |
91756b38 DS |
4360 | "Interface name\n" |
4361 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4362 | { |
4363 | struct ospf *ospf; | |
db7c8528 | 4364 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4365 | |
0bad4851 | 4366 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4367 | return CMD_SUCCESS; |
4368 | ||
db7c8528 | 4369 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4370 | } |
4371 | ||
4372 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
4373 | show_ip_ospf_instance_neighbor_int_cmd, | |
91756b38 | 4374 | "show ip ospf <1-65535> neighbor IFNAME {json}", |
7c8ff89e DS |
4375 | SHOW_STR |
4376 | IP_STR | |
4377 | "OSPF information\n" | |
4378 | "Instance ID\n" | |
4379 | "Neighbor list\n" | |
91756b38 DS |
4380 | "Interface name\n" |
4381 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4382 | { |
4383 | struct ospf *ospf; | |
4384 | u_short instance = 0; | |
db7c8528 | 4385 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4386 | |
4387 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4388 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4389 | return CMD_SUCCESS; |
4390 | ||
db7c8528 | 4391 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4392 | } |
4393 | ||
4dadc291 | 4394 | static void |
3ac237f8 MS |
4395 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4396 | u_char use_json, json_object *json) | |
718e3744 | 4397 | { |
649654ab | 4398 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4399 | json_object *json_sub = NULL; |
718e3744 | 4400 | |
3ac237f8 MS |
4401 | if (use_json) |
4402 | json_sub = json_object_new_object(); | |
4403 | else /* Show neighbor ID. */ | |
4404 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4405 | |
4406 | /* Show interface address. */ | |
3ac237f8 MS |
4407 | if (use_json) |
4408 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4409 | else | |
4410 | vty_out (vty, " interface address %s%s", | |
4411 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
4412 | ||
718e3744 | 4413 | /* Show Area ID. */ |
3ac237f8 MS |
4414 | if (use_json) |
4415 | { | |
4416 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4417 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4418 | } | |
4419 | else | |
4420 | vty_out (vty, " In the area %s via interface %s%s", | |
4421 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
4422 | ||
718e3744 | 4423 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4424 | if (use_json) |
4425 | { | |
4426 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4427 | json_object_string_add(json_sub, "nbrState", "down"); | |
4428 | } | |
4429 | else | |
4430 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4431 | nbr_nbma->priority, "Down"); | |
4432 | ||
718e3744 | 4433 | /* Show state changes. */ |
3ac237f8 MS |
4434 | if (use_json) |
4435 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4436 | else | |
4437 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
718e3744 | 4438 | |
4439 | /* Show PollInterval */ | |
3ac237f8 MS |
4440 | if (use_json) |
4441 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4442 | else | |
4443 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
718e3744 | 4444 | |
4445 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4446 | if (use_json) |
4447 | { | |
4448 | struct timeval res = tv_sub (nbr_nbma->t_poll->u.sands, recent_relative_time ()); | |
4449 | unsigned long time_store = 0; | |
4450 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4451 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); | |
4452 | } | |
4453 | else | |
4454 | vty_out (vty, " Poll timer due in %s%s", | |
4455 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
4456 | VTY_NEWLINE); | |
718e3744 | 4457 | |
4458 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4459 | if (use_json) |
4460 | { | |
4461 | if (nbr_nbma->t_poll != NULL) | |
4462 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4463 | } | |
4464 | else | |
4465 | vty_out (vty, " Thread Poll Timer %s%s", | |
4466 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
4467 | ||
4468 | if (use_json) | |
4469 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4470 | } |
4471 | ||
4dadc291 | 4472 | static void |
718e3744 | 4473 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4474 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4475 | { |
649654ab | 4476 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4477 | json_object *json_sub = NULL; |
718e3744 | 4478 | |
3ac237f8 MS |
4479 | if (use_json) |
4480 | json_sub = json_object_new_object(); | |
718e3744 | 4481 | else |
3ac237f8 MS |
4482 | { |
4483 | /* Show neighbor ID. */ | |
4484 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4485 | vty_out (vty, " Neighbor %s,", "-"); | |
4486 | else | |
4487 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4488 | } | |
718e3744 | 4489 | |
4490 | /* Show interface address. */ | |
3ac237f8 MS |
4491 | if (use_json) |
4492 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4493 | else | |
4494 | vty_out (vty, " interface address %s%s", | |
4495 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
4496 | ||
718e3744 | 4497 | /* Show Area ID. */ |
3ac237f8 MS |
4498 | if (use_json) |
4499 | { | |
4500 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4501 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4502 | } | |
4503 | else | |
4504 | vty_out (vty, " In the area %s via interface %s%s", | |
4505 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
4506 | ||
718e3744 | 4507 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4508 | if (use_json) |
4509 | { | |
4510 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4511 | json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4512 | } | |
4513 | else | |
4514 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4515 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4516 | ||
718e3744 | 4517 | /* Show state changes. */ |
3ac237f8 MS |
4518 | if (use_json) |
4519 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4520 | else | |
4521 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
4522 | ||
3fed4160 | 4523 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4524 | { |
3ac237f8 MS |
4525 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
4526 | if (use_json) | |
4527 | { | |
4528 | unsigned long time_store = 0; | |
4529 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4530 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store); | |
4531 | } | |
4532 | else | |
4533 | { | |
4534 | vty_out (vty, " Most recent state change statistics:%s", | |
4535 | VTY_NEWLINE); | |
4536 | vty_out (vty, " Progressive change %s ago%s", | |
4537 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4538 | VTY_NEWLINE); | |
4539 | } | |
3fed4160 | 4540 | } |
3ac237f8 | 4541 | |
3fed4160 PJ |
4542 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4543 | { | |
3ac237f8 MS |
4544 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
4545 | if (use_json) | |
4546 | { | |
4547 | unsigned long time_store = 0; | |
4548 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4549 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); | |
4550 | if (nbr->last_regress_str) | |
4551 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4552 | } | |
4553 | else | |
4554 | { | |
4555 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4556 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4557 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
4558 | VTY_NEWLINE); | |
4559 | } | |
90c33177 | 4560 | } |
3ac237f8 | 4561 | |
718e3744 | 4562 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4563 | if (use_json) |
4564 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4565 | else | |
4566 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4567 | ||
718e3744 | 4568 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4569 | if (use_json) |
4570 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4571 | else | |
4572 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
4573 | ||
718e3744 | 4574 | /* Show options. */ |
3ac237f8 MS |
4575 | if (use_json) |
4576 | { | |
4577 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4578 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4579 | } | |
4580 | else | |
4581 | vty_out (vty, " Options %d %s%s", nbr->options, | |
4582 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
4583 | ||
718e3744 | 4584 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4585 | if (use_json) |
4586 | { | |
4587 | struct timeval res = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time ()); | |
4588 | unsigned long time_store = 0; | |
4589 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4590 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); | |
4591 | } | |
4592 | else | |
4593 | vty_out (vty, " Dead timer due in %s%s", | |
4594 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
4595 | VTY_NEWLINE); | |
4596 | ||
718e3744 | 4597 | /* Show Database Summary list. */ |
3ac237f8 MS |
4598 | if (use_json) |
4599 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4600 | else | |
4601 | vty_out (vty, " Database Summary List %d%s", | |
4602 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
4603 | ||
718e3744 | 4604 | /* Show Link State Request list. */ |
3ac237f8 MS |
4605 | if (use_json) |
4606 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4607 | else | |
4608 | vty_out (vty, " Link State Request List %ld%s", | |
4609 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
4610 | ||
718e3744 | 4611 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4612 | if (use_json) |
4613 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4614 | else | |
4615 | vty_out (vty, " Link State Retransmission List %ld%s", | |
4616 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
4617 | ||
718e3744 | 4618 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4619 | if (use_json) |
4620 | { | |
4621 | if (nbr->t_inactivity != NULL) | |
4622 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4623 | } | |
4624 | else | |
4625 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
4626 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
4627 | ||
718e3744 | 4628 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4629 | if (use_json) |
4630 | { | |
4631 | if (nbr->t_db_desc != NULL) | |
4632 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4633 | } | |
4634 | else | |
4635 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
4636 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
4637 | ||
718e3744 | 4638 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4639 | if (use_json) |
4640 | { | |
4641 | if (nbr->t_ls_req != NULL) | |
4642 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4643 | } | |
4644 | else | |
4645 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
4646 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
4647 | ||
718e3744 | 4648 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4649 | if (use_json) |
4650 | { | |
4651 | if (nbr->t_ls_upd != NULL) | |
4652 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4653 | } | |
4654 | else | |
4655 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
4656 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
4657 | ||
4658 | if (use_json) | |
4659 | { | |
4660 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4661 | json_object_object_add(json, "noNbrId", json_sub); | |
4662 | else | |
4663 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4664 | } | |
68fe91d6 | 4665 | |
4666 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4667 | } |
4668 | ||
7c8ff89e DS |
4669 | static int |
4670 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4671 | int arg_base, const char **argv, u_char use_json) |
718e3744 | 4672 | { |
52dc7ee6 | 4673 | struct listnode *node; |
718e3744 | 4674 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4675 | struct ospf_interface *oi; |
718e3744 | 4676 | struct in_addr router_id; |
4677 | int ret; | |
3ac237f8 MS |
4678 | json_object *json = NULL; |
4679 | ||
4680 | if (use_json) | |
4681 | json = json_object_new_object(); | |
718e3744 | 4682 | |
7c8ff89e | 4683 | if (ospf->instance) |
3ac237f8 MS |
4684 | { |
4685 | if (use_json) | |
4686 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4687 | else | |
4688 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4689 | VTY_NEWLINE, VTY_NEWLINE); | |
4690 | } | |
7c8ff89e | 4691 | |
3ac237f8 | 4692 | ret = inet_aton (argv[arg_base], &router_id); |
718e3744 | 4693 | if (!ret) |
4694 | { | |
3ac237f8 MS |
4695 | if (!use_json) |
4696 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
718e3744 | 4697 | return CMD_WARNING; |
4698 | } | |
4699 | ||
1eb8ef25 | 4700 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4701 | { |
4702 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4703 | { | |
4704 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4705 | } | |
4706 | } | |
4707 | ||
4708 | if (use_json) | |
4709 | { | |
4710 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4711 | json_object_free(json); | |
4712 | } | |
4713 | else | |
4714 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4715 | |
718e3744 | 4716 | return CMD_SUCCESS; |
4717 | } | |
4718 | ||
7c8ff89e DS |
4719 | DEFUN (show_ip_ospf_neighbor_id, |
4720 | show_ip_ospf_neighbor_id_cmd, | |
3ac237f8 | 4721 | "show ip ospf neighbor A.B.C.D {json}", |
718e3744 | 4722 | SHOW_STR |
4723 | IP_STR | |
4724 | "OSPF information\n" | |
4725 | "Neighbor list\n" | |
3ac237f8 MS |
4726 | "Neighbor ID\n" |
4727 | "JavaScript Object Notation\n") | |
718e3744 | 4728 | { |
020709f9 | 4729 | struct ospf *ospf; |
db7c8528 | 4730 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4731 | |
0bad4851 | 4732 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4733 | return CMD_SUCCESS; |
4734 | ||
db7c8528 | 4735 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4736 | } |
4737 | ||
4738 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4739 | show_ip_ospf_instance_neighbor_id_cmd, | |
3ac237f8 | 4740 | "show ip ospf <1-65535> neighbor A.B.C.D {json}", |
7c8ff89e DS |
4741 | SHOW_STR |
4742 | IP_STR | |
4743 | "OSPF information\n" | |
4744 | "Instance ID\n" | |
4745 | "Neighbor list\n" | |
3ac237f8 MS |
4746 | "Neighbor ID\n" |
4747 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4748 | { |
4749 | struct ospf *ospf; | |
4750 | u_short instance = 0; | |
db7c8528 | 4751 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4752 | |
4753 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4754 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4755 | return CMD_SUCCESS; |
4756 | ||
db7c8528 | 4757 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4758 | } |
4759 | ||
4760 | static int | |
3ac237f8 | 4761 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4762 | { |
1eb8ef25 | 4763 | struct ospf_interface *oi; |
52dc7ee6 | 4764 | struct listnode *node; |
3ac237f8 MS |
4765 | json_object *json = NULL; |
4766 | ||
4767 | if (use_json) | |
4768 | json = json_object_new_object(); | |
718e3744 | 4769 | |
7c8ff89e | 4770 | if (ospf->instance) |
3ac237f8 MS |
4771 | { |
4772 | if (use_json) | |
4773 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4774 | else | |
4775 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4776 | VTY_NEWLINE, VTY_NEWLINE); | |
4777 | } | |
718e3744 | 4778 | |
1eb8ef25 | 4779 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4780 | { |
718e3744 | 4781 | struct route_node *rn; |
4782 | struct ospf_neighbor *nbr; | |
4783 | ||
4784 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4785 | { |
4786 | if ((nbr = rn->info)) | |
4787 | { | |
4788 | if (nbr != oi->nbr_self) | |
4789 | { | |
4790 | if (nbr->state != NSM_Down) | |
4791 | { | |
4792 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4793 | } | |
4794 | } | |
4795 | } | |
4796 | } | |
718e3744 | 4797 | } |
4798 | ||
3ac237f8 MS |
4799 | if (use_json) |
4800 | { | |
4801 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4802 | json_object_free(json); | |
4803 | } | |
4804 | else | |
4805 | vty_out (vty, "%s", VTY_NEWLINE); | |
4806 | ||
718e3744 | 4807 | return CMD_SUCCESS; |
4808 | } | |
4809 | ||
7c8ff89e DS |
4810 | DEFUN (show_ip_ospf_neighbor_detail, |
4811 | show_ip_ospf_neighbor_detail_cmd, | |
3ac237f8 | 4812 | "show ip ospf neighbor detail {json}", |
718e3744 | 4813 | SHOW_STR |
4814 | IP_STR | |
4815 | "OSPF information\n" | |
4816 | "Neighbor list\n" | |
3ac237f8 MS |
4817 | "detail of all neighbors\n" |
4818 | "JavaScript Object Notation\n") | |
718e3744 | 4819 | { |
020709f9 | 4820 | struct ospf *ospf; |
db7c8528 | 4821 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4822 | |
0bad4851 | 4823 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4824 | return CMD_SUCCESS; |
4825 | ||
db7c8528 | 4826 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4827 | } |
4828 | ||
4829 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4830 | show_ip_ospf_instance_neighbor_detail_cmd, | |
3ac237f8 | 4831 | "show ip ospf <1-65535> neighbor detail {json}", |
7c8ff89e DS |
4832 | SHOW_STR |
4833 | IP_STR | |
4834 | "OSPF information\n" | |
4835 | "Instance ID\n" | |
4836 | "Neighbor list\n" | |
3ac237f8 MS |
4837 | "detail of all neighbors\n" |
4838 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4839 | { |
4840 | struct ospf *ospf; | |
4841 | u_short instance = 0; | |
db7c8528 | 4842 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4843 | |
4844 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4845 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4846 | return CMD_SUCCESS; |
4847 | ||
db7c8528 | 4848 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4849 | } |
4850 | ||
4851 | static int | |
3ac237f8 | 4852 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4853 | { |
52dc7ee6 | 4854 | struct listnode *node; |
1eb8ef25 | 4855 | struct ospf_interface *oi; |
3ac237f8 MS |
4856 | json_object *json = NULL; |
4857 | ||
4858 | if (use_json) | |
4859 | json = json_object_new_object(); | |
718e3744 | 4860 | |
7c8ff89e | 4861 | if (ospf->instance) |
3ac237f8 MS |
4862 | { |
4863 | if (use_json) | |
4864 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4865 | else | |
4866 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4867 | VTY_NEWLINE, VTY_NEWLINE); | |
4868 | } | |
718e3744 | 4869 | |
1eb8ef25 | 4870 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4871 | { |
718e3744 | 4872 | struct route_node *rn; |
4873 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4874 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4875 | |
4876 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4877 | if ((nbr = rn->info)) | |
4878 | if (nbr != oi->nbr_self) | |
4879 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) | |
3ac237f8 | 4880 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4881 | |
4882 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4883 | { |
4884 | struct listnode *nd; | |
718e3744 | 4885 | |
3ac237f8 MS |
4886 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4887 | { | |
4888 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4889 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4890 | } | |
4891 | } | |
4892 | } | |
4893 | ||
4894 | if (use_json) | |
4895 | { | |
4896 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4897 | json_object_free(json); | |
4898 | } | |
4899 | else | |
4900 | { | |
4901 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4902 | } |
4903 | ||
4904 | return CMD_SUCCESS; | |
4905 | } | |
4906 | ||
7c8ff89e DS |
4907 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4908 | show_ip_ospf_neighbor_detail_all_cmd, | |
3ac237f8 | 4909 | "show ip ospf neighbor detail all {json}", |
718e3744 | 4910 | SHOW_STR |
4911 | IP_STR | |
4912 | "OSPF information\n" | |
4913 | "Neighbor list\n" | |
7c8ff89e | 4914 | "detail of all neighbors\n" |
3ac237f8 MS |
4915 | "include down status neighbor\n" |
4916 | "JavaScript Object Notation\n") | |
718e3744 | 4917 | { |
020709f9 | 4918 | struct ospf *ospf; |
db7c8528 | 4919 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4920 | |
0bad4851 | 4921 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4922 | return CMD_SUCCESS; |
4923 | ||
db7c8528 | 4924 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4925 | } |
4926 | ||
4927 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4928 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
3ac237f8 | 4929 | "show ip ospf <1-65535> neighbor detail all {json}", |
7c8ff89e DS |
4930 | SHOW_STR |
4931 | IP_STR | |
4932 | "OSPF information\n" | |
4933 | "Instance ID\n" | |
4934 | "Neighbor list\n" | |
4935 | "detail of all neighbors\n" | |
3ac237f8 MS |
4936 | "include down status neighbor\n" |
4937 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4938 | { |
4939 | struct ospf *ospf; | |
4940 | u_short instance = 0; | |
db7c8528 | 4941 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
4942 | |
4943 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 4944 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4945 | return CMD_SUCCESS; |
4946 | ||
db7c8528 | 4947 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4948 | } |
4949 | ||
4950 | static int | |
4951 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4952 | int arg_base, const char **argv, u_char use_json) |
7c8ff89e | 4953 | { |
718e3744 | 4954 | struct ospf_interface *oi; |
bb5b7552 | 4955 | struct interface *ifp; |
4956 | struct route_node *rn, *nrn; | |
4957 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4958 | json_object *json = NULL; |
4959 | ||
4960 | if (use_json) | |
4961 | json = json_object_new_object(); | |
bb5b7552 | 4962 | |
7c8ff89e | 4963 | if (ospf->instance) |
3ac237f8 MS |
4964 | { |
4965 | if (use_json) | |
4966 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4967 | else | |
4968 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4969 | VTY_NEWLINE, VTY_NEWLINE); | |
4970 | } | |
7c8ff89e | 4971 | |
3ac237f8 | 4972 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4973 | if (!ifp) |
718e3744 | 4974 | { |
3ac237f8 MS |
4975 | if (!use_json) |
4976 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4977 | return CMD_WARNING; |
4978 | } | |
4979 | ||
bb5b7552 | 4980 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
4981 | { |
4982 | if ((oi = rn->info)) | |
4983 | { | |
4984 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
4985 | { | |
4986 | if ((nbr = nrn->info)) | |
4987 | { | |
4988 | if (nbr != oi->nbr_self) | |
4989 | { | |
4990 | if (nbr->state != NSM_Down) | |
4991 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4992 | } | |
4993 | } | |
4994 | } | |
4995 | } | |
4996 | } | |
4997 | ||
4998 | if (use_json) | |
4999 | { | |
5000 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
5001 | json_object_free(json); | |
5002 | } | |
5003 | else | |
5004 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5005 | |
5006 | return CMD_SUCCESS; | |
5007 | } | |
5008 | ||
7c8ff89e DS |
5009 | DEFUN (show_ip_ospf_neighbor_int_detail, |
5010 | show_ip_ospf_neighbor_int_detail_cmd, | |
3ac237f8 | 5011 | "show ip ospf neighbor IFNAME detail {json}", |
7c8ff89e DS |
5012 | SHOW_STR |
5013 | IP_STR | |
5014 | "OSPF information\n" | |
5015 | "Neighbor list\n" | |
5016 | "Interface name\n" | |
3ac237f8 MS |
5017 | "detail of all neighbors\n" |
5018 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5019 | { |
5020 | struct ospf *ospf; | |
db7c8528 | 5021 | u_char uj = use_json(argc, argv); |
7c8ff89e | 5022 | |
0bad4851 | 5023 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5024 | return CMD_SUCCESS; |
5025 | ||
db7c8528 | 5026 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
5027 | } |
5028 | ||
5029 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
5030 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
3ac237f8 | 5031 | "show ip ospf <1-65535> neighbor IFNAME detail {json}", |
7c8ff89e DS |
5032 | SHOW_STR |
5033 | IP_STR | |
5034 | "OSPF information\n" | |
5035 | "Instance ID\n" | |
5036 | "Neighbor list\n" | |
5037 | "Interface name\n" | |
3ac237f8 MS |
5038 | "detail of all neighbors\n" |
5039 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5040 | { |
5041 | struct ospf *ospf; | |
5042 | u_short instance = 0; | |
db7c8528 | 5043 | u_char uj = use_json(argc, argv); |
7c8ff89e DS |
5044 | |
5045 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 5046 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5047 | return CMD_SUCCESS; |
5048 | ||
db7c8528 | 5049 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); |
7c8ff89e | 5050 | } |
6b0655a2 | 5051 | |
718e3744 | 5052 | /* Show functions */ |
4dadc291 | 5053 | static int |
020709f9 | 5054 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 5055 | { |
718e3744 | 5056 | struct router_lsa *rl; |
5057 | struct summary_lsa *sl; | |
5058 | struct as_external_lsa *asel; | |
5059 | struct prefix_ipv4 p; | |
5060 | ||
5061 | if (lsa != NULL) | |
5062 | /* If self option is set, check LSA self flag. */ | |
5063 | if (self == 0 || IS_LSA_SELF (lsa)) | |
5064 | { | |
5065 | /* LSA common part show. */ | |
5066 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
5067 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
5068 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
5069 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
5070 | /* LSA specific part show. */ | |
5071 | switch (lsa->data->type) | |
5072 | { | |
5073 | case OSPF_ROUTER_LSA: | |
5074 | rl = (struct router_lsa *) lsa->data; | |
5075 | vty_out (vty, " %-d", ntohs (rl->links)); | |
5076 | break; | |
5077 | case OSPF_SUMMARY_LSA: | |
5078 | sl = (struct summary_lsa *) lsa->data; | |
5079 | ||
5080 | p.family = AF_INET; | |
5081 | p.prefix = sl->header.id; | |
5082 | p.prefixlen = ip_masklen (sl->mask); | |
5083 | apply_mask_ipv4 (&p); | |
5084 | ||
5085 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
5086 | break; | |
5087 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 5088 | case OSPF_AS_NSSA_LSA: |
718e3744 | 5089 | asel = (struct as_external_lsa *) lsa->data; |
5090 | ||
5091 | p.family = AF_INET; | |
5092 | p.prefix = asel->header.id; | |
5093 | p.prefixlen = ip_masklen (asel->mask); | |
5094 | apply_mask_ipv4 (&p); | |
5095 | ||
5096 | vty_out (vty, " %s %s/%d [0x%lx]", | |
5097 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
5098 | inet_ntoa (p.prefix), p.prefixlen, | |
5099 | (u_long)ntohl (asel->e[0].route_tag)); | |
5100 | break; | |
5101 | case OSPF_NETWORK_LSA: | |
5102 | case OSPF_ASBR_SUMMARY_LSA: | |
5103 | #ifdef HAVE_OPAQUE_LSA | |
5104 | case OSPF_OPAQUE_LINK_LSA: | |
5105 | case OSPF_OPAQUE_AREA_LSA: | |
5106 | case OSPF_OPAQUE_AS_LSA: | |
5107 | #endif /* HAVE_OPAQUE_LSA */ | |
5108 | default: | |
5109 | break; | |
5110 | } | |
5111 | vty_out (vty, VTY_NEWLINE); | |
5112 | } | |
5113 | ||
5114 | return 0; | |
5115 | } | |
5116 | ||
8b6a15b2 | 5117 | static const char *show_database_desc[] = |
718e3744 | 5118 | { |
5119 | "unknown", | |
5120 | "Router Link States", | |
5121 | "Net Link States", | |
5122 | "Summary Link States", | |
5123 | "ASBR-Summary Link States", | |
5124 | "AS External Link States", | |
718e3744 | 5125 | "Group Membership LSA", |
5126 | "NSSA-external Link States", | |
718e3744 | 5127 | #ifdef HAVE_OPAQUE_LSA |
5128 | "Type-8 LSA", | |
5129 | "Link-Local Opaque-LSA", | |
5130 | "Area-Local Opaque-LSA", | |
5131 | "AS-external Opaque-LSA", | |
5132 | #endif /* HAVE_OPAQUE_LSA */ | |
5133 | }; | |
5134 | ||
8b6a15b2 | 5135 | static const char *show_database_header[] = |
718e3744 | 5136 | { |
5137 | "", | |
5138 | "Link ID ADV Router Age Seq# CkSum Link count", | |
5139 | "Link ID ADV Router Age Seq# CkSum", | |
5140 | "Link ID ADV Router Age Seq# CkSum Route", | |
5141 | "Link ID ADV Router Age Seq# CkSum", | |
5142 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5143 | " --- header for Group Member ----", |
5144 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5145 | #ifdef HAVE_OPAQUE_LSA |
718e3744 | 5146 | " --- type-8 ---", |
5147 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5148 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5149 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5150 | #endif /* HAVE_OPAQUE_LSA */ | |
5151 | }; | |
5152 | ||
4dadc291 | 5153 | static void |
718e3744 | 5154 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
5155 | { | |
5156 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 5157 | |
718e3744 | 5158 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 5159 | vty_out (vty, " Options: 0x%-2x : %s%s", |
5160 | lsa->data->options, | |
5161 | ospf_options_dump(lsa->data->options), | |
5162 | VTY_NEWLINE); | |
5163 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 5164 | lsa->flags, |
4957f494 | 5165 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
5166 | VTY_NEWLINE); | |
718e3744 | 5167 | |
5168 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
5169 | { | |
5170 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
5171 | ||
5172 | if (rlsa->flags) | |
5173 | vty_out (vty, " :%s%s%s%s", | |
5174 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
5175 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
5176 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
5177 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
5178 | ||
5179 | vty_out (vty, "%s", VTY_NEWLINE); | |
5180 | } | |
5181 | vty_out (vty, " LS Type: %s%s", | |
5182 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
5183 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
5184 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
5185 | vty_out (vty, " Advertising Router: %s%s", | |
5186 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5187 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
5188 | VTY_NEWLINE); | |
5189 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
5190 | VTY_NEWLINE); | |
5191 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
5192 | } | |
5193 | ||
eb1ce605 | 5194 | const char *link_type_desc[] = |
718e3744 | 5195 | { |
5196 | "(null)", | |
5197 | "another Router (point-to-point)", | |
5198 | "a Transit Network", | |
5199 | "Stub Network", | |
5200 | "a Virtual Link", | |
5201 | }; | |
5202 | ||
eb1ce605 | 5203 | const char *link_id_desc[] = |
718e3744 | 5204 | { |
5205 | "(null)", | |
5206 | "Neighboring Router ID", | |
5207 | "Designated Router address", | |
68980084 | 5208 | "Net", |
718e3744 | 5209 | "Neighboring Router ID", |
5210 | }; | |
5211 | ||
eb1ce605 | 5212 | const char *link_data_desc[] = |
718e3744 | 5213 | { |
5214 | "(null)", | |
5215 | "Router Interface address", | |
5216 | "Router Interface address", | |
5217 | "Network Mask", | |
5218 | "Router Interface address", | |
5219 | }; | |
5220 | ||
5221 | /* Show router-LSA each Link information. */ | |
4dadc291 | 5222 | static void |
718e3744 | 5223 | show_ip_ospf_database_router_links (struct vty *vty, |
5224 | struct router_lsa *rl) | |
5225 | { | |
b07c4cb3 DS |
5226 | int len, type; |
5227 | unsigned int i; | |
718e3744 | 5228 | |
5229 | len = ntohs (rl->header.length) - 4; | |
5230 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
5231 | { | |
5232 | type = rl->link[i].type; | |
5233 | ||
5234 | vty_out (vty, " Link connected to: %s%s", | |
5235 | link_type_desc[type], VTY_NEWLINE); | |
5236 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
5237 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
5238 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
5239 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
5240 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
5241 | vty_out (vty, " TOS 0 Metric: %d%s", | |
5242 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
5243 | vty_out (vty, "%s", VTY_NEWLINE); | |
5244 | } | |
5245 | } | |
5246 | ||
5247 | /* Show router-LSA detail information. */ | |
4dadc291 | 5248 | static int |
718e3744 | 5249 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5250 | { | |
5251 | if (lsa != NULL) | |
5252 | { | |
5253 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
5254 | ||
5255 | show_ip_ospf_database_header (vty, lsa); | |
5256 | ||
5257 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
5258 | VTY_NEWLINE, VTY_NEWLINE); | |
5259 | ||
5260 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 5261 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5262 | } |
5263 | ||
5264 | return 0; | |
5265 | } | |
5266 | ||
5267 | /* Show network-LSA detail information. */ | |
4dadc291 | 5268 | static int |
718e3744 | 5269 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5270 | { | |
5271 | int length, i; | |
5272 | ||
5273 | if (lsa != NULL) | |
5274 | { | |
5275 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
5276 | ||
5277 | show_ip_ospf_database_header (vty, lsa); | |
5278 | ||
5279 | vty_out (vty, " Network Mask: /%d%s", | |
5280 | ip_masklen (nl->mask), VTY_NEWLINE); | |
5281 | ||
5282 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
5283 | ||
5284 | for (i = 0; length > 0; i++, length -= 4) | |
5285 | vty_out (vty, " Attached Router: %s%s", | |
5286 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
5287 | ||
5288 | vty_out (vty, "%s", VTY_NEWLINE); | |
5289 | } | |
5290 | ||
5291 | return 0; | |
5292 | } | |
5293 | ||
5294 | /* Show summary-LSA detail information. */ | |
4dadc291 | 5295 | static int |
718e3744 | 5296 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5297 | { | |
5298 | if (lsa != NULL) | |
5299 | { | |
5300 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5301 | ||
5302 | show_ip_ospf_database_header (vty, lsa); | |
5303 | ||
5304 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
5305 | VTY_NEWLINE); | |
5306 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5307 | VTY_NEWLINE); | |
b0a053be | 5308 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5309 | } |
5310 | ||
5311 | return 0; | |
5312 | } | |
5313 | ||
5314 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 5315 | static int |
718e3744 | 5316 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5317 | { | |
5318 | if (lsa != NULL) | |
5319 | { | |
5320 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5321 | ||
5322 | show_ip_ospf_database_header (vty, lsa); | |
5323 | ||
5324 | vty_out (vty, " Network Mask: /%d%s", | |
5325 | ip_masklen (sl->mask), VTY_NEWLINE); | |
5326 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5327 | VTY_NEWLINE); | |
b0a053be | 5328 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5329 | } |
5330 | ||
5331 | return 0; | |
5332 | } | |
5333 | ||
5334 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 5335 | static int |
718e3744 | 5336 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5337 | { | |
5338 | if (lsa != NULL) | |
5339 | { | |
5340 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5341 | ||
5342 | show_ip_ospf_database_header (vty, lsa); | |
5343 | ||
5344 | vty_out (vty, " Network Mask: /%d%s", | |
5345 | ip_masklen (al->mask), VTY_NEWLINE); | |
5346 | vty_out (vty, " Metric Type: %s%s", | |
5347 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5348 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5349 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5350 | vty_out (vty, " Metric: %d%s", | |
5351 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5352 | vty_out (vty, " Forward Address: %s%s", | |
5353 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5354 | ||
5355 | vty_out (vty, " External Route Tag: %lu%s%s", | |
5356 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
5357 | } | |
5358 | ||
5359 | return 0; | |
5360 | } | |
5361 | ||
075e12f5 | 5362 | #if 0 |
4dadc291 | 5363 | static int |
718e3744 | 5364 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
5365 | { | |
5366 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5367 | ||
5368 | /* show_ip_ospf_database_header (vty, lsa); */ | |
5369 | ||
2a42e285 | 5370 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 5371 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5372 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5373 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5374 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5375 | zlog_debug( " TOS: 0%s", "\n"); |
5376 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5377 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5378 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5379 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5380 | ||
2a42e285 | 5381 | zlog_debug( " External Route Tag: %u%s%s", |
718e3744 | 5382 | ntohl (al->e[0].route_tag), "\n", "\n"); |
5383 | ||
5384 | return 0; | |
5385 | } | |
075e12f5 | 5386 | #endif |
718e3744 | 5387 | |
5388 | /* Show AS-NSSA-LSA detail information. */ | |
4dadc291 | 5389 | static int |
718e3744 | 5390 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5391 | { | |
5392 | if (lsa != NULL) | |
5393 | { | |
5394 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5395 | ||
5396 | show_ip_ospf_database_header (vty, lsa); | |
5397 | ||
5398 | vty_out (vty, " Network Mask: /%d%s", | |
5399 | ip_masklen (al->mask), VTY_NEWLINE); | |
5400 | vty_out (vty, " Metric Type: %s%s", | |
5401 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5402 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5403 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5404 | vty_out (vty, " Metric: %d%s", | |
5405 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5406 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
5407 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5408 | ||
5409 | vty_out (vty, " External Route Tag: %u%s%s", | |
5410 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
5411 | } | |
5412 | ||
5413 | return 0; | |
5414 | } | |
5415 | ||
4dadc291 | 5416 | static int |
718e3744 | 5417 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5418 | { | |
5419 | return 0; | |
5420 | } | |
5421 | ||
5422 | #ifdef HAVE_OPAQUE_LSA | |
4dadc291 | 5423 | static int |
718e3744 | 5424 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5425 | { | |
5426 | if (lsa != NULL) | |
5427 | { | |
5428 | show_ip_ospf_database_header (vty, lsa); | |
5429 | show_opaque_info_detail (vty, lsa); | |
5430 | ||
5431 | vty_out (vty, "%s", VTY_NEWLINE); | |
5432 | } | |
5433 | return 0; | |
5434 | } | |
5435 | #endif /* HAVE_OPAQUE_LSA */ | |
5436 | ||
5437 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5438 | { | |
5439 | NULL, | |
5440 | show_router_lsa_detail, | |
5441 | show_network_lsa_detail, | |
5442 | show_summary_lsa_detail, | |
5443 | show_summary_asbr_lsa_detail, | |
5444 | show_as_external_lsa_detail, | |
718e3744 | 5445 | show_func_dummy, |
5446 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5447 | #ifdef HAVE_OPAQUE_LSA |
718e3744 | 5448 | NULL, /* type-8 */ |
5449 | show_opaque_lsa_detail, | |
5450 | show_opaque_lsa_detail, | |
5451 | show_opaque_lsa_detail, | |
5452 | #endif /* HAVE_OPAQUE_LSA */ | |
5453 | }; | |
5454 | ||
4dadc291 | 5455 | static void |
718e3744 | 5456 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5457 | struct in_addr *adv_router) | |
5458 | { | |
5459 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5460 | lp->family = 0; | |
5461 | if (id == NULL) | |
5462 | lp->prefixlen = 0; | |
5463 | else if (adv_router == NULL) | |
5464 | { | |
5465 | lp->prefixlen = 32; | |
5466 | lp->id = *id; | |
5467 | } | |
5468 | else | |
5469 | { | |
5470 | lp->prefixlen = 64; | |
5471 | lp->id = *id; | |
5472 | lp->adv_router = *adv_router; | |
5473 | } | |
5474 | } | |
5475 | ||
4dadc291 | 5476 | static void |
718e3744 | 5477 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5478 | struct in_addr *id, struct in_addr *adv_router) | |
5479 | { | |
5480 | struct prefix_ls lp; | |
5481 | struct route_node *rn, *start; | |
5482 | struct ospf_lsa *lsa; | |
5483 | ||
5484 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5485 | start = route_node_get (rt, (struct prefix *) &lp); | |
5486 | if (start) | |
5487 | { | |
5488 | route_lock_node (start); | |
5489 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5490 | if ((lsa = rn->info)) | |
5491 | { | |
718e3744 | 5492 | if (show_function[lsa->data->type] != NULL) |
5493 | show_function[lsa->data->type] (vty, lsa); | |
5494 | } | |
5495 | route_unlock_node (start); | |
5496 | } | |
5497 | } | |
5498 | ||
5499 | /* Show detail LSA information | |
5500 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5501 | static void |
020709f9 | 5502 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5503 | struct in_addr *id, struct in_addr *adv_router) |
5504 | { | |
52dc7ee6 | 5505 | struct listnode *node; |
1eb8ef25 | 5506 | struct ospf_area *area; |
5507 | ||
718e3744 | 5508 | switch (type) |
5509 | { | |
5510 | case OSPF_AS_EXTERNAL_LSA: | |
5511 | #ifdef HAVE_OPAQUE_LSA | |
5512 | case OSPF_OPAQUE_AS_LSA: | |
5513 | #endif /* HAVE_OPAQUE_LSA */ | |
5514 | vty_out (vty, " %s %s%s", | |
5515 | show_database_desc[type], | |
5516 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5517 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5518 | break; |
5519 | default: | |
1eb8ef25 | 5520 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5521 | { |
718e3744 | 5522 | vty_out (vty, "%s %s (Area %s)%s%s", |
5523 | VTY_NEWLINE, show_database_desc[type], | |
5524 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5525 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
5526 | } | |
5527 | break; | |
5528 | } | |
5529 | } | |
5530 | ||
4dadc291 | 5531 | static void |
718e3744 | 5532 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5533 | struct in_addr *adv_router) | |
5534 | { | |
5535 | struct route_node *rn; | |
5536 | struct ospf_lsa *lsa; | |
5537 | ||
5538 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5539 | if ((lsa = rn->info)) | |
5540 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5541 | { | |
718e3744 | 5542 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5543 | continue; | |
718e3744 | 5544 | if (show_function[lsa->data->type] != NULL) |
5545 | show_function[lsa->data->type] (vty, lsa); | |
5546 | } | |
5547 | } | |
5548 | ||
5549 | /* Show detail LSA information. */ | |
4dadc291 | 5550 | static void |
020709f9 | 5551 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5552 | struct in_addr *adv_router) |
5553 | { | |
52dc7ee6 | 5554 | struct listnode *node; |
1eb8ef25 | 5555 | struct ospf_area *area; |
718e3744 | 5556 | |
5557 | switch (type) | |
5558 | { | |
5559 | case OSPF_AS_EXTERNAL_LSA: | |
5560 | #ifdef HAVE_OPAQUE_LSA | |
5561 | case OSPF_OPAQUE_AS_LSA: | |
5562 | #endif /* HAVE_OPAQUE_LSA */ | |
5563 | vty_out (vty, " %s %s%s", | |
5564 | show_database_desc[type], | |
5565 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5566 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5567 | adv_router); |
5568 | break; | |
5569 | default: | |
1eb8ef25 | 5570 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5571 | { |
718e3744 | 5572 | vty_out (vty, "%s %s (Area %s)%s%s", |
5573 | VTY_NEWLINE, show_database_desc[type], | |
5574 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5575 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
5576 | adv_router); | |
5577 | } | |
5578 | break; | |
5579 | } | |
5580 | } | |
5581 | ||
4dadc291 | 5582 | static void |
020709f9 | 5583 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5584 | { |
020709f9 | 5585 | struct ospf_lsa *lsa; |
5586 | struct route_node *rn; | |
1eb8ef25 | 5587 | struct ospf_area *area; |
52dc7ee6 | 5588 | struct listnode *node; |
718e3744 | 5589 | int type; |
5590 | ||
1eb8ef25 | 5591 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5592 | { |
718e3744 | 5593 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5594 | { | |
5595 | switch (type) | |
5596 | { | |
5597 | case OSPF_AS_EXTERNAL_LSA: | |
5598 | #ifdef HAVE_OPAQUE_LSA | |
5599 | case OSPF_OPAQUE_AS_LSA: | |
5600 | #endif /* HAVE_OPAQUE_LSA */ | |
5601 | continue; | |
5602 | default: | |
5603 | break; | |
5604 | } | |
5605 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5606 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5607 | { | |
5608 | vty_out (vty, " %s (Area %s)%s%s", | |
5609 | show_database_desc[type], | |
5610 | ospf_area_desc_string (area), | |
5611 | VTY_NEWLINE, VTY_NEWLINE); | |
5612 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
5613 | ||
020709f9 | 5614 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5615 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5616 | |
5617 | vty_out (vty, "%s", VTY_NEWLINE); | |
5618 | } | |
5619 | } | |
5620 | } | |
5621 | ||
5622 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5623 | { | |
5624 | switch (type) | |
5625 | { | |
5626 | case OSPF_AS_EXTERNAL_LSA: | |
5627 | #ifdef HAVE_OPAQUE_LSA | |
5628 | case OSPF_OPAQUE_AS_LSA: | |
5629 | #endif /* HAVE_OPAQUE_LSA */ | |
e8e1946e | 5630 | break; |
718e3744 | 5631 | default: |
5632 | continue; | |
5633 | } | |
68980084 | 5634 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5635 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5636 | { |
5637 | vty_out (vty, " %s%s%s", | |
5638 | show_database_desc[type], | |
5639 | VTY_NEWLINE, VTY_NEWLINE); | |
5640 | vty_out (vty, "%s%s", show_database_header[type], | |
5641 | VTY_NEWLINE); | |
020709f9 | 5642 | |
5643 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5644 | show_lsa_summary (vty, lsa, self); | |
5645 | ||
718e3744 | 5646 | vty_out (vty, "%s", VTY_NEWLINE); |
5647 | } | |
5648 | } | |
5649 | ||
5650 | vty_out (vty, "%s", VTY_NEWLINE); | |
5651 | } | |
5652 | ||
4dadc291 | 5653 | static void |
020709f9 | 5654 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5655 | { |
91e6a0e5 | 5656 | struct route_node *rn; |
718e3744 | 5657 | |
5658 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
5659 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
5660 | ||
91e6a0e5 | 5661 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5662 | { |
91e6a0e5 DD |
5663 | struct ospf_lsa *lsa; |
5664 | ||
5665 | if ((lsa = rn->info) != NULL) | |
5666 | { | |
5667 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
5668 | vty_out (vty, "Link State ID: %s%s", | |
5669 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
5670 | vty_out (vty, "Advertising Router: %s%s", | |
5671 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5672 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
5673 | vty_out (vty, "%s", VTY_NEWLINE); | |
5674 | } | |
1eb8ef25 | 5675 | } |
718e3744 | 5676 | } |
5677 | ||
718e3744 | 5678 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5679 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5680 | |
5681 | #ifdef HAVE_OPAQUE_LSA | |
5682 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" | |
5683 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
5684 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
5685 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
5686 | #else /* HAVE_OPAQUE_LSA */ | |
5687 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" | |
5688 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" | |
5689 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" | |
5690 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" | |
5691 | #endif /* HAVE_OPAQUE_LSA */ | |
5692 | ||
5693 | #define OSPF_LSA_TYPES_CMD_STR \ | |
5694 | "asbr-summary|external|network|router|summary" \ | |
5695 | OSPF_LSA_TYPE_NSSA_CMD_STR \ | |
5696 | OSPF_LSA_TYPE_OPAQUE_CMD_STR | |
5697 | ||
5698 | #define OSPF_LSA_TYPES_DESC \ | |
5699 | "ASBR summary link states\n" \ | |
5700 | "External link states\n" \ | |
5701 | "Network link states\n" \ | |
5702 | "Router link states\n" \ | |
5703 | "Network summary link states\n" \ | |
5704 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5705 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5706 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5707 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5708 | ||
7c8ff89e DS |
5709 | static int |
5710 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
5711 | int arg_base, int argc, const char **argv) | |
718e3744 | 5712 | { |
5713 | int type, ret; | |
5714 | struct in_addr id, adv_router; | |
5715 | ||
7c8ff89e DS |
5716 | if (ospf->instance) |
5717 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5718 | VTY_NEWLINE); | |
718e3744 | 5719 | |
5720 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5721 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5722 | |
5723 | /* Show all LSA. */ | |
7c8ff89e | 5724 | if (argc == arg_base + 0) |
718e3744 | 5725 | { |
020709f9 | 5726 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5727 | return CMD_SUCCESS; |
5728 | } | |
5729 | ||
5730 | /* Set database type to show. */ | |
7c8ff89e | 5731 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5732 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5733 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5734 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5735 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5736 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5737 | else if (strncmp (argv[arg_base + 0], "su", 2) == 0) |
718e3744 | 5738 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5739 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5740 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5741 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5742 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 5743 | else if (strncmp (argv[arg_base + 0], "se", 2) == 0) |
718e3744 | 5744 | { |
020709f9 | 5745 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5746 | return CMD_SUCCESS; |
5747 | } | |
7c8ff89e | 5748 | else if (strncmp (argv[arg_base + 0], "m", 1) == 0) |
718e3744 | 5749 | { |
020709f9 | 5750 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5751 | return CMD_SUCCESS; |
5752 | } | |
5753 | #ifdef HAVE_OPAQUE_LSA | |
7c8ff89e | 5754 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5755 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5756 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5757 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5758 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5759 | type = OSPF_OPAQUE_AS_LSA; |
5760 | #endif /* HAVE_OPAQUE_LSA */ | |
5761 | else | |
5762 | return CMD_WARNING; | |
5763 | ||
5764 | /* `show ip ospf database LSA'. */ | |
7c8ff89e | 5765 | if (argc == arg_base + 1) |
020709f9 | 5766 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7c8ff89e | 5767 | else if (argc >= arg_base + 2) |
718e3744 | 5768 | { |
7c8ff89e | 5769 | ret = inet_aton (argv[arg_base + 1], &id); |
718e3744 | 5770 | if (!ret) |
5771 | return CMD_WARNING; | |
5772 | ||
5773 | /* `show ip ospf database LSA ID'. */ | |
7c8ff89e | 5774 | if (argc == arg_base + 2) |
020709f9 | 5775 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5776 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7c8ff89e | 5777 | else if (argc == arg_base + 3) |
718e3744 | 5778 | { |
7c8ff89e | 5779 | if (strncmp (argv[arg_base + 2], "s", 1) == 0) |
68980084 | 5780 | adv_router = ospf->router_id; |
718e3744 | 5781 | else |
5782 | { | |
7c8ff89e | 5783 | ret = inet_aton (argv[arg_base + 2], &adv_router); |
718e3744 | 5784 | if (!ret) |
5785 | return CMD_WARNING; | |
5786 | } | |
020709f9 | 5787 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5788 | } |
5789 | } | |
5790 | ||
5791 | return CMD_SUCCESS; | |
5792 | } | |
5793 | ||
7c8ff89e DS |
5794 | DEFUN (show_ip_ospf_database, |
5795 | show_ip_ospf_database_cmd, | |
5796 | "show ip ospf database", | |
5797 | SHOW_STR | |
5798 | IP_STR | |
5799 | "OSPF information\n" | |
5800 | "Database summary\n") | |
5801 | { | |
5802 | struct ospf *ospf; | |
5803 | ||
0bad4851 | 5804 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5805 | return CMD_SUCCESS; |
5806 | ||
5807 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); | |
5808 | } | |
5809 | ||
718e3744 | 5810 | ALIAS (show_ip_ospf_database, |
5811 | show_ip_ospf_database_type_cmd, | |
5812 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5813 | SHOW_STR | |
5814 | IP_STR | |
5815 | "OSPF information\n" | |
5816 | "Database summary\n" | |
5817 | OSPF_LSA_TYPES_DESC | |
5818 | "LSAs in MaxAge list\n" | |
5819 | "Self-originated link states\n") | |
5820 | ||
5821 | ALIAS (show_ip_ospf_database, | |
5822 | show_ip_ospf_database_type_id_cmd, | |
5823 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") 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 | ||
5831 | ALIAS (show_ip_ospf_database, | |
5832 | show_ip_ospf_database_type_id_adv_router_cmd, | |
5833 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5834 | SHOW_STR | |
5835 | IP_STR | |
5836 | "OSPF information\n" | |
5837 | "Database summary\n" | |
5838 | OSPF_LSA_TYPES_DESC | |
5839 | "Link State ID (as an IP address)\n" | |
5840 | "Advertising Router link states\n" | |
5841 | "Advertising Router (as an IP address)\n") | |
5842 | ||
5843 | ALIAS (show_ip_ospf_database, | |
5844 | show_ip_ospf_database_type_id_self_cmd, | |
5845 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5846 | SHOW_STR | |
5847 | IP_STR | |
5848 | "OSPF information\n" | |
5849 | "Database summary\n" | |
5850 | OSPF_LSA_TYPES_DESC | |
5851 | "Link State ID (as an IP address)\n" | |
5852 | "Self-originated link states\n" | |
5853 | "\n") | |
5854 | ||
7c8ff89e DS |
5855 | DEFUN (show_ip_ospf_instance_database, |
5856 | show_ip_ospf_instance_database_cmd, | |
5857 | "show ip ospf <1-65535> database", | |
718e3744 | 5858 | SHOW_STR |
5859 | IP_STR | |
5860 | "OSPF information\n" | |
7c8ff89e DS |
5861 | "Instance ID\n" |
5862 | "Database summary\n") | |
5863 | { | |
5864 | struct ospf *ospf; | |
5865 | u_short instance = 0; | |
5866 | ||
5867 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
5868 | ||
0bad4851 | 5869 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5870 | return CMD_SUCCESS; |
5871 | ||
5872 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); | |
5873 | } | |
5874 | ||
5875 | ALIAS (show_ip_ospf_instance_database, | |
5876 | show_ip_ospf_instance_database_type_cmd, | |
5877 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5878 | SHOW_STR | |
5879 | IP_STR | |
5880 | "OSPF information\n" | |
5881 | "Instance ID\n" | |
5882 | "Database summary\n" | |
5883 | OSPF_LSA_TYPES_DESC | |
5884 | "LSAs in MaxAge list\n" | |
5885 | "Self-originated link states\n") | |
5886 | ||
5887 | ALIAS (show_ip_ospf_instance_database, | |
5888 | show_ip_ospf_instance_database_type_id_cmd, | |
5889 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5890 | SHOW_STR | |
5891 | IP_STR | |
5892 | "OSPF information\n" | |
5893 | "Instance ID\n" | |
5894 | "Database summary\n" | |
5895 | OSPF_LSA_TYPES_DESC | |
5896 | "Link State ID (as an IP address)\n") | |
5897 | ||
5898 | ALIAS (show_ip_ospf_instance_database, | |
5899 | show_ip_ospf_instance_database_type_id_adv_router_cmd, | |
5900 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5901 | SHOW_STR | |
5902 | IP_STR | |
5903 | "OSPF information\n" | |
5904 | "Instance ID\n" | |
718e3744 | 5905 | "Database summary\n" |
5906 | OSPF_LSA_TYPES_DESC | |
7c8ff89e | 5907 | "Link State ID (as an IP address)\n" |
718e3744 | 5908 | "Advertising Router link states\n" |
5909 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
5910 | |
5911 | ALIAS (show_ip_ospf_instance_database, | |
5912 | show_ip_ospf_instance_database_type_id_self_cmd, | |
5913 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5914 | SHOW_STR | |
5915 | IP_STR | |
5916 | "OSPF information\n" | |
5917 | "Instance ID\n" | |
5918 | "Database summary\n" | |
5919 | OSPF_LSA_TYPES_DESC | |
5920 | "Link State ID (as an IP address)\n" | |
5921 | "Self-originated link states\n" | |
5922 | "\n") | |
5923 | ||
5924 | ||
5925 | static int | |
5926 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
5927 | int arg_base, int argc, const char **argv) | |
718e3744 | 5928 | { |
5929 | int type, ret; | |
5930 | struct in_addr adv_router; | |
5931 | ||
7c8ff89e DS |
5932 | if (ospf->instance) |
5933 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5934 | VTY_NEWLINE); | |
718e3744 | 5935 | |
5936 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5937 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5938 | |
7c8ff89e | 5939 | if (argc != arg_base + 2) |
718e3744 | 5940 | return CMD_WARNING; |
5941 | ||
5942 | /* Set database type to show. */ | |
7c8ff89e | 5943 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5944 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5945 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5946 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5947 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5948 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5949 | else if (strncmp (argv[arg_base + 0], "s", 1) == 0) |
718e3744 | 5950 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5951 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5952 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5953 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5954 | type = OSPF_AS_EXTERNAL_LSA; |
5955 | #ifdef HAVE_OPAQUE_LSA | |
7c8ff89e | 5956 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5957 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5958 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5959 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5960 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5961 | type = OSPF_OPAQUE_AS_LSA; |
5962 | #endif /* HAVE_OPAQUE_LSA */ | |
5963 | else | |
5964 | return CMD_WARNING; | |
5965 | ||
7c8ff89e DS |
5966 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
5967 | if (strncmp (argv[arg_base + 1], "s", 1) == 0) | |
5968 | adv_router = ospf->router_id; | |
5969 | else | |
5970 | { | |
5971 | ret = inet_aton (argv[arg_base + 1], &adv_router); | |
5972 | if (!ret) | |
5973 | return CMD_WARNING; | |
5974 | } | |
5975 | ||
5976 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5977 | ||
5978 | return CMD_SUCCESS; | |
5979 | } | |
5980 | ||
5981 | DEFUN (show_ip_ospf_database_type_adv_router, | |
5982 | show_ip_ospf_database_type_adv_router_cmd, | |
5983 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
5984 | SHOW_STR | |
5985 | IP_STR | |
5986 | "OSPF information\n" | |
5987 | "Database summary\n" | |
5988 | OSPF_LSA_TYPES_DESC | |
5989 | "Advertising Router link states\n" | |
5990 | "Advertising Router (as an IP address)\n") | |
5991 | { | |
5992 | struct ospf *ospf; | |
5993 | ||
0bad4851 | 5994 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5995 | return CMD_SUCCESS; |
5996 | ||
5997 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
5998 | } | |
5999 | ||
6000 | ALIAS (show_ip_ospf_database_type_adv_router, | |
6001 | show_ip_ospf_database_type_self_cmd, | |
6002 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
6003 | SHOW_STR | |
6004 | IP_STR | |
6005 | "OSPF information\n" | |
6006 | "Database summary\n" | |
6007 | OSPF_LSA_TYPES_DESC | |
6008 | "Self-originated link states\n") | |
6009 | ||
6010 | DEFUN (show_ip_ospf_instance_database_type_adv_router, | |
6011 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
6012 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", | |
6013 | SHOW_STR | |
6014 | IP_STR | |
6015 | "OSPF information\n" | |
6016 | "Instance ID\n" | |
6017 | "Database summary\n" | |
6018 | OSPF_LSA_TYPES_DESC | |
6019 | "Advertising Router link states\n" | |
6020 | "Advertising Router (as an IP address)\n") | |
6021 | { | |
6022 | struct ospf *ospf; | |
6023 | u_short instance = 0; | |
6024 | ||
6025 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
718e3744 | 6026 | |
0bad4851 | 6027 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 6028 | return CMD_SUCCESS; |
718e3744 | 6029 | |
7c8ff89e | 6030 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 6031 | } |
6032 | ||
7c8ff89e DS |
6033 | ALIAS (show_ip_ospf_instance_database_type_adv_router, |
6034 | show_ip_ospf_instance_database_type_self_cmd, | |
6035 | "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
718e3744 | 6036 | SHOW_STR |
6037 | IP_STR | |
6038 | "OSPF information\n" | |
7c8ff89e | 6039 | "Instance ID\n" |
718e3744 | 6040 | "Database summary\n" |
6041 | OSPF_LSA_TYPES_DESC | |
6042 | "Self-originated link states\n") | |
6043 | ||
718e3744 | 6044 | DEFUN (ip_ospf_authentication_args, |
6045 | ip_ospf_authentication_args_addr_cmd, | |
6046 | "ip ospf authentication (null|message-digest) A.B.C.D", | |
6047 | "IP Information\n" | |
6048 | "OSPF interface commands\n" | |
6049 | "Enable authentication on this interface\n" | |
6050 | "Use null authentication\n" | |
6051 | "Use message-digest authentication\n" | |
6052 | "Address of interface") | |
6053 | { | |
6054 | struct interface *ifp; | |
6055 | struct in_addr addr; | |
6056 | int ret; | |
6057 | struct ospf_if_params *params; | |
6058 | ||
6059 | ifp = vty->index; | |
6060 | params = IF_DEF_PARAMS (ifp); | |
6061 | ||
6062 | if (argc == 2) | |
6063 | { | |
6064 | ret = inet_aton(argv[1], &addr); | |
6065 | if (!ret) | |
6066 | { | |
6067 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6068 | VTY_NEWLINE); | |
6069 | return CMD_WARNING; | |
6070 | } | |
6071 | ||
6072 | params = ospf_get_if_params (ifp, addr); | |
6073 | ospf_if_update_params (ifp, addr); | |
6074 | } | |
6075 | ||
6076 | /* Handle null authentication */ | |
6077 | if ( argv[0][0] == 'n' ) | |
6078 | { | |
6079 | SET_IF_PARAM (params, auth_type); | |
6080 | params->auth_type = OSPF_AUTH_NULL; | |
6081 | return CMD_SUCCESS; | |
6082 | } | |
6083 | ||
6084 | /* Handle message-digest authentication */ | |
6085 | if ( argv[0][0] == 'm' ) | |
6086 | { | |
6087 | SET_IF_PARAM (params, auth_type); | |
6088 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6089 | return CMD_SUCCESS; | |
6090 | } | |
6091 | ||
6092 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
6093 | return CMD_WARNING; | |
6094 | } | |
6095 | ||
6096 | ALIAS (ip_ospf_authentication_args, | |
6097 | ip_ospf_authentication_args_cmd, | |
6098 | "ip ospf authentication (null|message-digest)", | |
6099 | "IP Information\n" | |
6100 | "OSPF interface commands\n" | |
6101 | "Enable authentication on this interface\n" | |
6102 | "Use null authentication\n" | |
6103 | "Use message-digest authentication\n") | |
6104 | ||
6105 | DEFUN (ip_ospf_authentication, | |
6106 | ip_ospf_authentication_addr_cmd, | |
6107 | "ip ospf authentication A.B.C.D", | |
6108 | "IP Information\n" | |
6109 | "OSPF interface commands\n" | |
6110 | "Enable authentication on this interface\n" | |
6111 | "Address of interface") | |
6112 | { | |
6113 | struct interface *ifp; | |
6114 | struct in_addr addr; | |
6115 | int ret; | |
6116 | struct ospf_if_params *params; | |
6117 | ||
6118 | ifp = vty->index; | |
6119 | params = IF_DEF_PARAMS (ifp); | |
6120 | ||
6121 | if (argc == 1) | |
6122 | { | |
5dcf71df | 6123 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6124 | if (!ret) |
6125 | { | |
6126 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6127 | VTY_NEWLINE); | |
6128 | return CMD_WARNING; | |
6129 | } | |
6130 | ||
6131 | params = ospf_get_if_params (ifp, addr); | |
6132 | ospf_if_update_params (ifp, addr); | |
6133 | } | |
6134 | ||
6135 | SET_IF_PARAM (params, auth_type); | |
6136 | params->auth_type = OSPF_AUTH_SIMPLE; | |
6137 | ||
6138 | return CMD_SUCCESS; | |
6139 | } | |
6140 | ||
6141 | ALIAS (ip_ospf_authentication, | |
6142 | ip_ospf_authentication_cmd, | |
6143 | "ip ospf authentication", | |
6144 | "IP Information\n" | |
6145 | "OSPF interface commands\n" | |
6146 | "Enable authentication on this interface\n") | |
6147 | ||
b4a039bf DS |
6148 | DEFUN (no_ip_ospf_authentication_args, |
6149 | no_ip_ospf_authentication_args_addr_cmd, | |
6150 | "no ip ospf authentication (null|message-digest) A.B.C.D", | |
6151 | NO_STR | |
6152 | "IP Information\n" | |
6153 | "OSPF interface commands\n" | |
6154 | "Enable authentication on this interface\n" | |
6155 | "Use null authentication\n" | |
6156 | "Use message-digest authentication\n" | |
6157 | "Address of interface") | |
6158 | { | |
6159 | struct interface *ifp; | |
6160 | struct in_addr addr; | |
6161 | int ret; | |
6162 | struct ospf_if_params *params; | |
6163 | struct route_node *rn; | |
6164 | int auth_type; | |
6165 | ||
6166 | ifp = vty->index; | |
6167 | params = IF_DEF_PARAMS (ifp); | |
6168 | ||
6169 | if (argc == 2) | |
6170 | { | |
6171 | ret = inet_aton(argv[1], &addr); | |
6172 | if (!ret) | |
6173 | { | |
6174 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6175 | VTY_NEWLINE); | |
6176 | return CMD_WARNING; | |
6177 | } | |
6178 | ||
6179 | params = ospf_lookup_if_params (ifp, addr); | |
6180 | if (params == NULL) | |
6181 | { | |
6182 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6183 | return CMD_WARNING; | |
6184 | } | |
6185 | params->auth_type = OSPF_AUTH_NOTSET; | |
6186 | UNSET_IF_PARAM (params, auth_type); | |
6187 | if (params != IF_DEF_PARAMS (ifp)) | |
6188 | { | |
6189 | ospf_free_if_params (ifp, addr); | |
6190 | ospf_if_update_params (ifp, addr); | |
6191 | } | |
6192 | } | |
6193 | else | |
6194 | { | |
6195 | if ( argv[0][0] == 'n' ) | |
6196 | { | |
6197 | auth_type = OSPF_AUTH_NULL; | |
6198 | } | |
6199 | else if ( argv[0][0] == 'm' ) | |
6200 | { | |
6201 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6202 | } | |
6203 | else | |
6204 | { | |
6205 | vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE); | |
6206 | return CMD_WARNING; | |
6207 | } | |
6208 | /* | |
6209 | * Here we have a case where the user has entered | |
6210 | * 'no ip ospf authentication (null | message_digest )' | |
6211 | * we need to find if we have any ip addresses underneath it that | |
6212 | * correspond to the associated type. | |
6213 | */ | |
813d4307 DW |
6214 | if (params->auth_type == auth_type) |
6215 | { | |
6216 | params->auth_type = OSPF_AUTH_NOTSET; | |
6217 | UNSET_IF_PARAM (params, auth_type); | |
6218 | } | |
6219 | ||
b4a039bf DS |
6220 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6221 | { | |
6222 | if ((params = rn->info)) | |
6223 | { | |
6224 | if (params->auth_type == auth_type) | |
6225 | { | |
6226 | params->auth_type = OSPF_AUTH_NOTSET; | |
6227 | UNSET_IF_PARAM (params, auth_type); | |
6228 | if (params != IF_DEF_PARAMS (ifp)) | |
6229 | { | |
6230 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6231 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6232 | } | |
6233 | } | |
6234 | } | |
6235 | } | |
6236 | } | |
6237 | ||
6238 | return CMD_SUCCESS; | |
6239 | } | |
6240 | ||
6241 | ALIAS (no_ip_ospf_authentication_args, | |
6242 | no_ip_ospf_authentication_args_cmd, | |
6243 | "no ip ospf authentication (null|message-digest)", | |
6244 | NO_STR | |
6245 | "IP Information\n" | |
6246 | "OSPF interface commands\n" | |
6247 | "Enable authentication on this interface\n" | |
6248 | "Use null authentication\n" | |
6249 | "Use message-digest authentication\n") | |
6250 | ||
718e3744 | 6251 | DEFUN (no_ip_ospf_authentication, |
6252 | no_ip_ospf_authentication_addr_cmd, | |
6253 | "no ip ospf authentication A.B.C.D", | |
6254 | NO_STR | |
6255 | "IP Information\n" | |
6256 | "OSPF interface commands\n" | |
6257 | "Enable authentication on this interface\n" | |
6258 | "Address of interface") | |
6259 | { | |
6260 | struct interface *ifp; | |
6261 | struct in_addr addr; | |
6262 | int ret; | |
6263 | struct ospf_if_params *params; | |
b4a039bf DS |
6264 | struct route_node *rn; |
6265 | ||
718e3744 | 6266 | ifp = vty->index; |
6267 | params = IF_DEF_PARAMS (ifp); | |
6268 | ||
6269 | if (argc == 1) | |
6270 | { | |
5dcf71df | 6271 | ret = inet_aton(argv[0], &addr); |
718e3744 | 6272 | if (!ret) |
6273 | { | |
6274 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6275 | VTY_NEWLINE); | |
6276 | return CMD_WARNING; | |
6277 | } | |
6278 | ||
6279 | params = ospf_lookup_if_params (ifp, addr); | |
6280 | if (params == NULL) | |
b4a039bf DS |
6281 | { |
6282 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6283 | return CMD_WARNING; | |
6284 | } | |
718e3744 | 6285 | |
b4a039bf DS |
6286 | params->auth_type = OSPF_AUTH_NOTSET; |
6287 | UNSET_IF_PARAM (params, auth_type); | |
6288 | if (params != IF_DEF_PARAMS (ifp)) | |
6289 | { | |
6290 | ospf_free_if_params (ifp, addr); | |
6291 | ospf_if_update_params (ifp, addr); | |
6292 | } | |
6293 | } | |
6294 | else | |
718e3744 | 6295 | { |
b4a039bf DS |
6296 | /* |
6297 | * When a user enters 'no ip ospf authentication' | |
6298 | * We should remove all authentication types from | |
6299 | * the interface. | |
6300 | */ | |
813d4307 DW |
6301 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6302 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6303 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6304 | { | |
6305 | params->auth_type = OSPF_AUTH_NOTSET; | |
6306 | UNSET_IF_PARAM (params, auth_type); | |
6307 | } | |
6308 | ||
b4a039bf DS |
6309 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6310 | { | |
6311 | if ((params = rn->info)) | |
6312 | { | |
813d4307 | 6313 | |
b4a039bf DS |
6314 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6315 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6316 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6317 | { | |
6318 | params->auth_type = OSPF_AUTH_NOTSET; | |
6319 | UNSET_IF_PARAM (params, auth_type); | |
6320 | if (params != IF_DEF_PARAMS (ifp)) | |
6321 | { | |
6322 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6323 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6324 | } | |
6325 | } | |
6326 | } | |
6327 | } | |
718e3744 | 6328 | } |
6329 | ||
6330 | return CMD_SUCCESS; | |
6331 | } | |
6332 | ||
6333 | ALIAS (no_ip_ospf_authentication, | |
6334 | no_ip_ospf_authentication_cmd, | |
6335 | "no ip ospf authentication", | |
6336 | NO_STR | |
6337 | "IP Information\n" | |
6338 | "OSPF interface commands\n" | |
6339 | "Enable authentication on this interface\n") | |
6340 | ||
6341 | DEFUN (ip_ospf_authentication_key, | |
6342 | ip_ospf_authentication_key_addr_cmd, | |
6343 | "ip ospf authentication-key AUTH_KEY A.B.C.D", | |
6344 | "IP Information\n" | |
6345 | "OSPF interface commands\n" | |
6346 | "Authentication password (key)\n" | |
6347 | "The OSPF password (key)\n" | |
6348 | "Address of interface") | |
6349 | { | |
6350 | struct interface *ifp; | |
6351 | struct in_addr addr; | |
6352 | int ret; | |
6353 | struct ospf_if_params *params; | |
6354 | ||
6355 | ifp = vty->index; | |
6356 | params = IF_DEF_PARAMS (ifp); | |
6357 | ||
6358 | if (argc == 2) | |
6359 | { | |
6360 | ret = inet_aton(argv[1], &addr); | |
6361 | if (!ret) | |
6362 | { | |
6363 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6364 | VTY_NEWLINE); | |
6365 | return CMD_WARNING; | |
6366 | } | |
6367 | ||
6368 | params = ospf_get_if_params (ifp, addr); | |
6369 | ospf_if_update_params (ifp, addr); | |
6370 | } | |
6371 | ||
718e3744 | 6372 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
c9e52be3 | 6373 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 6374 | SET_IF_PARAM (params, auth_simple); |
6375 | ||
6376 | return CMD_SUCCESS; | |
6377 | } | |
6378 | ||
6379 | ALIAS (ip_ospf_authentication_key, | |
6380 | ip_ospf_authentication_key_cmd, | |
6381 | "ip ospf authentication-key AUTH_KEY", | |
6382 | "IP Information\n" | |
6383 | "OSPF interface commands\n" | |
6384 | "Authentication password (key)\n" | |
6385 | "The OSPF password (key)") | |
6386 | ||
747e489c DW |
6387 | ALIAS_HIDDEN (ip_ospf_authentication_key, |
6388 | ospf_authentication_key_cmd, | |
6389 | "ospf authentication-key AUTH_KEY", | |
6390 | "OSPF interface commands\n" | |
6391 | "Authentication password (key)\n" | |
6392 | "The OSPF password (key)") | |
718e3744 | 6393 | |
6394 | DEFUN (no_ip_ospf_authentication_key, | |
813d4307 DW |
6395 | no_ip_ospf_authentication_key_authkey_addr_cmd, |
6396 | "no ip ospf authentication-key AUTH_KEY A.B.C.D", | |
718e3744 | 6397 | NO_STR |
6398 | "IP Information\n" | |
6399 | "OSPF interface commands\n" | |
6400 | "Authentication password (key)\n" | |
813d4307 | 6401 | "The OSPF password (key)") |
718e3744 | 6402 | { |
6403 | struct interface *ifp; | |
6404 | struct in_addr addr; | |
718e3744 | 6405 | struct ospf_if_params *params; |
813d4307 | 6406 | int ret; |
718e3744 | 6407 | |
6408 | ifp = vty->index; | |
6409 | params = IF_DEF_PARAMS (ifp); | |
6410 | ||
813d4307 | 6411 | if (argc == 2) |
718e3744 | 6412 | { |
813d4307 | 6413 | ret = inet_aton(argv[1], &addr); |
718e3744 | 6414 | if (!ret) |
6415 | { | |
6416 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6417 | VTY_NEWLINE); | |
6418 | return CMD_WARNING; | |
6419 | } | |
6420 | ||
6421 | params = ospf_lookup_if_params (ifp, addr); | |
6422 | if (params == NULL) | |
6423 | return CMD_SUCCESS; | |
6424 | } | |
6425 | ||
6426 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); | |
6427 | UNSET_IF_PARAM (params, auth_simple); | |
6428 | ||
6429 | if (params != IF_DEF_PARAMS (ifp)) | |
6430 | { | |
6431 | ospf_free_if_params (ifp, addr); | |
6432 | ospf_if_update_params (ifp, addr); | |
6433 | } | |
6434 | ||
6435 | return CMD_SUCCESS; | |
6436 | } | |
6437 | ||
813d4307 DW |
6438 | ALIAS (no_ip_ospf_authentication_key, |
6439 | no_ip_ospf_authentication_key_authkey_cmd, | |
6440 | "no ip ospf authentication-key AUTH_KEY", | |
6441 | NO_STR | |
6442 | "IP Information\n" | |
6443 | "OSPF interface commands\n" | |
6444 | "Authentication password (key)\n") | |
6445 | ||
718e3744 | 6446 | ALIAS (no_ip_ospf_authentication_key, |
6447 | no_ip_ospf_authentication_key_cmd, | |
6448 | "no ip ospf authentication-key", | |
6449 | NO_STR | |
6450 | "IP Information\n" | |
6451 | "OSPF interface commands\n" | |
6452 | "Authentication password (key)\n") | |
6453 | ||
6454 | ALIAS (no_ip_ospf_authentication_key, | |
6455 | no_ospf_authentication_key_cmd, | |
6456 | "no ospf authentication-key", | |
6457 | NO_STR | |
6458 | "OSPF interface commands\n" | |
6459 | "Authentication password (key)\n") | |
6460 | ||
813d4307 DW |
6461 | ALIAS (no_ip_ospf_authentication_key, |
6462 | no_ospf_authentication_key_authkey_cmd, | |
6463 | "no ospf authentication-key AUTH_KEY", | |
6464 | NO_STR | |
6465 | "OSPF interface commands\n" | |
6466 | "Authentication password (key)\n" | |
6467 | "The OSPF password (key)\n") | |
6468 | ||
6469 | ALIAS (no_ip_ospf_authentication_key, | |
6470 | no_ospf_authentication_key_authkey_ip_cmd, | |
6471 | "no ospf authentication-key AUTH_KEY A.B.C.D", | |
6472 | NO_STR | |
6473 | "OSPF interface commands\n" | |
6474 | "Authentication password (key)\n" | |
6475 | "The OSPF password (key)\n" | |
6476 | "Address of interface") | |
6477 | ||
718e3744 | 6478 | DEFUN (ip_ospf_message_digest_key, |
6479 | ip_ospf_message_digest_key_addr_cmd, | |
6480 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", | |
6481 | "IP Information\n" | |
6482 | "OSPF interface commands\n" | |
6483 | "Message digest authentication password (key)\n" | |
6484 | "Key ID\n" | |
6485 | "Use MD5 algorithm\n" | |
6486 | "The OSPF password (key)" | |
6487 | "Address of interface") | |
6488 | { | |
6489 | struct interface *ifp; | |
6490 | struct crypt_key *ck; | |
6491 | u_char key_id; | |
6492 | struct in_addr addr; | |
6493 | int ret; | |
6494 | struct ospf_if_params *params; | |
6495 | ||
6496 | ifp = vty->index; | |
6497 | params = IF_DEF_PARAMS (ifp); | |
6498 | ||
6499 | if (argc == 3) | |
6500 | { | |
6501 | ret = inet_aton(argv[2], &addr); | |
6502 | if (!ret) | |
6503 | { | |
6504 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6505 | VTY_NEWLINE); | |
6506 | return CMD_WARNING; | |
6507 | } | |
6508 | ||
6509 | params = ospf_get_if_params (ifp, addr); | |
6510 | ospf_if_update_params (ifp, addr); | |
6511 | } | |
6512 | ||
6513 | key_id = strtol (argv[0], NULL, 10); | |
6514 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) | |
6515 | { | |
6516 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
6517 | return CMD_WARNING; | |
6518 | } | |
6519 | ||
6520 | ck = ospf_crypt_key_new (); | |
6521 | ck->key_id = (u_char) key_id; | |
6522 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 6523 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
718e3744 | 6524 | |
6525 | ospf_crypt_key_add (params->auth_crypt, ck); | |
6526 | SET_IF_PARAM (params, auth_crypt); | |
6527 | ||
6528 | return CMD_SUCCESS; | |
6529 | } | |
6530 | ||
6531 | ALIAS (ip_ospf_message_digest_key, | |
6532 | ip_ospf_message_digest_key_cmd, | |
6533 | "ip ospf message-digest-key <1-255> md5 KEY", | |
6534 | "IP Information\n" | |
6535 | "OSPF interface commands\n" | |
6536 | "Message digest authentication password (key)\n" | |
6537 | "Key ID\n" | |
6538 | "Use MD5 algorithm\n" | |
6539 | "The OSPF password (key)") | |
6540 | ||
747e489c DW |
6541 | ALIAS_HIDDEN (ip_ospf_message_digest_key, |
6542 | ospf_message_digest_key_cmd, | |
6543 | "ospf message-digest-key <1-255> md5 KEY", | |
6544 | "OSPF interface commands\n" | |
6545 | "Message digest authentication password (key)\n" | |
6546 | "Key ID\n" | |
6547 | "Use MD5 algorithm\n" | |
6548 | "The OSPF password (key)") | |
718e3744 | 6549 | |
813d4307 DW |
6550 | DEFUN (no_ip_ospf_message_digest_key_md5, |
6551 | no_ip_ospf_message_digest_key_md5_addr_cmd, | |
6552 | "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", | |
6553 | NO_STR | |
6554 | "IP Information\n" | |
6555 | "OSPF interface commands\n" | |
6556 | "Message digest authentication password (key)\n" | |
6557 | "Key ID\n" | |
6558 | "Use MD5 algorithm\n" | |
6559 | "The OSPF password (key)" | |
6560 | "Address of interface") | |
6561 | { | |
6562 | struct interface *ifp; | |
6563 | struct crypt_key *ck; | |
6564 | int key_id; | |
6565 | struct in_addr addr; | |
6566 | int ret; | |
6567 | struct ospf_if_params *params; | |
6568 | ||
6569 | ifp = vty->index; | |
6570 | params = IF_DEF_PARAMS (ifp); | |
6571 | ||
6572 | if (argc == 3) | |
6573 | { | |
6574 | ret = inet_aton(argv[2], &addr); | |
6575 | if (!ret) | |
6576 | { | |
6577 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6578 | VTY_NEWLINE); | |
6579 | return CMD_WARNING; | |
6580 | } | |
6581 | ||
6582 | params = ospf_lookup_if_params (ifp, addr); | |
6583 | if (params == NULL) | |
6584 | return CMD_SUCCESS; | |
6585 | } | |
6586 | ||
6587 | key_id = strtol (argv[0], NULL, 10); | |
6588 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); | |
6589 | if (ck == NULL) | |
6590 | { | |
6591 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6592 | return CMD_WARNING; | |
6593 | } | |
6594 | ||
6595 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6596 | ||
6597 | if (params != IF_DEF_PARAMS (ifp)) | |
6598 | { | |
6599 | ospf_free_if_params (ifp, addr); | |
6600 | ospf_if_update_params (ifp, addr); | |
6601 | } | |
6602 | ||
6603 | return CMD_SUCCESS; | |
6604 | } | |
6605 | ||
6606 | ALIAS (no_ip_ospf_message_digest_key_md5, | |
6607 | no_ip_ospf_message_digest_key_md5_cmd, | |
6608 | "no ip ospf message-digest-key <1-255> md5 KEY", | |
6609 | NO_STR | |
6610 | "IP Information\n" | |
6611 | "OSPF interface commands\n" | |
6612 | "Message digest authentication password (key)\n" | |
6613 | "Key ID\n" | |
6614 | "Use MD5 algorithm\n" | |
6615 | "The OSPF password (key)") | |
6616 | ||
718e3744 | 6617 | DEFUN (no_ip_ospf_message_digest_key, |
6618 | no_ip_ospf_message_digest_key_addr_cmd, | |
6619 | "no ip ospf message-digest-key <1-255> A.B.C.D", | |
6620 | NO_STR | |
6621 | "IP Information\n" | |
6622 | "OSPF interface commands\n" | |
6623 | "Message digest authentication password (key)\n" | |
6624 | "Key ID\n" | |
6625 | "Address of interface") | |
6626 | { | |
6627 | struct interface *ifp; | |
6628 | struct crypt_key *ck; | |
6629 | int key_id; | |
6630 | struct in_addr addr; | |
6631 | int ret; | |
6632 | struct ospf_if_params *params; | |
6633 | ||
6634 | ifp = vty->index; | |
6635 | params = IF_DEF_PARAMS (ifp); | |
6636 | ||
6637 | if (argc == 2) | |
6638 | { | |
6639 | ret = inet_aton(argv[1], &addr); | |
6640 | if (!ret) | |
6641 | { | |
6642 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6643 | VTY_NEWLINE); | |
6644 | return CMD_WARNING; | |
6645 | } | |
6646 | ||
6647 | params = ospf_lookup_if_params (ifp, addr); | |
6648 | if (params == NULL) | |
6649 | return CMD_SUCCESS; | |
6650 | } | |
6651 | ||
6652 | key_id = strtol (argv[0], NULL, 10); | |
6653 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); | |
6654 | if (ck == NULL) | |
6655 | { | |
6656 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6657 | return CMD_WARNING; | |
6658 | } | |
6659 | ||
6660 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6661 | ||
6662 | if (params != IF_DEF_PARAMS (ifp)) | |
6663 | { | |
6664 | ospf_free_if_params (ifp, addr); | |
6665 | ospf_if_update_params (ifp, addr); | |
6666 | } | |
6667 | ||
6668 | return CMD_SUCCESS; | |
6669 | } | |
6670 | ||
6671 | ALIAS (no_ip_ospf_message_digest_key, | |
6672 | no_ip_ospf_message_digest_key_cmd, | |
6673 | "no ip ospf message-digest-key <1-255>", | |
6674 | NO_STR | |
6675 | "IP Information\n" | |
6676 | "OSPF interface commands\n" | |
6677 | "Message digest authentication password (key)\n" | |
6678 | "Key ID\n") | |
6679 | ||
6680 | ALIAS (no_ip_ospf_message_digest_key, | |
6681 | no_ospf_message_digest_key_cmd, | |
6682 | "no ospf message-digest-key <1-255>", | |
6683 | NO_STR | |
6684 | "OSPF interface commands\n" | |
6685 | "Message digest authentication password (key)\n" | |
6686 | "Key ID\n") | |
6687 | ||
6688 | DEFUN (ip_ospf_cost, | |
9eff36b3 | 6689 | ip_ospf_cost_u32_inet4_cmd, |
718e3744 | 6690 | "ip ospf cost <1-65535> A.B.C.D", |
6691 | "IP Information\n" | |
6692 | "OSPF interface commands\n" | |
6693 | "Interface cost\n" | |
6694 | "Cost\n" | |
6695 | "Address of interface") | |
6696 | { | |
6697 | struct interface *ifp = vty->index; | |
6698 | u_int32_t cost; | |
6699 | struct in_addr addr; | |
6700 | int ret; | |
6701 | struct ospf_if_params *params; | |
6702 | ||
6703 | params = IF_DEF_PARAMS (ifp); | |
6704 | ||
6705 | cost = strtol (argv[0], NULL, 10); | |
6706 | ||
6707 | /* cost range is <1-65535>. */ | |
6708 | if (cost < 1 || cost > 65535) | |
6709 | { | |
6710 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6711 | return CMD_WARNING; | |
6712 | } | |
6713 | ||
6714 | if (argc == 2) | |
6715 | { | |
6716 | ret = inet_aton(argv[1], &addr); | |
6717 | if (!ret) | |
6718 | { | |
6719 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6720 | VTY_NEWLINE); | |
6721 | return CMD_WARNING; | |
6722 | } | |
6723 | ||
6724 | params = ospf_get_if_params (ifp, addr); | |
6725 | ospf_if_update_params (ifp, addr); | |
6726 | } | |
6727 | ||
6728 | SET_IF_PARAM (params, output_cost_cmd); | |
6729 | params->output_cost_cmd = cost; | |
6730 | ||
6731 | ospf_if_recalculate_output_cost (ifp); | |
6732 | ||
6733 | return CMD_SUCCESS; | |
6734 | } | |
6735 | ||
6736 | ALIAS (ip_ospf_cost, | |
9eff36b3 | 6737 | ip_ospf_cost_u32_cmd, |
718e3744 | 6738 | "ip ospf cost <1-65535>", |
6739 | "IP Information\n" | |
6740 | "OSPF interface commands\n" | |
6741 | "Interface cost\n" | |
6742 | "Cost") | |
6743 | ||
747e489c DW |
6744 | ALIAS_HIDDEN (ip_ospf_cost, |
6745 | ospf_cost_u32_cmd, | |
6746 | "ospf cost <1-65535>", | |
6747 | "OSPF interface commands\n" | |
6748 | "Interface cost\n" | |
6749 | "Cost") | |
6750 | ||
6751 | ALIAS_HIDDEN (ip_ospf_cost, | |
6752 | ospf_cost_u32_inet4_cmd, | |
6753 | "ospf cost <1-65535> A.B.C.D", | |
6754 | "OSPF interface commands\n" | |
6755 | "Interface cost\n" | |
6756 | "Cost\n" | |
6757 | "Address of interface") | |
9eff36b3 | 6758 | |
718e3744 | 6759 | DEFUN (no_ip_ospf_cost, |
9eff36b3 | 6760 | no_ip_ospf_cost_inet4_cmd, |
718e3744 | 6761 | "no ip ospf cost A.B.C.D", |
6762 | NO_STR | |
6763 | "IP Information\n" | |
6764 | "OSPF interface commands\n" | |
6765 | "Interface cost\n" | |
6766 | "Address of interface") | |
6767 | { | |
6768 | struct interface *ifp = vty->index; | |
6769 | struct in_addr addr; | |
6770 | int ret; | |
6771 | struct ospf_if_params *params; | |
6772 | ||
6773 | ifp = vty->index; | |
6774 | params = IF_DEF_PARAMS (ifp); | |
6775 | ||
6776 | if (argc == 1) | |
6777 | { | |
6778 | ret = inet_aton(argv[0], &addr); | |
6779 | if (!ret) | |
6780 | { | |
6781 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6782 | VTY_NEWLINE); | |
6783 | return CMD_WARNING; | |
6784 | } | |
6785 | ||
6786 | params = ospf_lookup_if_params (ifp, addr); | |
6787 | if (params == NULL) | |
6788 | return CMD_SUCCESS; | |
6789 | } | |
6790 | ||
6791 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6792 | ||
6793 | if (params != IF_DEF_PARAMS (ifp)) | |
6794 | { | |
6795 | ospf_free_if_params (ifp, addr); | |
6796 | ospf_if_update_params (ifp, addr); | |
6797 | } | |
6798 | ||
6799 | ospf_if_recalculate_output_cost (ifp); | |
6800 | ||
6801 | return CMD_SUCCESS; | |
6802 | } | |
6803 | ||
6804 | ALIAS (no_ip_ospf_cost, | |
6805 | no_ip_ospf_cost_cmd, | |
6806 | "no ip ospf cost", | |
6807 | NO_STR | |
6808 | "IP Information\n" | |
6809 | "OSPF interface commands\n" | |
6810 | "Interface cost\n") | |
6811 | ||
6812 | ALIAS (no_ip_ospf_cost, | |
6813 | no_ospf_cost_cmd, | |
6814 | "no ospf cost", | |
6815 | NO_STR | |
6816 | "OSPF interface commands\n" | |
6817 | "Interface cost\n") | |
6818 | ||
9eff36b3 DO |
6819 | ALIAS (no_ip_ospf_cost, |
6820 | no_ospf_cost_inet4_cmd, | |
6821 | "no ospf cost A.B.C.D", | |
6822 | NO_STR | |
6823 | "OSPF interface commands\n" | |
6824 | "Interface cost\n" | |
6825 | "Address of interface") | |
6826 | ||
827341b7 DO |
6827 | DEFUN (no_ip_ospf_cost2, |
6828 | no_ip_ospf_cost_u32_cmd, | |
6829 | "no ip ospf cost <1-65535>", | |
6830 | NO_STR | |
6831 | "IP Information\n" | |
6832 | "OSPF interface commands\n" | |
6833 | "Interface cost\n" | |
6834 | "Cost") | |
6835 | { | |
6836 | struct interface *ifp = vty->index; | |
6837 | struct in_addr addr; | |
6838 | u_int32_t cost; | |
6839 | int ret; | |
6840 | struct ospf_if_params *params; | |
6841 | ||
6842 | ifp = vty->index; | |
6843 | params = IF_DEF_PARAMS (ifp); | |
6844 | ||
6845 | /* According to the semantics we are mimicking "no ip ospf cost N" is | |
6846 | * always treated as "no ip ospf cost" regardless of the actual value | |
6847 | * of N already configured for the interface. Thus the first argument | |
6848 | * is always checked to be a number, but is ignored after that. | |
6849 | */ | |
6850 | cost = strtol (argv[0], NULL, 10); | |
6851 | if (cost < 1 || cost > 65535) | |
6852 | { | |
6853 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6854 | return CMD_WARNING; | |
6855 | } | |
6856 | ||
6857 | if (argc == 2) | |
6858 | { | |
6859 | ret = inet_aton(argv[1], &addr); | |
6860 | if (!ret) | |
6861 | { | |
6862 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6863 | VTY_NEWLINE); | |
6864 | return CMD_WARNING; | |
6865 | } | |
6866 | ||
6867 | params = ospf_lookup_if_params (ifp, addr); | |
6868 | if (params == NULL) | |
6869 | return CMD_SUCCESS; | |
6870 | } | |
6871 | ||
6872 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6873 | ||
6874 | if (params != IF_DEF_PARAMS (ifp)) | |
6875 | { | |
6876 | ospf_free_if_params (ifp, addr); | |
6877 | ospf_if_update_params (ifp, addr); | |
6878 | } | |
6879 | ||
6880 | ospf_if_recalculate_output_cost (ifp); | |
6881 | ||
6882 | return CMD_SUCCESS; | |
6883 | } | |
6884 | ||
6885 | ALIAS (no_ip_ospf_cost2, | |
6886 | no_ospf_cost_u32_cmd, | |
6887 | "no ospf cost <1-65535>", | |
6888 | NO_STR | |
6889 | "OSPF interface commands\n" | |
6890 | "Interface cost\n" | |
6891 | "Cost") | |
6892 | ||
6893 | ALIAS (no_ip_ospf_cost2, | |
6894 | no_ip_ospf_cost_u32_inet4_cmd, | |
6895 | "no ip ospf cost <1-65535> A.B.C.D", | |
6896 | NO_STR | |
6897 | "IP Information\n" | |
6898 | "OSPF interface commands\n" | |
6899 | "Interface cost\n" | |
6900 | "Cost\n" | |
6901 | "Address of interface") | |
6902 | ||
6903 | ALIAS (no_ip_ospf_cost2, | |
6904 | no_ospf_cost_u32_inet4_cmd, | |
6905 | "no ospf cost <1-65535> A.B.C.D", | |
6906 | NO_STR | |
6907 | "OSPF interface commands\n" | |
6908 | "Interface cost\n" | |
6909 | "Cost\n" | |
6910 | "Address of interface") | |
9eff36b3 | 6911 | |
4dadc291 | 6912 | static void |
718e3744 | 6913 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6914 | { | |
6915 | struct route_node *rn; | |
6916 | struct ospf_neighbor *nbr; | |
6917 | ||
6918 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6919 | if ((nbr = rn->info)) | |
6920 | { | |
6921 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6922 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6923 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6924 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6925 | } | |
6926 | } | |
6927 | ||
f9ad937f | 6928 | static int |
6929 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6930 | const char *nbr_str, | |
6931 | const char *fast_hello_str) | |
718e3744 | 6932 | { |
6933 | struct interface *ifp = vty->index; | |
6934 | u_int32_t seconds; | |
f9ad937f | 6935 | u_char hellomult; |
718e3744 | 6936 | struct in_addr addr; |
6937 | int ret; | |
6938 | struct ospf_if_params *params; | |
6939 | struct ospf_interface *oi; | |
6940 | struct route_node *rn; | |
6941 | ||
6942 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6943 | |
6944 | if (nbr_str) | |
718e3744 | 6945 | { |
f9ad937f | 6946 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6947 | if (!ret) |
6948 | { | |
6949 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6950 | VTY_NEWLINE); | |
6951 | return CMD_WARNING; | |
6952 | } | |
6953 | ||
6954 | params = ospf_get_if_params (ifp, addr); | |
6955 | ospf_if_update_params (ifp, addr); | |
6956 | } | |
6957 | ||
f9ad937f | 6958 | if (interval_str) |
6959 | { | |
6960 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
6961 | 1, 65535); | |
6962 | ||
6963 | /* reset fast_hello too, just to be sure */ | |
6964 | UNSET_IF_PARAM (params, fast_hello); | |
6965 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6966 | } | |
6967 | else if (fast_hello_str) | |
6968 | { | |
6969 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
6970 | 1, 10); | |
6971 | /* 1s dead-interval with sub-second hellos desired */ | |
6972 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6973 | SET_IF_PARAM (params, fast_hello); | |
6974 | params->fast_hello = hellomult; | |
6975 | } | |
6976 | else | |
6977 | { | |
6978 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
6979 | VTY_NEWLINE); | |
6980 | return CMD_WARNING; | |
6981 | } | |
6982 | ||
718e3744 | 6983 | SET_IF_PARAM (params, v_wait); |
6984 | params->v_wait = seconds; | |
6985 | ||
6986 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6987 | if (nbr_str) |
718e3744 | 6988 | { |
cac3b5c4 PJ |
6989 | struct ospf *ospf; |
6990 | if ((ospf = ospf_lookup())) | |
68980084 | 6991 | { |
6992 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6993 | if (oi) | |
6994 | ospf_nbr_timer_update (oi); | |
6995 | } | |
718e3744 | 6996 | } |
6997 | else | |
6998 | { | |
6999 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7000 | if ((oi = rn->info)) | |
7001 | ospf_nbr_timer_update (oi); | |
7002 | } | |
7003 | ||
7004 | return CMD_SUCCESS; | |
7005 | } | |
7006 | ||
f9ad937f | 7007 | |
7008 | DEFUN (ip_ospf_dead_interval, | |
7009 | ip_ospf_dead_interval_addr_cmd, | |
7010 | "ip ospf dead-interval <1-65535> A.B.C.D", | |
7011 | "IP Information\n" | |
7012 | "OSPF interface commands\n" | |
7013 | "Interval after which a neighbor is declared dead\n" | |
7014 | "Seconds\n" | |
7015 | "Address of interface\n") | |
7016 | { | |
7017 | if (argc == 2) | |
7018 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); | |
7019 | else | |
7020 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); | |
7021 | } | |
7022 | ||
718e3744 | 7023 | ALIAS (ip_ospf_dead_interval, |
7024 | ip_ospf_dead_interval_cmd, | |
7025 | "ip ospf dead-interval <1-65535>", | |
7026 | "IP Information\n" | |
7027 | "OSPF interface commands\n" | |
7028 | "Interval after which a neighbor is declared dead\n" | |
7029 | "Seconds\n") | |
7030 | ||
747e489c DW |
7031 | ALIAS_HIDDEN (ip_ospf_dead_interval, |
7032 | ospf_dead_interval_cmd, | |
7033 | "ospf dead-interval <1-65535>", | |
7034 | "OSPF interface commands\n" | |
7035 | "Interval after which a neighbor is declared dead\n" | |
7036 | "Seconds\n") | |
718e3744 | 7037 | |
f9ad937f | 7038 | DEFUN (ip_ospf_dead_interval_minimal, |
7039 | ip_ospf_dead_interval_minimal_addr_cmd, | |
7040 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
7041 | "IP Information\n" | |
7042 | "OSPF interface commands\n" | |
7043 | "Interval after which a neighbor is declared dead\n" | |
7044 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7045 | "Hello multiplier factor\n" | |
7046 | "Number of Hellos to send each second\n" | |
7047 | "Address of interface\n") | |
7048 | { | |
7049 | if (argc == 2) | |
7050 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); | |
7051 | else | |
7052 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); | |
7053 | } | |
7054 | ||
7055 | ALIAS (ip_ospf_dead_interval_minimal, | |
7056 | ip_ospf_dead_interval_minimal_cmd, | |
7057 | "ip ospf dead-interval minimal hello-multiplier <1-10>", | |
7058 | "IP Information\n" | |
7059 | "OSPF interface commands\n" | |
7060 | "Interval after which a neighbor is declared dead\n" | |
7061 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7062 | "Hello multiplier factor\n" | |
7063 | "Number of Hellos to send each second\n") | |
7064 | ||
718e3744 | 7065 | DEFUN (no_ip_ospf_dead_interval, |
7066 | no_ip_ospf_dead_interval_addr_cmd, | |
f9dfba8d | 7067 | "no ip ospf dead-interval <1-65535> A.B.C.D", |
718e3744 | 7068 | NO_STR |
7069 | "IP Information\n" | |
7070 | "OSPF interface commands\n" | |
7071 | "Interval after which a neighbor is declared dead\n" | |
f9dfba8d | 7072 | "Seconds\n" |
718e3744 | 7073 | "Address of interface") |
7074 | { | |
7075 | struct interface *ifp = vty->index; | |
7076 | struct in_addr addr; | |
7077 | int ret; | |
7078 | struct ospf_if_params *params; | |
7079 | struct ospf_interface *oi; | |
7080 | struct route_node *rn; | |
020709f9 | 7081 | |
718e3744 | 7082 | ifp = vty->index; |
7083 | params = IF_DEF_PARAMS (ifp); | |
7084 | ||
f9dfba8d | 7085 | if (argc == 2) |
718e3744 | 7086 | { |
f9dfba8d | 7087 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7088 | if (!ret) |
7089 | { | |
7090 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7091 | VTY_NEWLINE); | |
7092 | return CMD_WARNING; | |
7093 | } | |
7094 | ||
7095 | params = ospf_lookup_if_params (ifp, addr); | |
7096 | if (params == NULL) | |
7097 | return CMD_SUCCESS; | |
7098 | } | |
7099 | ||
7100 | UNSET_IF_PARAM (params, v_wait); | |
7101 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 7102 | |
7103 | UNSET_IF_PARAM (params, fast_hello); | |
7104 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
7105 | ||
718e3744 | 7106 | if (params != IF_DEF_PARAMS (ifp)) |
7107 | { | |
7108 | ospf_free_if_params (ifp, addr); | |
7109 | ospf_if_update_params (ifp, addr); | |
7110 | } | |
7111 | ||
7112 | /* Update timer values in neighbor structure. */ | |
7113 | if (argc == 1) | |
7114 | { | |
cac3b5c4 PJ |
7115 | struct ospf *ospf; |
7116 | ||
7117 | if ((ospf = ospf_lookup())) | |
68980084 | 7118 | { |
7119 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
7120 | if (oi) | |
7121 | ospf_nbr_timer_update (oi); | |
7122 | } | |
718e3744 | 7123 | } |
7124 | else | |
7125 | { | |
7126 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7127 | if ((oi = rn->info)) | |
7128 | ospf_nbr_timer_update (oi); | |
7129 | } | |
7130 | ||
7131 | return CMD_SUCCESS; | |
7132 | } | |
7133 | ||
f9dfba8d DS |
7134 | ALIAS (no_ip_ospf_dead_interval, |
7135 | no_ip_ospf_dead_interval_seconds_cmd, | |
7136 | "no ip ospf dead-interval <1-65535>", | |
7137 | NO_STR | |
7138 | "IP Information\n" | |
7139 | "OSPF interface commands\n" | |
7140 | "Interval after which a neighbor is declared dead\n" | |
7141 | "Seconds\n") | |
7142 | ||
718e3744 | 7143 | ALIAS (no_ip_ospf_dead_interval, |
7144 | no_ip_ospf_dead_interval_cmd, | |
7145 | "no ip ospf dead-interval", | |
7146 | NO_STR | |
7147 | "IP Information\n" | |
7148 | "OSPF interface commands\n" | |
7149 | "Interval after which a neighbor is declared dead\n") | |
7150 | ||
7151 | ALIAS (no_ip_ospf_dead_interval, | |
7152 | no_ospf_dead_interval_cmd, | |
7153 | "no ospf dead-interval", | |
7154 | NO_STR | |
7155 | "OSPF interface commands\n" | |
7156 | "Interval after which a neighbor is declared dead\n") | |
7157 | ||
813d4307 DW |
7158 | ALIAS (no_ip_ospf_dead_interval, |
7159 | no_ip_ospf_dead_interval_minimal_addr_cmd, | |
7160 | "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
7161 | NO_STR | |
7162 | "IP Information\n" | |
7163 | "OSPF interface commands\n" | |
7164 | "Interval after which a neighbor is declared dead\n" | |
7165 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7166 | "Hello multiplier factor\n" | |
7167 | "Number of Hellos to send each second\n" | |
7168 | "Address of interface\n") | |
7169 | ||
7170 | ALIAS (no_ip_ospf_dead_interval, | |
7171 | no_ip_ospf_dead_interval_minimal_cmd, | |
7172 | "no ip ospf dead-interval minimal hello-multiplier <1-10>", | |
7173 | NO_STR | |
7174 | "IP Information\n" | |
7175 | "OSPF interface commands\n" | |
7176 | "Interval after which a neighbor is declared dead\n" | |
7177 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7178 | "Hello multiplier factor\n" | |
7179 | "Number of Hellos to send each second\n") | |
7180 | ||
718e3744 | 7181 | DEFUN (ip_ospf_hello_interval, |
7182 | ip_ospf_hello_interval_addr_cmd, | |
7183 | "ip ospf hello-interval <1-65535> A.B.C.D", | |
7184 | "IP Information\n" | |
7185 | "OSPF interface commands\n" | |
7186 | "Time between HELLO packets\n" | |
7187 | "Seconds\n" | |
7188 | "Address of interface") | |
7189 | { | |
7190 | struct interface *ifp = vty->index; | |
7191 | u_int32_t seconds; | |
7192 | struct in_addr addr; | |
7193 | int ret; | |
7194 | struct ospf_if_params *params; | |
7195 | ||
7196 | params = IF_DEF_PARAMS (ifp); | |
7197 | ||
7198 | seconds = strtol (argv[0], NULL, 10); | |
7199 | ||
7200 | /* HelloInterval range is <1-65535>. */ | |
7201 | if (seconds < 1 || seconds > 65535) | |
7202 | { | |
7203 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); | |
7204 | return CMD_WARNING; | |
7205 | } | |
7206 | ||
7207 | if (argc == 2) | |
7208 | { | |
7209 | ret = inet_aton(argv[1], &addr); | |
7210 | if (!ret) | |
7211 | { | |
7212 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7213 | VTY_NEWLINE); | |
7214 | return CMD_WARNING; | |
7215 | } | |
7216 | ||
7217 | params = ospf_get_if_params (ifp, addr); | |
7218 | ospf_if_update_params (ifp, addr); | |
7219 | } | |
7220 | ||
f9ad937f | 7221 | SET_IF_PARAM (params, v_hello); |
718e3744 | 7222 | params->v_hello = seconds; |
7223 | ||
7224 | return CMD_SUCCESS; | |
7225 | } | |
7226 | ||
7227 | ALIAS (ip_ospf_hello_interval, | |
7228 | ip_ospf_hello_interval_cmd, | |
7229 | "ip ospf hello-interval <1-65535>", | |
7230 | "IP Information\n" | |
7231 | "OSPF interface commands\n" | |
7232 | "Time between HELLO packets\n" | |
7233 | "Seconds\n") | |
7234 | ||
747e489c DW |
7235 | ALIAS_HIDDEN (ip_ospf_hello_interval, |
7236 | ospf_hello_interval_cmd, | |
7237 | "ospf hello-interval <1-65535>", | |
7238 | "OSPF interface commands\n" | |
7239 | "Time between HELLO packets\n" | |
7240 | "Seconds\n") | |
718e3744 | 7241 | |
7242 | DEFUN (no_ip_ospf_hello_interval, | |
7243 | no_ip_ospf_hello_interval_addr_cmd, | |
f9dfba8d | 7244 | "no ip ospf hello-interval <1-65535> A.B.C.D", |
718e3744 | 7245 | NO_STR |
7246 | "IP Information\n" | |
7247 | "OSPF interface commands\n" | |
7248 | "Time between HELLO packets\n" | |
f9dfba8d | 7249 | "Seconds\n" |
718e3744 | 7250 | "Address of interface") |
7251 | { | |
7252 | struct interface *ifp = vty->index; | |
7253 | struct in_addr addr; | |
7254 | int ret; | |
7255 | struct ospf_if_params *params; | |
7256 | ||
7257 | ifp = vty->index; | |
7258 | params = IF_DEF_PARAMS (ifp); | |
7259 | ||
f9dfba8d | 7260 | if (argc == 2) |
718e3744 | 7261 | { |
f9dfba8d | 7262 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7263 | if (!ret) |
7264 | { | |
7265 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7266 | VTY_NEWLINE); | |
7267 | return CMD_WARNING; | |
7268 | } | |
7269 | ||
7270 | params = ospf_lookup_if_params (ifp, addr); | |
7271 | if (params == NULL) | |
7272 | return CMD_SUCCESS; | |
7273 | } | |
7274 | ||
7275 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 7276 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 7277 | |
7278 | if (params != IF_DEF_PARAMS (ifp)) | |
7279 | { | |
7280 | ospf_free_if_params (ifp, addr); | |
7281 | ospf_if_update_params (ifp, addr); | |
7282 | } | |
7283 | ||
7284 | return CMD_SUCCESS; | |
7285 | } | |
7286 | ||
f9dfba8d DS |
7287 | ALIAS (no_ip_ospf_hello_interval, |
7288 | no_ip_ospf_hello_interval_seconds_cmd, | |
7289 | "no ip ospf hello-interval <1-65535>", | |
7290 | NO_STR | |
7291 | "IP Information\n" | |
7292 | "OSPF interface commands\n" | |
7293 | "Time between HELLO packets\n" | |
7294 | "Seconds\n") | |
7295 | ||
718e3744 | 7296 | ALIAS (no_ip_ospf_hello_interval, |
7297 | no_ip_ospf_hello_interval_cmd, | |
7298 | "no ip ospf hello-interval", | |
7299 | NO_STR | |
7300 | "IP Information\n" | |
7301 | "OSPF interface commands\n" | |
7302 | "Time between HELLO packets\n") | |
7303 | ||
7304 | ALIAS (no_ip_ospf_hello_interval, | |
7305 | no_ospf_hello_interval_cmd, | |
813d4307 | 7306 | "no ospf hello-interval <1-65535>", |
718e3744 | 7307 | NO_STR |
7308 | "OSPF interface commands\n" | |
813d4307 DW |
7309 | "Time between HELLO packets\n" |
7310 | "Seconds\n") | |
718e3744 | 7311 | |
7312 | DEFUN (ip_ospf_network, | |
7313 | ip_ospf_network_cmd, | |
7314 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7315 | "IP Information\n" | |
7316 | "OSPF interface commands\n" | |
7317 | "Network type\n" | |
7318 | "Specify OSPF broadcast multi-access network\n" | |
7319 | "Specify OSPF NBMA network\n" | |
7320 | "Specify OSPF point-to-multipoint network\n" | |
7321 | "Specify OSPF point-to-point network\n") | |
7322 | { | |
7323 | struct interface *ifp = vty->index; | |
7324 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7325 | struct route_node *rn; | |
4b4bda9b CF |
7326 | |
7327 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
7328 | { | |
7329 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
7330 | return CMD_WARNING; | |
7331 | } | |
7332 | ||
718e3744 | 7333 | if (strncmp (argv[0], "b", 1) == 0) |
7334 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; | |
7335 | else if (strncmp (argv[0], "n", 1) == 0) | |
7336 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; | |
7337 | else if (strncmp (argv[0], "point-to-m", 10) == 0) | |
7338 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; | |
7339 | else if (strncmp (argv[0], "point-to-p", 10) == 0) | |
7340 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; | |
7341 | ||
7342 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7343 | return CMD_SUCCESS; | |
7344 | ||
7345 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
7346 | ||
7347 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7348 | { | |
7349 | struct ospf_interface *oi = rn->info; | |
7350 | ||
7351 | if (!oi) | |
7352 | continue; | |
7353 | ||
7354 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7355 | ||
7356 | if (oi->state > ISM_Down) | |
7357 | { | |
7358 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7359 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7360 | } | |
7361 | } | |
7362 | ||
7363 | return CMD_SUCCESS; | |
7364 | } | |
7365 | ||
747e489c DW |
7366 | ALIAS_HIDDEN (ip_ospf_network, |
7367 | ospf_network_cmd, | |
7368 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7369 | "OSPF interface commands\n" | |
7370 | "Network type\n" | |
7371 | "Specify OSPF broadcast multi-access network\n" | |
7372 | "Specify OSPF NBMA network\n" | |
7373 | "Specify OSPF point-to-multipoint network\n" | |
7374 | "Specify OSPF point-to-point network\n") | |
718e3744 | 7375 | |
7376 | DEFUN (no_ip_ospf_network, | |
7377 | no_ip_ospf_network_cmd, | |
7378 | "no ip ospf network", | |
7379 | NO_STR | |
7380 | "IP Information\n" | |
7381 | "OSPF interface commands\n" | |
7382 | "Network type\n") | |
7383 | { | |
7384 | struct interface *ifp = vty->index; | |
7385 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7386 | struct route_node *rn; | |
7387 | ||
bc18d616 | 7388 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
718e3744 | 7389 | |
7390 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7391 | return CMD_SUCCESS; | |
7392 | ||
7393 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7394 | { | |
7395 | struct ospf_interface *oi = rn->info; | |
7396 | ||
7397 | if (!oi) | |
7398 | continue; | |
7399 | ||
7400 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7401 | ||
7402 | if (oi->state > ISM_Down) | |
7403 | { | |
7404 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7405 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7406 | } | |
7407 | } | |
7408 | ||
7409 | return CMD_SUCCESS; | |
7410 | } | |
7411 | ||
813d4307 DW |
7412 | ALIAS (no_ip_ospf_network, |
7413 | no_ip_ospf_network_val_cmd, | |
7414 | "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7415 | NO_STR | |
7416 | "IP Information\n" | |
7417 | "OSPF interface commands\n" | |
7418 | "Network type\n" | |
7419 | "Specify OSPF broadcast multi-access network\n" | |
7420 | "Specify OSPF NBMA network\n" | |
7421 | "Specify OSPF point-to-multipoint network\n" | |
7422 | "Specify OSPF point-to-point network\n") | |
7423 | ||
718e3744 | 7424 | ALIAS (no_ip_ospf_network, |
7425 | no_ospf_network_cmd, | |
7426 | "no ospf network", | |
7427 | NO_STR | |
7428 | "OSPF interface commands\n" | |
7429 | "Network type\n") | |
7430 | ||
813d4307 DW |
7431 | ALIAS (no_ip_ospf_network, |
7432 | no_ospf_network_val_cmd, | |
7433 | "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7434 | NO_STR | |
7435 | "OSPF interface commands\n" | |
7436 | "Network type\n" | |
7437 | "Specify OSPF broadcast multi-access network\n" | |
7438 | "Specify OSPF NBMA network\n" | |
7439 | "Specify OSPF point-to-multipoint network\n" | |
7440 | "Specify OSPF point-to-point network\n") | |
7441 | ||
718e3744 | 7442 | DEFUN (ip_ospf_priority, |
7443 | ip_ospf_priority_addr_cmd, | |
7444 | "ip ospf priority <0-255> A.B.C.D", | |
7445 | "IP Information\n" | |
7446 | "OSPF interface commands\n" | |
7447 | "Router priority\n" | |
7448 | "Priority\n" | |
7449 | "Address of interface") | |
7450 | { | |
7451 | struct interface *ifp = vty->index; | |
0798cee3 | 7452 | long priority; |
718e3744 | 7453 | struct route_node *rn; |
7454 | struct in_addr addr; | |
7455 | int ret; | |
7456 | struct ospf_if_params *params; | |
7457 | ||
7458 | params = IF_DEF_PARAMS (ifp); | |
7459 | ||
7460 | priority = strtol (argv[0], NULL, 10); | |
7461 | ||
7462 | /* Router Priority range is <0-255>. */ | |
7463 | if (priority < 0 || priority > 255) | |
7464 | { | |
7465 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); | |
7466 | return CMD_WARNING; | |
7467 | } | |
7468 | ||
7469 | if (argc == 2) | |
7470 | { | |
7471 | ret = inet_aton(argv[1], &addr); | |
7472 | if (!ret) | |
7473 | { | |
7474 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7475 | VTY_NEWLINE); | |
7476 | return CMD_WARNING; | |
7477 | } | |
7478 | ||
7479 | params = ospf_get_if_params (ifp, addr); | |
7480 | ospf_if_update_params (ifp, addr); | |
7481 | } | |
7482 | ||
7483 | SET_IF_PARAM (params, priority); | |
7484 | params->priority = priority; | |
7485 | ||
7486 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7487 | { | |
7488 | struct ospf_interface *oi = rn->info; | |
7489 | ||
7490 | if (!oi) | |
7491 | continue; | |
7492 | ||
7493 | ||
7494 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7495 | { | |
7496 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7497 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7498 | } | |
7499 | } | |
7500 | ||
7501 | return CMD_SUCCESS; | |
7502 | } | |
7503 | ||
7504 | ALIAS (ip_ospf_priority, | |
7505 | ip_ospf_priority_cmd, | |
7506 | "ip ospf priority <0-255>", | |
7507 | "IP Information\n" | |
7508 | "OSPF interface commands\n" | |
7509 | "Router priority\n" | |
7510 | "Priority\n") | |
7511 | ||
747e489c DW |
7512 | ALIAS_HIDDEN (ip_ospf_priority, |
7513 | ospf_priority_cmd, | |
7514 | "ospf priority <0-255>", | |
7515 | "OSPF interface commands\n" | |
7516 | "Router priority\n" | |
7517 | "Priority\n") | |
718e3744 | 7518 | |
7519 | DEFUN (no_ip_ospf_priority, | |
7520 | no_ip_ospf_priority_addr_cmd, | |
813d4307 | 7521 | "no ip ospf priority <0-255> A.B.C.D", |
718e3744 | 7522 | NO_STR |
7523 | "IP Information\n" | |
7524 | "OSPF interface commands\n" | |
7525 | "Router priority\n" | |
813d4307 | 7526 | "Priority\n" |
718e3744 | 7527 | "Address of interface") |
7528 | { | |
7529 | struct interface *ifp = vty->index; | |
7530 | struct route_node *rn; | |
7531 | struct in_addr addr; | |
7532 | int ret; | |
7533 | struct ospf_if_params *params; | |
7534 | ||
7535 | ifp = vty->index; | |
7536 | params = IF_DEF_PARAMS (ifp); | |
7537 | ||
813d4307 | 7538 | if (argc == 2) |
718e3744 | 7539 | { |
813d4307 | 7540 | ret = inet_aton(argv[1], &addr); |
718e3744 | 7541 | if (!ret) |
7542 | { | |
7543 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7544 | VTY_NEWLINE); | |
7545 | return CMD_WARNING; | |
7546 | } | |
7547 | ||
7548 | params = ospf_lookup_if_params (ifp, addr); | |
7549 | if (params == NULL) | |
7550 | return CMD_SUCCESS; | |
7551 | } | |
7552 | ||
7553 | UNSET_IF_PARAM (params, priority); | |
7554 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
7555 | ||
7556 | if (params != IF_DEF_PARAMS (ifp)) | |
7557 | { | |
7558 | ospf_free_if_params (ifp, addr); | |
7559 | ospf_if_update_params (ifp, addr); | |
7560 | } | |
7561 | ||
7562 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7563 | { | |
7564 | struct ospf_interface *oi = rn->info; | |
7565 | ||
7566 | if (!oi) | |
7567 | continue; | |
7568 | ||
7569 | ||
7570 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7571 | { | |
7572 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7573 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7574 | } | |
7575 | } | |
7576 | ||
7577 | return CMD_SUCCESS; | |
7578 | } | |
7579 | ||
a1afa410 DS |
7580 | ALIAS (no_ip_ospf_priority, |
7581 | no_ip_ospf_priority_no_param_cmd, | |
7582 | "no ip ospf priority", | |
7583 | NO_STR | |
7584 | "IP Information\n" | |
7585 | "OSPF interface commands\n" | |
7586 | "Router priority\n"); | |
7587 | ||
718e3744 | 7588 | ALIAS (no_ip_ospf_priority, |
7589 | no_ip_ospf_priority_cmd, | |
813d4307 | 7590 | "no ip ospf priority <0-255>", |
718e3744 | 7591 | NO_STR |
7592 | "IP Information\n" | |
7593 | "OSPF interface commands\n" | |
813d4307 DW |
7594 | "Router priority\n" |
7595 | "Priority\n") | |
718e3744 | 7596 | |
7597 | ALIAS (no_ip_ospf_priority, | |
7598 | no_ospf_priority_cmd, | |
813d4307 | 7599 | "no ospf priority <0-255>", |
718e3744 | 7600 | NO_STR |
7601 | "OSPF interface commands\n" | |
813d4307 DW |
7602 | "Router priority\n" |
7603 | "Priority\n") | |
718e3744 | 7604 | |
d5a5c8f0 | 7605 | |
718e3744 | 7606 | DEFUN (ip_ospf_retransmit_interval, |
7607 | ip_ospf_retransmit_interval_addr_cmd, | |
7608 | "ip ospf retransmit-interval <3-65535> A.B.C.D", | |
7609 | "IP Information\n" | |
7610 | "OSPF interface commands\n" | |
7611 | "Time between retransmitting lost link state advertisements\n" | |
7612 | "Seconds\n" | |
7613 | "Address of interface") | |
7614 | { | |
7615 | struct interface *ifp = vty->index; | |
7616 | u_int32_t seconds; | |
7617 | struct in_addr addr; | |
7618 | int ret; | |
7619 | struct ospf_if_params *params; | |
7620 | ||
7621 | params = IF_DEF_PARAMS (ifp); | |
7622 | seconds = strtol (argv[0], NULL, 10); | |
7623 | ||
7624 | /* Retransmit Interval range is <3-65535>. */ | |
7625 | if (seconds < 3 || seconds > 65535) | |
7626 | { | |
7627 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); | |
7628 | return CMD_WARNING; | |
7629 | } | |
7630 | ||
7631 | ||
7632 | if (argc == 2) | |
7633 | { | |
7634 | ret = inet_aton(argv[1], &addr); | |
7635 | if (!ret) | |
7636 | { | |
7637 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7638 | VTY_NEWLINE); | |
7639 | return CMD_WARNING; | |
7640 | } | |
7641 | ||
7642 | params = ospf_get_if_params (ifp, addr); | |
7643 | ospf_if_update_params (ifp, addr); | |
7644 | } | |
7645 | ||
7646 | SET_IF_PARAM (params, retransmit_interval); | |
7647 | params->retransmit_interval = seconds; | |
7648 | ||
7649 | return CMD_SUCCESS; | |
7650 | } | |
7651 | ||
7652 | ALIAS (ip_ospf_retransmit_interval, | |
7653 | ip_ospf_retransmit_interval_cmd, | |
7654 | "ip ospf retransmit-interval <3-65535>", | |
7655 | "IP Information\n" | |
7656 | "OSPF interface commands\n" | |
7657 | "Time between retransmitting lost link state advertisements\n" | |
7658 | "Seconds\n") | |
7659 | ||
747e489c DW |
7660 | ALIAS_HIDDEN (ip_ospf_retransmit_interval, |
7661 | ospf_retransmit_interval_cmd, | |
7662 | "ospf retransmit-interval <3-65535>", | |
7663 | "OSPF interface commands\n" | |
7664 | "Time between retransmitting lost link state advertisements\n" | |
7665 | "Seconds\n") | |
718e3744 | 7666 | |
7667 | DEFUN (no_ip_ospf_retransmit_interval, | |
7668 | no_ip_ospf_retransmit_interval_addr_cmd, | |
7669 | "no ip ospf retransmit-interval A.B.C.D", | |
7670 | NO_STR | |
7671 | "IP Information\n" | |
7672 | "OSPF interface commands\n" | |
7673 | "Time between retransmitting lost link state advertisements\n" | |
7674 | "Address of interface") | |
7675 | { | |
7676 | struct interface *ifp = vty->index; | |
7677 | struct in_addr addr; | |
7678 | int ret; | |
7679 | struct ospf_if_params *params; | |
813d4307 | 7680 | int addr_index; |
718e3744 | 7681 | |
7682 | ifp = vty->index; | |
7683 | params = IF_DEF_PARAMS (ifp); | |
7684 | ||
813d4307 | 7685 | if (argc >= 1) |
718e3744 | 7686 | { |
813d4307 DW |
7687 | if (argc == 1) |
7688 | addr_index = 0; | |
7689 | else | |
7690 | addr_index = 1; | |
7691 | ||
7692 | ret = inet_aton(argv[addr_index], &addr); | |
718e3744 | 7693 | if (!ret) |
7694 | { | |
7695 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7696 | VTY_NEWLINE); | |
7697 | return CMD_WARNING; | |
7698 | } | |
7699 | ||
7700 | params = ospf_lookup_if_params (ifp, addr); | |
7701 | if (params == NULL) | |
7702 | return CMD_SUCCESS; | |
7703 | } | |
7704 | ||
7705 | UNSET_IF_PARAM (params, retransmit_interval); | |
7706 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7707 | ||
7708 | if (params != IF_DEF_PARAMS (ifp)) | |
7709 | { | |
7710 | ospf_free_if_params (ifp, addr); | |
7711 | ospf_if_update_params (ifp, addr); | |
7712 | } | |
7713 | ||
7714 | return CMD_SUCCESS; | |
7715 | } | |
7716 | ||
813d4307 DW |
7717 | ALIAS (no_ip_ospf_retransmit_interval, |
7718 | no_ip_ospf_retransmit_interval_sec_addr_cmd, | |
7719 | "no ip ospf retransmit-interval <3-65535> A.B.C.D", | |
7720 | NO_STR | |
7721 | "IP Information\n" | |
7722 | "OSPF interface commands\n" | |
7723 | "Time between retransmitting lost link state advertisements\n" | |
7724 | "Seconds\n" | |
7725 | "Address of interface") | |
7726 | ||
718e3744 | 7727 | ALIAS (no_ip_ospf_retransmit_interval, |
7728 | no_ip_ospf_retransmit_interval_cmd, | |
7729 | "no ip ospf retransmit-interval", | |
7730 | NO_STR | |
7731 | "IP Information\n" | |
7732 | "OSPF interface commands\n" | |
7733 | "Time between retransmitting lost link state advertisements\n") | |
7734 | ||
7735 | ALIAS (no_ip_ospf_retransmit_interval, | |
7736 | no_ospf_retransmit_interval_cmd, | |
7737 | "no ospf retransmit-interval", | |
7738 | NO_STR | |
7739 | "OSPF interface commands\n" | |
7740 | "Time between retransmitting lost link state advertisements\n") | |
7741 | ||
813d4307 DW |
7742 | DEFUN (no_ip_ospf_retransmit_interval_sec, |
7743 | no_ip_ospf_retransmit_interval_sec_cmd, | |
7744 | "no ip ospf retransmit-interval <3-65535>", | |
7745 | NO_STR | |
7746 | "IP Information\n" | |
7747 | "OSPF interface commands\n" | |
7748 | "Time between retransmitting lost link state advertisements\n" | |
7749 | "Seconds\n") | |
7750 | { | |
7751 | struct interface *ifp = vty->index; | |
7752 | struct ospf_if_params *params; | |
7753 | ||
7754 | ifp = vty->index; | |
7755 | params = IF_DEF_PARAMS (ifp); | |
7756 | ||
7757 | UNSET_IF_PARAM (params, retransmit_interval); | |
7758 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7759 | ||
7760 | return CMD_SUCCESS; | |
7761 | } | |
7762 | ||
7763 | ||
718e3744 | 7764 | DEFUN (ip_ospf_transmit_delay, |
7765 | ip_ospf_transmit_delay_addr_cmd, | |
7766 | "ip ospf transmit-delay <1-65535> A.B.C.D", | |
7767 | "IP Information\n" | |
7768 | "OSPF interface commands\n" | |
7769 | "Link state transmit delay\n" | |
7770 | "Seconds\n" | |
7771 | "Address of interface") | |
7772 | { | |
7773 | struct interface *ifp = vty->index; | |
7774 | u_int32_t seconds; | |
7775 | struct in_addr addr; | |
7776 | int ret; | |
7777 | struct ospf_if_params *params; | |
7778 | ||
7779 | params = IF_DEF_PARAMS (ifp); | |
7780 | seconds = strtol (argv[0], NULL, 10); | |
7781 | ||
7782 | /* Transmit Delay range is <1-65535>. */ | |
7783 | if (seconds < 1 || seconds > 65535) | |
7784 | { | |
7785 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); | |
7786 | return CMD_WARNING; | |
7787 | } | |
7788 | ||
7789 | if (argc == 2) | |
7790 | { | |
7791 | ret = inet_aton(argv[1], &addr); | |
7792 | if (!ret) | |
7793 | { | |
7794 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7795 | VTY_NEWLINE); | |
7796 | return CMD_WARNING; | |
7797 | } | |
7798 | ||
7799 | params = ospf_get_if_params (ifp, addr); | |
7800 | ospf_if_update_params (ifp, addr); | |
7801 | } | |
7802 | ||
7803 | SET_IF_PARAM (params, transmit_delay); | |
7804 | params->transmit_delay = seconds; | |
7805 | ||
7806 | return CMD_SUCCESS; | |
7807 | } | |
7808 | ||
7809 | ALIAS (ip_ospf_transmit_delay, | |
7810 | ip_ospf_transmit_delay_cmd, | |
7811 | "ip ospf transmit-delay <1-65535>", | |
7812 | "IP Information\n" | |
7813 | "OSPF interface commands\n" | |
7814 | "Link state transmit delay\n" | |
7815 | "Seconds\n") | |
7816 | ||
747e489c DW |
7817 | ALIAS_HIDDEN (ip_ospf_transmit_delay, |
7818 | ospf_transmit_delay_cmd, | |
7819 | "ospf transmit-delay <1-65535>", | |
7820 | "OSPF interface commands\n" | |
7821 | "Link state transmit delay\n" | |
7822 | "Seconds\n") | |
718e3744 | 7823 | |
7824 | DEFUN (no_ip_ospf_transmit_delay, | |
7825 | no_ip_ospf_transmit_delay_addr_cmd, | |
7826 | "no ip ospf transmit-delay A.B.C.D", | |
7827 | NO_STR | |
7828 | "IP Information\n" | |
7829 | "OSPF interface commands\n" | |
7830 | "Link state transmit delay\n" | |
7831 | "Address of interface") | |
7832 | { | |
7833 | struct interface *ifp = vty->index; | |
7834 | struct in_addr addr; | |
7835 | int ret; | |
7836 | struct ospf_if_params *params; | |
813d4307 | 7837 | int addr_index; |
718e3744 | 7838 | |
7839 | ifp = vty->index; | |
7840 | params = IF_DEF_PARAMS (ifp); | |
7841 | ||
813d4307 | 7842 | if (argc >= 1) |
718e3744 | 7843 | { |
813d4307 DW |
7844 | if (argc == 1) |
7845 | addr_index = 0; | |
7846 | else | |
7847 | addr_index = 1; | |
7848 | ||
7849 | ret = inet_aton(argv[addr_index], &addr); | |
718e3744 | 7850 | if (!ret) |
7851 | { | |
7852 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7853 | VTY_NEWLINE); | |
7854 | return CMD_WARNING; | |
7855 | } | |
7856 | ||
7857 | params = ospf_lookup_if_params (ifp, addr); | |
7858 | if (params == NULL) | |
7859 | return CMD_SUCCESS; | |
7860 | } | |
7861 | ||
7862 | UNSET_IF_PARAM (params, transmit_delay); | |
7863 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7864 | ||
7865 | if (params != IF_DEF_PARAMS (ifp)) | |
7866 | { | |
7867 | ospf_free_if_params (ifp, addr); | |
7868 | ospf_if_update_params (ifp, addr); | |
7869 | } | |
7870 | ||
7871 | return CMD_SUCCESS; | |
7872 | } | |
7873 | ||
813d4307 DW |
7874 | ALIAS (no_ip_ospf_transmit_delay, |
7875 | no_ip_ospf_transmit_delay_sec_addr_cmd, | |
7876 | "no ip ospf transmit-delay <1-65535> A.B.C.D", | |
7877 | NO_STR | |
7878 | "IP Information\n" | |
7879 | "OSPF interface commands\n" | |
7880 | "Link state transmit delay\n" | |
7881 | "Seconds\n" | |
7882 | "Address of interface") | |
7883 | ||
718e3744 | 7884 | ALIAS (no_ip_ospf_transmit_delay, |
7885 | no_ip_ospf_transmit_delay_cmd, | |
7886 | "no ip ospf transmit-delay", | |
7887 | NO_STR | |
7888 | "IP Information\n" | |
7889 | "OSPF interface commands\n" | |
7890 | "Link state transmit delay\n") | |
7891 | ||
7892 | ALIAS (no_ip_ospf_transmit_delay, | |
7893 | no_ospf_transmit_delay_cmd, | |
7894 | "no ospf transmit-delay", | |
7895 | NO_STR | |
7896 | "OSPF interface commands\n" | |
7897 | "Link state transmit delay\n") | |
7898 | ||
813d4307 DW |
7899 | DEFUN (no_ip_ospf_transmit_delay_sec, |
7900 | no_ip_ospf_transmit_delay_sec_cmd, | |
7901 | "no ip ospf transmit-delay <1-65535>", | |
7902 | NO_STR | |
7903 | "IP Information\n" | |
7904 | "OSPF interface commands\n" | |
7905 | "Link state transmit delay\n" | |
7906 | "Seconds\n" | |
7907 | "Address of interface") | |
7908 | { | |
7909 | struct interface *ifp = vty->index; | |
7910 | struct ospf_if_params *params; | |
7911 | ||
7912 | ifp = vty->index; | |
7913 | params = IF_DEF_PARAMS (ifp); | |
7914 | ||
7915 | UNSET_IF_PARAM (params, transmit_delay); | |
7916 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7917 | ||
7918 | return CMD_SUCCESS; | |
7919 | } | |
7920 | ||
e723861d DS |
7921 | DEFUN (ip_ospf_area, |
7922 | ip_ospf_area_cmd, | |
7923 | "ip ospf area (A.B.C.D|<0-4294967295>)", | |
7924 | "IP Information\n" | |
7925 | "OSPF interface commands\n" | |
7926 | "Enable OSPF on this interface\n" | |
7927 | "OSPF area ID in IP address format\n" | |
7928 | "OSPF area ID as a decimal value\n") | |
7929 | { | |
7930 | struct interface *ifp = vty->index; | |
7931 | int format, ret; | |
7932 | struct in_addr area_id; | |
7933 | struct ospf *ospf; | |
7934 | struct ospf_if_params *params; | |
7935 | struct route_node *rn; | |
7c8ff89e | 7936 | u_short instance = 0; |
e723861d | 7937 | |
7c8ff89e DS |
7938 | if (argc == 2) |
7939 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
7940 | ||
7941 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
7942 | if (ospf == NULL) |
7943 | { | |
7c8ff89e DS |
7944 | params = IF_DEF_PARAMS (ifp); |
7945 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7946 | { | |
7947 | ospf_interface_unset (ifp); | |
7948 | ospf = ospf_lookup(); | |
7949 | ospf->if_ospf_cli_count--; | |
7950 | } | |
e723861d DS |
7951 | return CMD_SUCCESS; |
7952 | } | |
7953 | ||
7c8ff89e | 7954 | ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); |
e723861d DS |
7955 | if (ret < 0) |
7956 | { | |
7957 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
7958 | VTY_NEWLINE); | |
7959 | return CMD_WARNING; | |
7960 | } | |
7961 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
7962 | { | |
7963 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
7964 | return CMD_WARNING; | |
7965 | } | |
7966 | ||
7967 | params = IF_DEF_PARAMS (ifp); | |
7968 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7969 | { | |
73b9f703 VK |
7970 | vty_out (vty, |
7971 | "Must remove previous area config before changing ospf area %s", | |
7972 | VTY_NEWLINE); | |
e723861d DS |
7973 | return CMD_WARNING; |
7974 | } | |
7975 | ||
7976 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
7977 | { | |
7978 | if (rn->info != NULL) | |
7979 | { | |
7980 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
7981 | return CMD_WARNING; | |
7982 | } | |
7983 | } | |
7984 | ||
7985 | /* enable ospf on this interface with area_id */ | |
7986 | ospf_interface_set (ifp, area_id); | |
7987 | ospf->if_ospf_cli_count++; | |
7988 | ||
7989 | return CMD_SUCCESS; | |
7990 | } | |
7991 | ||
7c8ff89e DS |
7992 | ALIAS (ip_ospf_area, |
7993 | ip_ospf_instance_area_cmd, | |
7994 | "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
7995 | "IP Information\n" | |
7996 | "OSPF interface commands\n" | |
7997 | "Instance ID\n" | |
7998 | "Enable OSPF on this interface\n" | |
7999 | "OSPF area ID in IP address format\n" | |
8000 | "OSPF area ID as a decimal value\n") | |
8001 | ||
e723861d DS |
8002 | DEFUN (no_ip_ospf_area, |
8003 | no_ip_ospf_area_cmd, | |
8004 | "no ip ospf area", | |
8005 | NO_STR | |
8006 | "IP Information\n" | |
8007 | "OSPF interface commands\n" | |
8008 | "Disable OSPF on this interface\n") | |
8009 | { | |
8010 | struct interface *ifp = vty->index; | |
8011 | struct ospf *ospf; | |
8012 | struct ospf_if_params *params; | |
7c8ff89e | 8013 | u_short instance = 0; |
e723861d | 8014 | |
7c8ff89e DS |
8015 | if ((ospf = ospf_lookup_instance (instance)) == NULL) |
8016 | return CMD_SUCCESS; | |
e723861d DS |
8017 | |
8018 | params = IF_DEF_PARAMS (ifp); | |
8019 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
8020 | { | |
8021 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
8022 | return CMD_WARNING; | |
8023 | } | |
8024 | ||
8025 | ospf_interface_unset (ifp); | |
8026 | ospf->if_ospf_cli_count--; | |
8027 | return CMD_SUCCESS; | |
8028 | } | |
8029 | ||
7c8ff89e | 8030 | ALIAS (no_ip_ospf_area, |
813d4307 DW |
8031 | no_ip_ospf_area_val_cmd, |
8032 | "no ip ospf area (A.B.C.D|<0-4294967295>)", | |
8033 | NO_STR | |
8034 | "IP Information\n" | |
8035 | "OSPF interface commands\n" | |
8036 | "Disable OSPF on this interface\n" | |
8037 | "OSPF area ID in IP address format\n" | |
8038 | "OSPF area ID as a decimal value\n") | |
8039 | ||
8040 | DEFUN (no_ip_ospf_instance_area, | |
7c8ff89e DS |
8041 | no_ip_ospf_instance_area_cmd, |
8042 | "no ip ospf <1-65535> area", | |
8043 | NO_STR | |
8044 | "IP Information\n" | |
8045 | "OSPF interface commands\n" | |
8046 | "Instance ID\n" | |
8047 | "Disable OSPF on this interface\n") | |
813d4307 DW |
8048 | { |
8049 | struct interface *ifp = vty->index; | |
8050 | struct ospf *ospf; | |
8051 | struct ospf_if_params *params; | |
8052 | u_short instance = 0; | |
8053 | ||
8054 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
8055 | ||
8056 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
8057 | return CMD_SUCCESS; | |
8058 | ||
8059 | params = IF_DEF_PARAMS (ifp); | |
8060 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
8061 | { | |
8062 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
8063 | return CMD_WARNING; | |
8064 | } | |
8065 | ||
8066 | ospf_interface_unset (ifp); | |
8067 | ospf->if_ospf_cli_count--; | |
8068 | return CMD_SUCCESS; | |
8069 | } | |
8070 | ||
8071 | ALIAS (no_ip_ospf_instance_area, | |
8072 | no_ip_ospf_instance_area_val_cmd, | |
8073 | "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
8074 | NO_STR | |
8075 | "IP Information\n" | |
8076 | "OSPF interface commands\n" | |
8077 | "Instance ID\n" | |
8078 | "Disable OSPF on this interface\n" | |
8079 | "OSPF area ID in IP address format\n" | |
8080 | "OSPF area ID as a decimal value\n") | |
7c8ff89e | 8081 | |
6f2a6703 CF |
8082 | DEFUN (ospf_redistribute_source, |
8083 | ospf_redistribute_source_cmd, | |
8084 | "redistribute " QUAGGA_REDIST_STR_OSPFD | |
8085 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
d1c65c21 PJ |
8086 | REDIST_STR |
8087 | QUAGGA_REDIST_HELP_STR_OSPFD | |
718e3744 | 8088 | "Metric for redistributed routes\n" |
8089 | "OSPF default metric\n" | |
8090 | "OSPF exterior metric type for redistributed routes\n" | |
8091 | "Set OSPF External Type 1 metrics\n" | |
8092 | "Set OSPF External Type 2 metrics\n" | |
8093 | "Route map reference\n" | |
8094 | "Pointer to route-map entries\n") | |
8095 | { | |
020709f9 | 8096 | struct ospf *ospf = vty->index; |
718e3744 | 8097 | int source; |
8098 | int type = -1; | |
8099 | int metric = -1; | |
7c8ff89e | 8100 | struct ospf_redist *red; |
718e3744 | 8101 | |
d8f70b86 DS |
8102 | if (!ospf) |
8103 | return CMD_SUCCESS; | |
8104 | ||
6f2a6703 CF |
8105 | if (argc < 4) |
8106 | return CMD_WARNING; /* should not happen */ | |
8107 | ||
7c8ff89e DS |
8108 | if (!ospf) |
8109 | return CMD_SUCCESS; | |
8110 | ||
718e3744 | 8111 | /* Get distribute source. */ |
e0ca5fde DL |
8112 | source = proto_redistnum(AFI_IP, argv[0]); |
8113 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 8114 | return CMD_WARNING; |
8115 | ||
8116 | /* Get metric value. */ | |
6f2a6703 | 8117 | if (argv[1] != NULL) |
718e3744 | 8118 | if (!str2metric (argv[1], &metric)) |
8119 | return CMD_WARNING; | |
8120 | ||
8121 | /* Get metric type. */ | |
6f2a6703 | 8122 | if (argv[2] != NULL) |
718e3744 | 8123 | if (!str2metric_type (argv[2], &type)) |
8124 | return CMD_WARNING; | |
8125 | ||
7c8ff89e DS |
8126 | red = ospf_redist_add(ospf, source, 0); |
8127 | ||
6f2a6703 | 8128 | if (argv[3] != NULL) |
7c8ff89e | 8129 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8130 | else |
7c8ff89e | 8131 | ospf_routemap_unset (red); |
718e3744 | 8132 | |
7c8ff89e | 8133 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 8134 | } |
8135 | ||
718e3744 | 8136 | DEFUN (no_ospf_redistribute_source, |
8137 | no_ospf_redistribute_source_cmd, | |
813d4307 DW |
8138 | "no redistribute " QUAGGA_REDIST_STR_OSPFD |
8139 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 8140 | NO_STR |
d1c65c21 | 8141 | REDIST_STR |
813d4307 DW |
8142 | QUAGGA_REDIST_HELP_STR_OSPFD |
8143 | "Metric for redistributed routes\n" | |
8144 | "OSPF default metric\n" | |
8145 | "OSPF exterior metric type for redistributed routes\n" | |
8146 | "Set OSPF External Type 1 metrics\n" | |
8147 | "Set OSPF External Type 2 metrics\n" | |
8148 | "Route map reference\n" | |
8149 | "Pointer to route-map entries\n") | |
718e3744 | 8150 | { |
020709f9 | 8151 | struct ospf *ospf = vty->index; |
718e3744 | 8152 | int source; |
7c8ff89e DS |
8153 | struct ospf_redist *red; |
8154 | if (!ospf) | |
8155 | return CMD_SUCCESS; | |
718e3744 | 8156 | |
e0ca5fde DL |
8157 | source = proto_redistnum(AFI_IP, argv[0]); |
8158 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
718e3744 | 8159 | return CMD_WARNING; |
8160 | ||
7c8ff89e DS |
8161 | red = ospf_redist_lookup(ospf, source, 0); |
8162 | if (!red) | |
8163 | return CMD_SUCCESS; | |
8164 | ||
8165 | ospf_routemap_unset (red); | |
8166 | return ospf_redistribute_unset (ospf, source, 0); | |
8167 | } | |
8168 | ||
8169 | DEFUN (ospf_redistribute_instance_source, | |
8170 | ospf_redistribute_instance_source_cmd, | |
2d627ff5 | 8171 | "redistribute (ospf|table) <1-65535>" |
7c8ff89e DS |
8172 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
8173 | REDIST_STR | |
8174 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8175 | "Non-main Kernel Routing Table\n" |
8176 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
8177 | "Metric for redistributed routes\n" |
8178 | "OSPF default metric\n" | |
8179 | "OSPF exterior metric type for redistributed routes\n" | |
8180 | "Set OSPF External Type 1 metrics\n" | |
8181 | "Set OSPF External Type 2 metrics\n" | |
8182 | "Route map reference\n" | |
8183 | "Pointer to route-map entries\n") | |
8184 | { | |
8185 | struct ospf *ospf = vty->index; | |
8186 | int source; | |
8187 | int type = -1; | |
8188 | int metric = -1; | |
8189 | u_short instance; | |
8190 | struct ospf_redist *red; | |
8191 | ||
d8f70b86 DS |
8192 | if (!ospf) |
8193 | return CMD_SUCCESS; | |
8194 | ||
2d627ff5 DS |
8195 | if (strncmp(argv[0], "o", 1) == 0) |
8196 | source = ZEBRA_ROUTE_OSPF; | |
8197 | else | |
8198 | source = ZEBRA_ROUTE_TABLE; | |
8199 | ||
8200 | VTY_GET_INTEGER ("Instance ID", instance, argv[1]); | |
7c8ff89e DS |
8201 | |
8202 | if (!ospf) | |
8203 | return CMD_SUCCESS; | |
8204 | ||
2d627ff5 | 8205 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
8206 | { |
8207 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
8208 | VTY_NEWLINE); | |
8209 | return CMD_WARNING; | |
8210 | } | |
8211 | ||
2d627ff5 | 8212 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
8213 | { |
8214 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
8215 | VTY_NEWLINE); | |
8216 | return CMD_WARNING; | |
8217 | } | |
8218 | ||
7c8ff89e | 8219 | /* Get metric value. */ |
2d627ff5 DS |
8220 | if (argv[2] != NULL) |
8221 | if (!str2metric (argv[2], &metric)) | |
7c8ff89e DS |
8222 | return CMD_WARNING; |
8223 | ||
8224 | /* Get metric type. */ | |
2d627ff5 DS |
8225 | if (argv[3] != NULL) |
8226 | if (!str2metric_type (argv[3], &type)) | |
7c8ff89e DS |
8227 | return CMD_WARNING; |
8228 | ||
8229 | red = ospf_redist_add(ospf, source, instance); | |
2d627ff5 DS |
8230 | if (argv[4] != NULL) |
8231 | ospf_routemap_set (red, argv[4]); | |
7c8ff89e DS |
8232 | else |
8233 | ospf_routemap_unset (red); | |
8234 | ||
8235 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
8236 | } | |
8237 | ||
8238 | DEFUN (no_ospf_redistribute_instance_source, | |
8239 | no_ospf_redistribute_instance_source_cmd, | |
2d627ff5 | 8240 | "no redistribute (ospf|table) <1-65535>" |
7c8ff89e DS |
8241 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
8242 | NO_STR | |
8243 | REDIST_STR | |
8244 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8245 | "Non-main Kernel Routing Table\n" |
8246 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
8247 | "Metric for redistributed routes\n" |
8248 | "OSPF default metric\n" | |
8249 | "OSPF exterior metric type for redistributed routes\n" | |
8250 | "Set OSPF External Type 1 metrics\n" | |
8251 | "Set OSPF External Type 2 metrics\n" | |
8252 | "Route map reference\n" | |
8253 | "Pointer to route-map entries\n") | |
8254 | { | |
8255 | struct ospf *ospf = vty->index; | |
8256 | u_int instance; | |
8257 | struct ospf_redist *red; | |
8258 | int source; | |
8259 | ||
8260 | if (!ospf) | |
8261 | return CMD_SUCCESS; | |
8262 | ||
2d627ff5 DS |
8263 | if (strncmp(argv[0], "o", 1) == 0) |
8264 | source = ZEBRA_ROUTE_OSPF; | |
8265 | else | |
8266 | source = ZEBRA_ROUTE_TABLE; | |
8267 | ||
8268 | VTY_GET_INTEGER ("Instance ID", instance, argv[1]); | |
7c8ff89e | 8269 | |
2d627ff5 | 8270 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
8271 | { |
8272 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
8273 | VTY_NEWLINE); | |
8274 | return CMD_WARNING; | |
8275 | } | |
8276 | ||
2d627ff5 | 8277 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
8278 | { |
8279 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
8280 | VTY_NEWLINE); | |
8281 | return CMD_WARNING; | |
8282 | } | |
8283 | ||
7c8ff89e DS |
8284 | red = ospf_redist_lookup(ospf, source, instance); |
8285 | if (!red) | |
8286 | return CMD_SUCCESS; | |
8287 | ||
8288 | ospf_routemap_unset (red); | |
8289 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 8290 | } |
8291 | ||
8292 | DEFUN (ospf_distribute_list_out, | |
8293 | ospf_distribute_list_out_cmd, | |
d1c65c21 | 8294 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
718e3744 | 8295 | "Filter networks in routing updates\n" |
6f2a6703 CF |
8296 | "Access-list name\n" |
8297 | OUT_STR | |
8298 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 8299 | { |
020709f9 | 8300 | struct ospf *ospf = vty->index; |
6f2a6703 | 8301 | int source; |
718e3744 | 8302 | |
7c8ff89e DS |
8303 | if (!ospf) |
8304 | return CMD_SUCCESS; | |
8305 | ||
6f2a6703 CF |
8306 | /* Get distribute source. */ |
8307 | source = proto_redistnum(AFI_IP, argv[1]); | |
8308 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
8309 | return CMD_WARNING; | |
718e3744 | 8310 | |
6f2a6703 | 8311 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
718e3744 | 8312 | } |
8313 | ||
6f2a6703 CF |
8314 | DEFUN (no_ospf_distribute_list_out, |
8315 | no_ospf_distribute_list_out_cmd, | |
8316 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, | |
8317 | NO_STR | |
8318 | "Filter networks in routing updates\n" | |
8319 | "Access-list name\n" | |
8320 | OUT_STR | |
8321 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 8322 | { |
020709f9 | 8323 | struct ospf *ospf = vty->index; |
6f2a6703 | 8324 | int source; |
020709f9 | 8325 | |
7c8ff89e DS |
8326 | if (!ospf) |
8327 | return CMD_SUCCESS; | |
8328 | ||
6f2a6703 CF |
8329 | source = proto_redistnum(AFI_IP, argv[1]); |
8330 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) | |
8331 | return CMD_WARNING; | |
718e3744 | 8332 | |
6f2a6703 | 8333 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
718e3744 | 8334 | } |
8335 | ||
6f2a6703 CF |
8336 | /* Default information originate. */ |
8337 | DEFUN (ospf_default_information_originate, | |
8338 | ospf_default_information_originate_cmd, | |
8339 | "default-information originate " | |
8340 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 8341 | "Control distribution of default information\n" |
8342 | "Distribute a default route\n" | |
8343 | "Always advertise default route\n" | |
6f2a6703 CF |
8344 | "OSPF default metric\n" |
8345 | "OSPF metric\n" | |
718e3744 | 8346 | "OSPF metric type for default routes\n" |
8347 | "Set OSPF External Type 1 metrics\n" | |
8348 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 8349 | "Route map reference\n" |
8350 | "Pointer to route-map entries\n") | |
8351 | { | |
020709f9 | 8352 | struct ospf *ospf = vty->index; |
6f2a6703 | 8353 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 8354 | int type = -1; |
8355 | int metric = -1; | |
7c8ff89e DS |
8356 | struct ospf_redist *red; |
8357 | ||
8358 | if (!ospf) | |
8359 | return CMD_SUCCESS; | |
718e3744 | 8360 | |
6f2a6703 CF |
8361 | if (argc < 4) |
8362 | return CMD_WARNING; /* this should not happen */ | |
8363 | ||
8364 | /* Check whether "always" was specified */ | |
8365 | if (argv[0] != NULL) | |
8366 | default_originate = DEFAULT_ORIGINATE_ALWAYS; | |
718e3744 | 8367 | |
7c8ff89e DS |
8368 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
8369 | ||
718e3744 | 8370 | /* Get metric value. */ |
6f2a6703 | 8371 | if (argv[1] != NULL) |
718e3744 | 8372 | if (!str2metric (argv[1], &metric)) |
8373 | return CMD_WARNING; | |
8374 | ||
718e3744 | 8375 | /* Get metric type. */ |
6f2a6703 CF |
8376 | if (argv[2] != NULL) |
8377 | if (!str2metric_type (argv[2], &type)) | |
718e3744 | 8378 | return CMD_WARNING; |
8379 | ||
6f2a6703 | 8380 | if (argv[3] != NULL) |
7c8ff89e | 8381 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8382 | else |
7c8ff89e | 8383 | ospf_routemap_unset (red); |
718e3744 | 8384 | |
6f2a6703 CF |
8385 | return ospf_redistribute_default_set (ospf, default_originate, |
8386 | type, metric); | |
718e3744 | 8387 | } |
8388 | ||
8389 | DEFUN (no_ospf_default_information_originate, | |
8390 | no_ospf_default_information_originate_cmd, | |
813d4307 DW |
8391 | "no default-information originate" |
8392 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", | |
718e3744 | 8393 | NO_STR |
8394 | "Control distribution of default information\n" | |
813d4307 DW |
8395 | "Distribute a default route\n" |
8396 | "Always advertise default route\n" | |
8397 | "OSPF default metric\n" | |
8398 | "OSPF metric\n" | |
8399 | "OSPF metric type for default routes\n" | |
8400 | "Set OSPF External Type 1 metrics\n" | |
8401 | "Set OSPF External Type 2 metrics\n" | |
8402 | "Route map reference\n" | |
8403 | "Pointer to route-map entries\n") | |
718e3744 | 8404 | { |
68980084 | 8405 | struct ospf *ospf = vty->index; |
718e3744 | 8406 | struct prefix_ipv4 p; |
7c8ff89e DS |
8407 | struct ospf_external *ext; |
8408 | struct ospf_redist *red; | |
718e3744 | 8409 | |
7c8ff89e DS |
8410 | if (!ospf) |
8411 | return CMD_SUCCESS; | |
8412 | ||
718e3744 | 8413 | p.family = AF_INET; |
8414 | p.prefix.s_addr = 0; | |
8415 | p.prefixlen = 0; | |
8416 | ||
5339cfdb | 8417 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 8418 | |
7c8ff89e DS |
8419 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
8420 | EXTERNAL_INFO (ext)) { | |
8421 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
8422 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 8423 | } |
8424 | ||
7c8ff89e DS |
8425 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8426 | if (!red) | |
8427 | return CMD_SUCCESS; | |
8428 | ||
8429 | ospf_routemap_unset (red); | |
020709f9 | 8430 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 8431 | } |
8432 | ||
8433 | DEFUN (ospf_default_metric, | |
8434 | ospf_default_metric_cmd, | |
8435 | "default-metric <0-16777214>", | |
8436 | "Set metric of redistributed routes\n" | |
8437 | "Default metric\n") | |
8438 | { | |
68980084 | 8439 | struct ospf *ospf = vty->index; |
718e3744 | 8440 | int metric = -1; |
8441 | ||
7c8ff89e DS |
8442 | if (!ospf) |
8443 | return CMD_SUCCESS; | |
8444 | ||
718e3744 | 8445 | if (!str2metric (argv[0], &metric)) |
8446 | return CMD_WARNING; | |
8447 | ||
68980084 | 8448 | ospf->default_metric = metric; |
718e3744 | 8449 | |
8450 | return CMD_SUCCESS; | |
8451 | } | |
8452 | ||
8453 | DEFUN (no_ospf_default_metric, | |
8454 | no_ospf_default_metric_cmd, | |
8455 | "no default-metric", | |
8456 | NO_STR | |
8457 | "Set metric of redistributed routes\n") | |
8458 | { | |
68980084 | 8459 | struct ospf *ospf = vty->index; |
8460 | ||
7c8ff89e DS |
8461 | if (!ospf) |
8462 | return CMD_SUCCESS; | |
8463 | ||
68980084 | 8464 | ospf->default_metric = -1; |
8465 | ||
718e3744 | 8466 | return CMD_SUCCESS; |
8467 | } | |
8468 | ||
8469 | ALIAS (no_ospf_default_metric, | |
8470 | no_ospf_default_metric_val_cmd, | |
8471 | "no default-metric <0-16777214>", | |
8472 | NO_STR | |
8473 | "Set metric of redistributed routes\n" | |
8474 | "Default metric\n") | |
8475 | ||
8476 | DEFUN (ospf_distance, | |
8477 | ospf_distance_cmd, | |
8478 | "distance <1-255>", | |
8479 | "Define an administrative distance\n" | |
8480 | "OSPF Administrative distance\n") | |
8481 | { | |
68980084 | 8482 | struct ospf *ospf = vty->index; |
8483 | ||
7c8ff89e DS |
8484 | if (!ospf) |
8485 | return CMD_SUCCESS; | |
8486 | ||
68980084 | 8487 | ospf->distance_all = atoi (argv[0]); |
8488 | ||
718e3744 | 8489 | return CMD_SUCCESS; |
8490 | } | |
8491 | ||
8492 | DEFUN (no_ospf_distance, | |
8493 | no_ospf_distance_cmd, | |
8494 | "no distance <1-255>", | |
8495 | NO_STR | |
8496 | "Define an administrative distance\n" | |
8497 | "OSPF Administrative distance\n") | |
8498 | { | |
68980084 | 8499 | struct ospf *ospf = vty->index; |
8500 | ||
7c8ff89e DS |
8501 | if (!ospf) |
8502 | return CMD_SUCCESS; | |
8503 | ||
68980084 | 8504 | ospf->distance_all = 0; |
8505 | ||
718e3744 | 8506 | return CMD_SUCCESS; |
8507 | } | |
8508 | ||
8509 | DEFUN (no_ospf_distance_ospf, | |
8510 | no_ospf_distance_ospf_cmd, | |
813d4307 | 8511 | "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
718e3744 | 8512 | NO_STR |
8513 | "Define an administrative distance\n" | |
8514 | "OSPF Administrative distance\n" | |
718e3744 | 8515 | "Intra-area routes\n" |
813d4307 | 8516 | "Distance for intra-area routes\n" |
718e3744 | 8517 | "Inter-area routes\n" |
813d4307 DW |
8518 | "Distance for inter-area routes\n" |
8519 | "External routes\n" | |
8520 | "Distance for external routes\n") | |
718e3744 | 8521 | { |
68980084 | 8522 | struct ospf *ospf = vty->index; |
8523 | ||
d8f70b86 DS |
8524 | if (!ospf) |
8525 | return CMD_SUCCESS; | |
8526 | ||
6f2a6703 CF |
8527 | if (argc < 3) |
8528 | return CMD_WARNING; | |
718e3744 | 8529 | |
7c8ff89e DS |
8530 | if (!ospf) |
8531 | return CMD_SUCCESS; | |
8532 | ||
6f2a6703 CF |
8533 | if (argv[0] != NULL) |
8534 | ospf->distance_intra = 0; | |
68980084 | 8535 | |
6f2a6703 CF |
8536 | if (argv[1] != NULL) |
8537 | ospf->distance_inter = 0; | |
68980084 | 8538 | |
6f2a6703 CF |
8539 | if (argv[2] != NULL) |
8540 | ospf->distance_external = 0; | |
718e3744 | 8541 | |
6f2a6703 CF |
8542 | if (argv[0] || argv[1] || argv[2]) |
8543 | return CMD_SUCCESS; | |
68980084 | 8544 | |
6f2a6703 CF |
8545 | /* If no arguments are given, clear all distance information */ |
8546 | ospf->distance_intra = 0; | |
8547 | ospf->distance_inter = 0; | |
8548 | ospf->distance_external = 0; | |
68980084 | 8549 | |
718e3744 | 8550 | return CMD_SUCCESS; |
8551 | } | |
8552 | ||
6f2a6703 CF |
8553 | DEFUN (ospf_distance_ospf, |
8554 | ospf_distance_ospf_cmd, | |
8555 | "distance ospf " | |
2b053042 | 8556 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
718e3744 | 8557 | "Define an administrative distance\n" |
8558 | "OSPF Administrative distance\n" | |
718e3744 | 8559 | "Intra-area routes\n" |
8560 | "Distance for intra-area routes\n" | |
718e3744 | 8561 | "Inter-area routes\n" |
8562 | "Distance for inter-area routes\n" | |
8563 | "External routes\n" | |
718e3744 | 8564 | "Distance for external routes\n") |
8565 | { | |
68980084 | 8566 | struct ospf *ospf = vty->index; |
8567 | ||
d8f70b86 DS |
8568 | if (!ospf) |
8569 | return CMD_SUCCESS; | |
8570 | ||
6f2a6703 CF |
8571 | if (argc < 3) /* should not happen */ |
8572 | return CMD_WARNING; | |
68980084 | 8573 | |
6f2a6703 CF |
8574 | if (!argv[0] && !argv[1] && !argv[2]) |
8575 | { | |
8576 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", | |
8577 | VTY_NEWLINE); | |
8578 | return CMD_WARNING; | |
8579 | } | |
68980084 | 8580 | |
6f2a6703 CF |
8581 | if (argv[0] != NULL) |
8582 | ospf->distance_intra = atoi(argv[0]); | |
718e3744 | 8583 | |
6f2a6703 CF |
8584 | if (argv[1] != NULL) |
8585 | ospf->distance_inter = atoi(argv[1]); | |
68980084 | 8586 | |
6f2a6703 CF |
8587 | if (argv[2] != NULL) |
8588 | ospf->distance_external = atoi(argv[2]); | |
68980084 | 8589 | |
718e3744 | 8590 | return CMD_SUCCESS; |
8591 | } | |
8592 | ||
8593 | DEFUN (ospf_distance_source, | |
8594 | ospf_distance_source_cmd, | |
8595 | "distance <1-255> A.B.C.D/M", | |
8596 | "Administrative distance\n" | |
8597 | "Distance value\n" | |
8598 | "IP source prefix\n") | |
8599 | { | |
020709f9 | 8600 | struct ospf *ospf = vty->index; |
8601 | ||
7c8ff89e DS |
8602 | if (!ospf) |
8603 | return CMD_SUCCESS; | |
8604 | ||
020709f9 | 8605 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
68980084 | 8606 | |
718e3744 | 8607 | return CMD_SUCCESS; |
8608 | } | |
8609 | ||
8610 | DEFUN (no_ospf_distance_source, | |
8611 | no_ospf_distance_source_cmd, | |
8612 | "no distance <1-255> A.B.C.D/M", | |
8613 | NO_STR | |
8614 | "Administrative distance\n" | |
8615 | "Distance value\n" | |
8616 | "IP source prefix\n") | |
8617 | { | |
020709f9 | 8618 | struct ospf *ospf = vty->index; |
8619 | ||
7c8ff89e DS |
8620 | if (!ospf) |
8621 | return CMD_SUCCESS; | |
8622 | ||
020709f9 | 8623 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
8624 | ||
718e3744 | 8625 | return CMD_SUCCESS; |
8626 | } | |
8627 | ||
8628 | DEFUN (ospf_distance_source_access_list, | |
8629 | ospf_distance_source_access_list_cmd, | |
8630 | "distance <1-255> A.B.C.D/M WORD", | |
8631 | "Administrative distance\n" | |
8632 | "Distance value\n" | |
8633 | "IP source prefix\n" | |
8634 | "Access list name\n") | |
8635 | { | |
020709f9 | 8636 | struct ospf *ospf = vty->index; |
8637 | ||
7c8ff89e DS |
8638 | if (!ospf) |
8639 | return CMD_SUCCESS; | |
8640 | ||
020709f9 | 8641 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
8642 | ||
718e3744 | 8643 | return CMD_SUCCESS; |
8644 | } | |
8645 | ||
8646 | DEFUN (no_ospf_distance_source_access_list, | |
8647 | no_ospf_distance_source_access_list_cmd, | |
8648 | "no distance <1-255> A.B.C.D/M WORD", | |
8649 | NO_STR | |
8650 | "Administrative distance\n" | |
8651 | "Distance value\n" | |
8652 | "IP source prefix\n" | |
8653 | "Access list name\n") | |
8654 | { | |
020709f9 | 8655 | struct ospf *ospf = vty->index; |
8656 | ||
7c8ff89e DS |
8657 | if (!ospf) |
8658 | return CMD_SUCCESS; | |
8659 | ||
020709f9 | 8660 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
8661 | ||
718e3744 | 8662 | return CMD_SUCCESS; |
8663 | } | |
8664 | ||
ba682537 | 8665 | DEFUN (ip_ospf_mtu_ignore, |
8666 | ip_ospf_mtu_ignore_addr_cmd, | |
8667 | "ip ospf mtu-ignore A.B.C.D", | |
8668 | "IP Information\n" | |
8669 | "OSPF interface commands\n" | |
8670 | "Disable mtu mismatch detection\n" | |
8671 | "Address of interface") | |
8672 | { | |
8673 | struct interface *ifp = vty->index; | |
8674 | struct in_addr addr; | |
8675 | int ret; | |
8676 | ||
8677 | struct ospf_if_params *params; | |
8678 | params = IF_DEF_PARAMS (ifp); | |
8679 | ||
8680 | if (argc == 1) | |
8681 | { | |
8682 | ret = inet_aton(argv[0], &addr); | |
8683 | if (!ret) | |
8684 | { | |
8685 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8686 | VTY_NEWLINE); | |
8687 | return CMD_WARNING; | |
8688 | } | |
8689 | params = ospf_get_if_params (ifp, addr); | |
8690 | ospf_if_update_params (ifp, addr); | |
8691 | } | |
8692 | params->mtu_ignore = 1; | |
8693 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8694 | SET_IF_PARAM (params, mtu_ignore); | |
8695 | else | |
8696 | { | |
8697 | UNSET_IF_PARAM (params, mtu_ignore); | |
8698 | if (params != IF_DEF_PARAMS (ifp)) | |
8699 | { | |
8700 | ospf_free_if_params (ifp, addr); | |
8701 | ospf_if_update_params (ifp, addr); | |
8702 | } | |
8703 | } | |
8704 | return CMD_SUCCESS; | |
8705 | } | |
8706 | ||
8707 | ALIAS (ip_ospf_mtu_ignore, | |
8708 | ip_ospf_mtu_ignore_cmd, | |
8709 | "ip ospf mtu-ignore", | |
8710 | "IP Information\n" | |
8711 | "OSPF interface commands\n" | |
8712 | "Disable mtu mismatch detection\n") | |
8713 | ||
8714 | ||
8715 | DEFUN (no_ip_ospf_mtu_ignore, | |
8716 | no_ip_ospf_mtu_ignore_addr_cmd, | |
8717 | "no ip ospf mtu-ignore A.B.C.D", | |
8718 | "IP Information\n" | |
8719 | "OSPF interface commands\n" | |
8720 | "Disable mtu mismatch detection\n" | |
8721 | "Address of interface") | |
8722 | { | |
8723 | struct interface *ifp = vty->index; | |
8724 | struct in_addr addr; | |
8725 | int ret; | |
8726 | ||
8727 | struct ospf_if_params *params; | |
8728 | params = IF_DEF_PARAMS (ifp); | |
8729 | ||
8730 | if (argc == 1) | |
8731 | { | |
8732 | ret = inet_aton(argv[0], &addr); | |
8733 | if (!ret) | |
8734 | { | |
8735 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8736 | VTY_NEWLINE); | |
8737 | return CMD_WARNING; | |
8738 | } | |
8739 | params = ospf_get_if_params (ifp, addr); | |
8740 | ospf_if_update_params (ifp, addr); | |
8741 | } | |
8742 | params->mtu_ignore = 0; | |
8743 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8744 | SET_IF_PARAM (params, mtu_ignore); | |
8745 | else | |
8746 | { | |
8747 | UNSET_IF_PARAM (params, mtu_ignore); | |
8748 | if (params != IF_DEF_PARAMS (ifp)) | |
8749 | { | |
8750 | ospf_free_if_params (ifp, addr); | |
8751 | ospf_if_update_params (ifp, addr); | |
8752 | } | |
8753 | } | |
8754 | return CMD_SUCCESS; | |
8755 | } | |
8756 | ||
8757 | ALIAS (no_ip_ospf_mtu_ignore, | |
8758 | no_ip_ospf_mtu_ignore_cmd, | |
8759 | "no ip ospf mtu-ignore", | |
8760 | "IP Information\n" | |
8761 | "OSPF interface commands\n" | |
8762 | "Disable mtu mismatch detection\n") | |
6b0655a2 | 8763 | |
88d6cf37 | 8764 | DEFUN (ospf_max_metric_router_lsa_admin, |
8765 | ospf_max_metric_router_lsa_admin_cmd, | |
8766 | "max-metric router-lsa administrative", | |
8767 | "OSPF maximum / infinite-distance metric\n" | |
8768 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8769 | "Administratively applied, for an indefinite period\n") | |
8770 | { | |
8771 | struct listnode *ln; | |
8772 | struct ospf_area *area; | |
8773 | struct ospf *ospf = vty->index; | |
ba682537 | 8774 | |
7c8ff89e DS |
8775 | if (!ospf) |
8776 | return CMD_SUCCESS; | |
8777 | ||
88d6cf37 | 8778 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8779 | { | |
8780 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8781 | ||
8782 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 8783 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8784 | } |
4ba4fc85 AB |
8785 | |
8786 | /* Allows for areas configured later to get the property */ | |
8787 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
8788 | ||
88d6cf37 | 8789 | return CMD_SUCCESS; |
8790 | } | |
8791 | ||
8792 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
8793 | no_ospf_max_metric_router_lsa_admin_cmd, | |
8794 | "no max-metric router-lsa administrative", | |
8795 | NO_STR | |
8796 | "OSPF maximum / infinite-distance metric\n" | |
8797 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8798 | "Administratively applied, for an indefinite period\n") | |
8799 | { | |
8800 | struct listnode *ln; | |
8801 | struct ospf_area *area; | |
8802 | struct ospf *ospf = vty->index; | |
8803 | ||
7c8ff89e DS |
8804 | if (!ospf) |
8805 | return CMD_SUCCESS; | |
8806 | ||
88d6cf37 | 8807 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8808 | { | |
8809 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8810 | ||
8811 | /* Don't trample on the start-up stub timer */ | |
8812 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
8813 | && !area->t_stub_router) | |
8814 | { | |
8815 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8816 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8817 | } |
8818 | } | |
4ba4fc85 | 8819 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 8820 | return CMD_SUCCESS; |
8821 | } | |
8822 | ||
8823 | DEFUN (ospf_max_metric_router_lsa_startup, | |
8824 | ospf_max_metric_router_lsa_startup_cmd, | |
8825 | "max-metric router-lsa on-startup <5-86400>", | |
8826 | "OSPF maximum / infinite-distance metric\n" | |
8827 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8828 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8829 | "Time (seconds) to advertise self as stub-router\n") | |
8830 | { | |
8831 | unsigned int seconds; | |
8832 | struct ospf *ospf = vty->index; | |
8833 | ||
7c8ff89e DS |
8834 | if (!ospf) |
8835 | return CMD_SUCCESS; | |
8836 | ||
88d6cf37 | 8837 | if (argc != 1) |
8838 | { | |
8839 | vty_out (vty, "%% Must supply stub-router period"); | |
8840 | return CMD_WARNING; | |
8841 | } | |
8842 | ||
8843 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); | |
8844 | ||
8845 | ospf->stub_router_startup_time = seconds; | |
8846 | ||
8847 | return CMD_SUCCESS; | |
8848 | } | |
8849 | ||
8850 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
8851 | no_ospf_max_metric_router_lsa_startup_cmd, | |
813d4307 | 8852 | "no max-metric router-lsa on-startup <5-86400>", |
88d6cf37 | 8853 | NO_STR |
8854 | "OSPF maximum / infinite-distance metric\n" | |
8855 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8856 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
8857 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 8858 | { |
8859 | struct listnode *ln; | |
8860 | struct ospf_area *area; | |
8861 | struct ospf *ospf = vty->index; | |
8862 | ||
7c8ff89e DS |
8863 | if (!ospf) |
8864 | return CMD_SUCCESS; | |
8865 | ||
88d6cf37 | 8866 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8867 | ||
8868 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8869 | { | |
8870 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
8871 | OSPF_TIMER_OFF (area->t_stub_router); | |
8872 | ||
8873 | /* Don't trample on admin stub routed */ | |
8874 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8875 | { | |
8876 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8877 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8878 | } |
8879 | } | |
8880 | return CMD_SUCCESS; | |
8881 | } | |
8882 | ||
a1afa410 DS |
8883 | ALIAS (no_ospf_max_metric_router_lsa_startup, |
8884 | no_ospf_max_metric_router_lsa_startup_no_param_cmd, | |
8885 | "no max-metric router-lsa on-startup", | |
8886 | NO_STR | |
8887 | "OSPF maximum / infinite-distance metric\n" | |
8888 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8889 | "Automatically advertise stub Router-LSA on startup of OSPF\n"); | |
8890 | ||
88d6cf37 | 8891 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
8892 | ospf_max_metric_router_lsa_shutdown_cmd, | |
804fb5c1 | 8893 | "max-metric router-lsa on-shutdown <5-100>", |
88d6cf37 | 8894 | "OSPF maximum / infinite-distance metric\n" |
8895 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8896 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
8897 | "Time (seconds) to wait till full shutdown\n") | |
8898 | { | |
8899 | unsigned int seconds; | |
8900 | struct ospf *ospf = vty->index; | |
8901 | ||
7c8ff89e DS |
8902 | if (!ospf) |
8903 | return CMD_SUCCESS; | |
8904 | ||
88d6cf37 | 8905 | if (argc != 1) |
8906 | { | |
8907 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
8908 | return CMD_WARNING; | |
8909 | } | |
8910 | ||
8911 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); | |
8912 | ||
8913 | ospf->stub_router_shutdown_time = seconds; | |
8914 | ||
8915 | return CMD_SUCCESS; | |
8916 | } | |
8917 | ||
8918 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
8919 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
813d4307 | 8920 | "no max-metric router-lsa on-shutdown <5-100>", |
88d6cf37 | 8921 | NO_STR |
8922 | "OSPF maximum / infinite-distance metric\n" | |
8923 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8924 | "Advertise stub-router prior to full shutdown of OSPF\n" |
8925 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 8926 | { |
8927 | struct ospf *ospf = vty->index; | |
8928 | ||
7c8ff89e DS |
8929 | if (!ospf) |
8930 | return CMD_SUCCESS; | |
8931 | ||
88d6cf37 | 8932 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8933 | ||
8934 | return CMD_SUCCESS; | |
8935 | } | |
8936 | ||
a1afa410 DS |
8937 | ALIAS (no_ospf_max_metric_router_lsa_shutdown, |
8938 | no_ospf_max_metric_router_lsa_shutdown_no_param_cmd, | |
8939 | "no max-metric router-lsa on-shutdown", | |
8940 | NO_STR | |
8941 | "OSPF maximum / infinite-distance metric\n" | |
8942 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8943 | "Advertise stub-router prior to full shutdown of OSPF\n"); | |
8944 | ||
88d6cf37 | 8945 | static void |
8946 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
8947 | { | |
8948 | struct listnode *ln; | |
8949 | struct ospf_area *area; | |
8950 | ||
8951 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8952 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
8953 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
8954 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8955 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
8956 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
8957 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8958 | { | |
8959 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8960 | { | |
8961 | vty_out (vty, " max-metric router-lsa administrative%s", | |
8962 | VTY_NEWLINE); | |
8963 | break; | |
8964 | } | |
8965 | } | |
8966 | return; | |
8967 | } | |
6b0655a2 | 8968 | |
4dadc291 | 8969 | static void |
718e3744 | 8970 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
8971 | { | |
8972 | struct route_node *rn; | |
8973 | struct ospf_route *or; | |
1eb8ef25 | 8974 | struct listnode *pnode, *pnnode; |
718e3744 | 8975 | struct ospf_path *path; |
8976 | ||
8977 | vty_out (vty, "============ OSPF network routing table ============%s", | |
8978 | VTY_NEWLINE); | |
8979 | ||
8980 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8981 | if ((or = rn->info) != NULL) | |
8982 | { | |
8983 | char buf1[19]; | |
8984 | snprintf (buf1, 19, "%s/%d", | |
8985 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8986 | ||
8987 | switch (or->path_type) | |
8988 | { | |
8989 | case OSPF_PATH_INTER_AREA: | |
8990 | if (or->type == OSPF_DESTINATION_NETWORK) | |
8991 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
8992 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8993 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
8994 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
8995 | break; | |
8996 | case OSPF_PATH_INTRA_AREA: | |
8997 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
8998 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
8999 | break; | |
9000 | default: | |
9001 | break; | |
9002 | } | |
9003 | ||
9004 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 9005 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 9006 | { |
a8ba847f | 9007 | if (if_lookup_by_index(path->ifindex)) |
96735eea | 9008 | { |
9009 | if (path->nexthop.s_addr == 0) | |
9010 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f | 9011 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 9012 | else |
9013 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
9014 | inet_ntoa (path->nexthop), |
9015 | ifindex2ifname (path->ifindex), VTY_NEWLINE); | |
96735eea | 9016 | } |
9017 | } | |
718e3744 | 9018 | } |
9019 | vty_out (vty, "%s", VTY_NEWLINE); | |
9020 | } | |
9021 | ||
4dadc291 | 9022 | static void |
718e3744 | 9023 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
9024 | { | |
9025 | struct route_node *rn; | |
9026 | struct ospf_route *or; | |
1eb8ef25 | 9027 | struct listnode *pnode; |
9028 | struct listnode *node; | |
718e3744 | 9029 | struct ospf_path *path; |
9030 | ||
9031 | vty_out (vty, "============ OSPF router routing table =============%s", | |
9032 | VTY_NEWLINE); | |
9033 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
9034 | if (rn->info) | |
9035 | { | |
9036 | int flag = 0; | |
9037 | ||
9038 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
9039 | ||
1eb8ef25 | 9040 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
9041 | { | |
9042 | if (flag++) | |
9043 | vty_out (vty, "%24s", ""); | |
9044 | ||
9045 | /* Show path. */ | |
9046 | vty_out (vty, "%s [%d] area: %s", | |
9047 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
9048 | or->cost, inet_ntoa (or->u.std.area_id)); | |
9049 | /* Show flags. */ | |
9050 | vty_out (vty, "%s%s%s", | |
9051 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
9052 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
9053 | VTY_NEWLINE); | |
9054 | ||
9055 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
9056 | { | |
a8ba847f | 9057 | if (if_lookup_by_index(path->ifindex)) |
54bedb55 | 9058 | { |
9059 | if (path->nexthop.s_addr == 0) | |
9060 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f JT |
9061 | "", ifindex2ifname (path->ifindex), |
9062 | VTY_NEWLINE); | |
54bedb55 | 9063 | else |
9064 | vty_out (vty, "%24s via %s, %s%s", "", | |
9065 | inet_ntoa (path->nexthop), | |
a8ba847f JT |
9066 | ifindex2ifname (path->ifindex), |
9067 | VTY_NEWLINE); | |
54bedb55 | 9068 | } |
1eb8ef25 | 9069 | } |
9070 | } | |
718e3744 | 9071 | } |
9072 | vty_out (vty, "%s", VTY_NEWLINE); | |
9073 | } | |
9074 | ||
4dadc291 | 9075 | static void |
718e3744 | 9076 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
9077 | { | |
9078 | struct route_node *rn; | |
9079 | struct ospf_route *er; | |
1eb8ef25 | 9080 | struct listnode *pnode, *pnnode; |
718e3744 | 9081 | struct ospf_path *path; |
9082 | ||
9083 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
9084 | VTY_NEWLINE); | |
9085 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
9086 | if ((er = rn->info) != NULL) | |
9087 | { | |
9088 | char buf1[19]; | |
9089 | snprintf (buf1, 19, "%s/%d", | |
9090 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
9091 | ||
9092 | switch (er->path_type) | |
9093 | { | |
9094 | case OSPF_PATH_TYPE1_EXTERNAL: | |
9095 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, | |
9096 | er->cost, er->u.ext.tag, VTY_NEWLINE); | |
9097 | break; | |
9098 | case OSPF_PATH_TYPE2_EXTERNAL: | |
9099 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, | |
9100 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); | |
9101 | break; | |
9102 | } | |
9103 | ||
1eb8ef25 | 9104 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 9105 | { |
a8ba847f | 9106 | if (if_lookup_by_index(path->ifindex)) |
718e3744 | 9107 | { |
9108 | if (path->nexthop.s_addr == 0) | |
96735eea | 9109 | vty_out (vty, "%24s directly attached to %s%s", |
a8ba847f | 9110 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 9111 | else |
9112 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
9113 | inet_ntoa (path->nexthop), |
9114 | ifindex2ifname (path->ifindex), | |
96735eea | 9115 | VTY_NEWLINE); |
718e3744 | 9116 | } |
9117 | } | |
9118 | } | |
9119 | vty_out (vty, "%s", VTY_NEWLINE); | |
9120 | } | |
9121 | ||
7c8ff89e DS |
9122 | static int |
9123 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 9124 | { |
7c8ff89e DS |
9125 | if (ospf->instance) |
9126 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
9127 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9128 | |
68980084 | 9129 | if (ospf->new_table == NULL) |
718e3744 | 9130 | { |
9131 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
9132 | return CMD_SUCCESS; | |
9133 | } | |
9134 | ||
9135 | /* Show Network routes. | |
020709f9 | 9136 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 9137 | |
9138 | /* Show Router routes. */ | |
68980084 | 9139 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 9140 | |
7c8ff89e DS |
9141 | vty_out (vty, "%s", VTY_NEWLINE); |
9142 | ||
718e3744 | 9143 | return CMD_SUCCESS; |
9144 | } | |
718e3744 | 9145 | |
7c8ff89e DS |
9146 | DEFUN (show_ip_ospf_border_routers, |
9147 | show_ip_ospf_border_routers_cmd, | |
9148 | "show ip ospf border-routers", | |
718e3744 | 9149 | SHOW_STR |
9150 | IP_STR | |
9151 | "OSPF information\n" | |
7c8ff89e | 9152 | "Show all the ABR's and ASBR's\n") |
718e3744 | 9153 | { |
020709f9 | 9154 | struct ospf *ospf; |
68980084 | 9155 | |
0bad4851 | 9156 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9157 | return CMD_SUCCESS; |
9158 | ||
9159 | return show_ip_ospf_border_routers_common(vty, ospf); | |
9160 | } | |
9161 | ||
9162 | DEFUN (show_ip_ospf_instance_border_routers, | |
9163 | show_ip_ospf_instance_border_routers_cmd, | |
9164 | "show ip ospf <1-65535> border-routers", | |
9165 | SHOW_STR | |
9166 | IP_STR | |
9167 | "OSPF information\n" | |
9168 | "Instance ID\n" | |
9169 | "Show all the ABR's and ASBR's\n") | |
9170 | { | |
9171 | struct ospf *ospf; | |
9172 | u_short instance = 0; | |
9173 | ||
9174 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 9175 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9176 | return CMD_SUCCESS; |
9177 | ||
9178 | return show_ip_ospf_border_routers_common(vty, ospf); | |
9179 | } | |
9180 | ||
9181 | static int | |
9182 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
9183 | { | |
9184 | if (ospf->instance) | |
9185 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
9186 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9187 | |
68980084 | 9188 | if (ospf->new_table == NULL) |
718e3744 | 9189 | { |
9190 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
9191 | return CMD_SUCCESS; | |
9192 | } | |
9193 | ||
9194 | /* Show Network routes. */ | |
68980084 | 9195 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 9196 | |
9197 | /* Show Router routes. */ | |
68980084 | 9198 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 9199 | |
9200 | /* Show AS External routes. */ | |
68980084 | 9201 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 9202 | |
7c8ff89e DS |
9203 | vty_out (vty, "%s", VTY_NEWLINE); |
9204 | ||
718e3744 | 9205 | return CMD_SUCCESS; |
9206 | } | |
9207 | ||
7c8ff89e DS |
9208 | DEFUN (show_ip_ospf_route, |
9209 | show_ip_ospf_route_cmd, | |
9210 | "show ip ospf route", | |
9211 | SHOW_STR | |
9212 | IP_STR | |
9213 | "OSPF information\n" | |
9214 | "OSPF routing table\n") | |
9215 | { | |
9216 | struct ospf *ospf; | |
9217 | ||
0bad4851 | 9218 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9219 | return CMD_SUCCESS; |
9220 | ||
9221 | return show_ip_ospf_route_common(vty, ospf); | |
9222 | } | |
9223 | ||
9224 | DEFUN (show_ip_ospf_instance_route, | |
9225 | show_ip_ospf_instance_route_cmd, | |
9226 | "show ip ospf <1-65535> route", | |
9227 | SHOW_STR | |
9228 | IP_STR | |
9229 | "OSPF information\n" | |
9230 | "Instance ID\n" | |
9231 | "OSPF routing table\n") | |
9232 | { | |
9233 | struct ospf *ospf; | |
9234 | u_short instance = 0; | |
9235 | ||
9236 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
0bad4851 | 9237 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9238 | return CMD_SUCCESS; |
9239 | ||
9240 | return show_ip_ospf_route_common(vty, ospf); | |
9241 | } | |
6b0655a2 | 9242 | |
eb1ce605 | 9243 | const char *ospf_abr_type_str[] = |
718e3744 | 9244 | { |
9245 | "unknown", | |
9246 | "standard", | |
9247 | "ibm", | |
9248 | "cisco", | |
9249 | "shortcut" | |
9250 | }; | |
9251 | ||
eb1ce605 | 9252 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 9253 | { |
9254 | "default", | |
9255 | "enable", | |
9256 | "disable" | |
9257 | }; | |
9258 | ||
9259 | ||
4dadc291 | 9260 | static void |
718e3744 | 9261 | area_id2str (char *buf, int length, struct ospf_area *area) |
9262 | { | |
9263 | memset (buf, 0, length); | |
9264 | ||
9265 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
9266 | strncpy (buf, inet_ntoa (area->area_id), length); | |
9267 | else | |
9268 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); | |
9269 | } | |
9270 | ||
6b0655a2 | 9271 | |
eb1ce605 | 9272 | const char *ospf_int_type_str[] = |
718e3744 | 9273 | { |
9274 | "unknown", /* should never be used. */ | |
9275 | "point-to-point", | |
9276 | "broadcast", | |
9277 | "non-broadcast", | |
9278 | "point-to-multipoint", | |
9279 | "virtual-link", /* should never be used. */ | |
9280 | "loopback" | |
9281 | }; | |
9282 | ||
9283 | /* Configuration write function for ospfd. */ | |
4dadc291 | 9284 | static int |
718e3744 | 9285 | config_write_interface (struct vty *vty) |
9286 | { | |
52dc7ee6 | 9287 | struct listnode *n1, *n2; |
718e3744 | 9288 | struct interface *ifp; |
9289 | struct crypt_key *ck; | |
9290 | int write = 0; | |
9291 | struct route_node *rn = NULL; | |
9292 | struct ospf_if_params *params; | |
7c8ff89e | 9293 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 9294 | |
b2d7c082 | 9295 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp)) |
718e3744 | 9296 | { |
718e3744 | 9297 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
9298 | continue; | |
9299 | ||
84361d61 DS |
9300 | if (ifp->ifindex == IFINDEX_DELETED) |
9301 | continue; | |
9302 | ||
718e3744 | 9303 | vty_out (vty, "!%s", VTY_NEWLINE); |
9304 | vty_out (vty, "interface %s%s", ifp->name, | |
9305 | VTY_NEWLINE); | |
9306 | if (ifp->desc) | |
9307 | vty_out (vty, " description %s%s", ifp->desc, | |
9308 | VTY_NEWLINE); | |
9309 | ||
9310 | write++; | |
9311 | ||
9312 | params = IF_DEF_PARAMS (ifp); | |
9313 | ||
9314 | do { | |
9315 | /* Interface Network print. */ | |
9316 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 9317 | params->type != OSPF_IFTYPE_LOOPBACK) |
9318 | { | |
bc18d616 | 9319 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 9320 | { |
9321 | vty_out (vty, " ip ospf network %s", | |
9322 | ospf_int_type_str[params->type]); | |
9323 | if (params != IF_DEF_PARAMS (ifp)) | |
9324 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9325 | vty_out (vty, "%s", VTY_NEWLINE); | |
9326 | } | |
718e3744 | 9327 | } |
9328 | ||
9329 | /* OSPF interface authentication print */ | |
9330 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
9331 | params->auth_type != OSPF_AUTH_NOTSET) | |
9332 | { | |
eb1ce605 | 9333 | const char *auth_str; |
718e3744 | 9334 | |
9335 | /* Translation tables are not that much help here due to syntax | |
9336 | of the simple option */ | |
9337 | switch (params->auth_type) | |
9338 | { | |
9339 | ||
9340 | case OSPF_AUTH_NULL: | |
9341 | auth_str = " null"; | |
9342 | break; | |
9343 | ||
9344 | case OSPF_AUTH_SIMPLE: | |
9345 | auth_str = ""; | |
9346 | break; | |
9347 | ||
9348 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
9349 | auth_str = " message-digest"; | |
9350 | break; | |
9351 | ||
9352 | default: | |
9353 | auth_str = ""; | |
9354 | break; | |
9355 | } | |
9356 | ||
9357 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
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 | /* Simple Authentication Password print. */ | |
9364 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
9365 | params->auth_simple[0] != '\0') | |
9366 | { | |
9367 | vty_out (vty, " ip ospf authentication-key %s", | |
9368 | params->auth_simple); | |
9369 | if (params != IF_DEF_PARAMS (ifp)) | |
9370 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9371 | vty_out (vty, "%s", VTY_NEWLINE); | |
9372 | } | |
9373 | ||
9374 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 9375 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 9376 | { |
718e3744 | 9377 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 9378 | ck->key_id, ck->auth_key); |
718e3744 | 9379 | if (params != IF_DEF_PARAMS (ifp)) |
9380 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9381 | vty_out (vty, "%s", VTY_NEWLINE); | |
9382 | } | |
9383 | ||
9384 | /* Interface Output Cost print. */ | |
9385 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
9386 | { | |
9387 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
9388 | if (params != IF_DEF_PARAMS (ifp)) | |
9389 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9390 | vty_out (vty, "%s", VTY_NEWLINE); | |
9391 | } | |
9392 | ||
9393 | /* Hello Interval print. */ | |
9394 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
9395 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
9396 | { | |
9397 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
9398 | if (params != IF_DEF_PARAMS (ifp)) | |
9399 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9400 | vty_out (vty, "%s", VTY_NEWLINE); | |
9401 | } | |
9402 | ||
9403 | ||
9404 | /* Router Dead Interval print. */ | |
9405 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
9406 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
9407 | { | |
f9ad937f | 9408 | vty_out (vty, " ip ospf dead-interval "); |
9409 | ||
9410 | /* fast hello ? */ | |
9411 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
9412 | vty_out (vty, "minimal hello-multiplier %d", | |
9413 | params->fast_hello); | |
9414 | else | |
9415 | vty_out (vty, "%u", params->v_wait); | |
9416 | ||
718e3744 | 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 | /* Router Priority print. */ | |
9423 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
9424 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
9425 | { | |
9426 | vty_out (vty, " ip ospf priority %u", params->priority); | |
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 | ||
9432 | /* Retransmit Interval print. */ | |
9433 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
9434 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
9435 | { | |
9436 | vty_out (vty, " ip ospf retransmit-interval %u", | |
9437 | params->retransmit_interval); | |
9438 | if (params != IF_DEF_PARAMS (ifp)) | |
9439 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9440 | vty_out (vty, "%s", VTY_NEWLINE); | |
9441 | } | |
9442 | ||
9443 | /* Transmit Delay print. */ | |
9444 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
9445 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9446 | { | |
9447 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
9448 | if (params != IF_DEF_PARAMS (ifp)) | |
9449 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9450 | vty_out (vty, "%s", VTY_NEWLINE); | |
9451 | } | |
9452 | ||
e723861d DS |
9453 | /* Area print. */ |
9454 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
9455 | { | |
7c8ff89e DS |
9456 | if (ospf->instance) |
9457 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
9458 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
9459 | else | |
9460 | vty_out (vty, " ip ospf area %s%s", | |
9461 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
e723861d DS |
9462 | |
9463 | } | |
9464 | ||
d5a5c8f0 | 9465 | /* bfd print. */ |
7f342629 | 9466 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 9467 | |
ba682537 | 9468 | /* MTU ignore print. */ |
9469 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
9470 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
9471 | { | |
9472 | if (params->mtu_ignore == 0) | |
9473 | vty_out (vty, " no ip ospf mtu-ignore"); | |
9474 | else | |
9475 | vty_out (vty, " ip ospf mtu-ignore"); | |
9476 | if (params != IF_DEF_PARAMS (ifp)) | |
9477 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9478 | vty_out (vty, "%s", VTY_NEWLINE); | |
9479 | } | |
9480 | ||
9481 | ||
718e3744 | 9482 | while (1) |
9483 | { | |
9484 | if (rn == NULL) | |
9485 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
9486 | else | |
9487 | rn = route_next (rn); | |
9488 | ||
9489 | if (rn == NULL) | |
9490 | break; | |
9491 | params = rn->info; | |
9492 | if (params != NULL) | |
9493 | break; | |
9494 | } | |
9495 | } while (rn); | |
9496 | ||
9497 | #ifdef HAVE_OPAQUE_LSA | |
9498 | ospf_opaque_config_write_if (vty, ifp); | |
9499 | #endif /* HAVE_OPAQUE_LSA */ | |
9500 | } | |
9501 | ||
9502 | return write; | |
9503 | } | |
9504 | ||
4dadc291 | 9505 | static int |
68980084 | 9506 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9507 | { |
9508 | struct route_node *rn; | |
9509 | u_char buf[INET_ADDRSTRLEN]; | |
9510 | ||
9511 | /* `network area' print. */ | |
68980084 | 9512 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 9513 | if (rn->info) |
9514 | { | |
9515 | struct ospf_network *n = rn->info; | |
9516 | ||
9517 | memset (buf, 0, INET_ADDRSTRLEN); | |
9518 | ||
9519 | /* Create Area ID string by specified Area ID format. */ | |
9520 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9521 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 9522 | else |
c9e52be3 | 9523 | sprintf ((char *) buf, "%lu", |
718e3744 | 9524 | (unsigned long int) ntohl (n->area_id.s_addr)); |
9525 | ||
9526 | /* Network print. */ | |
9527 | vty_out (vty, " network %s/%d area %s%s", | |
9528 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9529 | buf, VTY_NEWLINE); | |
9530 | } | |
9531 | ||
9532 | return 0; | |
9533 | } | |
9534 | ||
4dadc291 | 9535 | static int |
68980084 | 9536 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9537 | { |
52dc7ee6 | 9538 | struct listnode *node; |
1eb8ef25 | 9539 | struct ospf_area *area; |
718e3744 | 9540 | u_char buf[INET_ADDRSTRLEN]; |
9541 | ||
9542 | /* Area configuration print. */ | |
1eb8ef25 | 9543 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 9544 | { |
718e3744 | 9545 | struct route_node *rn1; |
9546 | ||
c9e52be3 | 9547 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
718e3744 | 9548 | |
9549 | if (area->auth_type != OSPF_AUTH_NULL) | |
9550 | { | |
9551 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
9552 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
9553 | else | |
9554 | vty_out (vty, " area %s authentication message-digest%s", | |
9555 | buf, VTY_NEWLINE); | |
9556 | } | |
9557 | ||
9558 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
9559 | vty_out (vty, " area %s shortcut %s%s", buf, | |
9560 | ospf_shortcut_mode_str[area->shortcut_configured], | |
9561 | VTY_NEWLINE); | |
9562 | ||
9563 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 9564 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 9565 | ) |
9566 | { | |
b0a053be | 9567 | if (area->external_routing == OSPF_AREA_STUB) |
9568 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 9569 | else if (area->external_routing == OSPF_AREA_NSSA) |
9570 | { | |
9571 | vty_out (vty, " area %s nssa", buf); | |
9572 | switch (area->NSSATranslatorRole) | |
9573 | { | |
9574 | case OSPF_NSSA_ROLE_NEVER: | |
9575 | vty_out (vty, " translate-never"); | |
9576 | break; | |
9577 | case OSPF_NSSA_ROLE_ALWAYS: | |
9578 | vty_out (vty, " translate-always"); | |
9579 | break; | |
9580 | case OSPF_NSSA_ROLE_CANDIDATE: | |
9581 | default: | |
9582 | vty_out (vty, " translate-candidate"); | |
9583 | } | |
9584 | } | |
718e3744 | 9585 | |
9586 | if (area->no_summary) | |
9587 | vty_out (vty, " no-summary"); | |
9588 | ||
9589 | vty_out (vty, "%s", VTY_NEWLINE); | |
9590 | ||
9591 | if (area->default_cost != 1) | |
9592 | vty_out (vty, " area %s default-cost %d%s", buf, | |
9593 | area->default_cost, VTY_NEWLINE); | |
9594 | } | |
9595 | ||
9596 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
9597 | if (rn1->info) | |
9598 | { | |
9599 | struct ospf_area_range *range = rn1->info; | |
9600 | ||
9601 | vty_out (vty, " area %s range %s/%d", buf, | |
9602 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
9603 | ||
6c835671 | 9604 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 9605 | vty_out (vty, " cost %d", range->cost_config); |
9606 | ||
9607 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
9608 | vty_out (vty, " not-advertise"); | |
9609 | ||
9610 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
9611 | vty_out (vty, " substitute %s/%d", | |
9612 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
9613 | ||
9614 | vty_out (vty, "%s", VTY_NEWLINE); | |
9615 | } | |
9616 | ||
9617 | if (EXPORT_NAME (area)) | |
9618 | vty_out (vty, " area %s export-list %s%s", buf, | |
9619 | EXPORT_NAME (area), VTY_NEWLINE); | |
9620 | ||
9621 | if (IMPORT_NAME (area)) | |
9622 | vty_out (vty, " area %s import-list %s%s", buf, | |
9623 | IMPORT_NAME (area), VTY_NEWLINE); | |
9624 | ||
9625 | if (PREFIX_NAME_IN (area)) | |
9626 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
9627 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
9628 | ||
9629 | if (PREFIX_NAME_OUT (area)) | |
9630 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
9631 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
9632 | } | |
9633 | ||
9634 | return 0; | |
9635 | } | |
9636 | ||
4dadc291 | 9637 | static int |
68980084 | 9638 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 9639 | { |
9640 | struct ospf_nbr_nbma *nbr_nbma; | |
9641 | struct route_node *rn; | |
9642 | ||
9643 | /* Static Neighbor configuration print. */ | |
68980084 | 9644 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 9645 | if ((nbr_nbma = rn->info)) |
9646 | { | |
9647 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
9648 | ||
9649 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
9650 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
9651 | ||
9652 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
9653 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
9654 | ||
9655 | vty_out (vty, "%s", VTY_NEWLINE); | |
9656 | } | |
9657 | ||
9658 | return 0; | |
9659 | } | |
9660 | ||
4dadc291 | 9661 | static int |
68980084 | 9662 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 9663 | { |
52dc7ee6 | 9664 | struct listnode *node; |
1eb8ef25 | 9665 | struct ospf_vl_data *vl_data; |
718e3744 | 9666 | u_char buf[INET_ADDRSTRLEN]; |
9667 | ||
9668 | /* Virtual-Link print */ | |
1eb8ef25 | 9669 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 9670 | { |
52dc7ee6 | 9671 | struct listnode *n2; |
718e3744 | 9672 | struct crypt_key *ck; |
718e3744 | 9673 | struct ospf_interface *oi; |
9674 | ||
9675 | if (vl_data != NULL) | |
9676 | { | |
9677 | memset (buf, 0, INET_ADDRSTRLEN); | |
9678 | ||
9679 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9680 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
718e3744 | 9681 | else |
c9e52be3 | 9682 | sprintf ((char *) buf, "%lu", |
718e3744 | 9683 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
9684 | oi = vl_data->vl_oi; | |
9685 | ||
9686 | /* timers */ | |
9687 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
9688 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
9689 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
9690 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9691 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
9692 | buf, | |
9693 | inet_ntoa (vl_data->vl_peer), | |
9694 | OSPF_IF_PARAM (oi, v_hello), | |
9695 | OSPF_IF_PARAM (oi, retransmit_interval), | |
9696 | OSPF_IF_PARAM (oi, transmit_delay), | |
9697 | OSPF_IF_PARAM (oi, v_wait), | |
9698 | VTY_NEWLINE); | |
9699 | else | |
9700 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
9701 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
9702 | /* Auth key */ | |
9703 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
9704 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
9705 | buf, | |
9706 | inet_ntoa (vl_data->vl_peer), | |
9707 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
9708 | VTY_NEWLINE); | |
9709 | /* md5 keys */ | |
1eb8ef25 | 9710 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
9711 | n2, ck)) | |
9712 | vty_out (vty, " area %s virtual-link %s" | |
9713 | " message-digest-key %d md5 %s%s", | |
9714 | buf, | |
9715 | inet_ntoa (vl_data->vl_peer), | |
9716 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 9717 | |
9718 | } | |
9719 | } | |
9720 | ||
9721 | return 0; | |
9722 | } | |
9723 | ||
6b0655a2 | 9724 | |
4dadc291 | 9725 | static int |
68980084 | 9726 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9727 | { |
9728 | int type; | |
9729 | ||
9730 | /* redistribute print. */ | |
9731 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
9732 | { |
9733 | struct list *red_list; | |
9734 | struct listnode *node; | |
9735 | struct ospf_redist *red; | |
718e3744 | 9736 | |
7c8ff89e DS |
9737 | red_list = ospf->redist[type]; |
9738 | if (!red_list) | |
9739 | continue; | |
9740 | ||
9741 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
9742 | { | |
9743 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
9744 | if (red->instance) | |
9745 | vty_out (vty, " %d", red->instance); | |
9746 | ||
9747 | if (red->dmetric.value >= 0) | |
9748 | vty_out (vty, " metric %d", red->dmetric.value); | |
9749 | ||
9750 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9751 | vty_out (vty, " metric-type 1"); | |
9752 | ||
9753 | if (ROUTEMAP_NAME (red)) | |
9754 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
9755 | ||
9756 | vty_out (vty, "%s", VTY_NEWLINE); | |
9757 | } | |
9758 | } | |
718e3744 | 9759 | |
9760 | return 0; | |
9761 | } | |
9762 | ||
4dadc291 | 9763 | static int |
68980084 | 9764 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 9765 | { |
68980084 | 9766 | if (ospf->default_metric != -1) |
9767 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 9768 | VTY_NEWLINE); |
9769 | return 0; | |
9770 | } | |
9771 | ||
4dadc291 | 9772 | static int |
68980084 | 9773 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9774 | { |
9775 | int type; | |
7c8ff89e | 9776 | struct ospf_redist *red; |
718e3744 | 9777 | |
68980084 | 9778 | if (ospf) |
718e3744 | 9779 | { |
9780 | /* distribute-list print. */ | |
9781 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 9782 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 9783 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 9784 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 9785 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 9786 | |
9787 | /* default-information print. */ | |
68980084 | 9788 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 9789 | { |
c42c177d | 9790 | vty_out (vty, " default-information originate"); |
9791 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
9792 | vty_out (vty, " always"); | |
718e3744 | 9793 | |
7c8ff89e DS |
9794 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
9795 | if (red) | |
9796 | { | |
9797 | if (red->dmetric.value >= 0) | |
9798 | vty_out (vty, " metric %d", | |
9799 | red->dmetric.value); | |
9800 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9801 | vty_out (vty, " metric-type 1"); | |
9802 | ||
9803 | if (ROUTEMAP_NAME (red)) | |
9804 | vty_out (vty, " route-map %s", | |
9805 | ROUTEMAP_NAME (red)); | |
9806 | } | |
718e3744 | 9807 | |
9808 | vty_out (vty, "%s", VTY_NEWLINE); | |
9809 | } | |
9810 | ||
9811 | } | |
9812 | ||
9813 | return 0; | |
9814 | } | |
9815 | ||
4dadc291 | 9816 | static int |
68980084 | 9817 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 9818 | { |
9819 | struct route_node *rn; | |
9820 | struct ospf_distance *odistance; | |
9821 | ||
68980084 | 9822 | if (ospf->distance_all) |
9823 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 9824 | |
68980084 | 9825 | if (ospf->distance_intra |
9826 | || ospf->distance_inter | |
9827 | || ospf->distance_external) | |
718e3744 | 9828 | { |
9829 | vty_out (vty, " distance ospf"); | |
9830 | ||
68980084 | 9831 | if (ospf->distance_intra) |
9832 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
9833 | if (ospf->distance_inter) | |
9834 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
9835 | if (ospf->distance_external) | |
9836 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 9837 | |
9838 | vty_out (vty, "%s", VTY_NEWLINE); | |
9839 | } | |
9840 | ||
68980084 | 9841 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 9842 | if ((odistance = rn->info) != NULL) |
9843 | { | |
9844 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
9845 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9846 | odistance->access_list ? odistance->access_list : "", | |
9847 | VTY_NEWLINE); | |
9848 | } | |
9849 | return 0; | |
9850 | } | |
9851 | ||
9852 | /* OSPF configuration write function. */ | |
4dadc291 | 9853 | static int |
718e3744 | 9854 | ospf_config_write (struct vty *vty) |
9855 | { | |
020709f9 | 9856 | struct ospf *ospf; |
1eb8ef25 | 9857 | struct interface *ifp; |
9858 | struct ospf_interface *oi; | |
52dc7ee6 | 9859 | struct listnode *node; |
718e3744 | 9860 | int write = 0; |
9861 | ||
020709f9 | 9862 | ospf = ospf_lookup (); |
0bad4851 | 9863 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 9864 | { |
9865 | /* `router ospf' print. */ | |
7c8ff89e DS |
9866 | if (ospf->instance) |
9867 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
9868 | else | |
9869 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 9870 | |
9871 | write++; | |
9872 | ||
68980084 | 9873 | if (!ospf->networks) |
718e3744 | 9874 | return write; |
9875 | ||
9876 | /* Router ID print. */ | |
68980084 | 9877 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 9878 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 9879 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 9880 | |
9881 | /* ABR type print. */ | |
d57834f6 | 9882 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 9883 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 9884 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 9885 | |
d7e60dd7 AS |
9886 | /* log-adjacency-changes flag print. */ |
9887 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
9888 | { | |
d7e60dd7 | 9889 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
692c7954 | 9890 | vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE); |
d7e60dd7 | 9891 | } |
692c7954 DW |
9892 | else |
9893 | { | |
9894 | vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE); | |
9895 | } | |
d7e60dd7 | 9896 | |
718e3744 | 9897 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 9898 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 9899 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
9900 | ||
9901 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 9902 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 9903 | { |
9904 | vty_out (vty, "! Important: ensure reference bandwidth " | |
9905 | "is consistent across all routers%s", VTY_NEWLINE); | |
9906 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
9907 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); | |
9908 | } | |
718e3744 | 9909 | |
9910 | /* SPF timers print. */ | |
68980084 | 9911 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 9912 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
9913 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
9914 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 9915 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 9916 | ospf->spf_max_holdtime, VTY_NEWLINE); |
b6927875 DS |
9917 | |
9918 | /* LSA timers print. */ | |
ac7424f9 MR |
9919 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
9920 | vty_out (vty, " timers throttle lsa all %d%s", | |
9921 | ospf->min_ls_interval, VTY_NEWLINE); | |
9922 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
b6927875 | 9923 | vty_out (vty, " timers lsa min-arrival %d%s", |
ac7424f9 | 9924 | ospf->min_ls_arrival, VTY_NEWLINE); |
b6927875 | 9925 | |
2f8f370e | 9926 | /* Write multiplier print. */ |
e8f45e82 | 9927 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 9928 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 9929 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 9930 | |
88d6cf37 | 9931 | /* Max-metric router-lsa print */ |
9932 | config_write_stub_router (vty, ospf); | |
9933 | ||
718e3744 | 9934 | /* SPF refresh parameters print. */ |
68980084 | 9935 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 9936 | vty_out (vty, " refresh timer %d%s", |
68980084 | 9937 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 9938 | |
9939 | /* Redistribute information print. */ | |
68980084 | 9940 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 9941 | |
9942 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
9943 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
9944 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
9945 | ||
1eb8ef25 | 9946 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
9947 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
9948 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
9949 | ospf->passive_interface_default) | |
9950 | { | |
9951 | vty_out (vty, " %spassive-interface %s%s", | |
9952 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
9953 | ifp->name, VTY_NEWLINE); | |
9954 | } | |
1eb8ef25 | 9955 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
9956 | { |
9957 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
9958 | continue; | |
9959 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
9960 | passive_interface)) | |
9961 | { | |
9962 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
9963 | continue; | |
9964 | } | |
9965 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
9966 | continue; | |
9967 | ||
9968 | vty_out (vty, " %spassive-interface %s %s%s", | |
9969 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 9970 | oi->ifp->name, |
9971 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 9972 | } |
718e3744 | 9973 | |
9974 | /* Network area print. */ | |
68980084 | 9975 | config_write_network_area (vty, ospf); |
718e3744 | 9976 | |
9977 | /* Area config print. */ | |
68980084 | 9978 | config_write_ospf_area (vty, ospf); |
718e3744 | 9979 | |
9980 | /* static neighbor print. */ | |
68980084 | 9981 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 9982 | |
9983 | /* Virtual-Link print. */ | |
68980084 | 9984 | config_write_virtual_link (vty, ospf); |
718e3744 | 9985 | |
9986 | /* Default metric configuration. */ | |
68980084 | 9987 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 9988 | |
9989 | /* Distribute-list and default-information print. */ | |
68980084 | 9990 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 9991 | |
9992 | /* Distance configuration. */ | |
68980084 | 9993 | config_write_ospf_distance (vty, ospf); |
718e3744 | 9994 | |
9995 | #ifdef HAVE_OPAQUE_LSA | |
68980084 | 9996 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 9997 | #endif /* HAVE_OPAQUE_LSA */ |
9998 | } | |
9999 | ||
10000 | return write; | |
10001 | } | |
10002 | ||
10003 | void | |
4dadc291 | 10004 | ospf_vty_show_init (void) |
718e3744 | 10005 | { |
10006 | /* "show ip ospf" commands. */ | |
10007 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
10008 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); | |
10009 | ||
7c8ff89e DS |
10010 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
10011 | install_element (ENABLE_NODE, &show_ip_ospf_instance_cmd); | |
10012 | ||
718e3744 | 10013 | /* "show ip ospf database" commands. */ |
10014 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); | |
10015 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); | |
10016 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
10017 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
10018 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
10019 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); | |
10020 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); | |
10021 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); | |
10022 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); | |
10023 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); | |
10024 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); | |
10025 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); | |
10026 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); | |
10027 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); | |
10028 | ||
7c8ff89e DS |
10029 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd); |
10030 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
10031 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
10032 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
10033 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
10034 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
10035 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); | |
10036 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_cmd); | |
10037 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_cmd); | |
10038 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd); | |
10039 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); | |
10040 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_id_self_cmd); | |
10041 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_self_cmd); | |
10042 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_cmd); | |
10043 | ||
718e3744 | 10044 | /* "show ip ospf interface" commands. */ |
10045 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
10046 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); | |
10047 | ||
7c8ff89e DS |
10048 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
10049 | install_element (ENABLE_NODE, &show_ip_ospf_instance_interface_cmd); | |
10050 | ||
718e3744 | 10051 | /* "show ip ospf neighbor" commands. */ |
10052 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
10053 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
10054 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
10055 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
10056 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
10057 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
10058 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
10059 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
10060 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); | |
10061 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); | |
10062 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
10063 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
10064 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); | |
10065 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); | |
10066 | ||
7c8ff89e DS |
10067 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
10068 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
10069 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
10070 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
10071 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
10072 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
10073 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
10074 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); | |
10075 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
10076 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
10077 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
10078 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
10079 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
10080 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
10081 | ||
718e3744 | 10082 | /* "show ip ospf route" commands. */ |
10083 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
10084 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 10085 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
10086 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); | |
7c8ff89e DS |
10087 | |
10088 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
10089 | install_element (ENABLE_NODE, &show_ip_ospf_instance_route_cmd); | |
10090 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
10091 | install_element (ENABLE_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
718e3744 | 10092 | } |
10093 | ||
6b0655a2 | 10094 | |
718e3744 | 10095 | /* ospfd's interface node. */ |
7fc626de | 10096 | static struct cmd_node interface_node = |
718e3744 | 10097 | { |
10098 | INTERFACE_NODE, | |
10099 | "%s(config-if)# ", | |
10100 | 1 | |
10101 | }; | |
10102 | ||
10103 | /* Initialization of OSPF interface. */ | |
4dadc291 | 10104 | static void |
10105 | ospf_vty_if_init (void) | |
718e3744 | 10106 | { |
10107 | /* Install interface node. */ | |
10108 | install_node (&interface_node, config_write_interface); | |
10109 | ||
10110 | install_element (CONFIG_NODE, &interface_cmd); | |
32d2463c | 10111 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 10112 | install_default (INTERFACE_NODE); |
10113 | ||
10114 | /* "description" commands. */ | |
10115 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
10116 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
10117 | ||
10118 | /* "ip ospf authentication" commands. */ | |
10119 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
10120 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); | |
10121 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); | |
10122 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); | |
b4a039bf DS |
10123 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
10124 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_cmd); | |
718e3744 | 10125 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
10126 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); | |
10127 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); | |
10128 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); | |
813d4307 DW |
10129 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); |
10130 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_cmd); | |
718e3744 | 10131 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
10132 | ||
10133 | /* "ip ospf message-digest-key" commands. */ | |
10134 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); | |
10135 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); | |
10136 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); | |
10137 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
813d4307 DW |
10138 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd); |
10139 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_cmd); | |
718e3744 | 10140 | |
10141 | /* "ip ospf cost" commands. */ | |
9eff36b3 DO |
10142 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
10143 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); | |
827341b7 DO |
10144 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
10145 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 10146 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
718e3744 | 10147 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
10148 | ||
ba682537 | 10149 | /* "ip ospf mtu-ignore" commands. */ |
10150 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
10151 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); | |
10152 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); | |
10153 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); | |
10154 | ||
718e3744 | 10155 | /* "ip ospf dead-interval" commands. */ |
10156 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); | |
10157 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); | |
f9ad937f | 10158 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
10159 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); | |
718e3744 | 10160 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
10161 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); | |
f9dfba8d | 10162 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd); |
f9ad937f | 10163 | |
718e3744 | 10164 | /* "ip ospf hello-interval" commands. */ |
10165 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); | |
10166 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); | |
10167 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); | |
10168 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
f9dfba8d | 10169 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd); |
718e3744 | 10170 | |
10171 | /* "ip ospf network" commands. */ | |
10172 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
10173 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
813d4307 | 10174 | install_element (INTERFACE_NODE, &no_ip_ospf_network_val_cmd); |
718e3744 | 10175 | |
10176 | /* "ip ospf priority" commands. */ | |
10177 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); | |
10178 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); | |
718e3744 | 10179 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
a1afa410 | 10180 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_no_param_cmd); |
813d4307 | 10181 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
718e3744 | 10182 | |
10183 | /* "ip ospf retransmit-interval" commands. */ | |
10184 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
10185 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); | |
10186 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); | |
10187 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); | |
813d4307 DW |
10188 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_addr_cmd); |
10189 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_cmd); | |
718e3744 | 10190 | |
10191 | /* "ip ospf transmit-delay" commands. */ | |
10192 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
10193 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); | |
10194 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); | |
10195 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); | |
813d4307 DW |
10196 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_addr_cmd); |
10197 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_cmd); | |
718e3744 | 10198 | |
e723861d DS |
10199 | /* "ip ospf area" commands. */ |
10200 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
10201 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
813d4307 | 10202 | install_element (INTERFACE_NODE, &no_ip_ospf_area_val_cmd); |
7c8ff89e DS |
10203 | install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd); |
10204 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd); | |
813d4307 | 10205 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_val_cmd); |
e723861d | 10206 | |
718e3744 | 10207 | /* These commands are compatibitliy for previous version. */ |
10208 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
10209 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); | |
813d4307 DW |
10210 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_cmd); |
10211 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_ip_cmd); | |
718e3744 | 10212 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
10213 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); | |
9eff36b3 DO |
10214 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
10215 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); | |
718e3744 | 10216 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
827341b7 DO |
10217 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
10218 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); | |
9eff36b3 | 10219 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
718e3744 | 10220 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
10221 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); | |
813d4307 DW |
10222 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_addr_cmd); |
10223 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_cmd); | |
718e3744 | 10224 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
10225 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); | |
10226 | install_element (INTERFACE_NODE, &ospf_network_cmd); | |
10227 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); | |
813d4307 | 10228 | install_element (INTERFACE_NODE, &no_ospf_network_val_cmd); |
718e3744 | 10229 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
10230 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); | |
10231 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); | |
10232 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); | |
10233 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); | |
10234 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); | |
10235 | } | |
10236 | ||
4dadc291 | 10237 | static void |
10238 | ospf_vty_zebra_init (void) | |
718e3744 | 10239 | { |
718e3744 | 10240 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 10241 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
10242 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
10243 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 10244 | |
10245 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
10246 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
10247 | ||
718e3744 | 10248 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 10249 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
10250 | ||
10251 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
10252 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
10253 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); | |
10254 | ||
10255 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
10256 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
10257 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 10258 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 10259 | #if 0 |
10260 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
10261 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
10262 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
10263 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
10264 | #endif /* 0 */ | |
10265 | } | |
10266 | ||
7fc626de | 10267 | static struct cmd_node ospf_node = |
718e3744 | 10268 | { |
10269 | OSPF_NODE, | |
10270 | "%s(config-router)# ", | |
10271 | 1 | |
10272 | }; | |
10273 | ||
09f35f8c DS |
10274 | static void |
10275 | ospf_interface_clear (struct interface *ifp) | |
10276 | { | |
10277 | if (!if_is_operative (ifp)) return; | |
10278 | ||
10279 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
10280 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); | |
10281 | ||
10282 | ospf_if_reset(ifp); | |
10283 | } | |
10284 | ||
10285 | DEFUN (clear_ip_ospf_interface, | |
10286 | clear_ip_ospf_interface_cmd, | |
10287 | "clear ip ospf interface [IFNAME]", | |
10288 | CLEAR_STR | |
10289 | IP_STR | |
10290 | "OSPF information\n" | |
10291 | "Interface information\n" | |
10292 | "Interface name\n") | |
10293 | { | |
10294 | struct interface *ifp; | |
10295 | struct listnode *node; | |
10296 | ||
10297 | if (argc == 0) /* Clear all the ospfv2 interfaces. */ | |
10298 | { | |
b2d7c082 | 10299 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
09f35f8c DS |
10300 | ospf_interface_clear(ifp); |
10301 | } | |
10302 | else /* Interface name is specified. */ | |
10303 | { | |
10304 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) | |
10305 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
10306 | else | |
10307 | ospf_interface_clear(ifp); | |
10308 | } | |
10309 | ||
10310 | return CMD_SUCCESS; | |
10311 | } | |
10312 | ||
10313 | void | |
10314 | ospf_vty_clear_init (void) | |
10315 | { | |
10316 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
10317 | } | |
10318 | ||
6b0655a2 | 10319 | |
718e3744 | 10320 | /* Install OSPF related vty commands. */ |
10321 | void | |
4dadc291 | 10322 | ospf_vty_init (void) |
718e3744 | 10323 | { |
10324 | /* Install ospf top node. */ | |
10325 | install_node (&ospf_node, ospf_config_write); | |
10326 | ||
10327 | /* "router ospf" commands. */ | |
10328 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
10329 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
10330 | ||
7c8ff89e DS |
10331 | install_element (CONFIG_NODE, &router_ospf_instance_cmd); |
10332 | install_element (CONFIG_NODE, &no_router_ospf_instance_cmd); | |
10333 | ||
718e3744 | 10334 | install_default (OSPF_NODE); |
10335 | ||
10336 | /* "ospf router-id" commands. */ | |
10337 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
747e489c | 10338 | install_element (OSPF_NODE, &ospf_router_id_old_cmd); |
718e3744 | 10339 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
12fde75b | 10340 | install_element (OSPF_NODE, &no_ospf_router_id_val_cmd); |
718e3744 | 10341 | |
10342 | /* "passive-interface" commands. */ | |
a2c62831 | 10343 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
10344 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); | |
7ffa8fa2 | 10345 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
a2c62831 | 10346 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
10347 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); | |
7ffa8fa2 | 10348 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
718e3744 | 10349 | |
10350 | /* "ospf abr-type" commands. */ | |
10351 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
10352 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
10353 | ||
d7e60dd7 AS |
10354 | /* "ospf log-adjacency-changes" commands. */ |
10355 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
10356 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
10357 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
10358 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
10359 | ||
718e3744 | 10360 | /* "ospf rfc1583-compatible" commands. */ |
10361 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); | |
10362 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
10363 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); | |
10364 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
10365 | ||
10366 | /* "network area" commands. */ | |
a2c62831 | 10367 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
10368 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 10369 | |
10370 | /* "area authentication" commands. */ | |
a2c62831 | 10371 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
10372 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
10373 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 10374 | |
10375 | /* "area range" commands. */ | |
a2c62831 | 10376 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
10377 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); | |
10378 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); | |
10379 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); | |
10380 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); | |
10381 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
10382 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); | |
10383 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); | |
10384 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); | |
10385 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); | |
10386 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 10387 | |
10388 | /* "area virtual-link" commands. */ | |
a2c62831 | 10389 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
10390 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); | |
718e3744 | 10391 | |
a2c62831 | 10392 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
10393 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); | |
718e3744 | 10394 | |
a2c62831 | 10395 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
10396 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); | |
718e3744 | 10397 | |
a2c62831 | 10398 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
10399 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); | |
718e3744 | 10400 | |
a2c62831 | 10401 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
10402 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); | |
718e3744 | 10403 | |
a2c62831 | 10404 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
813d4307 | 10405 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_cmd); |
a2c62831 | 10406 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
10407 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); | |
718e3744 | 10408 | |
a2c62831 | 10409 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
10410 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); | |
718e3744 | 10411 | |
a2c62831 | 10412 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
10413 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); | |
718e3744 | 10414 | |
a2c62831 | 10415 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
813d4307 | 10416 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_authkey_cmd); |
a2c62831 | 10417 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
10418 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); | |
718e3744 | 10419 | |
a2c62831 | 10420 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
813d4307 | 10421 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_md5_cmd); |
a2c62831 | 10422 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
10423 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); | |
718e3744 | 10424 | |
10425 | /* "area stub" commands. */ | |
a2c62831 | 10426 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
10427 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
10428 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
10429 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 10430 | |
718e3744 | 10431 | /* "area nssa" commands. */ |
a2c62831 | 10432 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
10433 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
10434 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
10435 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
10436 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
10437 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); | |
718e3744 | 10438 | |
a2c62831 | 10439 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
10440 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 10441 | |
a2c62831 | 10442 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
10443 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 10444 | |
a2c62831 | 10445 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
10446 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 10447 | |
a2c62831 | 10448 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
10449 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 10450 | |
a2c62831 | 10451 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
10452 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 10453 | |
10454 | /* SPF timer commands */ | |
d24f6e2a | 10455 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
10456 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
b4a039bf | 10457 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_val_cmd); |
d24f6e2a | 10458 | |
b6927875 | 10459 | /* LSA timers commands */ |
ac7424f9 MR |
10460 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
10461 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
813d4307 | 10462 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_val_cmd); |
ac7424f9 MR |
10463 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); |
10464 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
813d4307 | 10465 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_val_cmd); |
b6927875 DS |
10466 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
10467 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
10468 | install_element (OSPF_NODE, &no_ospf_timers_lsa_val_cmd); | |
10469 | ||
88d6cf37 | 10470 | /* refresh timer commands */ |
a2c62831 | 10471 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
10472 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
10473 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); | |
718e3744 | 10474 | |
88d6cf37 | 10475 | /* max-metric commands */ |
10476 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
10477 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
10478 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
10479 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
a1afa410 | 10480 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_no_param_cmd); |
88d6cf37 | 10481 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
10482 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
a1afa410 | 10483 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd); |
88d6cf37 | 10484 | |
10485 | /* reference bandwidth commands */ | |
a2c62831 | 10486 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
10487 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
813d4307 | 10488 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_val_cmd); |
718e3744 | 10489 | |
10490 | /* "neighbor" commands. */ | |
a2c62831 | 10491 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
10492 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); | |
10493 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); | |
10494 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); | |
10495 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); | |
10496 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); | |
10497 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); | |
10498 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); | |
813d4307 DW |
10499 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_priority_cmd); |
10500 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_pollinterval_cmd); | |
718e3744 | 10501 | |
2f8f370e DS |
10502 | /* write multiplier commands */ |
10503 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
10504 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); | |
e8f45e82 DS |
10505 | install_element (OSPF_NODE, &write_multiplier_cmd); |
10506 | install_element (OSPF_NODE, &no_write_multiplier_cmd); | |
813d4307 | 10507 | install_element (OSPF_NODE, &no_write_multiplier_val_cmd); |
2f8f370e | 10508 | |
718e3744 | 10509 | /* Init interface related vty commands. */ |
10510 | ospf_vty_if_init (); | |
10511 | ||
10512 | /* Init zebra related vty commands. */ | |
10513 | ospf_vty_zebra_init (); | |
10514 | } |