]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPF VTY interface. |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 Toshiaki Takada |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #include <zebra.h> | |
7ec4159b | 24 | #include <string.h> |
718e3744 | 25 | |
26 | #include "memory.h" | |
27 | #include "thread.h" | |
28 | #include "prefix.h" | |
29 | #include "table.h" | |
30 | #include "vty.h" | |
31 | #include "command.h" | |
32 | #include "plist.h" | |
33 | #include "log.h" | |
34 | #include "zclient.h" | |
bf2bfafd | 35 | #include <lib/json.h> |
718e3744 | 36 | |
37 | #include "ospfd/ospfd.h" | |
38 | #include "ospfd/ospf_asbr.h" | |
39 | #include "ospfd/ospf_lsa.h" | |
40 | #include "ospfd/ospf_lsdb.h" | |
41 | #include "ospfd/ospf_ism.h" | |
42 | #include "ospfd/ospf_interface.h" | |
43 | #include "ospfd/ospf_nsm.h" | |
44 | #include "ospfd/ospf_neighbor.h" | |
45 | #include "ospfd/ospf_flood.h" | |
46 | #include "ospfd/ospf_abr.h" | |
47 | #include "ospfd/ospf_spf.h" | |
48 | #include "ospfd/ospf_route.h" | |
49 | #include "ospfd/ospf_zebra.h" | |
50 | /*#include "ospfd/ospf_routemap.h" */ | |
51 | #include "ospfd/ospf_vty.h" | |
52 | #include "ospfd/ospf_dump.h" | |
7f342629 | 53 | #include "ospfd/ospf_bfd.h" |
718e3744 | 54 | |
30a2231a | 55 | static const char *ospf_network_type_str[] = |
718e3744 | 56 | { |
57 | "Null", | |
58 | "POINTOPOINT", | |
59 | "BROADCAST", | |
60 | "NBMA", | |
61 | "POINTOMULTIPOINT", | |
62 | "VIRTUALLINK", | |
63 | "LOOPBACK" | |
64 | }; | |
65 | ||
718e3744 | 66 | /* Utility functions. */ |
16f1b9ee | 67 | int |
6c835671 | 68 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
718e3744 | 69 | { |
70 | char *endptr = NULL; | |
71 | unsigned long ret; | |
72 | ||
73 | /* match "A.B.C.D". */ | |
74 | if (strchr (str, '.') != NULL) | |
75 | { | |
76 | ret = inet_aton (str, area_id); | |
77 | if (!ret) | |
78 | return -1; | |
79 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; | |
80 | } | |
81 | /* match "<0-4294967295>". */ | |
82 | else | |
83 | { | |
664711c1 UW |
84 | if (*str == '-') |
85 | return -1; | |
86 | errno = 0; | |
718e3744 | 87 | ret = strtoul (str, &endptr, 10); |
664711c1 | 88 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
718e3744 | 89 | return -1; |
90 | ||
91 | area_id->s_addr = htonl (ret); | |
92 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; | |
93 | } | |
94 | ||
95 | return 0; | |
96 | } | |
97 | ||
6b0655a2 | 98 | |
4dadc291 | 99 | static int |
6c835671 | 100 | str2metric (const char *str, int *metric) |
718e3744 | 101 | { |
102 | /* Sanity check. */ | |
103 | if (str == NULL) | |
104 | return 0; | |
105 | ||
106 | *metric = strtol (str, NULL, 10); | |
107 | if (*metric < 0 && *metric > 16777214) | |
108 | { | |
109 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
110 | return 0; | |
111 | } | |
112 | ||
113 | return 1; | |
114 | } | |
115 | ||
4dadc291 | 116 | static int |
6c835671 | 117 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 118 | { |
119 | /* Sanity check. */ | |
120 | if (str == NULL) | |
121 | return 0; | |
122 | ||
123 | if (strncmp (str, "1", 1) == 0) | |
124 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
125 | else if (strncmp (str, "2", 1) == 0) | |
126 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
127 | else | |
128 | return 0; | |
129 | ||
130 | return 1; | |
131 | } | |
132 | ||
133 | int | |
134 | ospf_oi_count (struct interface *ifp) | |
135 | { | |
136 | struct route_node *rn; | |
137 | int i = 0; | |
138 | ||
139 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
140 | if (rn->info) | |
141 | i++; | |
142 | ||
143 | return i; | |
144 | } | |
145 | ||
6b0655a2 | 146 | |
f412b39a DW |
147 | /* |
148 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
149 | * "router ospf <1-65535>", | |
150 | * "Enable a routing process\n" | |
151 | * "Start OSPF configuration\n" | |
152 | * "Instance ID\n" | |
153 | * | |
154 | */ | |
718e3744 | 155 | DEFUN (router_ospf, |
156 | router_ospf_cmd, | |
157 | "router ospf", | |
158 | "Enable a routing process\n" | |
159 | "Start OSPF configuration\n") | |
160 | { | |
7c8ff89e DS |
161 | struct ospf *ospf; |
162 | u_short instance = 0; | |
163 | ||
164 | ospf = ospf_lookup(); | |
165 | if (!ospf) | |
166 | { | |
167 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
168 | return CMD_WARNING; | |
169 | } | |
170 | ||
718e3744 | 171 | vty->node = OSPF_NODE; |
7c8ff89e DS |
172 | |
173 | if (argc) | |
174 | VTY_GET_INTEGER ("Instance", instance, argv[0]); | |
175 | ||
176 | /* The following logic to set the vty->index is in place to be able | |
177 | to ignore the commands which dont belong to this instance. */ | |
178 | if (ospf->instance != instance) | |
179 | vty->index = NULL; | |
180 | else | |
0bad4851 DS |
181 | { |
182 | if (IS_DEBUG_OSPF_EVENT) | |
183 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
184 | ospf->oi_running = 1; | |
185 | vty->index = ospf; | |
186 | ospf_router_id_update (ospf); | |
187 | } | |
718e3744 | 188 | |
189 | return CMD_SUCCESS; | |
190 | } | |
191 | ||
7c8ff89e | 192 | |
f412b39a DW |
193 | /* |
194 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
195 | * "no router ospf <1-65535>", | |
196 | * NO_STR | |
197 | * "Enable a routing process\n" | |
198 | * "Start OSPF configuration\n" | |
199 | * "Instance ID\n" | |
200 | * | |
201 | */ | |
718e3744 | 202 | DEFUN (no_router_ospf, |
203 | no_router_ospf_cmd, | |
204 | "no router ospf", | |
205 | NO_STR | |
206 | "Enable a routing process\n" | |
207 | "Start OSPF configuration\n") | |
208 | { | |
020709f9 | 209 | struct ospf *ospf; |
7c8ff89e | 210 | u_short instance = 0; |
020709f9 | 211 | |
7c8ff89e | 212 | if (argc) |
bf2bfafd | 213 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
7c8ff89e DS |
214 | |
215 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
216 | return CMD_SUCCESS; | |
718e3744 | 217 | |
020709f9 | 218 | ospf_finish (ospf); |
718e3744 | 219 | |
220 | return CMD_SUCCESS; | |
221 | } | |
222 | ||
7c8ff89e | 223 | |
718e3744 | 224 | DEFUN (ospf_router_id, |
225 | ospf_router_id_cmd, | |
226 | "ospf router-id A.B.C.D", | |
227 | "OSPF specific commands\n" | |
228 | "router-id for the OSPF process\n" | |
229 | "OSPF router-id in IP address format\n") | |
230 | { | |
68980084 | 231 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
232 | struct listnode *node; |
233 | struct ospf_area *area; | |
718e3744 | 234 | struct in_addr router_id; |
68980084 | 235 | int ret; |
718e3744 | 236 | |
7c8ff89e DS |
237 | if (!ospf) |
238 | return CMD_SUCCESS; | |
239 | ||
bf2bfafd | 240 | ret = inet_aton (argv[2]->arg, &router_id); |
718e3744 | 241 | if (!ret) |
242 | { | |
243 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
244 | return CMD_WARNING; | |
245 | } | |
246 | ||
68980084 | 247 | ospf->router_id_static = router_id; |
2c19a6ec DS |
248 | |
249 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
250 | if (area->full_nbrs) | |
251 | { | |
252 | vty_out (vty, "For this router-id change to take effect," | |
253 | " save config and restart ospfd%s", VTY_NEWLINE); | |
254 | return CMD_SUCCESS; | |
255 | } | |
256 | ||
b29800a6 | 257 | ospf_router_id_update (ospf); |
258 | ||
718e3744 | 259 | return CMD_SUCCESS; |
260 | } | |
261 | ||
747e489c DW |
262 | ALIAS_HIDDEN (ospf_router_id, |
263 | ospf_router_id_old_cmd, | |
264 | "router-id A.B.C.D", | |
265 | "router-id for the OSPF process\n" | |
266 | "OSPF router-id in IP address format\n") | |
267 | ||
f412b39a DW |
268 | /* |
269 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
270 | * "no ospf router-id A.B.C.D", | |
271 | * NO_STR | |
272 | * "OSPF specific commands\n" | |
273 | * "router-id for the OSPF process\n" | |
274 | * "OSPF router-id in IP address format\n" | |
275 | * | |
276 | */ | |
718e3744 | 277 | DEFUN (no_ospf_router_id, |
278 | no_ospf_router_id_cmd, | |
279 | "no ospf router-id", | |
280 | NO_STR | |
281 | "OSPF specific commands\n" | |
282 | "router-id for the OSPF process\n") | |
283 | { | |
68980084 | 284 | struct ospf *ospf = vty->index; |
2c19a6ec DS |
285 | struct listnode *node; |
286 | struct ospf_area *area; | |
68980084 | 287 | |
7c8ff89e DS |
288 | if (!ospf) |
289 | return CMD_SUCCESS; | |
290 | ||
68980084 | 291 | ospf->router_id_static.s_addr = 0; |
718e3744 | 292 | |
2c19a6ec DS |
293 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
294 | if (area->full_nbrs) | |
295 | { | |
296 | vty_out (vty, "For this router-id change to take effect," | |
297 | " save config and restart ospfd%s", VTY_NEWLINE); | |
298 | return CMD_SUCCESS; | |
299 | } | |
300 | ||
68980084 | 301 | ospf_router_id_update (ospf); |
718e3744 | 302 | |
303 | return CMD_SUCCESS; | |
304 | } | |
305 | ||
718e3744 | 306 | |
7ffa8fa2 | 307 | static void |
43540886 | 308 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
309 | { |
310 | struct listnode *ln; | |
311 | struct interface *ifp; | |
312 | struct ospf_interface *oi; | |
313 | ||
43540886 AS |
314 | ospf->passive_interface_default = newval; |
315 | ||
7ffa8fa2 PJ |
316 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
317 | { | |
318 | if (ifp && | |
319 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
320 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
321 | } | |
322 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
323 | { | |
324 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
325 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
326 | /* update multicast memberships */ |
327 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
328 | } |
329 | } | |
330 | ||
331 | static void | |
f842f166 PJ |
332 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
333 | struct ospf_if_params *params, u_char value, | |
334 | struct in_addr addr) | |
7ffa8fa2 PJ |
335 | { |
336 | u_char dflt; | |
337 | ||
338 | params->passive_interface = value; | |
339 | if (params != IF_DEF_PARAMS (ifp)) | |
340 | { | |
341 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
342 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
343 | else | |
344 | dflt = ospf->passive_interface_default; | |
345 | ||
346 | if (value != dflt) | |
347 | SET_IF_PARAM (params, passive_interface); | |
348 | else | |
349 | UNSET_IF_PARAM (params, passive_interface); | |
350 | ||
351 | ospf_free_if_params (ifp, addr); | |
352 | ospf_if_update_params (ifp, addr); | |
353 | } | |
f842f166 PJ |
354 | } |
355 | ||
356 | static void | |
357 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
358 | struct ospf_if_params *params, u_char value) | |
359 | { | |
360 | params->passive_interface = value; | |
361 | if (params == IF_DEF_PARAMS (ifp)) | |
7ffa8fa2 PJ |
362 | { |
363 | if (value != ospf->passive_interface_default) | |
364 | SET_IF_PARAM (params, passive_interface); | |
365 | else | |
366 | UNSET_IF_PARAM (params, passive_interface); | |
367 | } | |
368 | } | |
369 | ||
f412b39a DW |
370 | /* |
371 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
372 | * "passive-interface IFNAME", | |
373 | * "Suppress routing updates on an interface\n" | |
374 | * "Interface's name\n" | |
375 | * | |
376 | * "passive-interface default", | |
377 | * "Suppress routing updates on an interface\n" | |
378 | * "Suppress routing updates on interfaces by default\n" | |
379 | * | |
380 | */ | |
a2c62831 | 381 | DEFUN (ospf_passive_interface, |
382 | ospf_passive_interface_addr_cmd, | |
718e3744 | 383 | "passive-interface IFNAME A.B.C.D", |
384 | "Suppress routing updates on an interface\n" | |
385 | "Interface's name\n") | |
386 | { | |
7ffa8fa2 | 387 | struct interface *ifp; |
cb2af5d0 | 388 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
7ffa8fa2 PJ |
389 | int ret; |
390 | struct ospf_if_params *params; | |
391 | struct route_node *rn; | |
392 | struct ospf *ospf = vty->index; | |
718e3744 | 393 | |
7c8ff89e DS |
394 | if (!ospf) |
395 | return CMD_SUCCESS; | |
396 | ||
43540886 AS |
397 | if (argc == 0) |
398 | { | |
399 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
400 | return CMD_SUCCESS; | |
401 | } | |
402 | ||
bf2bfafd | 403 | ifp = if_get_by_name (argv[2]->arg); |
718e3744 | 404 | |
405 | params = IF_DEF_PARAMS (ifp); | |
406 | ||
43540886 | 407 | if (argc == 2) |
718e3744 | 408 | { |
43540886 AS |
409 | ret = inet_aton(argv[1], &addr); |
410 | if (!ret) | |
411 | { | |
412 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
413 | VTY_NEWLINE); | |
414 | return CMD_WARNING; | |
415 | } | |
416 | ||
417 | params = ospf_get_if_params (ifp, addr); | |
418 | ospf_if_update_params (ifp, addr); | |
f842f166 PJ |
419 | ospf_passive_interface_update_addr (ospf, ifp, params, |
420 | OSPF_IF_PASSIVE, addr); | |
7ffa8fa2 | 421 | } |
f842f166 PJ |
422 | |
423 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); | |
43540886 | 424 | |
ba6454ec | 425 | /* XXX We should call ospf_if_set_multicast on exactly those |
426 | * interfaces for which the passive property changed. It is too much | |
427 | * work to determine this set, so we do this for every interface. | |
428 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
429 | * record of joined groups to avoid systems calls if the desired | |
430 | * memberships match the current memership. | |
431 | */ | |
7ffa8fa2 | 432 | |
ba6454ec | 433 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
434 | { | |
435 | struct ospf_interface *oi = rn->info; | |
436 | ||
437 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 438 | ospf_if_set_multicast(oi); |
ba6454ec | 439 | } |
440 | /* | |
441 | * XXX It is not clear what state transitions the interface needs to | |
442 | * undergo when going from active to passive. Fixing this will | |
443 | * require precise identification of interfaces having such a | |
444 | * transition. | |
445 | */ | |
446 | ||
718e3744 | 447 | return CMD_SUCCESS; |
448 | } | |
449 | ||
718e3744 | 450 | |
7ffa8fa2 | 451 | |
f412b39a DW |
452 | /* |
453 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
454 | * "no passive-interface default", | |
455 | * NO_STR | |
456 | * "Allow routing updates on an interface\n" | |
457 | * "Allow routing updates on interfaces by default\n" | |
458 | * | |
459 | * "no passive-interface IFNAME", | |
460 | * NO_STR | |
461 | * "Allow routing updates on an interface\n" | |
462 | * "Interface's name\n" | |
463 | * | |
464 | */ | |
a2c62831 | 465 | DEFUN (no_ospf_passive_interface, |
466 | no_ospf_passive_interface_addr_cmd, | |
718e3744 | 467 | "no passive-interface IFNAME A.B.C.D", |
468 | NO_STR | |
469 | "Allow routing updates on an interface\n" | |
470 | "Interface's name\n") | |
471 | { | |
472 | struct interface *ifp; | |
cb2af5d0 | 473 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
718e3744 | 474 | struct ospf_if_params *params; |
475 | int ret; | |
ba6454ec | 476 | struct route_node *rn; |
7ffa8fa2 | 477 | struct ospf *ospf = vty->index; |
43540886 | 478 | |
7c8ff89e DS |
479 | if (!ospf) |
480 | return CMD_SUCCESS; | |
481 | ||
43540886 AS |
482 | if (argc == 0) |
483 | { | |
484 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
485 | return CMD_SUCCESS; | |
486 | } | |
718e3744 | 487 | |
bf2bfafd | 488 | ifp = if_get_by_name (argv[3]->arg); |
718e3744 | 489 | |
490 | params = IF_DEF_PARAMS (ifp); | |
491 | ||
43540886 | 492 | if (argc == 2) |
718e3744 | 493 | { |
43540886 AS |
494 | ret = inet_aton(argv[1], &addr); |
495 | if (!ret) | |
496 | { | |
497 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
498 | VTY_NEWLINE); | |
499 | return CMD_WARNING; | |
500 | } | |
501 | ||
502 | params = ospf_lookup_if_params (ifp, addr); | |
503 | if (params == NULL) | |
504 | return CMD_SUCCESS; | |
f842f166 PJ |
505 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
506 | addr); | |
718e3744 | 507 | } |
f842f166 PJ |
508 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
509 | ||
ba6454ec | 510 | /* XXX We should call ospf_if_set_multicast on exactly those |
511 | * interfaces for which the passive property changed. It is too much | |
512 | * work to determine this set, so we do this for every interface. | |
513 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
514 | * record of joined groups to avoid systems calls if the desired | |
515 | * memberships match the current memership. | |
516 | */ | |
517 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
518 | { | |
519 | struct ospf_interface *oi = rn->info; | |
520 | ||
521 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
522 | ospf_if_set_multicast(oi); | |
523 | } | |
524 | ||
718e3744 | 525 | return CMD_SUCCESS; |
526 | } | |
527 | ||
718e3744 | 528 | |
7ffa8fa2 | 529 | |
a2c62831 | 530 | DEFUN (ospf_network_area, |
531 | ospf_network_area_cmd, | |
6147e2c6 | 532 | "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 533 | "Enable routing on an IP network\n" |
534 | "OSPF network prefix\n" | |
535 | "Set the OSPF area ID\n" | |
536 | "OSPF area ID in IP address format\n" | |
537 | "OSPF area ID as a decimal value\n") | |
538 | { | |
539 | struct ospf *ospf= vty->index; | |
540 | struct prefix_ipv4 p; | |
541 | struct in_addr area_id; | |
542 | int ret, format; | |
543 | ||
7c8ff89e DS |
544 | if (!ospf) |
545 | return CMD_SUCCESS; | |
546 | ||
547 | if (ospf->instance) | |
548 | { | |
549 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
550 | VTY_NEWLINE); | |
551 | return CMD_WARNING; | |
552 | } | |
553 | ||
953cde65 JT |
554 | if (ospf->if_ospf_cli_count > 0) |
555 | { | |
556 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
557 | VTY_NEWLINE); | |
558 | return CMD_WARNING; | |
559 | } | |
560 | ||
718e3744 | 561 | /* Get network prefix and Area ID. */ |
bf2bfafd DW |
562 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[1]->arg); |
563 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[3]->arg); | |
718e3744 | 564 | |
565 | ret = ospf_network_set (ospf, &p, area_id); | |
566 | if (ret == 0) | |
567 | { | |
568 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
569 | return CMD_WARNING; | |
570 | } | |
571 | ||
572 | return CMD_SUCCESS; | |
573 | } | |
574 | ||
a2c62831 | 575 | DEFUN (no_ospf_network_area, |
576 | no_ospf_network_area_cmd, | |
6147e2c6 | 577 | "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 578 | NO_STR |
579 | "Enable routing on an IP network\n" | |
580 | "OSPF network prefix\n" | |
581 | "Set the OSPF area ID\n" | |
582 | "OSPF area ID in IP address format\n" | |
583 | "OSPF area ID as a decimal value\n") | |
584 | { | |
585 | struct ospf *ospf = (struct ospf *) vty->index; | |
586 | struct prefix_ipv4 p; | |
587 | struct in_addr area_id; | |
588 | int ret, format; | |
589 | ||
7c8ff89e DS |
590 | if (!ospf) |
591 | return CMD_SUCCESS; | |
592 | ||
593 | if (ospf->instance) | |
594 | { | |
595 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
596 | VTY_NEWLINE); | |
597 | return CMD_WARNING; | |
598 | } | |
599 | ||
718e3744 | 600 | /* Get network prefix and Area ID. */ |
bf2bfafd DW |
601 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[2]->arg); |
602 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[4]->arg); | |
718e3744 | 603 | |
604 | ret = ospf_network_unset (ospf, &p, area_id); | |
605 | if (ret == 0) | |
606 | { | |
607 | vty_out (vty, "Can't find specified network area configuration.%s", | |
608 | VTY_NEWLINE); | |
609 | return CMD_WARNING; | |
610 | } | |
611 | ||
612 | return CMD_SUCCESS; | |
613 | } | |
614 | ||
6b0655a2 | 615 | |
f412b39a DW |
616 | /* |
617 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
618 | * "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", | |
619 | * "OSPF area parameters\n" | |
620 | * "OSPF area ID in IP address format\n" | |
621 | * "OSPF area ID as a decimal value\n" | |
622 | * "OSPF area range for route advertise (default)\n" | |
623 | * "Area range prefix\n" | |
624 | * "Advertise this range (default)\n" | |
625 | * | |
626 | * "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", | |
627 | * "OSPF area parameters\n" | |
628 | * "OSPF area ID in IP address format\n" | |
629 | * "OSPF area ID as a decimal value\n" | |
630 | * "Summarize routes matching address/mask (border routers only)\n" | |
631 | * "Area range prefix\n" | |
632 | * "User specified metric for this range\n" | |
633 | * "Advertised metric for this range\n" | |
634 | * | |
635 | * "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", | |
636 | * "OSPF area parameters\n" | |
637 | * "OSPF area ID in IP address format\n" | |
638 | * "OSPF area ID as a decimal value\n" | |
639 | * "Summarize routes matching address/mask (border routers only)\n" | |
640 | * "Area range prefix\n" | |
641 | * "Advertise this range (default)\n" | |
642 | * "User specified metric for this range\n" | |
643 | * "Advertised metric for this range\n" | |
644 | * | |
645 | */ | |
a2c62831 | 646 | DEFUN (ospf_area_range, |
647 | ospf_area_range_cmd, | |
6147e2c6 | 648 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M", |
718e3744 | 649 | "OSPF area parameters\n" |
650 | "OSPF area ID in IP address format\n" | |
651 | "OSPF area ID as a decimal value\n" | |
652 | "Summarize routes matching address/mask (border routers only)\n" | |
653 | "Area range prefix\n") | |
654 | { | |
655 | struct ospf *ospf = vty->index; | |
656 | struct prefix_ipv4 p; | |
657 | struct in_addr area_id; | |
658 | int format; | |
659 | u_int32_t cost; | |
660 | ||
7c8ff89e DS |
661 | if (!ospf) |
662 | return CMD_SUCCESS; | |
663 | ||
bf2bfafd DW |
664 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
665 | VTY_GET_IPV4_PREFIX ("area range", p, argv[3]->arg); | |
718e3744 | 666 | |
667 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
668 | if (argc > 2) | |
669 | { | |
4dadc291 | 670 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
718e3744 | 671 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
672 | } | |
673 | ||
674 | return CMD_SUCCESS; | |
675 | } | |
676 | ||
718e3744 | 677 | |
718e3744 | 678 | |
718e3744 | 679 | |
a2c62831 | 680 | DEFUN (ospf_area_range_not_advertise, |
681 | ospf_area_range_not_advertise_cmd, | |
6147e2c6 | 682 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise", |
718e3744 | 683 | "OSPF area parameters\n" |
684 | "OSPF area ID in IP address format\n" | |
685 | "OSPF area ID as a decimal value\n" | |
686 | "Summarize routes matching address/mask (border routers only)\n" | |
687 | "Area range prefix\n" | |
688 | "DoNotAdvertise this range\n") | |
689 | { | |
690 | struct ospf *ospf = vty->index; | |
691 | struct prefix_ipv4 p; | |
692 | struct in_addr area_id; | |
693 | int format; | |
694 | ||
7c8ff89e DS |
695 | if (!ospf) |
696 | return CMD_SUCCESS; | |
697 | ||
bf2bfafd DW |
698 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
699 | VTY_GET_IPV4_PREFIX ("area range", p, argv[3]->arg); | |
718e3744 | 700 | |
701 | ospf_area_range_set (ospf, area_id, &p, 0); | |
702 | ||
703 | return CMD_SUCCESS; | |
704 | } | |
705 | ||
f412b39a DW |
706 | /* |
707 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
708 | * "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", | |
709 | * NO_STR | |
710 | * "OSPF area parameters\n" | |
711 | * "OSPF area ID in IP address format\n" | |
712 | * "OSPF area ID as a decimal value\n" | |
713 | * "Summarize routes matching address/mask (border routers only)\n" | |
714 | * "Area range prefix\n" | |
715 | * "Advertise this range (default)\n" | |
716 | * "DoNotAdvertise this range\n" | |
717 | * | |
718 | * "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", | |
719 | * NO_STR | |
720 | * "OSPF area parameters\n" | |
721 | * "OSPF area ID in IP address format\n" | |
722 | * "OSPF area ID as a decimal value\n" | |
723 | * "Summarize routes matching address/mask (border routers only)\n" | |
724 | * "Area range prefix\n" | |
725 | * "Advertise this range (default)\n" | |
726 | * "User specified metric for this range\n" | |
727 | * "Advertised metric for this range\n" | |
728 | * | |
729 | * "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", | |
730 | * NO_STR | |
731 | * "OSPF area parameters\n" | |
732 | * "OSPF area ID in IP address format\n" | |
733 | * "OSPF area ID as a decimal value\n" | |
734 | * "Summarize routes matching address/mask (border routers only)\n" | |
735 | * "Area range prefix\n" | |
736 | * "User specified metric for this range\n" | |
737 | * "Advertised metric for this range\n" | |
738 | * | |
739 | */ | |
a2c62831 | 740 | DEFUN (no_ospf_area_range, |
741 | no_ospf_area_range_cmd, | |
6147e2c6 | 742 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M", |
718e3744 | 743 | NO_STR |
744 | "OSPF area parameters\n" | |
745 | "OSPF area ID in IP address format\n" | |
746 | "OSPF area ID as a decimal value\n" | |
747 | "Summarize routes matching address/mask (border routers only)\n" | |
748 | "Area range prefix\n") | |
749 | { | |
750 | struct ospf *ospf = vty->index; | |
751 | struct prefix_ipv4 p; | |
752 | struct in_addr area_id; | |
753 | int format; | |
754 | ||
7c8ff89e DS |
755 | if (!ospf) |
756 | return CMD_SUCCESS; | |
757 | ||
bf2bfafd DW |
758 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); |
759 | VTY_GET_IPV4_PREFIX ("area range", p, argv[4]->arg); | |
718e3744 | 760 | |
761 | ospf_area_range_unset (ospf, area_id, &p); | |
762 | ||
763 | return CMD_SUCCESS; | |
764 | } | |
765 | ||
718e3744 | 766 | |
718e3744 | 767 | |
6b0655a2 | 768 | |
a2c62831 | 769 | DEFUN (ospf_area_range_substitute, |
770 | ospf_area_range_substitute_cmd, | |
6147e2c6 | 771 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 772 | "OSPF area parameters\n" |
773 | "OSPF area ID in IP address format\n" | |
774 | "OSPF area ID as a decimal value\n" | |
775 | "Summarize routes matching address/mask (border routers only)\n" | |
776 | "Area range prefix\n" | |
777 | "Announce area range as another prefix\n" | |
778 | "Network prefix to be announced instead of range\n") | |
779 | { | |
780 | struct ospf *ospf = vty->index; | |
781 | struct prefix_ipv4 p, s; | |
782 | struct in_addr area_id; | |
783 | int format; | |
784 | ||
7c8ff89e DS |
785 | if (!ospf) |
786 | return CMD_SUCCESS; | |
787 | ||
bf2bfafd DW |
788 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
789 | VTY_GET_IPV4_PREFIX ("area range", p, argv[3]->arg); | |
790 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[5]->arg); | |
718e3744 | 791 | |
792 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
793 | ||
794 | return CMD_SUCCESS; | |
795 | } | |
796 | ||
a2c62831 | 797 | DEFUN (no_ospf_area_range_substitute, |
798 | no_ospf_area_range_substitute_cmd, | |
6147e2c6 | 799 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 800 | NO_STR |
801 | "OSPF area parameters\n" | |
802 | "OSPF area ID in IP address format\n" | |
803 | "OSPF area ID as a decimal value\n" | |
804 | "Summarize routes matching address/mask (border routers only)\n" | |
805 | "Area range prefix\n" | |
806 | "Announce area range as another prefix\n" | |
807 | "Network prefix to be announced instead of range\n") | |
808 | { | |
809 | struct ospf *ospf = vty->index; | |
810 | struct prefix_ipv4 p, s; | |
811 | struct in_addr area_id; | |
812 | int format; | |
813 | ||
7c8ff89e DS |
814 | if (!ospf) |
815 | return CMD_SUCCESS; | |
816 | ||
bf2bfafd DW |
817 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); |
818 | VTY_GET_IPV4_PREFIX ("area range", p, argv[4]->arg); | |
819 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[6]->arg); | |
718e3744 | 820 | |
821 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
822 | ||
823 | return CMD_SUCCESS; | |
824 | } | |
825 | ||
6b0655a2 | 826 | |
718e3744 | 827 | /* Command Handler Logic in VLink stuff is delicate!! |
828 | ||
829 | ALTER AT YOUR OWN RISK!!!! | |
830 | ||
831 | Various dummy values are used to represent 'NoChange' state for | |
832 | VLink configuration NOT being changed by a VLink command, and | |
833 | special syntax is used within the command strings so that the | |
834 | typed in command verbs can be seen in the configuration command | |
835 | bacckend handler. This is to drastically reduce the verbeage | |
836 | required to coe up with a reasonably compatible Cisco VLink command | |
837 | ||
838 | - Matthew Grant <grantma@anathoth.gen.nz> | |
839 | Wed, 21 Feb 2001 15:13:52 +1300 | |
840 | */ | |
841 | ||
842 | ||
843 | /* Configuration data for virtual links | |
844 | */ | |
845 | struct ospf_vl_config_data { | |
846 | struct vty *vty; /* vty stuff */ | |
847 | struct in_addr area_id; /* area ID from command line */ | |
848 | int format; /* command line area ID format */ | |
849 | struct in_addr vl_peer; /* command line vl_peer */ | |
850 | int auth_type; /* Authehntication type, if given */ | |
851 | char *auth_key; /* simple password if present */ | |
852 | int crypto_key_id; /* Cryptographic key ID */ | |
853 | char *md5_key; /* MD5 authentication key */ | |
854 | int hello_interval; /* Obvious what these are... */ | |
855 | int retransmit_interval; | |
856 | int transmit_delay; | |
857 | int dead_interval; | |
858 | }; | |
859 | ||
4dadc291 | 860 | static void |
718e3744 | 861 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
862 | struct vty *vty) | |
863 | { | |
864 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
865 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
866 | vl_config->vty = vty; | |
867 | } | |
868 | ||
4dadc291 | 869 | static struct ospf_vl_data * |
68980084 | 870 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 871 | { |
872 | struct ospf_area *area; | |
873 | struct ospf_vl_data *vl_data; | |
874 | struct vty *vty; | |
875 | struct in_addr area_id; | |
876 | ||
877 | vty = vl_config->vty; | |
878 | area_id = vl_config->area_id; | |
879 | ||
880 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
881 | { | |
882 | vty_out (vty, | |
883 | "Configuring VLs over the backbone is not allowed%s", | |
884 | VTY_NEWLINE); | |
885 | return NULL; | |
886 | } | |
68980084 | 887 | area = ospf_area_get (ospf, area_id, vl_config->format); |
718e3744 | 888 | |
889 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
890 | { | |
891 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
892 | vty_out (vty, "Area %s is %s%s", | |
893 | inet_ntoa (area_id), | |
718e3744 | 894 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 895 | VTY_NEWLINE); |
896 | else | |
897 | vty_out (vty, "Area %ld is %s%s", | |
898 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 899 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 900 | VTY_NEWLINE); |
901 | return NULL; | |
902 | } | |
903 | ||
9c27ef9b | 904 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 905 | { |
906 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
907 | if (vl_data->vl_oi == NULL) | |
908 | { | |
68980084 | 909 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
910 | ospf_vl_add (ospf, vl_data); | |
d3a9c768 | 911 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 912 | } |
913 | } | |
914 | return vl_data; | |
915 | } | |
916 | ||
917 | ||
4dadc291 | 918 | static int |
718e3744 | 919 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
920 | struct ospf_vl_config_data *vl_config) | |
921 | { | |
922 | struct crypt_key *ck; | |
923 | struct vty *vty; | |
924 | struct interface *ifp = vl_data->vl_oi->ifp; | |
925 | ||
926 | vty = vl_config->vty; | |
927 | ||
928 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
929 | { | |
930 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
931 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
932 | } | |
933 | ||
934 | if (vl_config->auth_key) | |
935 | { | |
936 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 937 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 938 | OSPF_AUTH_SIMPLE_SIZE); |
939 | } | |
940 | else if (vl_config->md5_key) | |
941 | { | |
942 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
943 | != NULL) | |
944 | { | |
945 | vty_out (vty, "OSPF: Key %d already exists%s", | |
946 | vl_config->crypto_key_id, VTY_NEWLINE); | |
947 | return CMD_WARNING; | |
948 | } | |
949 | ck = ospf_crypt_key_new (); | |
950 | ck->key_id = vl_config->crypto_key_id; | |
951 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 952 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 953 | |
954 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
955 | } | |
956 | else if (vl_config->crypto_key_id != 0) | |
957 | { | |
958 | /* Delete a key */ | |
959 | ||
960 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
961 | vl_config->crypto_key_id) == NULL) | |
962 | { | |
963 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
964 | vl_config->crypto_key_id, VTY_NEWLINE); | |
965 | return CMD_WARNING; | |
966 | } | |
967 | ||
968 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
969 | ||
970 | } | |
971 | ||
972 | return CMD_SUCCESS; | |
973 | } | |
974 | ||
4dadc291 | 975 | static int |
718e3744 | 976 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
977 | struct ospf_vl_config_data *vl_config) | |
978 | { | |
979 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; | |
980 | /* Virtual Link data initialised to defaults, so only set | |
981 | if a value given */ | |
982 | if (vl_config->hello_interval) | |
983 | { | |
984 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
985 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
986 | } | |
987 | ||
988 | if (vl_config->dead_interval) | |
989 | { | |
990 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
991 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
992 | } | |
993 | ||
994 | if (vl_config->retransmit_interval) | |
995 | { | |
996 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
997 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
998 | } | |
999 | ||
1000 | if (vl_config->transmit_delay) | |
1001 | { | |
1002 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
1003 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
1004 | } | |
1005 | ||
1006 | return CMD_SUCCESS; | |
1007 | } | |
1008 | ||
1009 | ||
1010 | ||
1011 | /* The business end of all of the above */ | |
4dadc291 | 1012 | static int |
68980084 | 1013 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 1014 | { |
1015 | struct ospf_vl_data *vl_data; | |
1016 | int ret; | |
1017 | ||
68980084 | 1018 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 1019 | if (!vl_data) |
1020 | return CMD_WARNING; | |
1021 | ||
1022 | /* Process this one first as it can have a fatal result, which can | |
1023 | only logically occur if the virtual link exists already | |
1024 | Thus a command error does not result in a change to the | |
1025 | running configuration such as unexpectedly altered timer | |
1026 | values etc.*/ | |
1027 | ret = ospf_vl_set_security (vl_data, vl_config); | |
1028 | if (ret != CMD_SUCCESS) | |
1029 | return ret; | |
1030 | ||
1031 | /* Set any time based parameters, these area already range checked */ | |
1032 | ||
1033 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
1034 | if (ret != CMD_SUCCESS) | |
1035 | return ret; | |
1036 | ||
1037 | return CMD_SUCCESS; | |
1038 | ||
1039 | } | |
1040 | ||
1041 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1042 | */ | |
1043 | #define VLINK_HELPSTR_IPADDR \ | |
1044 | "OSPF area parameters\n" \ | |
1045 | "OSPF area ID in IP address format\n" \ | |
1046 | "OSPF area ID as a decimal value\n" \ | |
1047 | "Configure a virtual link\n" \ | |
1048 | "Router ID of the remote ABR\n" | |
1049 | ||
1050 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1051 | "Enable authentication on this virtual link\n" \ | |
1052 | "dummy string \n" | |
1053 | ||
1054 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1055 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1056 | "Use null authentication\n" \ | |
1057 | "Use message-digest authentication\n" | |
1058 | ||
1059 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1060 | "Time between HELLO packets\n" \ | |
1061 | "Time between retransmitting lost link state advertisements\n" \ | |
1062 | "Link state transmit delay\n" \ | |
1063 | "Interval after which a neighbor is declared dead\n" | |
1064 | ||
1065 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1066 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
1067 | "Seconds\n" | |
1068 | ||
1069 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1070 | "Authentication password (key)\n" \ | |
1071 | "The OSPF password (key)" | |
1072 | ||
1073 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1074 | "Message digest authentication password (key)\n" \ | |
1075 | "dummy string \n" \ | |
1076 | "Key ID\n" \ | |
1077 | "Use MD5 algorithm\n" \ | |
1078 | "The OSPF password (key)" | |
1079 | ||
f412b39a DW |
1080 | /* |
1081 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1082 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1083 | * "(authentication|) (message-digest|null) " | |
1084 | * "(authentication-key|) AUTH_KEY", | |
1085 | * VLINK_HELPSTR_IPADDR | |
1086 | * VLINK_HELPSTR_AUTHTYPE_ALL | |
1087 | * VLINK_HELPSTR_AUTH_SIMPLE | |
1088 | * | |
1089 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1090 | * "(authentication|) " | |
1091 | * "(authentication-key|) AUTH_KEY", | |
1092 | * VLINK_HELPSTR_IPADDR | |
1093 | * VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1094 | * VLINK_HELPSTR_AUTH_SIMPLE | |
1095 | * | |
1096 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1097 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1098 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1099 | * VLINK_HELPSTR_IPADDR | |
1100 | * VLINK_HELPSTR_TIME_PARAM | |
1101 | * VLINK_HELPSTR_TIME_PARAM | |
1102 | * | |
1103 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1104 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1105 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1106 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1107 | * VLINK_HELPSTR_IPADDR | |
1108 | * VLINK_HELPSTR_TIME_PARAM | |
1109 | * VLINK_HELPSTR_TIME_PARAM | |
1110 | * VLINK_HELPSTR_TIME_PARAM | |
1111 | * | |
1112 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1113 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1114 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1115 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1116 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1117 | * VLINK_HELPSTR_IPADDR | |
1118 | * VLINK_HELPSTR_TIME_PARAM | |
1119 | * VLINK_HELPSTR_TIME_PARAM | |
1120 | * VLINK_HELPSTR_TIME_PARAM | |
1121 | * VLINK_HELPSTR_TIME_PARAM | |
1122 | * | |
1123 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1124 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1125 | * VLINK_HELPSTR_IPADDR | |
1126 | * VLINK_HELPSTR_TIME_PARAM | |
1127 | * | |
1128 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1129 | * "(authentication|) (message-digest|null)", | |
1130 | * VLINK_HELPSTR_IPADDR | |
1131 | * VLINK_HELPSTR_AUTHTYPE_ALL | |
1132 | * | |
1133 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1134 | * "(message-digest-key|) <1-255> md5 KEY", | |
1135 | * VLINK_HELPSTR_IPADDR | |
1136 | * VLINK_HELPSTR_AUTH_MD5 | |
1137 | * | |
1138 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1139 | * "(authentication|) " | |
1140 | * "(message-digest-key|) <1-255> md5 KEY", | |
1141 | * VLINK_HELPSTR_IPADDR | |
1142 | * VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1143 | * VLINK_HELPSTR_AUTH_MD5 | |
1144 | * | |
1145 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1146 | * "(authentication|) (message-digest|null) " | |
1147 | * "(message-digest-key|) <1-255> md5 KEY", | |
1148 | * VLINK_HELPSTR_IPADDR | |
1149 | * VLINK_HELPSTR_AUTHTYPE_ALL | |
1150 | * VLINK_HELPSTR_AUTH_MD5 | |
1151 | * | |
1152 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1153 | * "(authentication|)", | |
1154 | * VLINK_HELPSTR_IPADDR | |
1155 | * VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1156 | * | |
1157 | * "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1158 | * "(authentication-key|) AUTH_KEY", | |
1159 | * VLINK_HELPSTR_IPADDR | |
1160 | * VLINK_HELPSTR_AUTH_SIMPLE | |
1161 | * | |
1162 | */ | |
a2c62831 | 1163 | DEFUN (ospf_area_vlink, |
1164 | ospf_area_vlink_cmd, | |
6147e2c6 | 1165 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D", |
718e3744 | 1166 | VLINK_HELPSTR_IPADDR) |
1167 | { | |
68980084 | 1168 | struct ospf *ospf = vty->index; |
718e3744 | 1169 | struct ospf_vl_config_data vl_config; |
1170 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1171 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1172 | int i; | |
1173 | int ret; | |
1174 | ||
7c8ff89e DS |
1175 | if (!ospf) |
1176 | return CMD_SUCCESS; | |
1177 | ||
718e3744 | 1178 | ospf_vl_config_data_init(&vl_config, vty); |
1179 | ||
1180 | /* Read off first 2 parameters and check them */ | |
bf2bfafd | 1181 | ret = ospf_str2area_id (argv[1]->arg, &vl_config.area_id, &vl_config.format); |
718e3744 | 1182 | if (ret < 0) |
1183 | { | |
1184 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1185 | return CMD_WARNING; | |
1186 | } | |
1187 | ||
bf2bfafd | 1188 | ret = inet_aton (argv[3]->arg, &vl_config.vl_peer); |
718e3744 | 1189 | if (! ret) |
1190 | { | |
1191 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1192 | VTY_NEWLINE); | |
1193 | return CMD_WARNING; | |
1194 | } | |
1195 | ||
1196 | if (argc <=2) | |
1197 | { | |
1198 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1199 | ||
68980084 | 1200 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1201 | } |
1202 | ||
1203 | /* Deal with other parameters */ | |
1204 | for (i=2; i < argc; i++) | |
1205 | { | |
1206 | ||
1207 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ | |
1208 | ||
1209 | switch (argv[i][0]) | |
1210 | { | |
1211 | ||
1212 | case 'a': | |
1213 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1214 | { | |
1215 | /* authentication-key - this option can occur anywhere on | |
1216 | command line. At start of command line | |
1217 | must check for authentication option. */ | |
1218 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1219 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); | |
1220 | vl_config.auth_key = auth_key; | |
1221 | i++; | |
1222 | } | |
1223 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1224 | { | |
1225 | /* authentication - this option can only occur at start | |
1226 | of command line */ | |
1227 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1228 | if ((i+1) < argc) | |
1229 | { | |
1230 | if (strncmp (argv[i+1], "n", 1) == 0) | |
1231 | { | |
1232 | /* "authentication null" */ | |
1233 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1234 | i++; | |
1235 | } | |
1236 | else if (strncmp (argv[i+1], "m", 1) == 0 | |
1237 | && strcmp (argv[i+1], "message-digest-") != 0) | |
1238 | { | |
1239 | /* "authentication message-digest" */ | |
1240 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1241 | i++; | |
1242 | } | |
1243 | } | |
1244 | } | |
1245 | break; | |
1246 | ||
1247 | case 'm': | |
1248 | /* message-digest-key */ | |
1249 | i++; | |
1250 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1251 | if (vl_config.crypto_key_id < 0) | |
1252 | return CMD_WARNING; | |
1253 | i++; | |
1254 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1255 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); | |
1256 | vl_config.md5_key = md5_key; | |
1257 | break; | |
1258 | ||
1259 | case 'h': | |
1260 | /* Hello interval */ | |
1261 | i++; | |
1262 | vl_config.hello_interval = strtol (argv[i], NULL, 10); | |
1263 | if (vl_config.hello_interval < 0) | |
1264 | return CMD_WARNING; | |
1265 | break; | |
1266 | ||
1267 | case 'r': | |
1268 | /* Retransmit Interval */ | |
1269 | i++; | |
1270 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); | |
1271 | if (vl_config.retransmit_interval < 0) | |
1272 | return CMD_WARNING; | |
1273 | break; | |
1274 | ||
1275 | case 't': | |
1276 | /* Transmit Delay */ | |
1277 | i++; | |
1278 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); | |
1279 | if (vl_config.transmit_delay < 0) | |
1280 | return CMD_WARNING; | |
1281 | break; | |
1282 | ||
1283 | case 'd': | |
1284 | /* Dead Interval */ | |
1285 | i++; | |
1286 | vl_config.dead_interval = strtol (argv[i], NULL, 10); | |
1287 | if (vl_config.dead_interval < 0) | |
1288 | return CMD_WARNING; | |
1289 | break; | |
1290 | } | |
1291 | } | |
1292 | ||
1293 | ||
1294 | /* Action configuration */ | |
1295 | ||
68980084 | 1296 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1297 | |
1298 | } | |
1299 | ||
f412b39a DW |
1300 | /* |
1301 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1302 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1303 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1304 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1305 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1306 | * NO_STR | |
1307 | * VLINK_HELPSTR_IPADDR | |
1308 | * VLINK_HELPSTR_TIME_PARAM | |
1309 | * VLINK_HELPSTR_TIME_PARAM | |
1310 | * VLINK_HELPSTR_TIME_PARAM | |
1311 | * | |
1312 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1313 | * "(authentication|) " | |
1314 | * "(message-digest-key|) <1-255> md5 KEY", | |
1315 | * NO_STR | |
1316 | * VLINK_HELPSTR_IPADDR | |
1317 | * VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1318 | * VLINK_HELPSTR_AUTH_MD5 | |
1319 | * | |
1320 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1321 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1322 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1323 | * NO_STR | |
1324 | * VLINK_HELPSTR_IPADDR | |
1325 | * VLINK_HELPSTR_TIME_PARAM | |
1326 | * VLINK_HELPSTR_TIME_PARAM | |
1327 | * | |
1328 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1329 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1330 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1331 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " | |
1332 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1333 | * NO_STR | |
1334 | * VLINK_HELPSTR_IPADDR | |
1335 | * VLINK_HELPSTR_TIME_PARAM | |
1336 | * VLINK_HELPSTR_TIME_PARAM | |
1337 | * VLINK_HELPSTR_TIME_PARAM | |
1338 | * VLINK_HELPSTR_TIME_PARAM | |
1339 | * | |
1340 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1341 | * "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", | |
1342 | * NO_STR | |
1343 | * VLINK_HELPSTR_IPADDR | |
1344 | * VLINK_HELPSTR_TIME_PARAM | |
1345 | * | |
1346 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1347 | * "(message-digest-key|) <1-255> md5 KEY", | |
1348 | * NO_STR | |
1349 | * VLINK_HELPSTR_IPADDR | |
1350 | * VLINK_HELPSTR_AUTH_MD5 | |
1351 | * | |
1352 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1353 | * "(authentication|)", | |
1354 | * NO_STR | |
1355 | * VLINK_HELPSTR_IPADDR | |
1356 | * VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1357 | * | |
1358 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1359 | * "(authentication|) (message-digest|null) " | |
1360 | * "(message-digest-key|) <1-255> md5 KEY", | |
1361 | * NO_STR | |
1362 | * VLINK_HELPSTR_IPADDR | |
1363 | * VLINK_HELPSTR_AUTHTYPE_ALL | |
1364 | * VLINK_HELPSTR_AUTH_MD5 | |
1365 | * | |
1366 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1367 | * "(authentication|) " | |
1368 | * "(authentication-key|) AUTH_KEY", | |
1369 | * NO_STR | |
1370 | * VLINK_HELPSTR_IPADDR | |
1371 | * VLINK_HELPSTR_AUTHTYPE_SIMPLE | |
1372 | * VLINK_HELPSTR_AUTH_SIMPLE | |
1373 | * | |
1374 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1375 | * "(authentication-key|) AUTH_KEY", | |
1376 | * NO_STR | |
1377 | * VLINK_HELPSTR_IPADDR | |
1378 | * VLINK_HELPSTR_AUTH_SIMPLE | |
1379 | * | |
1380 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1381 | * "(authentication|) (message-digest|null)", | |
1382 | * NO_STR | |
1383 | * VLINK_HELPSTR_IPADDR | |
1384 | * VLINK_HELPSTR_AUTHTYPE_ALL | |
1385 | * | |
1386 | * "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " | |
1387 | * "(authentication|) (message-digest|null) " | |
1388 | * "(authentication-key|) AUTH_KEY", | |
1389 | * NO_STR | |
1390 | * VLINK_HELPSTR_IPADDR | |
1391 | * VLINK_HELPSTR_AUTHTYPE_ALL | |
1392 | * VLINK_HELPSTR_AUTH_SIMPLE | |
1393 | * | |
1394 | */ | |
a2c62831 | 1395 | DEFUN (no_ospf_area_vlink, |
1396 | no_ospf_area_vlink_cmd, | |
6147e2c6 | 1397 | "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D", |
718e3744 | 1398 | NO_STR |
1399 | VLINK_HELPSTR_IPADDR) | |
1400 | { | |
68980084 | 1401 | struct ospf *ospf = vty->index; |
718e3744 | 1402 | struct ospf_area *area; |
1403 | struct ospf_vl_config_data vl_config; | |
1404 | struct ospf_vl_data *vl_data = NULL; | |
1405 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1406 | int i; | |
1407 | int ret, format; | |
1408 | ||
7c8ff89e DS |
1409 | if (!ospf) |
1410 | return CMD_SUCCESS; | |
1411 | ||
718e3744 | 1412 | ospf_vl_config_data_init(&vl_config, vty); |
1413 | ||
bf2bfafd | 1414 | ret = ospf_str2area_id (argv[2]->arg, &vl_config.area_id, &format); |
718e3744 | 1415 | if (ret < 0) |
1416 | { | |
1417 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1418 | return CMD_WARNING; | |
1419 | } | |
1420 | ||
68980084 | 1421 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1422 | if (!area) |
1423 | { | |
1424 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1425 | return CMD_WARNING; | |
1426 | } | |
1427 | ||
bf2bfafd | 1428 | ret = inet_aton (argv[4]->arg, &vl_config.vl_peer); |
718e3744 | 1429 | if (! ret) |
1430 | { | |
1431 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1432 | VTY_NEWLINE); | |
1433 | return CMD_WARNING; | |
1434 | } | |
1435 | ||
1436 | if (argc <=2) | |
1437 | { | |
1438 | /* Basic VLink no command */ | |
1439 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1440 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1441 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1442 | |
68980084 | 1443 | ospf_area_check_free (ospf, vl_config.area_id); |
718e3744 | 1444 | |
1445 | return CMD_SUCCESS; | |
1446 | } | |
1447 | ||
1448 | /* If we are down here, we are reseting parameters */ | |
1449 | ||
1450 | /* Deal with other parameters */ | |
1451 | for (i=2; i < argc; i++) | |
1452 | { | |
718e3744 | 1453 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1454 | ||
1455 | switch (argv[i][0]) | |
1456 | { | |
1457 | ||
1458 | case 'a': | |
1459 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) | |
1460 | { | |
1461 | /* authentication-key - this option can occur anywhere on | |
1462 | command line. At start of command line | |
1463 | must check for authentication option. */ | |
1464 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1465 | vl_config.auth_key = auth_key; | |
1466 | } | |
1467 | else if (strncmp (argv[i], "authentication", 14) == 0) | |
1468 | { | |
1469 | /* authentication - this option can only occur at start | |
1470 | of command line */ | |
1471 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1472 | } | |
1473 | break; | |
1474 | ||
1475 | case 'm': | |
1476 | /* message-digest-key */ | |
1477 | /* Delete one key */ | |
1478 | i++; | |
1479 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); | |
1480 | if (vl_config.crypto_key_id < 0) | |
1481 | return CMD_WARNING; | |
1482 | vl_config.md5_key = NULL; | |
1483 | break; | |
1484 | ||
1485 | case 'h': | |
1486 | /* Hello interval */ | |
1487 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1488 | break; | |
1489 | ||
1490 | case 'r': | |
1491 | /* Retransmit Interval */ | |
1492 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1493 | break; | |
1494 | ||
1495 | case 't': | |
1496 | /* Transmit Delay */ | |
1497 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1498 | break; | |
1499 | ||
1500 | case 'd': | |
1501 | /* Dead Interval */ | |
1502 | i++; | |
1503 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
1504 | break; | |
1505 | } | |
1506 | } | |
1507 | ||
1508 | ||
1509 | /* Action configuration */ | |
1510 | ||
68980084 | 1511 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1512 | } |
1513 | ||
718e3744 | 1514 | |
f412b39a DW |
1515 | |
1516 | ||
1517 | ||
1518 | ||
1519 | ||
1520 | ||
1521 | ||
1522 | ||
1523 | ||
1524 | ||
1525 | ||
1526 | ||
1527 | ||
1528 | ||
1529 | ||
1530 | ||
1531 | ||
1532 | ||
1533 | ||
1534 | ||
1535 | ||
1536 | ||
718e3744 | 1537 | |
6b0655a2 | 1538 | |
a2c62831 | 1539 | DEFUN (ospf_area_shortcut, |
1540 | ospf_area_shortcut_cmd, | |
6147e2c6 | 1541 | "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>", |
718e3744 | 1542 | "OSPF area parameters\n" |
1543 | "OSPF area ID in IP address format\n" | |
1544 | "OSPF area ID as a decimal value\n" | |
1545 | "Configure the area's shortcutting mode\n" | |
1546 | "Set default shortcutting behavior\n" | |
1547 | "Enable shortcutting through the area\n" | |
1548 | "Disable shortcutting through the area\n") | |
1549 | { | |
68980084 | 1550 | struct ospf *ospf = vty->index; |
718e3744 | 1551 | struct ospf_area *area; |
1552 | struct in_addr area_id; | |
1553 | int mode; | |
1554 | int format; | |
1555 | ||
7c8ff89e DS |
1556 | if (!ospf) |
1557 | return CMD_SUCCESS; | |
1558 | ||
bf2bfafd | 1559 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[1]->arg); |
718e3744 | 1560 | |
68980084 | 1561 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1562 | |
bf2bfafd | 1563 | if (strncmp (argv[3]->arg, "de", 2) == 0) |
718e3744 | 1564 | mode = OSPF_SHORTCUT_DEFAULT; |
bf2bfafd | 1565 | else if (strncmp (argv[3]->arg, "di", 2) == 0) |
718e3744 | 1566 | mode = OSPF_SHORTCUT_DISABLE; |
bf2bfafd | 1567 | else if (strncmp (argv[3]->arg, "e", 1) == 0) |
718e3744 | 1568 | mode = OSPF_SHORTCUT_ENABLE; |
1569 | else | |
1570 | return CMD_WARNING; | |
1571 | ||
68980084 | 1572 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1573 | |
68980084 | 1574 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1575 | vty_out (vty, "Shortcut area setting will take effect " |
1576 | "only when the router is configured as Shortcut ABR%s", | |
1577 | VTY_NEWLINE); | |
1578 | ||
1579 | return CMD_SUCCESS; | |
1580 | } | |
1581 | ||
a2c62831 | 1582 | DEFUN (no_ospf_area_shortcut, |
1583 | no_ospf_area_shortcut_cmd, | |
6147e2c6 | 1584 | "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>", |
718e3744 | 1585 | NO_STR |
1586 | "OSPF area parameters\n" | |
1587 | "OSPF area ID in IP address format\n" | |
1588 | "OSPF area ID as a decimal value\n" | |
1589 | "Deconfigure the area's shortcutting mode\n" | |
1590 | "Deconfigure enabled shortcutting through the area\n" | |
1591 | "Deconfigure disabled shortcutting through the area\n") | |
1592 | { | |
68980084 | 1593 | struct ospf *ospf = vty->index; |
718e3744 | 1594 | struct ospf_area *area; |
1595 | struct in_addr area_id; | |
1596 | int format; | |
1597 | ||
7c8ff89e DS |
1598 | if (!ospf) |
1599 | return CMD_SUCCESS; | |
1600 | ||
bf2bfafd | 1601 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[2]->arg); |
718e3744 | 1602 | |
68980084 | 1603 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1604 | if (!area) |
1605 | return CMD_SUCCESS; | |
1606 | ||
68980084 | 1607 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1608 | |
1609 | return CMD_SUCCESS; | |
1610 | } | |
1611 | ||
6b0655a2 | 1612 | |
a2c62831 | 1613 | DEFUN (ospf_area_stub, |
1614 | ospf_area_stub_cmd, | |
6147e2c6 | 1615 | "area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1616 | "OSPF area parameters\n" |
1617 | "OSPF area ID in IP address format\n" | |
1618 | "OSPF area ID as a decimal value\n" | |
1619 | "Configure OSPF area as stub\n") | |
1620 | { | |
1621 | struct ospf *ospf = vty->index; | |
1622 | struct in_addr area_id; | |
1623 | int ret, format; | |
1624 | ||
7c8ff89e DS |
1625 | if (!ospf) |
1626 | return CMD_SUCCESS; | |
1627 | ||
bf2bfafd | 1628 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[1]->arg); |
718e3744 | 1629 | |
1630 | ret = ospf_area_stub_set (ospf, area_id); | |
1631 | if (ret == 0) | |
1632 | { | |
1633 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1634 | VTY_NEWLINE); | |
1635 | return CMD_WARNING; | |
1636 | } | |
1637 | ||
1638 | ospf_area_no_summary_unset (ospf, area_id); | |
1639 | ||
1640 | return CMD_SUCCESS; | |
1641 | } | |
1642 | ||
a2c62831 | 1643 | DEFUN (ospf_area_stub_no_summary, |
1644 | ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1645 | "area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1646 | "OSPF stub parameters\n" |
1647 | "OSPF area ID in IP address format\n" | |
1648 | "OSPF area ID as a decimal value\n" | |
1649 | "Configure OSPF area as stub\n" | |
1650 | "Do not inject inter-area routes into stub\n") | |
1651 | { | |
1652 | struct ospf *ospf = vty->index; | |
1653 | struct in_addr area_id; | |
1654 | int ret, format; | |
1655 | ||
7c8ff89e DS |
1656 | if (!ospf) |
1657 | return CMD_SUCCESS; | |
1658 | ||
bf2bfafd | 1659 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[1]->arg); |
718e3744 | 1660 | |
1661 | ret = ospf_area_stub_set (ospf, area_id); | |
1662 | if (ret == 0) | |
1663 | { | |
b0a053be | 1664 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1665 | VTY_NEWLINE); |
1666 | return CMD_WARNING; | |
1667 | } | |
1668 | ||
1669 | ospf_area_no_summary_set (ospf, area_id); | |
1670 | ||
1671 | return CMD_SUCCESS; | |
1672 | } | |
1673 | ||
a2c62831 | 1674 | DEFUN (no_ospf_area_stub, |
1675 | no_ospf_area_stub_cmd, | |
6147e2c6 | 1676 | "no area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1677 | NO_STR |
1678 | "OSPF area parameters\n" | |
1679 | "OSPF area ID in IP address format\n" | |
1680 | "OSPF area ID as a decimal value\n" | |
1681 | "Configure OSPF area as stub\n") | |
1682 | { | |
1683 | struct ospf *ospf = vty->index; | |
1684 | struct in_addr area_id; | |
1685 | int format; | |
1686 | ||
7c8ff89e DS |
1687 | if (!ospf) |
1688 | return CMD_SUCCESS; | |
1689 | ||
bf2bfafd | 1690 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[2]->arg); |
718e3744 | 1691 | |
1692 | ospf_area_stub_unset (ospf, area_id); | |
1693 | ospf_area_no_summary_unset (ospf, area_id); | |
1694 | ||
1695 | return CMD_SUCCESS; | |
1696 | } | |
1697 | ||
a2c62831 | 1698 | DEFUN (no_ospf_area_stub_no_summary, |
1699 | no_ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1700 | "no area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1701 | NO_STR |
1702 | "OSPF area parameters\n" | |
1703 | "OSPF area ID in IP address format\n" | |
1704 | "OSPF area ID as a decimal value\n" | |
1705 | "Configure OSPF area as stub\n" | |
1706 | "Do not inject inter-area routes into area\n") | |
1707 | { | |
1708 | struct ospf *ospf = vty->index; | |
1709 | struct in_addr area_id; | |
1710 | int format; | |
1711 | ||
7c8ff89e DS |
1712 | if (!ospf) |
1713 | return CMD_SUCCESS; | |
1714 | ||
bf2bfafd | 1715 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[2]->arg); |
718e3744 | 1716 | ospf_area_no_summary_unset (ospf, area_id); |
1717 | ||
1718 | return CMD_SUCCESS; | |
1719 | } | |
1720 | ||
4dadc291 | 1721 | static int |
6c835671 | 1722 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
1723 | int nosum) | |
718e3744 | 1724 | { |
1725 | struct ospf *ospf = vty->index; | |
1726 | struct in_addr area_id; | |
1727 | int ret, format; | |
1728 | ||
7c8ff89e DS |
1729 | if (!ospf) |
1730 | return CMD_SUCCESS; | |
1731 | ||
718e3744 | 1732 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
1733 | ||
1734 | ret = ospf_area_nssa_set (ospf, area_id); | |
1735 | if (ret == 0) | |
1736 | { | |
1737 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1738 | VTY_NEWLINE); | |
1739 | return CMD_WARNING; | |
1740 | } | |
1741 | ||
1742 | if (argc > 1) | |
1743 | { | |
1744 | if (strncmp (argv[1], "translate-c", 11) == 0) | |
b0a053be | 1745 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1746 | OSPF_NSSA_ROLE_CANDIDATE); |
1747 | else if (strncmp (argv[1], "translate-n", 11) == 0) | |
b0a053be | 1748 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1749 | OSPF_NSSA_ROLE_NEVER); |
1750 | else if (strncmp (argv[1], "translate-a", 11) == 0) | |
b0a053be | 1751 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1752 | OSPF_NSSA_ROLE_ALWAYS); |
1753 | } | |
b0a053be | 1754 | else |
1755 | { | |
1756 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1757 | OSPF_NSSA_ROLE_CANDIDATE); | |
1758 | } | |
718e3744 | 1759 | |
b0a053be | 1760 | if (nosum) |
718e3744 | 1761 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1762 | else |
1763 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1764 | |
b0a053be | 1765 | ospf_schedule_abr_task (ospf); |
1766 | ||
718e3744 | 1767 | return CMD_SUCCESS; |
1768 | } | |
1769 | ||
b0a053be | 1770 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1771 | ospf_area_nssa_translate_no_summary_cmd, |
6147e2c6 | 1772 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary", |
718e3744 | 1773 | "OSPF area parameters\n" |
1774 | "OSPF area ID in IP address format\n" | |
1775 | "OSPF area ID as a decimal value\n" | |
1776 | "Configure OSPF area as nssa\n" | |
1777 | "Configure NSSA-ABR for translate election (default)\n" | |
1778 | "Configure NSSA-ABR to never translate\n" | |
1779 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1780 | "Do not inject inter-area routes into nssa\n") |
1781 | { | |
1782 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1783 | } | |
718e3744 | 1784 | |
b0a053be | 1785 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1786 | ospf_area_nssa_translate_cmd, |
6147e2c6 | 1787 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>", |
718e3744 | 1788 | "OSPF area parameters\n" |
1789 | "OSPF area ID in IP address format\n" | |
1790 | "OSPF area ID as a decimal value\n" | |
1791 | "Configure OSPF area as nssa\n" | |
1792 | "Configure NSSA-ABR for translate election (default)\n" | |
1793 | "Configure NSSA-ABR to never translate\n" | |
1794 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1795 | { |
1796 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1797 | } | |
1798 | ||
1799 | DEFUN (ospf_area_nssa, | |
1800 | ospf_area_nssa_cmd, | |
6147e2c6 | 1801 | "area <A.B.C.D|(0-4294967295)> nssa", |
b0a053be | 1802 | "OSPF area parameters\n" |
1803 | "OSPF area ID in IP address format\n" | |
1804 | "OSPF area ID as a decimal value\n" | |
1805 | "Configure OSPF area as nssa\n") | |
1806 | { | |
1807 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1808 | } | |
718e3744 | 1809 | |
a2c62831 | 1810 | DEFUN (ospf_area_nssa_no_summary, |
1811 | ospf_area_nssa_no_summary_cmd, | |
6147e2c6 | 1812 | "area <A.B.C.D|(0-4294967295)> nssa no-summary", |
718e3744 | 1813 | "OSPF area parameters\n" |
1814 | "OSPF area ID in IP address format\n" | |
1815 | "OSPF area ID as a decimal value\n" | |
1816 | "Configure OSPF area as nssa\n" | |
1817 | "Do not inject inter-area routes into nssa\n") | |
1818 | { | |
b0a053be | 1819 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1820 | } |
1821 | ||
f412b39a DW |
1822 | /* |
1823 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
1824 | * "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}", | |
1825 | * NO_STR | |
1826 | * "OSPF area parameters\n" | |
1827 | * "OSPF area ID in IP address format\n" | |
1828 | * "OSPF area ID as a decimal value\n" | |
1829 | * "Configure OSPF area as nssa\n" | |
1830 | * "Configure NSSA-ABR for translate election (default)\n" | |
1831 | * "Configure NSSA-ABR to never translate\n" | |
1832 | * "Configure NSSA-ABR to always translate\n" | |
1833 | * "Do not inject inter-area routes into nssa\n" | |
1834 | * | |
1835 | */ | |
a2c62831 | 1836 | DEFUN (no_ospf_area_nssa, |
1837 | no_ospf_area_nssa_cmd, | |
6147e2c6 | 1838 | "no area <A.B.C.D|(0-4294967295)> nssa", |
718e3744 | 1839 | NO_STR |
1840 | "OSPF area parameters\n" | |
1841 | "OSPF area ID in IP address format\n" | |
1842 | "OSPF area ID as a decimal value\n" | |
1843 | "Configure OSPF area as nssa\n") | |
1844 | { | |
1845 | struct ospf *ospf = vty->index; | |
1846 | struct in_addr area_id; | |
1847 | int format; | |
1848 | ||
7c8ff89e DS |
1849 | if (!ospf) |
1850 | return CMD_SUCCESS; | |
1851 | ||
bf2bfafd | 1852 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[2]->arg); |
718e3744 | 1853 | |
1854 | ospf_area_nssa_unset (ospf, area_id); | |
1855 | ospf_area_no_summary_unset (ospf, area_id); | |
1856 | ||
b0a053be | 1857 | ospf_schedule_abr_task (ospf); |
1858 | ||
718e3744 | 1859 | return CMD_SUCCESS; |
1860 | } | |
1861 | ||
718e3744 | 1862 | |
a2c62831 | 1863 | DEFUN (ospf_area_default_cost, |
1864 | ospf_area_default_cost_cmd, | |
6147e2c6 | 1865 | "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1866 | "OSPF area parameters\n" |
1867 | "OSPF area ID in IP address format\n" | |
1868 | "OSPF area ID as a decimal value\n" | |
1869 | "Set the summary-default cost of a NSSA or stub area\n" | |
1870 | "Stub's advertised default summary cost\n") | |
1871 | { | |
68980084 | 1872 | struct ospf *ospf = vty->index; |
718e3744 | 1873 | struct ospf_area *area; |
1874 | struct in_addr area_id; | |
1875 | u_int32_t cost; | |
1876 | int format; | |
ba682537 | 1877 | struct prefix_ipv4 p; |
718e3744 | 1878 | |
7c8ff89e DS |
1879 | if (!ospf) |
1880 | return CMD_SUCCESS; | |
1881 | ||
bf2bfafd DW |
1882 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[1]->arg); |
1883 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[3]->arg, 0, 16777215); | |
718e3744 | 1884 | |
68980084 | 1885 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 1886 | |
1887 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1888 | { | |
1889 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1890 | return CMD_WARNING; | |
1891 | } | |
1892 | ||
1893 | area->default_cost = cost; | |
1894 | ||
ba682537 | 1895 | p.family = AF_INET; |
1896 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1897 | p.prefixlen = 0; | |
1898 | if (IS_DEBUG_OSPF_EVENT) | |
1899 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1900 | "announcing 0.0.0.0/0 to area %s", | |
1901 | inet_ntoa (area->area_id)); | |
1902 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1903 | ||
718e3744 | 1904 | return CMD_SUCCESS; |
1905 | } | |
1906 | ||
a2c62831 | 1907 | DEFUN (no_ospf_area_default_cost, |
1908 | no_ospf_area_default_cost_cmd, | |
6147e2c6 | 1909 | "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1910 | NO_STR |
1911 | "OSPF area parameters\n" | |
1912 | "OSPF area ID in IP address format\n" | |
1913 | "OSPF area ID as a decimal value\n" | |
1914 | "Set the summary-default cost of a NSSA or stub area\n" | |
1915 | "Stub's advertised default summary cost\n") | |
1916 | { | |
68980084 | 1917 | struct ospf *ospf = vty->index; |
718e3744 | 1918 | struct ospf_area *area; |
1919 | struct in_addr area_id; | |
718e3744 | 1920 | int format; |
ba682537 | 1921 | struct prefix_ipv4 p; |
718e3744 | 1922 | |
7c8ff89e DS |
1923 | if (!ospf) |
1924 | return CMD_SUCCESS; | |
1925 | ||
bf2bfafd DW |
1926 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[2]->arg); |
1927 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[4]->arg, 0, OSPF_LS_INFINITY); | |
718e3744 | 1928 | |
68980084 | 1929 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1930 | if (area == NULL) |
1931 | return CMD_SUCCESS; | |
1932 | ||
1933 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1934 | { | |
1935 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1936 | return CMD_WARNING; | |
1937 | } | |
1938 | ||
1939 | area->default_cost = 1; | |
1940 | ||
ba682537 | 1941 | p.family = AF_INET; |
1942 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1943 | p.prefixlen = 0; | |
1944 | if (IS_DEBUG_OSPF_EVENT) | |
1945 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1946 | "announcing 0.0.0.0/0 to area %s", | |
1947 | inet_ntoa (area->area_id)); | |
1948 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1949 | ||
1950 | ||
68980084 | 1951 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1952 | |
1953 | return CMD_SUCCESS; | |
1954 | } | |
1955 | ||
a2c62831 | 1956 | DEFUN (ospf_area_export_list, |
1957 | ospf_area_export_list_cmd, | |
6147e2c6 | 1958 | "area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1959 | "OSPF area parameters\n" |
1960 | "OSPF area ID in IP address format\n" | |
1961 | "OSPF area ID as a decimal value\n" | |
1962 | "Set the filter for networks announced to other areas\n" | |
1963 | "Name of the access-list\n") | |
1964 | { | |
68980084 | 1965 | struct ospf *ospf = vty->index; |
718e3744 | 1966 | struct ospf_area *area; |
1967 | struct in_addr area_id; | |
1968 | int format; | |
1969 | ||
7c8ff89e DS |
1970 | if (!ospf) |
1971 | return CMD_SUCCESS; | |
1972 | ||
bf2bfafd | 1973 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
52930766 | 1974 | |
68980084 | 1975 | area = ospf_area_get (ospf, area_id, format); |
1976 | ospf_area_export_list_set (ospf, area, argv[1]); | |
718e3744 | 1977 | |
1978 | return CMD_SUCCESS; | |
1979 | } | |
1980 | ||
a2c62831 | 1981 | DEFUN (no_ospf_area_export_list, |
1982 | no_ospf_area_export_list_cmd, | |
6147e2c6 | 1983 | "no area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1984 | NO_STR |
1985 | "OSPF area parameters\n" | |
1986 | "OSPF area ID in IP address format\n" | |
1987 | "OSPF area ID as a decimal value\n" | |
1988 | "Unset the filter for networks announced to other areas\n" | |
1989 | "Name of the access-list\n") | |
1990 | { | |
68980084 | 1991 | struct ospf *ospf = vty->index; |
718e3744 | 1992 | struct ospf_area *area; |
1993 | struct in_addr area_id; | |
1994 | int format; | |
1995 | ||
7c8ff89e DS |
1996 | if (!ospf) |
1997 | return CMD_SUCCESS; | |
1998 | ||
bf2bfafd | 1999 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); |
52930766 | 2000 | |
68980084 | 2001 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2002 | if (area == NULL) |
2003 | return CMD_SUCCESS; | |
2004 | ||
68980084 | 2005 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 2006 | |
2007 | return CMD_SUCCESS; | |
2008 | } | |
2009 | ||
2010 | ||
a2c62831 | 2011 | DEFUN (ospf_area_import_list, |
2012 | ospf_area_import_list_cmd, | |
6147e2c6 | 2013 | "area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 2014 | "OSPF area parameters\n" |
2015 | "OSPF area ID in IP address format\n" | |
2016 | "OSPF area ID as a decimal value\n" | |
2017 | "Set the filter for networks from other areas announced to the specified one\n" | |
2018 | "Name of the access-list\n") | |
2019 | { | |
68980084 | 2020 | struct ospf *ospf = vty->index; |
718e3744 | 2021 | struct ospf_area *area; |
2022 | struct in_addr area_id; | |
2023 | int format; | |
2024 | ||
7c8ff89e DS |
2025 | if (!ospf) |
2026 | return CMD_SUCCESS; | |
2027 | ||
bf2bfafd | 2028 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
52930766 | 2029 | |
68980084 | 2030 | area = ospf_area_get (ospf, area_id, format); |
2031 | ospf_area_import_list_set (ospf, area, argv[1]); | |
718e3744 | 2032 | |
2033 | return CMD_SUCCESS; | |
2034 | } | |
2035 | ||
a2c62831 | 2036 | DEFUN (no_ospf_area_import_list, |
2037 | no_ospf_area_import_list_cmd, | |
6147e2c6 | 2038 | "no area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 2039 | NO_STR |
2040 | "OSPF area parameters\n" | |
2041 | "OSPF area ID in IP address format\n" | |
2042 | "OSPF area ID as a decimal value\n" | |
2043 | "Unset the filter for networks announced to other areas\n" | |
2044 | "Name of the access-list\n") | |
2045 | { | |
68980084 | 2046 | struct ospf *ospf = vty->index; |
718e3744 | 2047 | struct ospf_area *area; |
2048 | struct in_addr area_id; | |
2049 | int format; | |
2050 | ||
7c8ff89e DS |
2051 | if (!ospf) |
2052 | return CMD_SUCCESS; | |
2053 | ||
bf2bfafd | 2054 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); |
52930766 | 2055 | |
68980084 | 2056 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2057 | if (area == NULL) |
2058 | return CMD_SUCCESS; | |
2059 | ||
68980084 | 2060 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 2061 | |
2062 | return CMD_SUCCESS; | |
2063 | } | |
2064 | ||
a2c62831 | 2065 | DEFUN (ospf_area_filter_list, |
2066 | ospf_area_filter_list_cmd, | |
6147e2c6 | 2067 | "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 2068 | "OSPF area parameters\n" |
2069 | "OSPF area ID in IP address format\n" | |
2070 | "OSPF area ID as a decimal value\n" | |
2071 | "Filter networks between OSPF areas\n" | |
2072 | "Filter prefixes between OSPF areas\n" | |
2073 | "Name of an IP prefix-list\n" | |
2074 | "Filter networks sent to this area\n" | |
2075 | "Filter networks sent from this area\n") | |
2076 | { | |
68980084 | 2077 | struct ospf *ospf = vty->index; |
718e3744 | 2078 | struct ospf_area *area; |
2079 | struct in_addr area_id; | |
2080 | struct prefix_list *plist; | |
2081 | int format; | |
2082 | ||
7c8ff89e DS |
2083 | if (!ospf) |
2084 | return CMD_SUCCESS; | |
2085 | ||
bf2bfafd | 2086 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
718e3744 | 2087 | |
68980084 | 2088 | area = ospf_area_get (ospf, area_id, format); |
bf2bfafd DW |
2089 | plist = prefix_list_lookup (AFI_IP, argv[4]->arg); |
2090 | if (strncmp (argv[5]->arg, "in", 2) == 0) | |
718e3744 | 2091 | { |
2092 | PREFIX_LIST_IN (area) = plist; | |
2093 | if (PREFIX_NAME_IN (area)) | |
2094 | free (PREFIX_NAME_IN (area)); | |
2095 | ||
bf2bfafd | 2096 | PREFIX_NAME_IN (area) = strdup (argv[4]->arg); |
68980084 | 2097 | ospf_schedule_abr_task (ospf); |
718e3744 | 2098 | } |
2099 | else | |
2100 | { | |
2101 | PREFIX_LIST_OUT (area) = plist; | |
2102 | if (PREFIX_NAME_OUT (area)) | |
2103 | free (PREFIX_NAME_OUT (area)); | |
2104 | ||
bf2bfafd | 2105 | PREFIX_NAME_OUT (area) = strdup (argv[4]->arg); |
68980084 | 2106 | ospf_schedule_abr_task (ospf); |
718e3744 | 2107 | } |
2108 | ||
2109 | return CMD_SUCCESS; | |
2110 | } | |
2111 | ||
a2c62831 | 2112 | DEFUN (no_ospf_area_filter_list, |
2113 | no_ospf_area_filter_list_cmd, | |
6147e2c6 | 2114 | "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 2115 | NO_STR |
2116 | "OSPF area parameters\n" | |
2117 | "OSPF area ID in IP address format\n" | |
2118 | "OSPF area ID as a decimal value\n" | |
2119 | "Filter networks between OSPF areas\n" | |
2120 | "Filter prefixes between OSPF areas\n" | |
2121 | "Name of an IP prefix-list\n" | |
2122 | "Filter networks sent to this area\n" | |
2123 | "Filter networks sent from this area\n") | |
2124 | { | |
68980084 | 2125 | struct ospf *ospf = vty->index; |
718e3744 | 2126 | struct ospf_area *area; |
2127 | struct in_addr area_id; | |
718e3744 | 2128 | int format; |
2129 | ||
7c8ff89e DS |
2130 | if (!ospf) |
2131 | return CMD_SUCCESS; | |
2132 | ||
bf2bfafd | 2133 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); |
718e3744 | 2134 | |
1a8ec2b9 PJ |
2135 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
2136 | return CMD_SUCCESS; | |
2137 | ||
bf2bfafd | 2138 | if (strncmp (argv[6]->arg, "in", 2) == 0) |
718e3744 | 2139 | { |
2140 | if (PREFIX_NAME_IN (area)) | |
bf2bfafd | 2141 | if (strcmp (PREFIX_NAME_IN (area), argv[5]->arg) != 0) |
718e3744 | 2142 | return CMD_SUCCESS; |
2143 | ||
2144 | PREFIX_LIST_IN (area) = NULL; | |
2145 | if (PREFIX_NAME_IN (area)) | |
2146 | free (PREFIX_NAME_IN (area)); | |
2147 | ||
2148 | PREFIX_NAME_IN (area) = NULL; | |
2149 | ||
68980084 | 2150 | ospf_schedule_abr_task (ospf); |
718e3744 | 2151 | } |
2152 | else | |
2153 | { | |
2154 | if (PREFIX_NAME_OUT (area)) | |
bf2bfafd | 2155 | if (strcmp (PREFIX_NAME_OUT (area), argv[5]->arg) != 0) |
718e3744 | 2156 | return CMD_SUCCESS; |
2157 | ||
2158 | PREFIX_LIST_OUT (area) = NULL; | |
2159 | if (PREFIX_NAME_OUT (area)) | |
2160 | free (PREFIX_NAME_OUT (area)); | |
2161 | ||
2162 | PREFIX_NAME_OUT (area) = NULL; | |
2163 | ||
68980084 | 2164 | ospf_schedule_abr_task (ospf); |
718e3744 | 2165 | } |
2166 | ||
2167 | return CMD_SUCCESS; | |
2168 | } | |
2169 | ||
6b0655a2 | 2170 | |
a2c62831 | 2171 | DEFUN (ospf_area_authentication_message_digest, |
2172 | ospf_area_authentication_message_digest_cmd, | |
6147e2c6 | 2173 | "area <A.B.C.D|(0-4294967295)> authentication message-digest", |
718e3744 | 2174 | "OSPF area parameters\n" |
2b00515a CF |
2175 | "OSPF area ID in IP address format\n" |
2176 | "OSPF area ID as a decimal value\n" | |
718e3744 | 2177 | "Enable authentication\n" |
2178 | "Use message-digest authentication\n") | |
2179 | { | |
68980084 | 2180 | struct ospf *ospf = vty->index; |
718e3744 | 2181 | struct ospf_area *area; |
2182 | struct in_addr area_id; | |
2183 | int format; | |
2184 | ||
7c8ff89e DS |
2185 | if (!ospf) |
2186 | return CMD_SUCCESS; | |
2187 | ||
bf2bfafd | 2188 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
718e3744 | 2189 | |
68980084 | 2190 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2191 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
2192 | ||
2193 | return CMD_SUCCESS; | |
2194 | } | |
2195 | ||
a2c62831 | 2196 | DEFUN (ospf_area_authentication, |
2197 | ospf_area_authentication_cmd, | |
6147e2c6 | 2198 | "area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 2199 | "OSPF area parameters\n" |
2200 | "OSPF area ID in IP address format\n" | |
2201 | "OSPF area ID as a decimal value\n" | |
2202 | "Enable authentication\n") | |
2203 | { | |
68980084 | 2204 | struct ospf *ospf = vty->index; |
718e3744 | 2205 | struct ospf_area *area; |
2206 | struct in_addr area_id; | |
2207 | int format; | |
2208 | ||
7c8ff89e DS |
2209 | if (!ospf) |
2210 | return CMD_SUCCESS; | |
2211 | ||
bf2bfafd | 2212 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]->arg); |
718e3744 | 2213 | |
68980084 | 2214 | area = ospf_area_get (ospf, area_id, format); |
718e3744 | 2215 | area->auth_type = OSPF_AUTH_SIMPLE; |
2216 | ||
2217 | return CMD_SUCCESS; | |
2218 | } | |
2219 | ||
a2c62831 | 2220 | DEFUN (no_ospf_area_authentication, |
2221 | no_ospf_area_authentication_cmd, | |
6147e2c6 | 2222 | "no area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 2223 | NO_STR |
2224 | "OSPF area parameters\n" | |
2225 | "OSPF area ID in IP address format\n" | |
2226 | "OSPF area ID as a decimal value\n" | |
2227 | "Enable authentication\n") | |
2228 | { | |
68980084 | 2229 | struct ospf *ospf = vty->index; |
718e3744 | 2230 | struct ospf_area *area; |
2231 | struct in_addr area_id; | |
2232 | int format; | |
2233 | ||
7c8ff89e DS |
2234 | if (!ospf) |
2235 | return CMD_SUCCESS; | |
2236 | ||
bf2bfafd | 2237 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[2]->arg); |
718e3744 | 2238 | |
68980084 | 2239 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2240 | if (area == NULL) |
2241 | return CMD_SUCCESS; | |
2242 | ||
2243 | area->auth_type = OSPF_AUTH_NULL; | |
2244 | ||
68980084 | 2245 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2246 | |
2247 | return CMD_SUCCESS; | |
2248 | } | |
2249 | ||
6b0655a2 | 2250 | |
718e3744 | 2251 | DEFUN (ospf_abr_type, |
2252 | ospf_abr_type_cmd, | |
6147e2c6 | 2253 | "ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2254 | "OSPF specific commands\n" |
2255 | "Set OSPF ABR type\n" | |
2256 | "Alternative ABR, cisco implementation\n" | |
2257 | "Alternative ABR, IBM implementation\n" | |
2258 | "Shortcut ABR\n" | |
2259 | "Standard behavior (RFC2328)\n") | |
2260 | { | |
68980084 | 2261 | struct ospf *ospf = vty->index; |
718e3744 | 2262 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2263 | ||
7c8ff89e DS |
2264 | if (!ospf) |
2265 | return CMD_SUCCESS; | |
2266 | ||
bf2bfafd | 2267 | if (strncmp (argv[2]->arg, "c", 1) == 0) |
718e3744 | 2268 | abr_type = OSPF_ABR_CISCO; |
bf2bfafd | 2269 | else if (strncmp (argv[2]->arg, "i", 1) == 0) |
718e3744 | 2270 | abr_type = OSPF_ABR_IBM; |
bf2bfafd | 2271 | else if (strncmp (argv[2]->arg, "sh", 2) == 0) |
718e3744 | 2272 | abr_type = OSPF_ABR_SHORTCUT; |
bf2bfafd | 2273 | else if (strncmp (argv[2]->arg, "st", 2) == 0) |
718e3744 | 2274 | abr_type = OSPF_ABR_STAND; |
2275 | else | |
2276 | return CMD_WARNING; | |
2277 | ||
2278 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2279 | if (ospf->abr_type != abr_type) |
718e3744 | 2280 | { |
68980084 | 2281 | ospf->abr_type = abr_type; |
2282 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2283 | } |
2284 | ||
2285 | return CMD_SUCCESS; | |
2286 | } | |
2287 | ||
2288 | DEFUN (no_ospf_abr_type, | |
2289 | no_ospf_abr_type_cmd, | |
6147e2c6 | 2290 | "no ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2291 | NO_STR |
2292 | "OSPF specific commands\n" | |
2293 | "Set OSPF ABR type\n" | |
2294 | "Alternative ABR, cisco implementation\n" | |
2295 | "Alternative ABR, IBM implementation\n" | |
2296 | "Shortcut ABR\n") | |
2297 | { | |
68980084 | 2298 | struct ospf *ospf = vty->index; |
718e3744 | 2299 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2300 | ||
7c8ff89e DS |
2301 | if (!ospf) |
2302 | return CMD_SUCCESS; | |
2303 | ||
bf2bfafd | 2304 | if (strncmp (argv[3]->arg, "c", 1) == 0) |
718e3744 | 2305 | abr_type = OSPF_ABR_CISCO; |
bf2bfafd | 2306 | else if (strncmp (argv[3]->arg, "i", 1) == 0) |
718e3744 | 2307 | abr_type = OSPF_ABR_IBM; |
bf2bfafd | 2308 | else if (strncmp (argv[3]->arg, "sh", 2) == 0) |
718e3744 | 2309 | abr_type = OSPF_ABR_SHORTCUT; |
bf2bfafd | 2310 | else if (strncmp (argv[3]->arg, "st", 2) == 0) |
04d23314 | 2311 | abr_type = OSPF_ABR_STAND; |
718e3744 | 2312 | else |
2313 | return CMD_WARNING; | |
2314 | ||
2315 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2316 | if (ospf->abr_type == abr_type) |
718e3744 | 2317 | { |
d57834f6 | 2318 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2319 | ospf_schedule_abr_task (ospf); |
718e3744 | 2320 | } |
2321 | ||
2322 | return CMD_SUCCESS; | |
2323 | } | |
2324 | ||
d7e60dd7 AS |
2325 | DEFUN (ospf_log_adjacency_changes, |
2326 | ospf_log_adjacency_changes_cmd, | |
2327 | "log-adjacency-changes", | |
2328 | "Log changes in adjacency state\n") | |
2329 | { | |
2330 | struct ospf *ospf = vty->index; | |
2331 | ||
7c8ff89e DS |
2332 | if (!ospf) |
2333 | return CMD_SUCCESS; | |
2334 | ||
d7e60dd7 | 2335 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
692c7954 | 2336 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
d7e60dd7 AS |
2337 | return CMD_SUCCESS; |
2338 | } | |
2339 | ||
2340 | DEFUN (ospf_log_adjacency_changes_detail, | |
2341 | ospf_log_adjacency_changes_detail_cmd, | |
2342 | "log-adjacency-changes detail", | |
2343 | "Log changes in adjacency state\n" | |
2344 | "Log all state changes\n") | |
2345 | { | |
2346 | struct ospf *ospf = vty->index; | |
2347 | ||
7c8ff89e DS |
2348 | if (!ospf) |
2349 | return CMD_SUCCESS; | |
2350 | ||
d7e60dd7 AS |
2351 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2352 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2353 | return CMD_SUCCESS; | |
2354 | } | |
2355 | ||
2356 | DEFUN (no_ospf_log_adjacency_changes, | |
2357 | no_ospf_log_adjacency_changes_cmd, | |
2358 | "no log-adjacency-changes", | |
2359 | NO_STR | |
2360 | "Log changes in adjacency state\n") | |
2361 | { | |
2362 | struct ospf *ospf = vty->index; | |
2363 | ||
7c8ff89e DS |
2364 | if (!ospf) |
2365 | return CMD_SUCCESS; | |
2366 | ||
d7e60dd7 AS |
2367 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2368 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2369 | return CMD_SUCCESS; | |
2370 | } | |
2371 | ||
2372 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2373 | no_ospf_log_adjacency_changes_detail_cmd, | |
2374 | "no log-adjacency-changes detail", | |
2375 | NO_STR | |
2376 | "Log changes in adjacency state\n" | |
2377 | "Log all state changes\n") | |
2378 | { | |
2379 | struct ospf *ospf = vty->index; | |
2380 | ||
7c8ff89e DS |
2381 | if (!ospf) |
2382 | return CMD_SUCCESS; | |
2383 | ||
692c7954 | 2384 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
d7e60dd7 AS |
2385 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2386 | return CMD_SUCCESS; | |
2387 | } | |
2388 | ||
f412b39a DW |
2389 | /* |
2390 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2391 | * "ospf rfc1583compatibility", | |
2392 | * "OSPF specific commands\n" | |
2393 | * "Enable the RFC1583Compatibility flag\n" | |
2394 | * | |
2395 | */ | |
718e3744 | 2396 | DEFUN (ospf_compatible_rfc1583, |
2397 | ospf_compatible_rfc1583_cmd, | |
2398 | "compatible rfc1583", | |
2399 | "OSPF compatibility list\n" | |
2400 | "compatible with RFC 1583\n") | |
2401 | { | |
2402 | struct ospf *ospf = vty->index; | |
2403 | ||
7c8ff89e DS |
2404 | if (!ospf) |
2405 | return CMD_SUCCESS; | |
2406 | ||
718e3744 | 2407 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2408 | { | |
2409 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2410 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2411 | } |
2412 | return CMD_SUCCESS; | |
2413 | } | |
2414 | ||
f412b39a DW |
2415 | /* |
2416 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2417 | * "no ospf rfc1583compatibility", | |
2418 | * NO_STR | |
2419 | * "OSPF specific commands\n" | |
2420 | * "Disable the RFC1583Compatibility flag\n" | |
2421 | * | |
2422 | */ | |
718e3744 | 2423 | DEFUN (no_ospf_compatible_rfc1583, |
2424 | no_ospf_compatible_rfc1583_cmd, | |
2425 | "no compatible rfc1583", | |
2426 | NO_STR | |
2427 | "OSPF compatibility list\n" | |
2428 | "compatible with RFC 1583\n") | |
2429 | { | |
2430 | struct ospf *ospf = vty->index; | |
2431 | ||
7c8ff89e DS |
2432 | if (!ospf) |
2433 | return CMD_SUCCESS; | |
2434 | ||
718e3744 | 2435 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
2436 | { | |
2437 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2438 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2439 | } |
2440 | return CMD_SUCCESS; | |
2441 | } | |
2442 | ||
718e3744 | 2443 | |
6b0655a2 | 2444 | |
d24f6e2a | 2445 | static int |
2446 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2447 | unsigned int hold, | |
2448 | unsigned int max) | |
2449 | { | |
2450 | struct ospf *ospf = vty->index; | |
2451 | ||
7c8ff89e DS |
2452 | if (!ospf) |
2453 | return CMD_SUCCESS; | |
2454 | ||
d24f6e2a | 2455 | ospf->spf_delay = delay; |
2456 | ospf->spf_holdtime = hold; | |
2457 | ospf->spf_max_holdtime = max; | |
2458 | ||
2459 | return CMD_SUCCESS; | |
2460 | } | |
718e3744 | 2461 | |
ac7424f9 MR |
2462 | DEFUN (ospf_timers_min_ls_interval, |
2463 | ospf_timers_min_ls_interval_cmd, | |
6147e2c6 | 2464 | "timers throttle lsa all (0-5000)", |
ac7424f9 MR |
2465 | "Adjust routing timers\n" |
2466 | "Throttling adaptive timer\n" | |
2467 | "LSA delay between transmissions\n" | |
813d4307 | 2468 | "All LSA types\n" |
ac7424f9 MR |
2469 | "Delay (msec) between sending LSAs\n") |
2470 | { | |
2471 | struct ospf *ospf = vty->index; | |
2472 | unsigned int interval; | |
2473 | ||
d8f70b86 DS |
2474 | if (!ospf) |
2475 | return CMD_SUCCESS; | |
2476 | ||
ac7424f9 MR |
2477 | if (argc != 1) |
2478 | { | |
2479 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2480 | return CMD_WARNING; | |
2481 | } | |
2482 | ||
bf2bfafd | 2483 | VTY_GET_INTEGER ("LSA interval", interval, argv[4]->arg); |
ac7424f9 MR |
2484 | |
2485 | ospf->min_ls_interval = interval; | |
2486 | ||
2487 | return CMD_SUCCESS; | |
2488 | } | |
2489 | ||
f412b39a DW |
2490 | /* |
2491 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2492 | * "no timers throttle lsa all <0-5000>", | |
2493 | * NO_STR | |
2494 | * "Adjust routing timers\n" | |
2495 | * "Throttling adaptive timer\n" | |
2496 | * "LSA delay between transmissions\n" | |
2497 | * "All LSA types\n" | |
2498 | * "Delay (msec) between sending LSAs\n" | |
2499 | * | |
2500 | */ | |
ac7424f9 MR |
2501 | DEFUN (no_ospf_timers_min_ls_interval, |
2502 | no_ospf_timers_min_ls_interval_cmd, | |
2503 | "no timers throttle lsa all", | |
2504 | NO_STR | |
2505 | "Adjust routing timers\n" | |
2506 | "Throttling adaptive timer\n" | |
813d4307 DW |
2507 | "LSA delay between transmissions\n" |
2508 | "All LSA types\n") | |
ac7424f9 MR |
2509 | { |
2510 | struct ospf *ospf = vty->index; | |
2511 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; | |
2512 | ||
2513 | return CMD_SUCCESS; | |
2514 | } | |
2515 | ||
813d4307 | 2516 | |
ac7424f9 MR |
2517 | DEFUN (ospf_timers_min_ls_arrival, |
2518 | ospf_timers_min_ls_arrival_cmd, | |
6147e2c6 | 2519 | "timers lsa arrival (0-1000)", |
ac7424f9 MR |
2520 | "Adjust routing timers\n" |
2521 | "Throttling link state advertisement delays\n" | |
2522 | "OSPF minimum arrival interval delay\n" | |
2523 | "Delay (msec) between accepted LSAs\n") | |
2524 | { | |
2525 | struct ospf *ospf = vty->index; | |
2526 | unsigned int arrival; | |
2527 | ||
d8f70b86 DS |
2528 | if (!ospf) |
2529 | return CMD_SUCCESS; | |
2530 | ||
ac7424f9 MR |
2531 | if (argc != 1) |
2532 | { | |
2533 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2534 | return CMD_WARNING; | |
2535 | } | |
2536 | ||
bf2bfafd | 2537 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[3]->arg, 0, 1000); |
ac7424f9 MR |
2538 | |
2539 | ospf->min_ls_arrival = arrival; | |
2540 | ||
2541 | return CMD_SUCCESS; | |
2542 | } | |
2543 | ||
f412b39a DW |
2544 | /* |
2545 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2546 | * "no timers lsa arrival <0-1000>", | |
2547 | * NO_STR | |
2548 | * "Adjust routing timers\n" | |
2549 | * "Throttling link state advertisement delays\n" | |
2550 | * "OSPF minimum arrival interval delay\n" | |
2551 | * "Delay (msec) between accepted LSAs\n" | |
2552 | * | |
2553 | */ | |
ac7424f9 MR |
2554 | DEFUN (no_ospf_timers_min_ls_arrival, |
2555 | no_ospf_timers_min_ls_arrival_cmd, | |
2556 | "no timers lsa arrival", | |
2557 | NO_STR | |
2558 | "Adjust routing timers\n" | |
2559 | "Throttling link state advertisement delays\n" | |
2560 | "OSPF minimum arrival interval delay\n") | |
2561 | { | |
2562 | struct ospf *ospf = vty->index; | |
d8f70b86 DS |
2563 | |
2564 | if (!ospf) | |
2565 | return CMD_SUCCESS; | |
2566 | ||
ac7424f9 MR |
2567 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
2568 | ||
2569 | return CMD_SUCCESS; | |
2570 | } | |
2571 | ||
813d4307 | 2572 | |
d24f6e2a | 2573 | DEFUN (ospf_timers_throttle_spf, |
2574 | ospf_timers_throttle_spf_cmd, | |
6147e2c6 | 2575 | "timers throttle spf (0-600000) (0-600000) (0-600000)", |
d24f6e2a | 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 | ||
bf2bfafd DW |
2591 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[3]->arg, 0, 600000); |
2592 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[4]->arg, 0, 600000); | |
2593 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[5]->arg, 0, 600000); | |
d24f6e2a | 2594 | |
2595 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2596 | } | |
2597 | ||
f412b39a DW |
2598 | /* |
2599 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2600 | * "no timers throttle spf <0-600000> <0-600000> <0-600000>", | |
2601 | * NO_STR | |
2602 | * "Adjust routing timers\n" | |
2603 | * "Throttling adaptive timer\n" | |
2604 | * "OSPF SPF timers\n" | |
2605 | * "Delay (msec) from first change received till SPF calculation\n" | |
2606 | * "Initial hold time (msec) between consecutive SPF calculations\n" | |
2607 | * "Maximum hold time (msec)\n" | |
2608 | * | |
2609 | */ | |
d24f6e2a | 2610 | DEFUN (no_ospf_timers_throttle_spf, |
2611 | no_ospf_timers_throttle_spf_cmd, | |
2612 | "no timers throttle spf", | |
718e3744 | 2613 | NO_STR |
2614 | "Adjust routing timers\n" | |
d24f6e2a | 2615 | "Throttling adaptive timer\n" |
718e3744 | 2616 | "OSPF SPF timers\n") |
2617 | { | |
d24f6e2a | 2618 | return ospf_timers_spf_set (vty, |
2619 | OSPF_SPF_DELAY_DEFAULT, | |
2620 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2621 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2622 | } |
2623 | ||
b4a039bf | 2624 | |
b6927875 DS |
2625 | DEFUN (ospf_timers_lsa, |
2626 | ospf_timers_lsa_cmd, | |
6147e2c6 | 2627 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
2628 | "Adjust routing timers\n" |
2629 | "OSPF LSA timers\n" | |
2630 | "Minimum delay in receiving new version of a LSA\n" | |
2631 | "Delay in milliseconds\n") | |
2632 | { | |
2633 | unsigned int minarrival; | |
2634 | struct ospf *ospf = vty->index; | |
2635 | ||
2636 | if (!ospf) | |
2637 | return CMD_SUCCESS; | |
2638 | ||
2639 | if (argc != 1) | |
2640 | { | |
2641 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2642 | return CMD_WARNING; | |
2643 | } | |
2644 | ||
bf2bfafd | 2645 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[3]->arg); |
b6927875 | 2646 | |
ac7424f9 | 2647 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2648 | |
2649 | return CMD_SUCCESS; | |
2650 | } | |
2651 | ||
f412b39a DW |
2652 | /* |
2653 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2654 | * "no timers lsa min-arrival <0-600000>", | |
2655 | * NO_STR | |
2656 | * "Adjust routing timers\n" | |
2657 | * "OSPF LSA timers\n" | |
2658 | * "Minimum delay in receiving new version of a LSA\n" | |
2659 | * "Delay in milliseconds\n" | |
2660 | * | |
2661 | */ | |
b6927875 DS |
2662 | DEFUN (no_ospf_timers_lsa, |
2663 | no_ospf_timers_lsa_cmd, | |
2664 | "no timers lsa min-arrival", | |
2665 | NO_STR | |
2666 | "Adjust routing timers\n" | |
2667 | "OSPF LSA timers\n" | |
2668 | "Minimum delay in receiving new version of a LSA\n") | |
2669 | { | |
2670 | unsigned int minarrival; | |
2671 | struct ospf *ospf = vty->index; | |
2672 | ||
2673 | if (!ospf) | |
2674 | return CMD_SUCCESS; | |
2675 | ||
2676 | if (argc) | |
2677 | { | |
2678 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]); | |
2679 | ||
ac7424f9 | 2680 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2681 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2682 | return CMD_SUCCESS; | |
2683 | } | |
2684 | ||
ac7424f9 | 2685 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2686 | |
2687 | return CMD_SUCCESS; | |
2688 | } | |
2689 | ||
b6927875 DS |
2690 | |
2691 | ||
f412b39a DW |
2692 | /* |
2693 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2694 | * "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", | |
2695 | * NEIGHBOR_STR | |
2696 | * "Neighbor IP address\n" | |
2697 | * "Neighbor Priority\n" | |
2698 | * "Priority\n" | |
2699 | * "Dead Neighbor Polling interval\n" | |
2700 | * "Seconds\n" | |
2701 | * | |
2702 | * "neighbor A.B.C.D priority <0-255>", | |
2703 | * NEIGHBOR_STR | |
2704 | * "Neighbor IP address\n" | |
2705 | * "Neighbor Priority\n" | |
2706 | * "Seconds\n" | |
2707 | * | |
2708 | */ | |
a2c62831 | 2709 | DEFUN (ospf_neighbor, |
2710 | ospf_neighbor_cmd, | |
718e3744 | 2711 | "neighbor A.B.C.D", |
2712 | NEIGHBOR_STR | |
2713 | "Neighbor IP address\n") | |
2714 | { | |
2715 | struct ospf *ospf = vty->index; | |
2716 | struct in_addr nbr_addr; | |
eb1ce605 | 2717 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2718 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2719 | |
7c8ff89e DS |
2720 | if (!ospf) |
2721 | return CMD_SUCCESS; | |
2722 | ||
bf2bfafd | 2723 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[1]->arg); |
718e3744 | 2724 | |
2725 | if (argc > 1) | |
2726 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); | |
2727 | ||
2728 | if (argc > 2) | |
2729 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); | |
2730 | ||
2731 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2732 | if (argc > 1) | |
2733 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2734 | if (argc > 2) | |
1a61ad10 | 2735 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2736 | |
2737 | return CMD_SUCCESS; | |
2738 | } | |
2739 | ||
718e3744 | 2740 | |
718e3744 | 2741 | |
f412b39a DW |
2742 | /* |
2743 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2744 | * "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", | |
2745 | * NEIGHBOR_STR | |
2746 | * "Neighbor address\n" | |
2747 | * "OSPF dead-router polling interval\n" | |
2748 | * "Seconds\n" | |
2749 | * "OSPF priority of non-broadcast neighbor\n" | |
2750 | * "Priority\n" | |
2751 | * | |
2752 | */ | |
a2c62831 | 2753 | DEFUN (ospf_neighbor_poll_interval, |
2754 | ospf_neighbor_poll_interval_cmd, | |
6147e2c6 | 2755 | "neighbor A.B.C.D poll-interval (1-65535)", |
718e3744 | 2756 | NEIGHBOR_STR |
2757 | "Neighbor IP address\n" | |
2758 | "Dead Neighbor Polling interval\n" | |
2759 | "Seconds\n") | |
2760 | { | |
2761 | struct ospf *ospf = vty->index; | |
2762 | struct in_addr nbr_addr; | |
eb1ce605 | 2763 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2764 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2765 | |
7c8ff89e DS |
2766 | if (!ospf) |
2767 | return CMD_SUCCESS; | |
2768 | ||
bf2bfafd | 2769 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[1]->arg); |
718e3744 | 2770 | |
2771 | if (argc > 1) | |
bf2bfafd | 2772 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[3]->arg, 1, 65535); |
718e3744 | 2773 | |
2774 | if (argc > 2) | |
2775 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); | |
2776 | ||
2777 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
2778 | if (argc > 1) | |
2779 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); | |
2780 | if (argc > 2) | |
2781 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); | |
2782 | ||
2783 | return CMD_SUCCESS; | |
2784 | } | |
2785 | ||
718e3744 | 2786 | |
f412b39a DW |
2787 | /* |
2788 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2789 | * "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", | |
2790 | * NO_STR | |
2791 | * NEIGHBOR_STR | |
2792 | * "Neighbor IP address\n" | |
2793 | * "Neighbor Priority\n" | |
2794 | * "Priority\n" | |
2795 | * "Dead Neighbor Polling interval\n" | |
2796 | * "Seconds\n" | |
2797 | * | |
2798 | * "no neighbor A.B.C.D priority <0-255>", | |
2799 | * NO_STR | |
2800 | * NEIGHBOR_STR | |
2801 | * "Neighbor IP address\n" | |
2802 | * "Neighbor Priority\n" | |
2803 | * "Priority\n" | |
2804 | * | |
2805 | * "no neighbor A.B.C.D poll-interval <1-65535>", | |
2806 | * NO_STR | |
2807 | * NEIGHBOR_STR | |
2808 | * "Neighbor IP address\n" | |
2809 | * "Dead Neighbor Polling interval\n" | |
2810 | * "Seconds\n" | |
2811 | * | |
2812 | * "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", | |
2813 | * NO_STR | |
2814 | * NEIGHBOR_STR | |
2815 | * "Neighbor IP address\n" | |
2816 | * "Dead Neighbor Polling interval\n" | |
2817 | * "Seconds\n" | |
2818 | * "OSPF priority of non-broadcast neighbor\n" | |
2819 | * "Priority\n" | |
2820 | * | |
2821 | */ | |
a2c62831 | 2822 | DEFUN (no_ospf_neighbor, |
2823 | no_ospf_neighbor_cmd, | |
718e3744 | 2824 | "no neighbor A.B.C.D", |
2825 | NO_STR | |
2826 | NEIGHBOR_STR | |
2827 | "Neighbor IP address\n") | |
2828 | { | |
2829 | struct ospf *ospf = vty->index; | |
2830 | struct in_addr nbr_addr; | |
718e3744 | 2831 | |
7c8ff89e DS |
2832 | if (!ospf) |
2833 | return CMD_SUCCESS; | |
2834 | ||
bf2bfafd | 2835 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[2]->arg); |
718e3744 | 2836 | |
0798cee3 | 2837 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2838 | |
2839 | return CMD_SUCCESS; | |
2840 | } | |
2841 | ||
718e3744 | 2842 | |
718e3744 | 2843 | |
813d4307 | 2844 | |
718e3744 | 2845 | |
bf2bfafd DW |
2846 | DEFUN (ospf_refresh_timer, |
2847 | ospf_refresh_timer_cmd, | |
6147e2c6 | 2848 | "refresh timer (10-1800)", |
718e3744 | 2849 | "Adjust refresh parameters\n" |
2850 | "Set refresh timer\n" | |
2851 | "Timer value in seconds\n") | |
2852 | { | |
2853 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2854 | unsigned int interval; |
718e3744 | 2855 | |
7c8ff89e DS |
2856 | if (!ospf) |
2857 | return CMD_SUCCESS; | |
2858 | ||
bf2bfafd | 2859 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[2]->arg, 10, 1800); |
535c84b1 | 2860 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; |
718e3744 | 2861 | |
2862 | ospf_timers_refresh_set (ospf, interval); | |
2863 | ||
2864 | return CMD_SUCCESS; | |
2865 | } | |
2866 | ||
f412b39a DW |
2867 | /* |
2868 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2869 | * "no refresh timer", | |
2870 | * "Adjust refresh parameters\n" | |
2871 | * "Unset refresh timer\n" | |
2872 | * | |
2873 | */ | |
bf2bfafd DW |
2874 | DEFUN (no_ospf_refresh_timer, |
2875 | no_ospf_refresh_timer_val_cmd, | |
6147e2c6 | 2876 | "no refresh timer (10-1800)", |
718e3744 | 2877 | "Adjust refresh parameters\n" |
2878 | "Unset refresh timer\n" | |
2879 | "Timer value in seconds\n") | |
2880 | { | |
2881 | struct ospf *ospf = vty->index; | |
eb1ce605 | 2882 | unsigned int interval; |
718e3744 | 2883 | |
7c8ff89e DS |
2884 | if (!ospf) |
2885 | return CMD_SUCCESS; | |
2886 | ||
718e3744 | 2887 | if (argc == 1) |
2888 | { | |
bf2bfafd | 2889 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[3]->arg, 10, 1800); |
718e3744 | 2890 | |
2891 | if (ospf->lsa_refresh_interval != interval || | |
2892 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2893 | return CMD_SUCCESS; | |
2894 | } | |
2895 | ||
2896 | ospf_timers_refresh_unset (ospf); | |
2897 | ||
2898 | return CMD_SUCCESS; | |
2899 | } | |
2900 | ||
718e3744 | 2901 | |
a2c62831 | 2902 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2903 | ospf_auto_cost_reference_bandwidth_cmd, | |
6147e2c6 | 2904 | "auto-cost reference-bandwidth (1-4294967)", |
718e3744 | 2905 | "Calculate OSPF interface cost according to bandwidth\n" |
2906 | "Use reference bandwidth method to assign OSPF cost\n" | |
2907 | "The reference bandwidth in terms of Mbits per second\n") | |
2908 | { | |
68980084 | 2909 | struct ospf *ospf = vty->index; |
718e3744 | 2910 | u_int32_t refbw; |
52dc7ee6 | 2911 | struct listnode *node; |
1eb8ef25 | 2912 | struct interface *ifp; |
718e3744 | 2913 | |
7c8ff89e DS |
2914 | if (!ospf) |
2915 | return CMD_SUCCESS; | |
2916 | ||
bf2bfafd | 2917 | refbw = strtol (argv[2]->arg, NULL, 10); |
718e3744 | 2918 | if (refbw < 1 || refbw > 4294967) |
2919 | { | |
2920 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2921 | return CMD_WARNING; | |
2922 | } | |
2923 | ||
2924 | /* If reference bandwidth is changed. */ | |
70bd3c43 | 2925 | if ((refbw) == ospf->ref_bandwidth) |
718e3744 | 2926 | return CMD_SUCCESS; |
2927 | ||
70bd3c43 | 2928 | ospf->ref_bandwidth = refbw; |
1eb8ef25 | 2929 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2930 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2931 | |
2932 | return CMD_SUCCESS; | |
2933 | } | |
2934 | ||
f412b39a DW |
2935 | /* |
2936 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2937 | * "no auto-cost reference-bandwidth <1-4294967>", | |
2938 | * NO_STR | |
2939 | * "Calculate OSPF interface cost according to bandwidth\n" | |
2940 | * "Use reference bandwidth method to assign OSPF cost\n" | |
2941 | * "The reference bandwidth in terms of Mbits per second\n" | |
2942 | * | |
2943 | */ | |
a2c62831 | 2944 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2945 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
718e3744 | 2946 | "no auto-cost reference-bandwidth", |
2947 | NO_STR | |
2948 | "Calculate OSPF interface cost according to bandwidth\n" | |
2949 | "Use reference bandwidth method to assign OSPF cost\n") | |
2950 | { | |
68980084 | 2951 | struct ospf *ospf = vty->index; |
1eb8ef25 | 2952 | struct listnode *node, *nnode; |
2953 | struct interface *ifp; | |
718e3744 | 2954 | |
7c8ff89e DS |
2955 | if (!ospf) |
2956 | return CMD_SUCCESS; | |
2957 | ||
68980084 | 2958 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2959 | return CMD_SUCCESS; |
2960 | ||
68980084 | 2961 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2962 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2963 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2964 | ||
1eb8ef25 | 2965 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2966 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2967 | |
2968 | return CMD_SUCCESS; | |
2969 | } | |
2970 | ||
813d4307 | 2971 | |
f412b39a DW |
2972 | /* |
2973 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
2974 | * "write-multiplier <1-100>", | |
2975 | * "Write multiplier\n" | |
2976 | * "Maximum number of interface serviced per write\n" | |
2977 | * | |
2978 | */ | |
2f8f370e DS |
2979 | DEFUN (ospf_write_multiplier, |
2980 | ospf_write_multiplier_cmd, | |
6147e2c6 | 2981 | "ospf write-multiplier (1-100)", |
e8f45e82 DS |
2982 | "OSPF specific commands\n" |
2983 | "Write multiplier\n" | |
2984 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
2985 | { |
2986 | struct ospf *ospf = vty->index; | |
e8f45e82 | 2987 | u_int32_t write_oi_count; |
2f8f370e | 2988 | |
7c8ff89e DS |
2989 | if (!ospf) |
2990 | return CMD_SUCCESS; | |
2991 | ||
bf2bfafd | 2992 | write_oi_count = strtol (argv[2]->arg, NULL, 10); |
e8f45e82 | 2993 | if (write_oi_count < 1 || write_oi_count > 100) |
2f8f370e DS |
2994 | { |
2995 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2996 | return CMD_WARNING; | |
2997 | } | |
2998 | ||
e8f45e82 | 2999 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
3000 | return CMD_SUCCESS; |
3001 | } | |
3002 | ||
e8f45e82 | 3003 | |
f412b39a DW |
3004 | /* |
3005 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
3006 | * "no write-multiplier", | |
3007 | * NO_STR | |
3008 | * "Write multiplier\n" | |
3009 | * | |
3010 | * "no write-multiplier <1-100>", | |
3011 | * NO_STR | |
3012 | * "Write multiplier\n" | |
3013 | * "Maximum number of interface serviced per write\n" | |
3014 | * | |
3015 | */ | |
2f8f370e DS |
3016 | DEFUN (no_ospf_write_multiplier, |
3017 | no_ospf_write_multiplier_cmd, | |
6147e2c6 | 3018 | "no ospf write-multiplier (1-100)", |
2f8f370e | 3019 | NO_STR |
e8f45e82 | 3020 | "OSPF specific commands\n" |
813d4307 DW |
3021 | "Write multiplier\n" |
3022 | "Maximum number of interface serviced per write\n") | |
2f8f370e DS |
3023 | { |
3024 | struct ospf *ospf = vty->index; | |
3025 | ||
7c8ff89e DS |
3026 | if (!ospf) |
3027 | return CMD_SUCCESS; | |
3028 | ||
e8f45e82 | 3029 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
3030 | return CMD_SUCCESS; |
3031 | } | |
3032 | ||
e8f45e82 | 3033 | |
813d4307 | 3034 | |
eb1ce605 | 3035 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 3036 | { |
3037 | "Unknown", | |
3038 | "Standard (RFC2328)", | |
3039 | "Alternative IBM", | |
3040 | "Alternative Cisco", | |
3041 | "Alternative Shortcut" | |
3042 | }; | |
3043 | ||
eb1ce605 | 3044 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 3045 | { |
3046 | "Default", | |
3047 | "Enabled", | |
3048 | "Disabled" | |
3049 | }; | |
3050 | ||
4dadc291 | 3051 | static void |
ca08c43d | 3052 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 3053 | { |
ca08c43d DS |
3054 | json_object *json_area = NULL; |
3055 | ||
3056 | if (use_json) | |
3057 | json_area = json_object_new_object(); | |
3058 | ||
718e3744 | 3059 | /* Show Area ID. */ |
ca08c43d DS |
3060 | if (!use_json) |
3061 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 3062 | |
3063 | /* Show Area type/mode. */ | |
3064 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
3065 | { |
3066 | if (use_json) | |
3067 | json_object_boolean_true_add(json_area, "backbone"); | |
3068 | else | |
3069 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
3070 | } | |
718e3744 | 3071 | else |
3072 | { | |
ca08c43d DS |
3073 | if (use_json) |
3074 | { | |
3075 | if (area->external_routing == OSPF_AREA_STUB) | |
3076 | { | |
3077 | if (area->no_summary) | |
3078 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
3079 | if (area->shortcut_configured) | |
3080 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
3081 | } | |
3082 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3083 | { | |
3084 | if (area->no_summary) | |
3085 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
3086 | if (area->shortcut_configured) | |
3087 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
3088 | } | |
3089 | ||
3090 | json_object_string_add(json_area,"shortcuttingMode", | |
3091 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3092 | if (area->shortcut_capability) | |
3093 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
3094 | } | |
3095 | else | |
3096 | { | |
3097 | if (area->external_routing == OSPF_AREA_STUB) | |
3098 | vty_out (vty, " (Stub%s%s)", | |
3099 | area->no_summary ? ", no summary" : "", | |
3100 | area->shortcut_configured ? "; " : ""); | |
3101 | else if (area->external_routing == OSPF_AREA_NSSA) | |
3102 | vty_out (vty, " (NSSA%s%s)", | |
3103 | area->no_summary ? ", no summary" : "", | |
3104 | area->shortcut_configured ? "; " : ""); | |
3105 | ||
3106 | vty_out (vty, "%s", VTY_NEWLINE); | |
3107 | vty_out (vty, " Shortcutting mode: %s", | |
3108 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
3109 | vty_out (vty, ", S-bit consensus: %s%s", | |
3110 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); | |
3111 | } | |
3112 | } | |
3113 | ||
3114 | /* Show number of interfaces */ | |
3115 | if (use_json) | |
3116 | { | |
3ac237f8 MS |
3117 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
3118 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 3119 | } |
ca08c43d DS |
3120 | else |
3121 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
3122 | "Active: %d%s", listcount (area->oiflist), | |
3123 | area->act_ints, VTY_NEWLINE); | |
718e3744 | 3124 | |
718e3744 | 3125 | if (area->external_routing == OSPF_AREA_NSSA) |
3126 | { | |
ca08c43d DS |
3127 | if (use_json) |
3128 | { | |
3129 | json_object_boolean_true_add(json_area, "nssa"); | |
3130 | if (! IS_OSPF_ABR (area->ospf)) | |
3131 | json_object_boolean_false_add(json_area, "abr"); | |
3132 | else if (area->NSSATranslatorState) | |
3133 | { | |
3134 | json_object_boolean_true_add(json_area, "abr"); | |
3135 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3136 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
3137 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3138 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
3139 | } | |
3140 | else | |
3141 | { | |
3142 | json_object_boolean_true_add(json_area, "abr"); | |
3143 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3144 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
3145 | else | |
3146 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
3147 | } | |
3148 | } | |
718e3744 | 3149 | else |
ca08c43d DS |
3150 | { |
3151 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
3152 | if (! IS_OSPF_ABR (area->ospf)) | |
3153 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
3154 | VTY_NEWLINE); | |
3155 | else if (area->NSSATranslatorState) | |
3156 | { | |
3157 | vty_out (vty, " We are an ABR and "); | |
3158 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3159 | vty_out (vty, "the NSSA Elected Translator. %s", | |
3160 | VTY_NEWLINE); | |
3161 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
3162 | vty_out (vty, "always an NSSA Translator. %s", | |
3163 | VTY_NEWLINE); | |
3164 | } | |
3165 | else | |
3166 | { | |
3167 | vty_out (vty, " We are an ABR, but "); | |
3168 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
3169 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
3170 | VTY_NEWLINE); | |
3171 | else | |
3172 | vty_out (vty, "never an NSSA Translator. %s", | |
3173 | VTY_NEWLINE); | |
3174 | } | |
3175 | } | |
718e3744 | 3176 | } |
ca08c43d | 3177 | |
88d6cf37 | 3178 | /* Stub-router state for this area */ |
3179 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
3180 | { | |
649654ab | 3181 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3182 | |
3183 | if (use_json) | |
3184 | { | |
3185 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
3186 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3187 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
3188 | if (area->t_stub_router) | |
3189 | { | |
3190 | struct timeval result; | |
3191 | unsigned long time_store = 0; | |
3192 | result = tv_sub (area->t_stub_router->u.sands, recent_relative_time()); | |
3193 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3194 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); | |
3195 | } | |
3196 | } | |
3197 | else | |
3198 | { | |
3199 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
3200 | VTY_NEWLINE); | |
3201 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
3202 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
3203 | VTY_NEWLINE); | |
3204 | if (area->t_stub_router) | |
3205 | vty_out (vty, " Active from startup, %s remaining%s", | |
3206 | ospf_timer_dump (area->t_stub_router, timebuf, | |
3207 | sizeof(timebuf)), VTY_NEWLINE); | |
3208 | } | |
3209 | } | |
3210 | ||
3211 | if (use_json) | |
3212 | { | |
3213 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 3214 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
3215 | |
3216 | /* Show authentication type. */ | |
3217 | if (area->auth_type == OSPF_AUTH_NULL) | |
3218 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
3219 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3220 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
3221 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3222 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
3223 | ||
3224 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 3225 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
3226 | |
3227 | /* Show SPF calculation times. */ | |
3ac237f8 | 3228 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
3229 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
3230 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
3231 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
3232 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
3233 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
3234 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
3235 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
3236 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3237 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
3238 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
3239 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 3240 | } |
ca08c43d DS |
3241 | else |
3242 | { | |
3243 | /* Show number of fully adjacent neighbors. */ | |
3244 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
3245 | " %d%s", area->full_nbrs, VTY_NEWLINE); | |
3246 | ||
3247 | /* Show authentication type. */ | |
3248 | vty_out (vty, " Area has "); | |
3249 | if (area->auth_type == OSPF_AUTH_NULL) | |
3250 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
3251 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
3252 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
3253 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
3254 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
3255 | ||
3256 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3257 | vty_out (vty, " Number of full virtual adjacencies going through" | |
3258 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
3259 | ||
3260 | /* Show SPF calculation times. */ | |
3261 | vty_out (vty, " SPF algorithm executed %d times%s", | |
3262 | area->spf_calculation, VTY_NEWLINE); | |
3263 | ||
3264 | /* Show number of LSA. */ | |
3265 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
3266 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", | |
3267 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
3268 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
3269 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
3270 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
3271 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
3272 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
3273 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
3274 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
3275 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
3276 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
3277 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
3278 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
3279 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
3280 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
3281 | } | |
3282 | ||
ca08c43d DS |
3283 | if (use_json) |
3284 | { | |
3285 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3286 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
3287 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3288 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
3289 | } | |
3290 | else | |
3291 | { | |
3292 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
3293 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
3294 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
3295 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
3296 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
3297 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
3298 | } | |
ca08c43d DS |
3299 | |
3300 | if (use_json) | |
3301 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
3302 | else | |
3303 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 3304 | } |
3305 | ||
7c8ff89e | 3306 | static int |
ca08c43d | 3307 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3308 | { |
1eb8ef25 | 3309 | struct listnode *node, *nnode; |
718e3744 | 3310 | struct ospf_area * area; |
d24f6e2a | 3311 | struct timeval result; |
649654ab | 3312 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
3313 | json_object *json = NULL; |
3314 | json_object *json_areas = NULL; | |
3315 | ||
3316 | if (use_json) | |
3317 | json = json_object_new_object(); | |
3318 | json_areas = json_object_new_object(); | |
718e3744 | 3319 | |
7c8ff89e | 3320 | if (ospf->instance) |
ca08c43d DS |
3321 | { |
3322 | if (use_json) | |
3323 | { | |
3324 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3325 | } | |
3326 | else | |
3327 | { | |
3328 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3329 | VTY_NEWLINE, VTY_NEWLINE); | |
3330 | } | |
3331 | } | |
718e3744 | 3332 | |
3333 | /* Show Router ID. */ | |
ca08c43d DS |
3334 | if (use_json) |
3335 | { | |
3336 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
3337 | } | |
3338 | else | |
3339 | { | |
3340 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
3341 | inet_ntoa (ospf->router_id), | |
3342 | VTY_NEWLINE); | |
3343 | } | |
7c8ff89e | 3344 | |
88d6cf37 | 3345 | /* Graceful shutdown */ |
c9c93d50 | 3346 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
3347 | { |
3348 | if (use_json) | |
3349 | { | |
3350 | unsigned long time_store = 0; | |
3351 | result = tv_sub (ospf->t_deferred_shutdown->u.sands, recent_relative_time()); | |
3352 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3353 | json_object_int_add(json, "deferredShutdownMsecs", time_store); | |
3354 | } | |
3355 | else | |
3356 | { | |
3357 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
3358 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
3359 | timebuf, sizeof (timebuf)), VTY_NEWLINE); | |
3360 | } | |
3361 | } | |
3362 | ||
718e3744 | 3363 | /* Show capability. */ |
ca08c43d DS |
3364 | if (use_json) |
3365 | { | |
3366 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
3367 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
3368 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
3369 | { | |
3370 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
3371 | } | |
3372 | } | |
3373 | else | |
3374 | { | |
3375 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
3376 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
3377 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
3378 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
3379 | "enabled" : "disabled", VTY_NEWLINE); | |
3380 | } | |
3381 | ||
ca08c43d DS |
3382 | if (use_json) |
3383 | { | |
3384 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
3385 | { | |
3386 | json_object_boolean_true_add(json, "opaqueCapable"); | |
3387 | } | |
ca08c43d DS |
3388 | } |
3389 | else | |
3390 | { | |
801e0e14 | 3391 | vty_out (vty, " OpaqueCapability flag is %s%s", |
ca08c43d | 3392 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", |
ca08c43d DS |
3393 | VTY_NEWLINE); |
3394 | } | |
ca08c43d | 3395 | |
88d6cf37 | 3396 | /* Show stub-router configuration */ |
3397 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3398 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3399 | { | |
ca08c43d DS |
3400 | if (use_json) |
3401 | { | |
3402 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3403 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3404 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3405 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3406 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3407 | } | |
3408 | else | |
3409 | { | |
3410 | vty_out (vty, " Stub router advertisement is configured%s", | |
3411 | VTY_NEWLINE); | |
3412 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3413 | vty_out (vty, " Enabled for %us after start-up%s", | |
3414 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3415 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3416 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3417 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3418 | } | |
88d6cf37 | 3419 | } |
ca08c43d | 3420 | |
718e3744 | 3421 | /* Show SPF timers. */ |
ca08c43d DS |
3422 | if (use_json) |
3423 | { | |
3424 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3425 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3426 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3427 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3428 | } |
3429 | else | |
ca08c43d DS |
3430 | { |
3431 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3432 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3433 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3434 | " Hold time multiplier is currently %d%s", | |
3435 | ospf->spf_delay, VTY_NEWLINE, | |
3436 | ospf->spf_holdtime, VTY_NEWLINE, | |
3437 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3438 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
3439 | } | |
b6927875 | 3440 | |
ca08c43d DS |
3441 | if (use_json) |
3442 | { | |
3443 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3444 | { | |
3445 | unsigned long time_store = 0; | |
3446 | ||
3447 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3448 | result = tv_sub (result, recent_relative_time()); | |
3449 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
3450 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); | |
3451 | ||
3452 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3453 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3454 | } | |
3455 | else | |
3456 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3457 | } | |
3458 | else | |
3459 | { | |
3460 | vty_out (vty, " SPF algorithm "); | |
3461 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3462 | { | |
3463 | result = tv_sub (recent_relative_time(), ospf->ts_spf); | |
3464 | vty_out (vty, "last executed %s ago%s", | |
3465 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3466 | VTY_NEWLINE); | |
3467 | vty_out (vty, " Last SPF duration %s%s", | |
3468 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3469 | VTY_NEWLINE); | |
3470 | } | |
3471 | else | |
3472 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
3473 | } | |
3474 | ||
3475 | if (use_json) | |
3476 | { | |
3477 | struct timeval temp_time; | |
3478 | unsigned long time_store = 0; | |
3479 | ||
3480 | if (ospf->t_spf_calc) | |
3481 | { | |
3482 | temp_time = tv_sub (ospf->t_spf_calc->u.sands, recent_relative_time()); | |
3483 | time_store = (1000 * temp_time.tv_sec) + (temp_time.tv_usec / 1000); | |
3484 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); | |
3485 | } | |
3486 | ||
ac7424f9 MR |
3487 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3488 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3489 | /* Show write multiplier values */ |
3490 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3491 | /* Show refresh parameters. */ | |
54b7214f | 3492 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000); |
ca08c43d DS |
3493 | } |
3494 | else | |
3495 | { | |
3496 | vty_out (vty, " SPF timer %s%s%s", | |
3497 | (ospf->t_spf_calc ? "due in " : "is "), | |
3498 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3499 | VTY_NEWLINE); | |
3500 | ||
ac7424f9 MR |
3501 | vty_out (vty, " LSA minimum interval %d msecs%s", |
3502 | ospf->min_ls_interval, VTY_NEWLINE); | |
ca08c43d | 3503 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
ac7424f9 | 3504 | ospf->min_ls_arrival, VTY_NEWLINE); |
ca08c43d DS |
3505 | |
3506 | /* Show write multiplier values */ | |
3507 | vty_out (vty, " Write Multiplier set to %d %s", | |
3508 | ospf->write_oi_count, VTY_NEWLINE); | |
3509 | ||
3510 | /* Show refresh parameters. */ | |
3511 | vty_out (vty, " Refresh timer %d secs%s", | |
3512 | ospf->lsa_refresh_interval, VTY_NEWLINE); | |
3513 | } | |
2f8f370e | 3514 | |
718e3744 | 3515 | /* Show ABR/ASBR flags. */ |
68980084 | 3516 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3517 | { |
3518 | if (use_json) | |
3519 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3520 | else | |
3521 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
3522 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); | |
3523 | } | |
68980084 | 3524 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3525 | { |
3526 | if (use_json) | |
3527 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3528 | else | |
3529 | vty_out (vty, " This router is an ASBR " | |
3530 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3531 | } | |
718e3744 | 3532 | |
3533 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3534 | if (use_json) |
3535 | { | |
3ac237f8 | 3536 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3537 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3538 | json_object_int_add(json, "lsaExternalChecksum", | |
3539 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3540 | } | |
3541 | else | |
3542 | { | |
3543 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3544 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3545 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3546 | } | |
3547 | ||
ca08c43d DS |
3548 | if (use_json) |
3549 | { | |
3ac237f8 | 3550 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3551 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3552 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3553 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3554 | } | |
3555 | else | |
3556 | { | |
3557 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3558 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3559 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3560 | } | |
ca08c43d | 3561 | |
718e3744 | 3562 | /* Show number of areas attached. */ |
ca08c43d | 3563 | if (use_json) |
3ac237f8 | 3564 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3565 | else |
3566 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
3567 | listcount (ospf->areas), VTY_NEWLINE); | |
d7e60dd7 AS |
3568 | |
3569 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3570 | { | |
3571 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3572 | { |
3573 | if (use_json) | |
3574 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3575 | else | |
3576 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3577 | } | |
d7e60dd7 | 3578 | else |
ca08c43d DS |
3579 | { |
3580 | if (use_json) | |
3581 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3582 | else | |
3583 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3584 | } | |
d7e60dd7 | 3585 | } |
718e3744 | 3586 | /* Show each area status. */ |
1eb8ef25 | 3587 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3588 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3589 | ||
3590 | if (use_json) | |
3591 | { | |
3592 | json_object_object_add(json, "areas", json_areas); | |
3593 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
3594 | json_object_free(json); | |
3595 | } | |
3596 | else | |
3597 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3598 | |
3599 | return CMD_SUCCESS; | |
3600 | } | |
3601 | ||
7c8ff89e DS |
3602 | DEFUN (show_ip_ospf, |
3603 | show_ip_ospf_cmd, | |
b162fa78 | 3604 | "show ip ospf [json]", |
7c8ff89e DS |
3605 | SHOW_STR |
3606 | IP_STR | |
ca08c43d DS |
3607 | "OSPF information\n" |
3608 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3609 | { |
3610 | struct ospf *ospf; | |
db7c8528 | 3611 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3612 | |
0bad4851 | 3613 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3614 | return CMD_SUCCESS; |
3615 | ||
db7c8528 | 3616 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3617 | } |
3618 | ||
3619 | DEFUN (show_ip_ospf_instance, | |
3620 | show_ip_ospf_instance_cmd, | |
6147e2c6 | 3621 | "show ip ospf (1-65535) [json]", |
7c8ff89e DS |
3622 | SHOW_STR |
3623 | IP_STR | |
3624 | "OSPF information\n" | |
ca08c43d DS |
3625 | "Instance ID\n" |
3626 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
3627 | { |
3628 | struct ospf *ospf; | |
3629 | u_short instance = 0; | |
db7c8528 | 3630 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3631 | |
bf2bfafd | 3632 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 3633 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3634 | return CMD_SUCCESS; |
3635 | ||
db7c8528 | 3636 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3637 | } |
3638 | ||
fd651fa6 | 3639 | static void |
7ec4159b DS |
3640 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3641 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3642 | { |
fd651fa6 | 3643 | int is_up; |
718e3744 | 3644 | struct ospf_neighbor *nbr; |
718e3744 | 3645 | struct route_node *rn; |
718e3744 | 3646 | |
718e3744 | 3647 | /* Is interface up? */ |
7ec4159b DS |
3648 | if (use_json) |
3649 | { | |
3650 | is_up = if_is_operative(ifp); | |
3651 | if (is_up) | |
3652 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3653 | else | |
3654 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3655 | ||
3656 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3657 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
70bd3c43 | 3658 | json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth); |
7ec4159b DS |
3659 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); |
3660 | } | |
3661 | else | |
3662 | { | |
3663 | vty_out (vty, "%s is %s%s", ifp->name, | |
3664 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
70bd3c43 | 3665 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s", |
7ec4159b DS |
3666 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
3667 | VTY_NEWLINE); | |
3668 | } | |
718e3744 | 3669 | |
3670 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3671 | if (use_json) |
718e3744 | 3672 | { |
7ec4159b DS |
3673 | if (ospf_oi_count(ifp) == 0) |
3674 | { | |
3675 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3676 | return; | |
3677 | } | |
3678 | else if (!is_up) | |
3679 | { | |
3680 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3681 | return; | |
3682 | } | |
3683 | else | |
3684 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3685 | } |
7ec4159b | 3686 | else |
fd651fa6 | 3687 | { |
7ec4159b DS |
3688 | if (ospf_oi_count(ifp) == 0) |
3689 | { | |
3690 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3691 | return; | |
3692 | } | |
3693 | else if (!is_up) | |
3694 | { | |
3695 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3696 | VTY_NEWLINE); | |
3697 | return; | |
3698 | } | |
fd651fa6 | 3699 | } |
3700 | ||
718e3744 | 3701 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3702 | { | |
3703 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3704 | |
718e3744 | 3705 | if (oi == NULL) |
7ec4159b DS |
3706 | continue; |
3707 | ||
525c1839 DS |
3708 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3709 | { | |
7ec4159b DS |
3710 | if (use_json) |
3711 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3712 | else | |
3713 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3714 | } |
3715 | else | |
9c27ef9b | 3716 | { |
525c1839 | 3717 | /* Show OSPF interface information. */ |
7ec4159b DS |
3718 | if (use_json) |
3719 | { | |
3720 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3721 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3722 | } | |
3723 | else | |
3724 | vty_out (vty, " Internet Address %s/%d,", | |
3725 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3726 | |
3727 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3728 | { | |
3729 | struct in_addr *dest; | |
3730 | const char *dstr; | |
3731 | ||
3732 | if (CONNECTED_PEER(oi->connected) | |
3733 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3734 | dstr = "Peer"; | |
3735 | else | |
3736 | dstr = "Broadcast"; | |
3737 | ||
3738 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3739 | * * * * * informative than the local interface that is being used |
3740 | * * * * */ | |
525c1839 DS |
3741 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3742 | dest = &oi->vl_data->peer_addr; | |
3743 | else | |
3744 | dest = &oi->connected->destination->u.prefix4; | |
3745 | ||
7ec4159b DS |
3746 | if (use_json) |
3747 | { | |
3748 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3749 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3750 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3751 | else | |
3752 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3753 | } | |
3754 | else | |
3755 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3756 | } |
9c27ef9b | 3757 | } |
7ec4159b DS |
3758 | if (use_json) |
3759 | { | |
3760 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3761 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3762 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3763 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3764 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3765 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3766 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
3767 | json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state)); | |
3768 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); | |
3769 | } | |
3770 | else | |
3771 | { | |
3772 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), | |
3773 | VTY_NEWLINE); | |
3fb9cd6e | 3774 | |
7ec4159b DS |
3775 | vty_out (vty, " MTU mismatch detection:%s%s", |
3776 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
ba682537 | 3777 | |
7ec4159b DS |
3778 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
3779 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3780 | oi->output_cost, VTY_NEWLINE); | |
718e3744 | 3781 | |
7ec4159b DS |
3782 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
3783 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3784 | PRIORITY (oi), VTY_NEWLINE); | |
3785 | } | |
718e3744 | 3786 | |
3787 | /* Show DR information. */ | |
3788 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3789 | { |
3790 | if (!use_json) | |
3791 | vty_out (vty, " No backup designated router on this network%s", | |
3792 | VTY_NEWLINE); | |
3793 | } | |
718e3744 | 3794 | else |
7ec4159b DS |
3795 | { |
3796 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3797 | if (nbr == NULL) | |
3798 | { | |
3799 | if (!use_json) | |
3800 | vty_out (vty, " No backup designated router on this network%s", | |
3801 | VTY_NEWLINE); | |
3802 | } | |
3803 | else | |
3804 | { | |
3805 | if (use_json) | |
3806 | { | |
3807 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3808 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3809 | } | |
3810 | else | |
3811 | { | |
3812 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3813 | inet_ntoa (nbr->router_id)); | |
3814 | vty_out (vty, " Interface Address %s%s", | |
3815 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3816 | } | |
3817 | } | |
3818 | } | |
525c1839 | 3819 | |
7eb5b47e | 3820 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3821 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3822 | { |
7ec4159b DS |
3823 | if (use_json) |
3824 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3825 | else | |
3826 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3827 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3828 | } | |
3829 | ||
3830 | if (use_json) | |
3831 | { | |
3832 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3833 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3834 | { | |
3835 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3836 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3837 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3838 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3839 | } | |
429ac78c PJ |
3840 | } |
3841 | else | |
7ec4159b DS |
3842 | { |
3843 | vty_out (vty, " Multicast group memberships:"); | |
3844 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3845 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3846 | { | |
3847 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3848 | vty_out (vty, " OSPFAllRouters"); | |
3849 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3850 | vty_out (vty, " OSPFDesignatedRouters"); | |
3851 | } | |
3852 | else | |
3853 | vty_out (vty, " <None>"); | |
3854 | vty_out (vty, "%s", VTY_NEWLINE); | |
3855 | } | |
ba6454ec | 3856 | |
7ec4159b DS |
3857 | if (use_json) |
3858 | { | |
3859 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3860 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3861 | else | |
3862 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3863 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3864 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3865 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3866 | } | |
f9ad937f | 3867 | else |
7ec4159b DS |
3868 | { |
3869 | vty_out (vty, " Timer intervals configured,"); | |
3870 | vty_out (vty, " Hello "); | |
3871 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3872 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3873 | else | |
3874 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3875 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3876 | OSPF_IF_PARAM (oi, v_wait), | |
3877 | OSPF_IF_PARAM (oi, v_wait), | |
3878 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3879 | VTY_NEWLINE); | |
3880 | } | |
3881 | ||
7ffa8fa2 | 3882 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3883 | { |
7ec4159b DS |
3884 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3885 | if (use_json) | |
3886 | { | |
3887 | struct timeval result; | |
3888 | unsigned long time_store = 0; | |
b8dfa544 DS |
3889 | if (oi->t_hello) |
3890 | result = tv_sub (oi->t_hello->u.sands, recent_relative_time()); | |
3891 | else | |
3892 | { | |
3893 | result.tv_sec = 0; | |
3894 | result.tv_usec = 0; | |
3895 | } | |
7ec4159b DS |
3896 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); |
3897 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); | |
3898 | } | |
3899 | else | |
3900 | vty_out (vty, " Hello due in %s%s", | |
3901 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
3902 | VTY_NEWLINE); | |
f9ad937f | 3903 | } |
7ffa8fa2 | 3904 | else /* passive-interface is set */ |
7ec4159b DS |
3905 | { |
3906 | if (use_json) | |
3907 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3908 | else | |
3909 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); | |
3910 | } | |
3911 | ||
3912 | if (use_json) | |
3913 | { | |
3914 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3915 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3916 | } | |
3917 | else | |
3918 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3919 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
3920 | VTY_NEWLINE); | |
68fe91d6 | 3921 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3922 | } |
3923 | } | |
3924 | ||
7c8ff89e | 3925 | static int |
7ec4159b DS |
3926 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
3927 | const char **argv, int iface_argv, u_char use_json) | |
718e3744 | 3928 | { |
3929 | struct interface *ifp; | |
52dc7ee6 | 3930 | struct listnode *node; |
7ec4159b DS |
3931 | json_object *json = NULL; |
3932 | json_object *json_interface_sub = NULL; | |
3933 | ||
3934 | if (use_json) | |
3935 | { | |
3936 | json = json_object_new_object(); | |
3937 | json_interface_sub = json_object_new_object(); | |
3938 | } | |
718e3744 | 3939 | |
7c8ff89e | 3940 | if (ospf->instance) |
7ec4159b DS |
3941 | { |
3942 | if (use_json) | |
3943 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3944 | else | |
3945 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3946 | VTY_NEWLINE, VTY_NEWLINE); | |
3947 | } | |
7c8ff89e | 3948 | |
7ec4159b DS |
3949 | if (argc == (iface_argv + 1)) |
3950 | { | |
3951 | /* Show All Interfaces.*/ | |
b2d7c082 | 3952 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3953 | { |
3954 | if (ospf_oi_count(ifp)) | |
3955 | { | |
3956 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3957 | if (use_json) |
3958 | json_object_object_add (json, ifp->name, json_interface_sub); | |
7ec4159b DS |
3959 | } |
3960 | } | |
3961 | } | |
3962 | else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0) | |
cac3b5c4 | 3963 | { |
b8dfa544 DS |
3964 | if (!use_json) |
3965 | { | |
3966 | json = json_object_new_object(); | |
3967 | json_interface_sub = json_object_new_object (); | |
3968 | use_json = 1; | |
3969 | } | |
7c8ff89e | 3970 | /* Show All Interfaces. */ |
b2d7c082 | 3971 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3972 | { |
3973 | if (ospf_oi_count(ifp)) | |
3974 | { | |
3975 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3976 | if (use_json) |
3977 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3978 | } | |
3979 | } | |
cac3b5c4 | 3980 | } |
718e3744 | 3981 | else |
3982 | { | |
7c8ff89e | 3983 | /* Interface name is specified. */ |
7ec4159b DS |
3984 | if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL) |
3985 | { | |
3986 | if (use_json) | |
3987 | json_object_boolean_true_add(json, "noSuchIface"); | |
3988 | else | |
3989 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
3990 | } | |
718e3744 | 3991 | else |
7ec4159b DS |
3992 | { |
3993 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3994 | if (use_json) | |
3995 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3996 | } | |
718e3744 | 3997 | } |
3998 | ||
7ec4159b DS |
3999 | if (use_json) |
4000 | { | |
4001 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4002 | json_object_free(json); | |
4003 | } | |
4004 | else | |
4005 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4006 | |
718e3744 | 4007 | return CMD_SUCCESS; |
4008 | } | |
4009 | ||
7c8ff89e DS |
4010 | DEFUN (show_ip_ospf_interface, |
4011 | show_ip_ospf_interface_cmd, | |
b162fa78 | 4012 | "show ip ospf interface [INTERFACE] [json]", |
7c8ff89e DS |
4013 | SHOW_STR |
4014 | IP_STR | |
4015 | "OSPF information\n" | |
4016 | "Interface information\n" | |
7ec4159b DS |
4017 | "Interface name\n" |
4018 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4019 | { |
4020 | struct ospf *ospf; | |
db7c8528 | 4021 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4022 | |
0bad4851 | 4023 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4024 | return CMD_SUCCESS; |
4025 | ||
db7c8528 | 4026 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj); |
7c8ff89e DS |
4027 | } |
4028 | ||
4029 | DEFUN (show_ip_ospf_instance_interface, | |
4030 | show_ip_ospf_instance_interface_cmd, | |
6147e2c6 | 4031 | "show ip ospf (1-65535) interface [INTERFACE] [json]", |
7c8ff89e DS |
4032 | SHOW_STR |
4033 | IP_STR | |
4034 | "OSPF information\n" | |
4035 | "Instance ID\n" | |
4036 | "Interface information\n" | |
7ec4159b DS |
4037 | "Interface name\n" |
4038 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4039 | { |
4040 | struct ospf *ospf; | |
4041 | u_short instance = 0; | |
db7c8528 | 4042 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4043 | |
bf2bfafd | 4044 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4045 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4046 | return CMD_SUCCESS; |
4047 | ||
db7c8528 | 4048 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj); |
7c8ff89e DS |
4049 | } |
4050 | ||
d24f6e2a | 4051 | static void |
4052 | show_ip_ospf_neighbour_header (struct vty *vty) | |
4053 | { | |
490578f3 | 4054 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 4055 | VTY_NEWLINE, |
4056 | "Neighbor ID", "Pri", "State", "Dead Time", | |
4057 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
4058 | VTY_NEWLINE); | |
4059 | } | |
4060 | ||
4dadc291 | 4061 | static void |
91756b38 | 4062 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 4063 | { |
4064 | struct route_node *rn; | |
4065 | struct ospf_neighbor *nbr; | |
4066 | char msgbuf[16]; | |
649654ab | 4067 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 4068 | json_object *json_neighbor = NULL; |
718e3744 | 4069 | |
4070 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
4071 | { |
4072 | if ((nbr = rn->info)) | |
4073 | { | |
4074 | /* Do not show myself. */ | |
4075 | if (nbr != oi->nbr_self) | |
4076 | { | |
4077 | /* Down state is not shown. */ | |
4078 | if (nbr->state != NSM_Down) | |
4079 | { | |
4080 | if (use_json) | |
4081 | { | |
4082 | json_neighbor = json_object_new_object(); | |
4083 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4084 | ||
4085 | struct timeval result; | |
4086 | unsigned long time_store = 0; | |
4087 | ||
4088 | result = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time()); | |
4089 | time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000); | |
4090 | ||
4091 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
4092 | json_object_string_add (json_neighbor, "state", msgbuf); | |
4093 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
4094 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
4095 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4096 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
4097 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
4098 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
4099 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
4100 | json_object_object_add(json, "neighbor", json_neighbor); | |
4101 | else | |
4102 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
4103 | } | |
4104 | else | |
4105 | { | |
4106 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
4107 | ||
4108 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4109 | vty_out (vty, "%-15s %3d %-15s ", | |
4110 | "-", nbr->priority, | |
4111 | msgbuf); | |
4112 | else | |
4113 | vty_out (vty, "%-15s %3d %-15s ", | |
4114 | inet_ntoa (nbr->router_id), nbr->priority, | |
4115 | msgbuf); | |
4116 | ||
4117 | vty_out (vty, "%9s ", | |
4118 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
4119 | sizeof(timebuf))); | |
4120 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
4121 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
4122 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
4123 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
4124 | VTY_NEWLINE); | |
4125 | } | |
4126 | } | |
4127 | } | |
4128 | } | |
4129 | } | |
718e3744 | 4130 | } |
4131 | ||
7c8ff89e | 4132 | static int |
91756b38 | 4133 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 4134 | { |
1eb8ef25 | 4135 | struct ospf_interface *oi; |
52dc7ee6 | 4136 | struct listnode *node; |
91756b38 | 4137 | json_object *json = NULL; |
718e3744 | 4138 | |
91756b38 DS |
4139 | if (use_json) |
4140 | json = json_object_new_object(); | |
4141 | else | |
4142 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 4143 | |
91756b38 DS |
4144 | if (ospf->instance) |
4145 | { | |
4146 | if (use_json) | |
4147 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4148 | else | |
4149 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4150 | VTY_NEWLINE, VTY_NEWLINE); | |
4151 | } | |
718e3744 | 4152 | |
1eb8ef25 | 4153 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 4154 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4155 | |
91756b38 DS |
4156 | if (use_json) |
4157 | { | |
4158 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4159 | json_object_free(json); | |
4160 | } | |
4161 | else | |
4162 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4163 | |
718e3744 | 4164 | return CMD_SUCCESS; |
4165 | } | |
4166 | ||
7c8ff89e DS |
4167 | DEFUN (show_ip_ospf_neighbor, |
4168 | show_ip_ospf_neighbor_cmd, | |
b162fa78 | 4169 | "show ip ospf neighbor [json]", |
718e3744 | 4170 | SHOW_STR |
4171 | IP_STR | |
4172 | "OSPF information\n" | |
91756b38 DS |
4173 | "Neighbor list\n" |
4174 | "JavaScript Object Notation\n") | |
718e3744 | 4175 | { |
7c8ff89e | 4176 | struct ospf *ospf; |
db7c8528 | 4177 | u_char uj = use_json(argc, argv); |
718e3744 | 4178 | |
0bad4851 | 4179 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4180 | return CMD_SUCCESS; |
4181 | ||
db7c8528 | 4182 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
4183 | } |
4184 | ||
4185 | ||
4186 | DEFUN (show_ip_ospf_instance_neighbor, | |
4187 | show_ip_ospf_instance_neighbor_cmd, | |
6147e2c6 | 4188 | "show ip ospf (1-65535) neighbor [json]", |
7c8ff89e DS |
4189 | SHOW_STR |
4190 | IP_STR | |
4191 | "OSPF information\n" | |
4192 | "Instance ID\n" | |
91756b38 DS |
4193 | "Neighbor list\n" |
4194 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4195 | { |
4196 | struct ospf *ospf; | |
4197 | u_short instance = 0; | |
db7c8528 | 4198 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4199 | |
bf2bfafd | 4200 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4201 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4202 | return CMD_SUCCESS; |
4203 | ||
db7c8528 | 4204 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
4205 | } |
4206 | ||
4207 | static int | |
91756b38 | 4208 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
4209 | { |
4210 | struct listnode *node; | |
4211 | struct ospf_interface *oi; | |
91756b38 DS |
4212 | json_object *json = NULL; |
4213 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 4214 | |
91756b38 DS |
4215 | if (use_json) |
4216 | { | |
4217 | json = json_object_new_object(); | |
4218 | json_neighbor_sub = json_object_new_object(); | |
4219 | } | |
4220 | else | |
4221 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 4222 | |
91756b38 DS |
4223 | if (ospf->instance) |
4224 | { | |
4225 | if (use_json) | |
4226 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4227 | else | |
4228 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4229 | VTY_NEWLINE, VTY_NEWLINE); | |
4230 | } | |
7c8ff89e DS |
4231 | |
4232 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
4233 | { | |
52dc7ee6 | 4234 | struct listnode *nbr_node; |
1eb8ef25 | 4235 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4236 | |
91756b38 | 4237 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4238 | |
91756b38 DS |
4239 | /* print Down neighbor status */ |
4240 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
4241 | { | |
4242 | if (nbr_nbma->nbr == NULL | |
4243 | || nbr_nbma->nbr->state == NSM_Down) | |
4244 | { | |
4245 | if (use_json) | |
4246 | { | |
4247 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
4248 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
4249 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
4250 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
4251 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
4252 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
4253 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
4254 | } | |
4255 | else | |
4256 | { | |
4257 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
4258 | "-", nbr_nbma->priority, "Down", "-"); | |
4259 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
4260 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
4261 | 0, 0, 0, VTY_NEWLINE); | |
4262 | } | |
4263 | } | |
4264 | } | |
718e3744 | 4265 | } |
4266 | ||
91756b38 DS |
4267 | if (use_json) |
4268 | { | |
4269 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4270 | json_object_free(json); | |
4271 | } | |
4272 | else | |
4273 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 4274 | |
718e3744 | 4275 | return CMD_SUCCESS; |
4276 | } | |
4277 | ||
7c8ff89e DS |
4278 | DEFUN (show_ip_ospf_neighbor_all, |
4279 | show_ip_ospf_neighbor_all_cmd, | |
b162fa78 | 4280 | "show ip ospf neighbor all [json]", |
718e3744 | 4281 | SHOW_STR |
4282 | IP_STR | |
4283 | "OSPF information\n" | |
4284 | "Neighbor list\n" | |
91756b38 DS |
4285 | "include down status neighbor\n" |
4286 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4287 | { |
4288 | struct ospf *ospf; | |
db7c8528 | 4289 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4290 | |
0bad4851 | 4291 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4292 | return CMD_SUCCESS; |
4293 | ||
db7c8528 | 4294 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4295 | } |
4296 | ||
4297 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
4298 | show_ip_ospf_instance_neighbor_all_cmd, | |
6147e2c6 | 4299 | "show ip ospf (1-65535) neighbor all [json]", |
7c8ff89e DS |
4300 | SHOW_STR |
4301 | IP_STR | |
4302 | "OSPF information\n" | |
4303 | "Instance ID\n" | |
4304 | "Neighbor list\n" | |
91756b38 DS |
4305 | "include down status neighbor\n" |
4306 | "JavaScript Object Notation\n") | |
718e3744 | 4307 | { |
020709f9 | 4308 | struct ospf *ospf; |
7c8ff89e | 4309 | u_short instance = 0; |
db7c8528 | 4310 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4311 | |
bf2bfafd | 4312 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4313 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4314 | return CMD_SUCCESS; |
4315 | ||
db7c8528 | 4316 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
4317 | } |
4318 | ||
4319 | static int | |
4320 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
91756b38 | 4321 | const char **argv, u_char use_json) |
7c8ff89e | 4322 | { |
bb5b7552 | 4323 | struct interface *ifp; |
4324 | struct route_node *rn; | |
91756b38 DS |
4325 | json_object *json = NULL; |
4326 | ||
4327 | if (use_json) | |
4328 | json = json_object_new_object(); | |
4329 | else | |
4330 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
4331 | |
4332 | if (ospf->instance) | |
91756b38 DS |
4333 | { |
4334 | if (use_json) | |
4335 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4336 | else | |
4337 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4338 | VTY_NEWLINE, VTY_NEWLINE); | |
4339 | } | |
7c8ff89e | 4340 | |
91756b38 | 4341 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4342 | if (!ifp) |
718e3744 | 4343 | { |
91756b38 DS |
4344 | if (use_json) |
4345 | json_object_boolean_true_add(json, "noSuchIface"); | |
4346 | else | |
4347 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4348 | return CMD_WARNING; |
4349 | } | |
d24f6e2a | 4350 | |
bb5b7552 | 4351 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 4352 | { |
bb5b7552 | 4353 | struct ospf_interface *oi = rn->info; |
4354 | ||
4355 | if (oi == NULL) | |
91756b38 | 4356 | continue; |
bb5b7552 | 4357 | |
91756b38 | 4358 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 4359 | } |
4360 | ||
91756b38 DS |
4361 | if (use_json) |
4362 | { | |
4363 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4364 | json_object_free(json); | |
4365 | } | |
4366 | else | |
4367 | vty_out (vty, "%s", VTY_NEWLINE); | |
4368 | ||
718e3744 | 4369 | return CMD_SUCCESS; |
4370 | } | |
4371 | ||
7c8ff89e DS |
4372 | DEFUN (show_ip_ospf_neighbor_int, |
4373 | show_ip_ospf_neighbor_int_cmd, | |
b162fa78 | 4374 | "show ip ospf neighbor IFNAME [json]", |
7c8ff89e DS |
4375 | SHOW_STR |
4376 | IP_STR | |
4377 | "OSPF information\n" | |
4378 | "Neighbor list\n" | |
91756b38 DS |
4379 | "Interface name\n" |
4380 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4381 | { |
4382 | struct ospf *ospf; | |
db7c8528 | 4383 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4384 | |
0bad4851 | 4385 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4386 | return CMD_SUCCESS; |
4387 | ||
db7c8528 | 4388 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4389 | } |
4390 | ||
4391 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
4392 | show_ip_ospf_instance_neighbor_int_cmd, | |
6147e2c6 | 4393 | "show ip ospf (1-65535) neighbor IFNAME [json]", |
7c8ff89e DS |
4394 | SHOW_STR |
4395 | IP_STR | |
4396 | "OSPF information\n" | |
4397 | "Instance ID\n" | |
4398 | "Neighbor list\n" | |
91756b38 DS |
4399 | "Interface name\n" |
4400 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4401 | { |
4402 | struct ospf *ospf; | |
4403 | u_short instance = 0; | |
db7c8528 | 4404 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4405 | |
bf2bfafd | 4406 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4407 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4408 | return CMD_SUCCESS; |
4409 | ||
db7c8528 | 4410 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4411 | } |
4412 | ||
4dadc291 | 4413 | static void |
3ac237f8 MS |
4414 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4415 | u_char use_json, json_object *json) | |
718e3744 | 4416 | { |
649654ab | 4417 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4418 | json_object *json_sub = NULL; |
718e3744 | 4419 | |
3ac237f8 MS |
4420 | if (use_json) |
4421 | json_sub = json_object_new_object(); | |
4422 | else /* Show neighbor ID. */ | |
4423 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4424 | |
4425 | /* Show interface address. */ | |
3ac237f8 MS |
4426 | if (use_json) |
4427 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4428 | else | |
4429 | vty_out (vty, " interface address %s%s", | |
4430 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
4431 | ||
718e3744 | 4432 | /* Show Area ID. */ |
3ac237f8 MS |
4433 | if (use_json) |
4434 | { | |
4435 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4436 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4437 | } | |
4438 | else | |
4439 | vty_out (vty, " In the area %s via interface %s%s", | |
4440 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
4441 | ||
718e3744 | 4442 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4443 | if (use_json) |
4444 | { | |
4445 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4446 | json_object_string_add(json_sub, "nbrState", "down"); | |
4447 | } | |
4448 | else | |
4449 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4450 | nbr_nbma->priority, "Down"); | |
4451 | ||
718e3744 | 4452 | /* Show state changes. */ |
3ac237f8 MS |
4453 | if (use_json) |
4454 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4455 | else | |
4456 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
718e3744 | 4457 | |
4458 | /* Show PollInterval */ | |
3ac237f8 MS |
4459 | if (use_json) |
4460 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4461 | else | |
4462 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
718e3744 | 4463 | |
4464 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4465 | if (use_json) |
4466 | { | |
4467 | struct timeval res = tv_sub (nbr_nbma->t_poll->u.sands, recent_relative_time ()); | |
4468 | unsigned long time_store = 0; | |
4469 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4470 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); | |
4471 | } | |
4472 | else | |
4473 | vty_out (vty, " Poll timer due in %s%s", | |
4474 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
4475 | VTY_NEWLINE); | |
718e3744 | 4476 | |
4477 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4478 | if (use_json) |
4479 | { | |
4480 | if (nbr_nbma->t_poll != NULL) | |
4481 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4482 | } | |
4483 | else | |
4484 | vty_out (vty, " Thread Poll Timer %s%s", | |
4485 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
4486 | ||
4487 | if (use_json) | |
4488 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4489 | } |
4490 | ||
4dadc291 | 4491 | static void |
718e3744 | 4492 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4493 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4494 | { |
649654ab | 4495 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4496 | json_object *json_sub = NULL; |
718e3744 | 4497 | |
3ac237f8 MS |
4498 | if (use_json) |
4499 | json_sub = json_object_new_object(); | |
718e3744 | 4500 | else |
3ac237f8 MS |
4501 | { |
4502 | /* Show neighbor ID. */ | |
4503 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4504 | vty_out (vty, " Neighbor %s,", "-"); | |
4505 | else | |
4506 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4507 | } | |
718e3744 | 4508 | |
4509 | /* Show interface address. */ | |
3ac237f8 MS |
4510 | if (use_json) |
4511 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4512 | else | |
4513 | vty_out (vty, " interface address %s%s", | |
4514 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
4515 | ||
718e3744 | 4516 | /* Show Area ID. */ |
3ac237f8 MS |
4517 | if (use_json) |
4518 | { | |
4519 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4520 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4521 | } | |
4522 | else | |
4523 | vty_out (vty, " In the area %s via interface %s%s", | |
4524 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
4525 | ||
718e3744 | 4526 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4527 | if (use_json) |
4528 | { | |
4529 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4530 | json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4531 | } | |
4532 | else | |
4533 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4534 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4535 | ||
718e3744 | 4536 | /* Show state changes. */ |
3ac237f8 MS |
4537 | if (use_json) |
4538 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4539 | else | |
4540 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
4541 | ||
3fed4160 | 4542 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4543 | { |
3ac237f8 MS |
4544 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
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, "lastPrgrsvChangeMsec", time_store); | |
4550 | } | |
4551 | else | |
4552 | { | |
4553 | vty_out (vty, " Most recent state change statistics:%s", | |
4554 | VTY_NEWLINE); | |
4555 | vty_out (vty, " Progressive change %s ago%s", | |
4556 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4557 | VTY_NEWLINE); | |
4558 | } | |
3fed4160 | 4559 | } |
3ac237f8 | 4560 | |
3fed4160 PJ |
4561 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4562 | { | |
3ac237f8 MS |
4563 | struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
4564 | if (use_json) | |
4565 | { | |
4566 | unsigned long time_store = 0; | |
4567 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4568 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); | |
4569 | if (nbr->last_regress_str) | |
4570 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4571 | } | |
4572 | else | |
4573 | { | |
4574 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4575 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4576 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
4577 | VTY_NEWLINE); | |
4578 | } | |
90c33177 | 4579 | } |
3ac237f8 | 4580 | |
718e3744 | 4581 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4582 | if (use_json) |
4583 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4584 | else | |
4585 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4586 | ||
718e3744 | 4587 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4588 | if (use_json) |
4589 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4590 | else | |
4591 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
4592 | ||
718e3744 | 4593 | /* Show options. */ |
3ac237f8 MS |
4594 | if (use_json) |
4595 | { | |
4596 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4597 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4598 | } | |
4599 | else | |
4600 | vty_out (vty, " Options %d %s%s", nbr->options, | |
4601 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
4602 | ||
718e3744 | 4603 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4604 | if (use_json) |
4605 | { | |
4606 | struct timeval res = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time ()); | |
4607 | unsigned long time_store = 0; | |
4608 | time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000); | |
4609 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); | |
4610 | } | |
4611 | else | |
4612 | vty_out (vty, " Dead timer due in %s%s", | |
4613 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
4614 | VTY_NEWLINE); | |
4615 | ||
718e3744 | 4616 | /* Show Database Summary list. */ |
3ac237f8 MS |
4617 | if (use_json) |
4618 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4619 | else | |
4620 | vty_out (vty, " Database Summary List %d%s", | |
4621 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
4622 | ||
718e3744 | 4623 | /* Show Link State Request list. */ |
3ac237f8 MS |
4624 | if (use_json) |
4625 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4626 | else | |
4627 | vty_out (vty, " Link State Request List %ld%s", | |
4628 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
4629 | ||
718e3744 | 4630 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4631 | if (use_json) |
4632 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4633 | else | |
4634 | vty_out (vty, " Link State Retransmission List %ld%s", | |
4635 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
4636 | ||
718e3744 | 4637 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4638 | if (use_json) |
4639 | { | |
4640 | if (nbr->t_inactivity != NULL) | |
4641 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4642 | } | |
4643 | else | |
4644 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
4645 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
4646 | ||
718e3744 | 4647 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4648 | if (use_json) |
4649 | { | |
4650 | if (nbr->t_db_desc != NULL) | |
4651 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4652 | } | |
4653 | else | |
4654 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
4655 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
4656 | ||
718e3744 | 4657 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4658 | if (use_json) |
4659 | { | |
4660 | if (nbr->t_ls_req != NULL) | |
4661 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4662 | } | |
4663 | else | |
4664 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
4665 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
4666 | ||
718e3744 | 4667 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4668 | if (use_json) |
4669 | { | |
4670 | if (nbr->t_ls_upd != NULL) | |
4671 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4672 | } | |
4673 | else | |
4674 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
4675 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
4676 | ||
4677 | if (use_json) | |
4678 | { | |
4679 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4680 | json_object_object_add(json, "noNbrId", json_sub); | |
4681 | else | |
4682 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4683 | } | |
68fe91d6 | 4684 | |
4685 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4686 | } |
4687 | ||
7c8ff89e DS |
4688 | static int |
4689 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4690 | int arg_base, const char **argv, u_char use_json) |
718e3744 | 4691 | { |
52dc7ee6 | 4692 | struct listnode *node; |
718e3744 | 4693 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4694 | struct ospf_interface *oi; |
718e3744 | 4695 | struct in_addr router_id; |
4696 | int ret; | |
3ac237f8 MS |
4697 | json_object *json = NULL; |
4698 | ||
4699 | if (use_json) | |
4700 | json = json_object_new_object(); | |
718e3744 | 4701 | |
7c8ff89e | 4702 | if (ospf->instance) |
3ac237f8 MS |
4703 | { |
4704 | if (use_json) | |
4705 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4706 | else | |
4707 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4708 | VTY_NEWLINE, VTY_NEWLINE); | |
4709 | } | |
7c8ff89e | 4710 | |
3ac237f8 | 4711 | ret = inet_aton (argv[arg_base], &router_id); |
718e3744 | 4712 | if (!ret) |
4713 | { | |
3ac237f8 MS |
4714 | if (!use_json) |
4715 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
718e3744 | 4716 | return CMD_WARNING; |
4717 | } | |
4718 | ||
1eb8ef25 | 4719 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4720 | { |
4721 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4722 | { | |
4723 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4724 | } | |
4725 | } | |
4726 | ||
4727 | if (use_json) | |
4728 | { | |
4729 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4730 | json_object_free(json); | |
4731 | } | |
4732 | else | |
4733 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4734 | |
718e3744 | 4735 | return CMD_SUCCESS; |
4736 | } | |
4737 | ||
7c8ff89e DS |
4738 | DEFUN (show_ip_ospf_neighbor_id, |
4739 | show_ip_ospf_neighbor_id_cmd, | |
b162fa78 | 4740 | "show ip ospf neighbor A.B.C.D [json]", |
718e3744 | 4741 | SHOW_STR |
4742 | IP_STR | |
4743 | "OSPF information\n" | |
4744 | "Neighbor list\n" | |
3ac237f8 MS |
4745 | "Neighbor ID\n" |
4746 | "JavaScript Object Notation\n") | |
718e3744 | 4747 | { |
020709f9 | 4748 | struct ospf *ospf; |
db7c8528 | 4749 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4750 | |
0bad4851 | 4751 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4752 | return CMD_SUCCESS; |
4753 | ||
db7c8528 | 4754 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4755 | } |
4756 | ||
4757 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4758 | show_ip_ospf_instance_neighbor_id_cmd, | |
6147e2c6 | 4759 | "show ip ospf (1-65535) neighbor A.B.C.D [json]", |
7c8ff89e DS |
4760 | SHOW_STR |
4761 | IP_STR | |
4762 | "OSPF information\n" | |
4763 | "Instance ID\n" | |
4764 | "Neighbor list\n" | |
3ac237f8 MS |
4765 | "Neighbor ID\n" |
4766 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4767 | { |
4768 | struct ospf *ospf; | |
4769 | u_short instance = 0; | |
db7c8528 | 4770 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4771 | |
bf2bfafd | 4772 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4773 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4774 | return CMD_SUCCESS; |
4775 | ||
db7c8528 | 4776 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4777 | } |
4778 | ||
4779 | static int | |
3ac237f8 | 4780 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4781 | { |
1eb8ef25 | 4782 | struct ospf_interface *oi; |
52dc7ee6 | 4783 | struct listnode *node; |
3ac237f8 MS |
4784 | json_object *json = NULL; |
4785 | ||
4786 | if (use_json) | |
4787 | json = json_object_new_object(); | |
718e3744 | 4788 | |
7c8ff89e | 4789 | if (ospf->instance) |
3ac237f8 MS |
4790 | { |
4791 | if (use_json) | |
4792 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4793 | else | |
4794 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4795 | VTY_NEWLINE, VTY_NEWLINE); | |
4796 | } | |
718e3744 | 4797 | |
1eb8ef25 | 4798 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4799 | { |
718e3744 | 4800 | struct route_node *rn; |
4801 | struct ospf_neighbor *nbr; | |
4802 | ||
4803 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4804 | { |
4805 | if ((nbr = rn->info)) | |
4806 | { | |
4807 | if (nbr != oi->nbr_self) | |
4808 | { | |
4809 | if (nbr->state != NSM_Down) | |
4810 | { | |
4811 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4812 | } | |
4813 | } | |
4814 | } | |
4815 | } | |
718e3744 | 4816 | } |
4817 | ||
3ac237f8 MS |
4818 | if (use_json) |
4819 | { | |
4820 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4821 | json_object_free(json); | |
4822 | } | |
4823 | else | |
4824 | vty_out (vty, "%s", VTY_NEWLINE); | |
4825 | ||
718e3744 | 4826 | return CMD_SUCCESS; |
4827 | } | |
4828 | ||
7c8ff89e DS |
4829 | DEFUN (show_ip_ospf_neighbor_detail, |
4830 | show_ip_ospf_neighbor_detail_cmd, | |
b162fa78 | 4831 | "show ip ospf neighbor detail [json]", |
718e3744 | 4832 | SHOW_STR |
4833 | IP_STR | |
4834 | "OSPF information\n" | |
4835 | "Neighbor list\n" | |
3ac237f8 MS |
4836 | "detail of all neighbors\n" |
4837 | "JavaScript Object Notation\n") | |
718e3744 | 4838 | { |
020709f9 | 4839 | struct ospf *ospf; |
db7c8528 | 4840 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4841 | |
0bad4851 | 4842 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4843 | return CMD_SUCCESS; |
4844 | ||
db7c8528 | 4845 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4846 | } |
4847 | ||
4848 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4849 | show_ip_ospf_instance_neighbor_detail_cmd, | |
6147e2c6 | 4850 | "show ip ospf (1-65535) neighbor detail [json]", |
7c8ff89e DS |
4851 | SHOW_STR |
4852 | IP_STR | |
4853 | "OSPF information\n" | |
4854 | "Instance ID\n" | |
4855 | "Neighbor list\n" | |
3ac237f8 MS |
4856 | "detail of all neighbors\n" |
4857 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4858 | { |
4859 | struct ospf *ospf; | |
4860 | u_short instance = 0; | |
db7c8528 | 4861 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4862 | |
bf2bfafd | 4863 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4864 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4865 | return CMD_SUCCESS; |
4866 | ||
db7c8528 | 4867 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4868 | } |
4869 | ||
4870 | static int | |
3ac237f8 | 4871 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4872 | { |
52dc7ee6 | 4873 | struct listnode *node; |
1eb8ef25 | 4874 | struct ospf_interface *oi; |
3ac237f8 MS |
4875 | json_object *json = NULL; |
4876 | ||
4877 | if (use_json) | |
4878 | json = json_object_new_object(); | |
718e3744 | 4879 | |
7c8ff89e | 4880 | if (ospf->instance) |
3ac237f8 MS |
4881 | { |
4882 | if (use_json) | |
4883 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4884 | else | |
4885 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4886 | VTY_NEWLINE, VTY_NEWLINE); | |
4887 | } | |
718e3744 | 4888 | |
1eb8ef25 | 4889 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4890 | { |
718e3744 | 4891 | struct route_node *rn; |
4892 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4893 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4894 | |
4895 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4896 | if ((nbr = rn->info)) | |
4897 | if (nbr != oi->nbr_self) | |
4898 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) | |
3ac237f8 | 4899 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4900 | |
4901 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4902 | { |
4903 | struct listnode *nd; | |
718e3744 | 4904 | |
3ac237f8 MS |
4905 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4906 | { | |
4907 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4908 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4909 | } | |
4910 | } | |
4911 | } | |
4912 | ||
4913 | if (use_json) | |
4914 | { | |
4915 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
4916 | json_object_free(json); | |
4917 | } | |
4918 | else | |
4919 | { | |
4920 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4921 | } |
4922 | ||
4923 | return CMD_SUCCESS; | |
4924 | } | |
4925 | ||
7c8ff89e DS |
4926 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4927 | show_ip_ospf_neighbor_detail_all_cmd, | |
b162fa78 | 4928 | "show ip ospf neighbor detail all [json]", |
718e3744 | 4929 | SHOW_STR |
4930 | IP_STR | |
4931 | "OSPF information\n" | |
4932 | "Neighbor list\n" | |
7c8ff89e | 4933 | "detail of all neighbors\n" |
3ac237f8 MS |
4934 | "include down status neighbor\n" |
4935 | "JavaScript Object Notation\n") | |
718e3744 | 4936 | { |
020709f9 | 4937 | struct ospf *ospf; |
db7c8528 | 4938 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4939 | |
0bad4851 | 4940 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4941 | return CMD_SUCCESS; |
4942 | ||
db7c8528 | 4943 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4944 | } |
4945 | ||
4946 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4947 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
6147e2c6 | 4948 | "show ip ospf (1-65535) neighbor detail all [json]", |
7c8ff89e DS |
4949 | SHOW_STR |
4950 | IP_STR | |
4951 | "OSPF information\n" | |
4952 | "Instance ID\n" | |
4953 | "Neighbor list\n" | |
4954 | "detail of all neighbors\n" | |
3ac237f8 MS |
4955 | "include down status neighbor\n" |
4956 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
4957 | { |
4958 | struct ospf *ospf; | |
4959 | u_short instance = 0; | |
db7c8528 | 4960 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4961 | |
bf2bfafd | 4962 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 4963 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4964 | return CMD_SUCCESS; |
4965 | ||
db7c8528 | 4966 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4967 | } |
4968 | ||
4969 | static int | |
4970 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
3ac237f8 | 4971 | int arg_base, const char **argv, u_char use_json) |
7c8ff89e | 4972 | { |
718e3744 | 4973 | struct ospf_interface *oi; |
bb5b7552 | 4974 | struct interface *ifp; |
4975 | struct route_node *rn, *nrn; | |
4976 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4977 | json_object *json = NULL; |
4978 | ||
4979 | if (use_json) | |
4980 | json = json_object_new_object(); | |
bb5b7552 | 4981 | |
7c8ff89e | 4982 | if (ospf->instance) |
3ac237f8 MS |
4983 | { |
4984 | if (use_json) | |
4985 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4986 | else | |
4987 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4988 | VTY_NEWLINE, VTY_NEWLINE); | |
4989 | } | |
7c8ff89e | 4990 | |
3ac237f8 | 4991 | ifp = if_lookup_by_name (argv[arg_base]); |
bb5b7552 | 4992 | if (!ifp) |
718e3744 | 4993 | { |
3ac237f8 MS |
4994 | if (!use_json) |
4995 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4996 | return CMD_WARNING; |
4997 | } | |
4998 | ||
bb5b7552 | 4999 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
5000 | { |
5001 | if ((oi = rn->info)) | |
5002 | { | |
5003 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
5004 | { | |
5005 | if ((nbr = nrn->info)) | |
5006 | { | |
5007 | if (nbr != oi->nbr_self) | |
5008 | { | |
5009 | if (nbr->state != NSM_Down) | |
5010 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
5011 | } | |
5012 | } | |
5013 | } | |
5014 | } | |
5015 | } | |
5016 | ||
5017 | if (use_json) | |
5018 | { | |
5019 | vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE); | |
5020 | json_object_free(json); | |
5021 | } | |
5022 | else | |
5023 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 5024 | |
5025 | return CMD_SUCCESS; | |
5026 | } | |
5027 | ||
7c8ff89e DS |
5028 | DEFUN (show_ip_ospf_neighbor_int_detail, |
5029 | show_ip_ospf_neighbor_int_detail_cmd, | |
b162fa78 | 5030 | "show ip ospf neighbor IFNAME detail [json]", |
7c8ff89e DS |
5031 | SHOW_STR |
5032 | IP_STR | |
5033 | "OSPF information\n" | |
5034 | "Neighbor list\n" | |
5035 | "Interface name\n" | |
3ac237f8 MS |
5036 | "detail of all neighbors\n" |
5037 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5038 | { |
5039 | struct ospf *ospf; | |
db7c8528 | 5040 | u_char uj = use_json(argc, argv); |
7c8ff89e | 5041 | |
0bad4851 | 5042 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5043 | return CMD_SUCCESS; |
5044 | ||
db7c8528 | 5045 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
5046 | } |
5047 | ||
5048 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
5049 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
6147e2c6 | 5050 | "show ip ospf (1-65535) neighbor IFNAME detail [json]", |
7c8ff89e DS |
5051 | SHOW_STR |
5052 | IP_STR | |
5053 | "OSPF information\n" | |
5054 | "Instance ID\n" | |
5055 | "Neighbor list\n" | |
5056 | "Interface name\n" | |
3ac237f8 MS |
5057 | "detail of all neighbors\n" |
5058 | "JavaScript Object Notation\n") | |
7c8ff89e DS |
5059 | { |
5060 | struct ospf *ospf; | |
5061 | u_short instance = 0; | |
db7c8528 | 5062 | u_char uj = use_json(argc, argv); |
7c8ff89e | 5063 | |
bf2bfafd | 5064 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 5065 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5066 | return CMD_SUCCESS; |
5067 | ||
db7c8528 | 5068 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); |
7c8ff89e | 5069 | } |
6b0655a2 | 5070 | |
718e3744 | 5071 | /* Show functions */ |
4dadc291 | 5072 | static int |
020709f9 | 5073 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 5074 | { |
718e3744 | 5075 | struct router_lsa *rl; |
5076 | struct summary_lsa *sl; | |
5077 | struct as_external_lsa *asel; | |
5078 | struct prefix_ipv4 p; | |
5079 | ||
5080 | if (lsa != NULL) | |
5081 | /* If self option is set, check LSA self flag. */ | |
5082 | if (self == 0 || IS_LSA_SELF (lsa)) | |
5083 | { | |
5084 | /* LSA common part show. */ | |
5085 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
5086 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
5087 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
5088 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
5089 | /* LSA specific part show. */ | |
5090 | switch (lsa->data->type) | |
5091 | { | |
5092 | case OSPF_ROUTER_LSA: | |
5093 | rl = (struct router_lsa *) lsa->data; | |
5094 | vty_out (vty, " %-d", ntohs (rl->links)); | |
5095 | break; | |
5096 | case OSPF_SUMMARY_LSA: | |
5097 | sl = (struct summary_lsa *) lsa->data; | |
5098 | ||
5099 | p.family = AF_INET; | |
5100 | p.prefix = sl->header.id; | |
5101 | p.prefixlen = ip_masklen (sl->mask); | |
5102 | apply_mask_ipv4 (&p); | |
5103 | ||
5104 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
5105 | break; | |
5106 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 5107 | case OSPF_AS_NSSA_LSA: |
718e3744 | 5108 | asel = (struct as_external_lsa *) lsa->data; |
5109 | ||
5110 | p.family = AF_INET; | |
5111 | p.prefix = asel->header.id; | |
5112 | p.prefixlen = ip_masklen (asel->mask); | |
5113 | apply_mask_ipv4 (&p); | |
5114 | ||
5115 | vty_out (vty, " %s %s/%d [0x%lx]", | |
5116 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
5117 | inet_ntoa (p.prefix), p.prefixlen, | |
5118 | (u_long)ntohl (asel->e[0].route_tag)); | |
5119 | break; | |
5120 | case OSPF_NETWORK_LSA: | |
5121 | case OSPF_ASBR_SUMMARY_LSA: | |
718e3744 | 5122 | case OSPF_OPAQUE_LINK_LSA: |
5123 | case OSPF_OPAQUE_AREA_LSA: | |
5124 | case OSPF_OPAQUE_AS_LSA: | |
718e3744 | 5125 | default: |
5126 | break; | |
5127 | } | |
5128 | vty_out (vty, VTY_NEWLINE); | |
5129 | } | |
5130 | ||
5131 | return 0; | |
5132 | } | |
5133 | ||
8b6a15b2 | 5134 | static const char *show_database_desc[] = |
718e3744 | 5135 | { |
5136 | "unknown", | |
5137 | "Router Link States", | |
5138 | "Net Link States", | |
5139 | "Summary Link States", | |
5140 | "ASBR-Summary Link States", | |
5141 | "AS External Link States", | |
718e3744 | 5142 | "Group Membership LSA", |
5143 | "NSSA-external Link States", | |
718e3744 | 5144 | "Type-8 LSA", |
5145 | "Link-Local Opaque-LSA", | |
5146 | "Area-Local Opaque-LSA", | |
5147 | "AS-external Opaque-LSA", | |
718e3744 | 5148 | }; |
5149 | ||
8b6a15b2 | 5150 | static const char *show_database_header[] = |
718e3744 | 5151 | { |
5152 | "", | |
5153 | "Link ID ADV Router Age Seq# CkSum Link count", | |
5154 | "Link ID ADV Router Age Seq# CkSum", | |
5155 | "Link ID ADV Router Age Seq# CkSum Route", | |
5156 | "Link ID ADV Router Age Seq# CkSum", | |
5157 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5158 | " --- header for Group Member ----", |
5159 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 5160 | " --- type-8 ---", |
5161 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5162 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5163 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
718e3744 | 5164 | }; |
5165 | ||
4dadc291 | 5166 | static void |
718e3744 | 5167 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
5168 | { | |
5169 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 5170 | |
718e3744 | 5171 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 5172 | vty_out (vty, " Options: 0x%-2x : %s%s", |
5173 | lsa->data->options, | |
5174 | ospf_options_dump(lsa->data->options), | |
5175 | VTY_NEWLINE); | |
5176 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 5177 | lsa->flags, |
4957f494 | 5178 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
5179 | VTY_NEWLINE); | |
718e3744 | 5180 | |
5181 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
5182 | { | |
5183 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
5184 | ||
5185 | if (rlsa->flags) | |
5186 | vty_out (vty, " :%s%s%s%s", | |
5187 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
5188 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
5189 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
5190 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
5191 | ||
5192 | vty_out (vty, "%s", VTY_NEWLINE); | |
5193 | } | |
5194 | vty_out (vty, " LS Type: %s%s", | |
5195 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
5196 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
5197 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
5198 | vty_out (vty, " Advertising Router: %s%s", | |
5199 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5200 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
5201 | VTY_NEWLINE); | |
5202 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
5203 | VTY_NEWLINE); | |
5204 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
5205 | } | |
5206 | ||
eb1ce605 | 5207 | const char *link_type_desc[] = |
718e3744 | 5208 | { |
5209 | "(null)", | |
5210 | "another Router (point-to-point)", | |
5211 | "a Transit Network", | |
5212 | "Stub Network", | |
5213 | "a Virtual Link", | |
5214 | }; | |
5215 | ||
eb1ce605 | 5216 | const char *link_id_desc[] = |
718e3744 | 5217 | { |
5218 | "(null)", | |
5219 | "Neighboring Router ID", | |
5220 | "Designated Router address", | |
68980084 | 5221 | "Net", |
718e3744 | 5222 | "Neighboring Router ID", |
5223 | }; | |
5224 | ||
eb1ce605 | 5225 | const char *link_data_desc[] = |
718e3744 | 5226 | { |
5227 | "(null)", | |
5228 | "Router Interface address", | |
5229 | "Router Interface address", | |
5230 | "Network Mask", | |
5231 | "Router Interface address", | |
5232 | }; | |
5233 | ||
5234 | /* Show router-LSA each Link information. */ | |
4dadc291 | 5235 | static void |
718e3744 | 5236 | show_ip_ospf_database_router_links (struct vty *vty, |
5237 | struct router_lsa *rl) | |
5238 | { | |
b07c4cb3 DS |
5239 | int len, type; |
5240 | unsigned int i; | |
718e3744 | 5241 | |
5242 | len = ntohs (rl->header.length) - 4; | |
5243 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
5244 | { | |
5245 | type = rl->link[i].type; | |
5246 | ||
5247 | vty_out (vty, " Link connected to: %s%s", | |
5248 | link_type_desc[type], VTY_NEWLINE); | |
5249 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
5250 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
5251 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
5252 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
5253 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
5254 | vty_out (vty, " TOS 0 Metric: %d%s", | |
5255 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
5256 | vty_out (vty, "%s", VTY_NEWLINE); | |
5257 | } | |
5258 | } | |
5259 | ||
5260 | /* Show router-LSA detail information. */ | |
4dadc291 | 5261 | static int |
718e3744 | 5262 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5263 | { | |
5264 | if (lsa != NULL) | |
5265 | { | |
5266 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
5267 | ||
5268 | show_ip_ospf_database_header (vty, lsa); | |
5269 | ||
5270 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
5271 | VTY_NEWLINE, VTY_NEWLINE); | |
5272 | ||
5273 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 5274 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5275 | } |
5276 | ||
5277 | return 0; | |
5278 | } | |
5279 | ||
5280 | /* Show network-LSA detail information. */ | |
4dadc291 | 5281 | static int |
718e3744 | 5282 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5283 | { | |
5284 | int length, i; | |
5285 | ||
5286 | if (lsa != NULL) | |
5287 | { | |
5288 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
5289 | ||
5290 | show_ip_ospf_database_header (vty, lsa); | |
5291 | ||
5292 | vty_out (vty, " Network Mask: /%d%s", | |
5293 | ip_masklen (nl->mask), VTY_NEWLINE); | |
5294 | ||
5295 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
5296 | ||
5297 | for (i = 0; length > 0; i++, length -= 4) | |
5298 | vty_out (vty, " Attached Router: %s%s", | |
5299 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
5300 | ||
5301 | vty_out (vty, "%s", VTY_NEWLINE); | |
5302 | } | |
5303 | ||
5304 | return 0; | |
5305 | } | |
5306 | ||
5307 | /* Show summary-LSA detail information. */ | |
4dadc291 | 5308 | static int |
718e3744 | 5309 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5310 | { | |
5311 | if (lsa != NULL) | |
5312 | { | |
5313 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5314 | ||
5315 | show_ip_ospf_database_header (vty, lsa); | |
5316 | ||
5317 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
5318 | VTY_NEWLINE); | |
5319 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5320 | VTY_NEWLINE); | |
b0a053be | 5321 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5322 | } |
5323 | ||
5324 | return 0; | |
5325 | } | |
5326 | ||
5327 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 5328 | static int |
718e3744 | 5329 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5330 | { | |
5331 | if (lsa != NULL) | |
5332 | { | |
5333 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
5334 | ||
5335 | show_ip_ospf_database_header (vty, lsa); | |
5336 | ||
5337 | vty_out (vty, " Network Mask: /%d%s", | |
5338 | ip_masklen (sl->mask), VTY_NEWLINE); | |
5339 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
5340 | VTY_NEWLINE); | |
b0a053be | 5341 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 5342 | } |
5343 | ||
5344 | return 0; | |
5345 | } | |
5346 | ||
5347 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 5348 | static int |
718e3744 | 5349 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5350 | { | |
5351 | if (lsa != NULL) | |
5352 | { | |
5353 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5354 | ||
5355 | show_ip_ospf_database_header (vty, lsa); | |
5356 | ||
5357 | vty_out (vty, " Network Mask: /%d%s", | |
5358 | ip_masklen (al->mask), VTY_NEWLINE); | |
5359 | vty_out (vty, " Metric Type: %s%s", | |
5360 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5361 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5362 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5363 | vty_out (vty, " Metric: %d%s", | |
5364 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5365 | vty_out (vty, " Forward Address: %s%s", | |
5366 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5367 | ||
5368 | vty_out (vty, " External Route Tag: %lu%s%s", | |
5369 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
5370 | } | |
5371 | ||
5372 | return 0; | |
5373 | } | |
5374 | ||
075e12f5 | 5375 | #if 0 |
4dadc291 | 5376 | static int |
718e3744 | 5377 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
5378 | { | |
5379 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5380 | ||
5381 | /* show_ip_ospf_database_header (vty, lsa); */ | |
5382 | ||
2a42e285 | 5383 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 5384 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5385 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5386 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5387 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5388 | zlog_debug( " TOS: 0%s", "\n"); |
5389 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5390 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5391 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5392 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5393 | ||
2a42e285 | 5394 | zlog_debug( " External Route Tag: %u%s%s", |
718e3744 | 5395 | ntohl (al->e[0].route_tag), "\n", "\n"); |
5396 | ||
5397 | return 0; | |
5398 | } | |
075e12f5 | 5399 | #endif |
718e3744 | 5400 | |
5401 | /* Show AS-NSSA-LSA detail information. */ | |
4dadc291 | 5402 | static int |
718e3744 | 5403 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5404 | { | |
5405 | if (lsa != NULL) | |
5406 | { | |
5407 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5408 | ||
5409 | show_ip_ospf_database_header (vty, lsa); | |
5410 | ||
5411 | vty_out (vty, " Network Mask: /%d%s", | |
5412 | ip_masklen (al->mask), VTY_NEWLINE); | |
5413 | vty_out (vty, " Metric Type: %s%s", | |
5414 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5415 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5416 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5417 | vty_out (vty, " Metric: %d%s", | |
5418 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5419 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
5420 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5421 | ||
5422 | vty_out (vty, " External Route Tag: %u%s%s", | |
5423 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
5424 | } | |
5425 | ||
5426 | return 0; | |
5427 | } | |
5428 | ||
4dadc291 | 5429 | static int |
718e3744 | 5430 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5431 | { | |
5432 | return 0; | |
5433 | } | |
5434 | ||
4dadc291 | 5435 | static int |
718e3744 | 5436 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5437 | { | |
5438 | if (lsa != NULL) | |
5439 | { | |
5440 | show_ip_ospf_database_header (vty, lsa); | |
5441 | show_opaque_info_detail (vty, lsa); | |
5442 | ||
5443 | vty_out (vty, "%s", VTY_NEWLINE); | |
5444 | } | |
5445 | return 0; | |
5446 | } | |
718e3744 | 5447 | |
5448 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5449 | { | |
5450 | NULL, | |
5451 | show_router_lsa_detail, | |
5452 | show_network_lsa_detail, | |
5453 | show_summary_lsa_detail, | |
5454 | show_summary_asbr_lsa_detail, | |
5455 | show_as_external_lsa_detail, | |
718e3744 | 5456 | show_func_dummy, |
5457 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5458 | NULL, /* type-8 */ |
5459 | show_opaque_lsa_detail, | |
5460 | show_opaque_lsa_detail, | |
5461 | show_opaque_lsa_detail, | |
718e3744 | 5462 | }; |
5463 | ||
4dadc291 | 5464 | static void |
718e3744 | 5465 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5466 | struct in_addr *adv_router) | |
5467 | { | |
5468 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5469 | lp->family = 0; | |
5470 | if (id == NULL) | |
5471 | lp->prefixlen = 0; | |
5472 | else if (adv_router == NULL) | |
5473 | { | |
5474 | lp->prefixlen = 32; | |
5475 | lp->id = *id; | |
5476 | } | |
5477 | else | |
5478 | { | |
5479 | lp->prefixlen = 64; | |
5480 | lp->id = *id; | |
5481 | lp->adv_router = *adv_router; | |
5482 | } | |
5483 | } | |
5484 | ||
4dadc291 | 5485 | static void |
718e3744 | 5486 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5487 | struct in_addr *id, struct in_addr *adv_router) | |
5488 | { | |
5489 | struct prefix_ls lp; | |
5490 | struct route_node *rn, *start; | |
5491 | struct ospf_lsa *lsa; | |
5492 | ||
5493 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5494 | start = route_node_get (rt, (struct prefix *) &lp); | |
5495 | if (start) | |
5496 | { | |
5497 | route_lock_node (start); | |
5498 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5499 | if ((lsa = rn->info)) | |
5500 | { | |
718e3744 | 5501 | if (show_function[lsa->data->type] != NULL) |
5502 | show_function[lsa->data->type] (vty, lsa); | |
5503 | } | |
5504 | route_unlock_node (start); | |
5505 | } | |
5506 | } | |
5507 | ||
5508 | /* Show detail LSA information | |
5509 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5510 | static void |
020709f9 | 5511 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5512 | struct in_addr *id, struct in_addr *adv_router) |
5513 | { | |
52dc7ee6 | 5514 | struct listnode *node; |
1eb8ef25 | 5515 | struct ospf_area *area; |
5516 | ||
718e3744 | 5517 | switch (type) |
5518 | { | |
5519 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5520 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5521 | vty_out (vty, " %s %s%s", |
5522 | show_database_desc[type], | |
5523 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5524 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5525 | break; |
5526 | default: | |
1eb8ef25 | 5527 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5528 | { |
718e3744 | 5529 | vty_out (vty, "%s %s (Area %s)%s%s", |
5530 | VTY_NEWLINE, show_database_desc[type], | |
5531 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5532 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
5533 | } | |
5534 | break; | |
5535 | } | |
5536 | } | |
5537 | ||
4dadc291 | 5538 | static void |
718e3744 | 5539 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5540 | struct in_addr *adv_router) | |
5541 | { | |
5542 | struct route_node *rn; | |
5543 | struct ospf_lsa *lsa; | |
5544 | ||
5545 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5546 | if ((lsa = rn->info)) | |
5547 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5548 | { | |
718e3744 | 5549 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5550 | continue; | |
718e3744 | 5551 | if (show_function[lsa->data->type] != NULL) |
5552 | show_function[lsa->data->type] (vty, lsa); | |
5553 | } | |
5554 | } | |
5555 | ||
5556 | /* Show detail LSA information. */ | |
4dadc291 | 5557 | static void |
020709f9 | 5558 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5559 | struct in_addr *adv_router) |
5560 | { | |
52dc7ee6 | 5561 | struct listnode *node; |
1eb8ef25 | 5562 | struct ospf_area *area; |
718e3744 | 5563 | |
5564 | switch (type) | |
5565 | { | |
5566 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5567 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5568 | vty_out (vty, " %s %s%s", |
5569 | show_database_desc[type], | |
5570 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5571 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5572 | adv_router); |
5573 | break; | |
5574 | default: | |
1eb8ef25 | 5575 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5576 | { |
718e3744 | 5577 | vty_out (vty, "%s %s (Area %s)%s%s", |
5578 | VTY_NEWLINE, show_database_desc[type], | |
5579 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5580 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
5581 | adv_router); | |
5582 | } | |
5583 | break; | |
5584 | } | |
5585 | } | |
5586 | ||
4dadc291 | 5587 | static void |
020709f9 | 5588 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5589 | { |
020709f9 | 5590 | struct ospf_lsa *lsa; |
5591 | struct route_node *rn; | |
1eb8ef25 | 5592 | struct ospf_area *area; |
52dc7ee6 | 5593 | struct listnode *node; |
718e3744 | 5594 | int type; |
5595 | ||
1eb8ef25 | 5596 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5597 | { |
718e3744 | 5598 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5599 | { | |
5600 | switch (type) | |
5601 | { | |
5602 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5603 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5604 | continue; |
5605 | default: | |
5606 | break; | |
5607 | } | |
5608 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5609 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5610 | { | |
5611 | vty_out (vty, " %s (Area %s)%s%s", | |
5612 | show_database_desc[type], | |
5613 | ospf_area_desc_string (area), | |
5614 | VTY_NEWLINE, VTY_NEWLINE); | |
5615 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
5616 | ||
020709f9 | 5617 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5618 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5619 | |
5620 | vty_out (vty, "%s", VTY_NEWLINE); | |
5621 | } | |
5622 | } | |
5623 | } | |
5624 | ||
5625 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5626 | { | |
5627 | switch (type) | |
5628 | { | |
5629 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5630 | case OSPF_OPAQUE_AS_LSA: |
e8e1946e | 5631 | break; |
718e3744 | 5632 | default: |
5633 | continue; | |
5634 | } | |
68980084 | 5635 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5636 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5637 | { |
5638 | vty_out (vty, " %s%s%s", | |
5639 | show_database_desc[type], | |
5640 | VTY_NEWLINE, VTY_NEWLINE); | |
5641 | vty_out (vty, "%s%s", show_database_header[type], | |
5642 | VTY_NEWLINE); | |
020709f9 | 5643 | |
5644 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5645 | show_lsa_summary (vty, lsa, self); | |
5646 | ||
718e3744 | 5647 | vty_out (vty, "%s", VTY_NEWLINE); |
5648 | } | |
5649 | } | |
5650 | ||
5651 | vty_out (vty, "%s", VTY_NEWLINE); | |
5652 | } | |
5653 | ||
4dadc291 | 5654 | static void |
020709f9 | 5655 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5656 | { |
91e6a0e5 | 5657 | struct route_node *rn; |
718e3744 | 5658 | |
5659 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
5660 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
5661 | ||
91e6a0e5 | 5662 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5663 | { |
91e6a0e5 DD |
5664 | struct ospf_lsa *lsa; |
5665 | ||
5666 | if ((lsa = rn->info) != NULL) | |
5667 | { | |
5668 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
5669 | vty_out (vty, "Link State ID: %s%s", | |
5670 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
5671 | vty_out (vty, "Advertising Router: %s%s", | |
5672 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5673 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
5674 | vty_out (vty, "%s", VTY_NEWLINE); | |
5675 | } | |
1eb8ef25 | 5676 | } |
718e3744 | 5677 | } |
5678 | ||
718e3744 | 5679 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5680 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5681 | |
718e3744 | 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" | |
718e3744 | 5686 | |
5687 | #define OSPF_LSA_TYPES_CMD_STR \ | |
5688 | "asbr-summary|external|network|router|summary" \ | |
5689 | OSPF_LSA_TYPE_NSSA_CMD_STR \ | |
5690 | OSPF_LSA_TYPE_OPAQUE_CMD_STR | |
5691 | ||
5692 | #define OSPF_LSA_TYPES_DESC \ | |
5693 | "ASBR summary link states\n" \ | |
5694 | "External link states\n" \ | |
5695 | "Network link states\n" \ | |
5696 | "Router link states\n" \ | |
5697 | "Network summary link states\n" \ | |
5698 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5699 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5700 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5701 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5702 | ||
7c8ff89e DS |
5703 | static int |
5704 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
5705 | int arg_base, int argc, const char **argv) | |
718e3744 | 5706 | { |
5707 | int type, ret; | |
5708 | struct in_addr id, adv_router; | |
5709 | ||
7c8ff89e DS |
5710 | if (ospf->instance) |
5711 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5712 | VTY_NEWLINE); | |
718e3744 | 5713 | |
5714 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5715 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5716 | |
5717 | /* Show all LSA. */ | |
7c8ff89e | 5718 | if (argc == arg_base + 0) |
718e3744 | 5719 | { |
020709f9 | 5720 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5721 | return CMD_SUCCESS; |
5722 | } | |
5723 | ||
5724 | /* Set database type to show. */ | |
7c8ff89e | 5725 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5726 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5727 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5728 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5729 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5730 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5731 | else if (strncmp (argv[arg_base + 0], "su", 2) == 0) |
718e3744 | 5732 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5733 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5734 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5735 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5736 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 5737 | else if (strncmp (argv[arg_base + 0], "se", 2) == 0) |
718e3744 | 5738 | { |
020709f9 | 5739 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5740 | return CMD_SUCCESS; |
5741 | } | |
7c8ff89e | 5742 | else if (strncmp (argv[arg_base + 0], "m", 1) == 0) |
718e3744 | 5743 | { |
020709f9 | 5744 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5745 | return CMD_SUCCESS; |
5746 | } | |
7c8ff89e | 5747 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5748 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5749 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5750 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5751 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5752 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5753 | else |
5754 | return CMD_WARNING; | |
5755 | ||
5756 | /* `show ip ospf database LSA'. */ | |
7c8ff89e | 5757 | if (argc == arg_base + 1) |
020709f9 | 5758 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7c8ff89e | 5759 | else if (argc >= arg_base + 2) |
718e3744 | 5760 | { |
7c8ff89e | 5761 | ret = inet_aton (argv[arg_base + 1], &id); |
718e3744 | 5762 | if (!ret) |
5763 | return CMD_WARNING; | |
5764 | ||
5765 | /* `show ip ospf database LSA ID'. */ | |
7c8ff89e | 5766 | if (argc == arg_base + 2) |
020709f9 | 5767 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5768 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7c8ff89e | 5769 | else if (argc == arg_base + 3) |
718e3744 | 5770 | { |
7c8ff89e | 5771 | if (strncmp (argv[arg_base + 2], "s", 1) == 0) |
68980084 | 5772 | adv_router = ospf->router_id; |
718e3744 | 5773 | else |
5774 | { | |
7c8ff89e | 5775 | ret = inet_aton (argv[arg_base + 2], &adv_router); |
718e3744 | 5776 | if (!ret) |
5777 | return CMD_WARNING; | |
5778 | } | |
020709f9 | 5779 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5780 | } |
5781 | } | |
5782 | ||
5783 | return CMD_SUCCESS; | |
5784 | } | |
5785 | ||
f412b39a DW |
5786 | /* |
5787 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
5788 | * "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5789 | * SHOW_STR | |
5790 | * IP_STR | |
5791 | * "OSPF information\n" | |
5792 | * "Database summary\n" | |
5793 | * OSPF_LSA_TYPES_DESC | |
5794 | * "Link State ID (as an IP address)\n" | |
5795 | * | |
5796 | * "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5797 | * SHOW_STR | |
5798 | * IP_STR | |
5799 | * "OSPF information\n" | |
5800 | * "Database summary\n" | |
5801 | * OSPF_LSA_TYPES_DESC | |
5802 | * "Link State ID (as an IP address)\n" | |
5803 | * "Self-originated link states\n" | |
5804 | * "\n" | |
5805 | * | |
5806 | * "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5807 | * SHOW_STR | |
5808 | * IP_STR | |
5809 | * "OSPF information\n" | |
5810 | * "Database summary\n" | |
5811 | * OSPF_LSA_TYPES_DESC | |
5812 | * "Link State ID (as an IP address)\n" | |
5813 | * "Advertising Router link states\n" | |
5814 | * "Advertising Router (as an IP address)\n" | |
5815 | * | |
5816 | * "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5817 | * SHOW_STR | |
5818 | * IP_STR | |
5819 | * "OSPF information\n" | |
5820 | * "Database summary\n" | |
5821 | * OSPF_LSA_TYPES_DESC | |
5822 | * "LSAs in MaxAge list\n" | |
5823 | * "Self-originated link states\n" | |
5824 | * | |
5825 | */ | |
7c8ff89e DS |
5826 | DEFUN (show_ip_ospf_database, |
5827 | show_ip_ospf_database_cmd, | |
5828 | "show ip ospf database", | |
5829 | SHOW_STR | |
5830 | IP_STR | |
5831 | "OSPF information\n" | |
5832 | "Database summary\n") | |
5833 | { | |
5834 | struct ospf *ospf; | |
5835 | ||
0bad4851 | 5836 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5837 | return CMD_SUCCESS; |
5838 | ||
5839 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); | |
5840 | } | |
5841 | ||
f412b39a DW |
5842 | |
5843 | ||
5844 | ||
5845 | ||
5846 | /* | |
5847 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
5848 | * "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", | |
5849 | * SHOW_STR | |
5850 | * IP_STR | |
5851 | * "OSPF information\n" | |
5852 | * "Instance ID\n" | |
5853 | * "Database summary\n" | |
5854 | * OSPF_LSA_TYPES_DESC | |
5855 | * "Link State ID (as an IP address)\n" | |
5856 | * "Advertising Router link states\n" | |
5857 | * "Advertising Router (as an IP address)\n" | |
5858 | * | |
5859 | * "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", | |
5860 | * SHOW_STR | |
5861 | * IP_STR | |
5862 | * "OSPF information\n" | |
5863 | * "Instance ID\n" | |
5864 | * "Database summary\n" | |
5865 | * OSPF_LSA_TYPES_DESC | |
5866 | * "Link State ID (as an IP address)\n" | |
5867 | * | |
5868 | * "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", | |
5869 | * SHOW_STR | |
5870 | * IP_STR | |
5871 | * "OSPF information\n" | |
5872 | * "Instance ID\n" | |
5873 | * "Database summary\n" | |
5874 | * OSPF_LSA_TYPES_DESC | |
5875 | * "Link State ID (as an IP address)\n" | |
5876 | * "Self-originated link states\n" | |
5877 | * "\n" | |
5878 | * | |
5879 | * "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", | |
5880 | * SHOW_STR | |
5881 | * IP_STR | |
5882 | * "OSPF information\n" | |
5883 | * "Instance ID\n" | |
5884 | * "Database summary\n" | |
5885 | * OSPF_LSA_TYPES_DESC | |
5886 | * "LSAs in MaxAge list\n" | |
5887 | * "Self-originated link states\n" | |
5888 | * | |
5889 | */ | |
5890 | DEFUN (show_ip_ospf_instance_database, | |
5891 | show_ip_ospf_instance_database_cmd, | |
6147e2c6 | 5892 | "show ip ospf (1-65535) database", |
718e3744 | 5893 | SHOW_STR |
5894 | IP_STR | |
5895 | "OSPF information\n" | |
7c8ff89e DS |
5896 | "Instance ID\n" |
5897 | "Database summary\n") | |
5898 | { | |
5899 | struct ospf *ospf; | |
5900 | u_short instance = 0; | |
5901 | ||
bf2bfafd | 5902 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
7c8ff89e | 5903 | |
0bad4851 | 5904 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5905 | return CMD_SUCCESS; |
5906 | ||
5907 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); | |
5908 | } | |
5909 | ||
7c8ff89e | 5910 | |
7c8ff89e | 5911 | |
7c8ff89e | 5912 | |
7c8ff89e DS |
5913 | |
5914 | ||
5915 | static int | |
5916 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
5917 | int arg_base, int argc, const char **argv) | |
718e3744 | 5918 | { |
5919 | int type, ret; | |
5920 | struct in_addr adv_router; | |
5921 | ||
7c8ff89e DS |
5922 | if (ospf->instance) |
5923 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5924 | VTY_NEWLINE); | |
718e3744 | 5925 | |
5926 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5927 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5928 | |
7c8ff89e | 5929 | if (argc != arg_base + 2) |
718e3744 | 5930 | return CMD_WARNING; |
5931 | ||
5932 | /* Set database type to show. */ | |
7c8ff89e | 5933 | if (strncmp (argv[arg_base + 0], "r", 1) == 0) |
718e3744 | 5934 | type = OSPF_ROUTER_LSA; |
7c8ff89e | 5935 | else if (strncmp (argv[arg_base + 0], "ne", 2) == 0) |
718e3744 | 5936 | type = OSPF_NETWORK_LSA; |
7c8ff89e | 5937 | else if (strncmp (argv[arg_base + 0], "ns", 2) == 0) |
718e3744 | 5938 | type = OSPF_AS_NSSA_LSA; |
7c8ff89e | 5939 | else if (strncmp (argv[arg_base + 0], "s", 1) == 0) |
718e3744 | 5940 | type = OSPF_SUMMARY_LSA; |
7c8ff89e | 5941 | else if (strncmp (argv[arg_base + 0], "a", 1) == 0) |
718e3744 | 5942 | type = OSPF_ASBR_SUMMARY_LSA; |
7c8ff89e | 5943 | else if (strncmp (argv[arg_base + 0], "e", 1) == 0) |
718e3744 | 5944 | type = OSPF_AS_EXTERNAL_LSA; |
7c8ff89e | 5945 | else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0) |
718e3744 | 5946 | type = OSPF_OPAQUE_LINK_LSA; |
7c8ff89e | 5947 | else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0) |
718e3744 | 5948 | type = OSPF_OPAQUE_AREA_LSA; |
7c8ff89e | 5949 | else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0) |
718e3744 | 5950 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5951 | else |
5952 | return CMD_WARNING; | |
5953 | ||
7c8ff89e DS |
5954 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
5955 | if (strncmp (argv[arg_base + 1], "s", 1) == 0) | |
5956 | adv_router = ospf->router_id; | |
5957 | else | |
5958 | { | |
5959 | ret = inet_aton (argv[arg_base + 1], &adv_router); | |
5960 | if (!ret) | |
5961 | return CMD_WARNING; | |
5962 | } | |
5963 | ||
5964 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5965 | ||
5966 | return CMD_SUCCESS; | |
5967 | } | |
5968 | ||
f412b39a DW |
5969 | /* |
5970 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
5971 | * "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
5972 | * SHOW_STR | |
5973 | * IP_STR | |
5974 | * "OSPF information\n" | |
5975 | * "Database summary\n" | |
5976 | * OSPF_LSA_TYPES_DESC | |
5977 | * "Self-originated link states\n" | |
5978 | * | |
5979 | */ | |
7c8ff89e DS |
5980 | DEFUN (show_ip_ospf_database_type_adv_router, |
5981 | show_ip_ospf_database_type_adv_router_cmd, | |
6147e2c6 | 5982 | "show ip ospf database <" OSPF_LSA_TYPES_CMD_STR "> adv-router A.B.C.D", |
7c8ff89e DS |
5983 | SHOW_STR |
5984 | IP_STR | |
5985 | "OSPF information\n" | |
5986 | "Database summary\n" | |
5987 | OSPF_LSA_TYPES_DESC | |
5988 | "Advertising Router link states\n" | |
5989 | "Advertising Router (as an IP address)\n") | |
5990 | { | |
5991 | struct ospf *ospf; | |
5992 | ||
0bad4851 | 5993 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5994 | return CMD_SUCCESS; |
5995 | ||
5996 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
5997 | } | |
5998 | ||
7c8ff89e | 5999 | |
f412b39a DW |
6000 | /* |
6001 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6002 | * "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", | |
6003 | * SHOW_STR | |
6004 | * IP_STR | |
6005 | * "OSPF information\n" | |
6006 | * "Instance ID\n" | |
6007 | * "Database summary\n" | |
6008 | * OSPF_LSA_TYPES_DESC | |
6009 | * "Self-originated link states\n" | |
6010 | * | |
6011 | */ | |
7c8ff89e DS |
6012 | DEFUN (show_ip_ospf_instance_database_type_adv_router, |
6013 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
6147e2c6 | 6014 | "show ip ospf (1-65535) database <" OSPF_LSA_TYPES_CMD_STR "> adv-router A.B.C.D", |
7c8ff89e DS |
6015 | SHOW_STR |
6016 | IP_STR | |
6017 | "OSPF information\n" | |
6018 | "Instance ID\n" | |
6019 | "Database summary\n" | |
6020 | OSPF_LSA_TYPES_DESC | |
6021 | "Advertising Router link states\n" | |
6022 | "Advertising Router (as an IP address)\n") | |
6023 | { | |
6024 | struct ospf *ospf; | |
6025 | u_short instance = 0; | |
6026 | ||
bf2bfafd | 6027 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
718e3744 | 6028 | |
0bad4851 | 6029 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 6030 | return CMD_SUCCESS; |
718e3744 | 6031 | |
7c8ff89e | 6032 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 6033 | } |
6034 | ||
718e3744 | 6035 | |
f412b39a DW |
6036 | /* |
6037 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6038 | * "ip ospf authentication (null|message-digest)", | |
6039 | * "IP Information\n" | |
6040 | * "OSPF interface commands\n" | |
6041 | * "Enable authentication on this interface\n" | |
6042 | * "Use null authentication\n" | |
6043 | * "Use message-digest authentication\n" | |
6044 | * | |
6045 | */ | |
718e3744 | 6046 | DEFUN (ip_ospf_authentication_args, |
6047 | ip_ospf_authentication_args_addr_cmd, | |
6147e2c6 | 6048 | "ip ospf authentication <null|message-digest> A.B.C.D", |
718e3744 | 6049 | "IP Information\n" |
6050 | "OSPF interface commands\n" | |
6051 | "Enable authentication on this interface\n" | |
6052 | "Use null authentication\n" | |
6053 | "Use message-digest authentication\n" | |
6054 | "Address of interface") | |
6055 | { | |
6056 | struct interface *ifp; | |
6057 | struct in_addr addr; | |
6058 | int ret; | |
6059 | struct ospf_if_params *params; | |
6060 | ||
6061 | ifp = vty->index; | |
6062 | params = IF_DEF_PARAMS (ifp); | |
6063 | ||
6064 | if (argc == 2) | |
6065 | { | |
bf2bfafd | 6066 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 6067 | if (!ret) |
6068 | { | |
6069 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6070 | VTY_NEWLINE); | |
6071 | return CMD_WARNING; | |
6072 | } | |
6073 | ||
6074 | params = ospf_get_if_params (ifp, addr); | |
6075 | ospf_if_update_params (ifp, addr); | |
6076 | } | |
6077 | ||
6078 | /* Handle null authentication */ | |
bf2bfafd | 6079 | if ( argv[3]->arg[0] == 'n' ) |
718e3744 | 6080 | { |
6081 | SET_IF_PARAM (params, auth_type); | |
6082 | params->auth_type = OSPF_AUTH_NULL; | |
6083 | return CMD_SUCCESS; | |
6084 | } | |
6085 | ||
6086 | /* Handle message-digest authentication */ | |
bf2bfafd | 6087 | if ( argv[3]->arg[0] == 'm' ) |
718e3744 | 6088 | { |
6089 | SET_IF_PARAM (params, auth_type); | |
6090 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6091 | return CMD_SUCCESS; | |
6092 | } | |
6093 | ||
6094 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
6095 | return CMD_WARNING; | |
6096 | } | |
6097 | ||
718e3744 | 6098 | |
f412b39a DW |
6099 | /* |
6100 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6101 | * "ip ospf authentication", | |
6102 | * "IP Information\n" | |
6103 | * "OSPF interface commands\n" | |
6104 | * "Enable authentication on this interface\n" | |
6105 | * | |
6106 | */ | |
718e3744 | 6107 | DEFUN (ip_ospf_authentication, |
6108 | ip_ospf_authentication_addr_cmd, | |
6109 | "ip ospf authentication A.B.C.D", | |
6110 | "IP Information\n" | |
6111 | "OSPF interface commands\n" | |
6112 | "Enable authentication on this interface\n" | |
6113 | "Address of interface") | |
6114 | { | |
6115 | struct interface *ifp; | |
6116 | struct in_addr addr; | |
6117 | int ret; | |
6118 | struct ospf_if_params *params; | |
6119 | ||
6120 | ifp = vty->index; | |
6121 | params = IF_DEF_PARAMS (ifp); | |
6122 | ||
6123 | if (argc == 1) | |
6124 | { | |
bf2bfafd | 6125 | ret = inet_aton(argv[3]->arg, &addr); |
718e3744 | 6126 | if (!ret) |
6127 | { | |
6128 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6129 | VTY_NEWLINE); | |
6130 | return CMD_WARNING; | |
6131 | } | |
6132 | ||
6133 | params = ospf_get_if_params (ifp, addr); | |
6134 | ospf_if_update_params (ifp, addr); | |
6135 | } | |
6136 | ||
6137 | SET_IF_PARAM (params, auth_type); | |
6138 | params->auth_type = OSPF_AUTH_SIMPLE; | |
6139 | ||
6140 | return CMD_SUCCESS; | |
6141 | } | |
6142 | ||
718e3744 | 6143 | |
f412b39a DW |
6144 | /* |
6145 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6146 | * "no ip ospf authentication (null|message-digest)", | |
6147 | * NO_STR | |
6148 | * "IP Information\n" | |
6149 | * "OSPF interface commands\n" | |
6150 | * "Enable authentication on this interface\n" | |
6151 | * "Use null authentication\n" | |
6152 | * "Use message-digest authentication\n" | |
6153 | * | |
6154 | */ | |
b4a039bf DS |
6155 | DEFUN (no_ip_ospf_authentication_args, |
6156 | no_ip_ospf_authentication_args_addr_cmd, | |
6147e2c6 | 6157 | "no ip ospf authentication <null|message-digest> A.B.C.D", |
b4a039bf DS |
6158 | NO_STR |
6159 | "IP Information\n" | |
6160 | "OSPF interface commands\n" | |
6161 | "Enable authentication on this interface\n" | |
6162 | "Use null authentication\n" | |
6163 | "Use message-digest authentication\n" | |
6164 | "Address of interface") | |
6165 | { | |
6166 | struct interface *ifp; | |
6167 | struct in_addr addr; | |
6168 | int ret; | |
6169 | struct ospf_if_params *params; | |
6170 | struct route_node *rn; | |
6171 | int auth_type; | |
6172 | ||
6173 | ifp = vty->index; | |
6174 | params = IF_DEF_PARAMS (ifp); | |
6175 | ||
6176 | if (argc == 2) | |
6177 | { | |
bf2bfafd | 6178 | ret = inet_aton(argv[5]->arg, &addr); |
b4a039bf DS |
6179 | if (!ret) |
6180 | { | |
6181 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6182 | VTY_NEWLINE); | |
6183 | return CMD_WARNING; | |
6184 | } | |
6185 | ||
6186 | params = ospf_lookup_if_params (ifp, addr); | |
6187 | if (params == NULL) | |
6188 | { | |
6189 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6190 | return CMD_WARNING; | |
6191 | } | |
6192 | params->auth_type = OSPF_AUTH_NOTSET; | |
6193 | UNSET_IF_PARAM (params, auth_type); | |
6194 | if (params != IF_DEF_PARAMS (ifp)) | |
6195 | { | |
6196 | ospf_free_if_params (ifp, addr); | |
6197 | ospf_if_update_params (ifp, addr); | |
6198 | } | |
6199 | } | |
6200 | else | |
6201 | { | |
bf2bfafd | 6202 | if ( argv[4]->arg[0] == 'n' ) |
b4a039bf DS |
6203 | { |
6204 | auth_type = OSPF_AUTH_NULL; | |
6205 | } | |
bf2bfafd | 6206 | else if ( argv[4]->arg[0] == 'm' ) |
b4a039bf DS |
6207 | { |
6208 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6209 | } | |
6210 | else | |
6211 | { | |
6212 | vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE); | |
6213 | return CMD_WARNING; | |
6214 | } | |
6215 | /* | |
6216 | * Here we have a case where the user has entered | |
6217 | * 'no ip ospf authentication (null | message_digest )' | |
6218 | * we need to find if we have any ip addresses underneath it that | |
6219 | * correspond to the associated type. | |
6220 | */ | |
813d4307 DW |
6221 | if (params->auth_type == auth_type) |
6222 | { | |
6223 | params->auth_type = OSPF_AUTH_NOTSET; | |
6224 | UNSET_IF_PARAM (params, auth_type); | |
6225 | } | |
6226 | ||
b4a039bf DS |
6227 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6228 | { | |
6229 | if ((params = rn->info)) | |
6230 | { | |
6231 | if (params->auth_type == auth_type) | |
6232 | { | |
6233 | params->auth_type = OSPF_AUTH_NOTSET; | |
6234 | UNSET_IF_PARAM (params, auth_type); | |
6235 | if (params != IF_DEF_PARAMS (ifp)) | |
6236 | { | |
6237 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6238 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6239 | } | |
6240 | } | |
6241 | } | |
6242 | } | |
6243 | } | |
6244 | ||
6245 | return CMD_SUCCESS; | |
6246 | } | |
6247 | ||
b4a039bf | 6248 | |
f412b39a DW |
6249 | /* |
6250 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6251 | * "no ip ospf authentication", | |
6252 | * NO_STR | |
6253 | * "IP Information\n" | |
6254 | * "OSPF interface commands\n" | |
6255 | * "Enable authentication on this interface\n" | |
6256 | * | |
6257 | */ | |
718e3744 | 6258 | DEFUN (no_ip_ospf_authentication, |
6259 | no_ip_ospf_authentication_addr_cmd, | |
6260 | "no ip ospf authentication A.B.C.D", | |
6261 | NO_STR | |
6262 | "IP Information\n" | |
6263 | "OSPF interface commands\n" | |
6264 | "Enable authentication on this interface\n" | |
6265 | "Address of interface") | |
6266 | { | |
6267 | struct interface *ifp; | |
6268 | struct in_addr addr; | |
6269 | int ret; | |
6270 | struct ospf_if_params *params; | |
b4a039bf DS |
6271 | struct route_node *rn; |
6272 | ||
718e3744 | 6273 | ifp = vty->index; |
6274 | params = IF_DEF_PARAMS (ifp); | |
6275 | ||
6276 | if (argc == 1) | |
6277 | { | |
bf2bfafd | 6278 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 6279 | if (!ret) |
6280 | { | |
6281 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6282 | VTY_NEWLINE); | |
6283 | return CMD_WARNING; | |
6284 | } | |
6285 | ||
6286 | params = ospf_lookup_if_params (ifp, addr); | |
6287 | if (params == NULL) | |
b4a039bf DS |
6288 | { |
6289 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
6290 | return CMD_WARNING; | |
6291 | } | |
718e3744 | 6292 | |
b4a039bf DS |
6293 | params->auth_type = OSPF_AUTH_NOTSET; |
6294 | UNSET_IF_PARAM (params, auth_type); | |
6295 | if (params != IF_DEF_PARAMS (ifp)) | |
6296 | { | |
6297 | ospf_free_if_params (ifp, addr); | |
6298 | ospf_if_update_params (ifp, addr); | |
6299 | } | |
6300 | } | |
6301 | else | |
718e3744 | 6302 | { |
b4a039bf DS |
6303 | /* |
6304 | * When a user enters 'no ip ospf authentication' | |
6305 | * We should remove all authentication types from | |
6306 | * the interface. | |
6307 | */ | |
813d4307 DW |
6308 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6309 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6310 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6311 | { | |
6312 | params->auth_type = OSPF_AUTH_NOTSET; | |
6313 | UNSET_IF_PARAM (params, auth_type); | |
6314 | } | |
6315 | ||
b4a039bf DS |
6316 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
6317 | { | |
6318 | if ((params = rn->info)) | |
6319 | { | |
813d4307 | 6320 | |
b4a039bf DS |
6321 | if ((params->auth_type == OSPF_AUTH_NULL) || |
6322 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
6323 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
6324 | { | |
6325 | params->auth_type = OSPF_AUTH_NOTSET; | |
6326 | UNSET_IF_PARAM (params, auth_type); | |
6327 | if (params != IF_DEF_PARAMS (ifp)) | |
6328 | { | |
6329 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
6330 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
6331 | } | |
6332 | } | |
6333 | } | |
6334 | } | |
718e3744 | 6335 | } |
6336 | ||
6337 | return CMD_SUCCESS; | |
6338 | } | |
6339 | ||
718e3744 | 6340 | |
f412b39a DW |
6341 | /* |
6342 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6343 | * "ip ospf authentication-key AUTH_KEY", | |
6344 | * "IP Information\n" | |
6345 | * "OSPF interface commands\n" | |
6346 | * "Authentication password (key)\n" | |
6347 | * "The OSPF password (key)" | |
6348 | * | |
6349 | */ | |
718e3744 | 6350 | DEFUN (ip_ospf_authentication_key, |
6351 | ip_ospf_authentication_key_addr_cmd, | |
6352 | "ip ospf authentication-key AUTH_KEY A.B.C.D", | |
6353 | "IP Information\n" | |
6354 | "OSPF interface commands\n" | |
6355 | "Authentication password (key)\n" | |
6356 | "The OSPF password (key)\n" | |
6357 | "Address of interface") | |
6358 | { | |
6359 | struct interface *ifp; | |
6360 | struct in_addr addr; | |
6361 | int ret; | |
6362 | struct ospf_if_params *params; | |
6363 | ||
6364 | ifp = vty->index; | |
6365 | params = IF_DEF_PARAMS (ifp); | |
6366 | ||
6367 | if (argc == 2) | |
6368 | { | |
6369 | ret = inet_aton(argv[1], &addr); | |
6370 | if (!ret) | |
6371 | { | |
6372 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6373 | VTY_NEWLINE); | |
6374 | return CMD_WARNING; | |
6375 | } | |
6376 | ||
6377 | params = ospf_get_if_params (ifp, addr); | |
6378 | ospf_if_update_params (ifp, addr); | |
6379 | } | |
6380 | ||
718e3744 | 6381 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
bf2bfafd | 6382 | strncpy ((char *) params->auth_simple, argv[4]->arg, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 6383 | SET_IF_PARAM (params, auth_simple); |
6384 | ||
6385 | return CMD_SUCCESS; | |
6386 | } | |
6387 | ||
718e3744 | 6388 | |
747e489c DW |
6389 | ALIAS_HIDDEN (ip_ospf_authentication_key, |
6390 | ospf_authentication_key_cmd, | |
6391 | "ospf authentication-key AUTH_KEY", | |
6392 | "OSPF interface commands\n" | |
6393 | "Authentication password (key)\n" | |
6394 | "The OSPF password (key)") | |
718e3744 | 6395 | |
f412b39a DW |
6396 | /* |
6397 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6398 | * "no ospf authentication-key AUTH_KEY A.B.C.D", | |
6399 | * NO_STR | |
6400 | * "OSPF interface commands\n" | |
6401 | * "Authentication password (key)\n" | |
6402 | * "The OSPF password (key)\n" | |
6403 | * "Address of interface" | |
6404 | * | |
6405 | * "no ospf authentication-key AUTH_KEY", | |
6406 | * NO_STR | |
6407 | * "OSPF interface commands\n" | |
6408 | * "Authentication password (key)\n" | |
6409 | * "The OSPF password (key)\n" | |
6410 | * | |
6411 | * "no ip ospf authentication-key", | |
6412 | * NO_STR | |
6413 | * "IP Information\n" | |
6414 | * "OSPF interface commands\n" | |
6415 | * "Authentication password (key)\n" | |
6416 | * | |
6417 | * "no ip ospf authentication-key AUTH_KEY", | |
6418 | * NO_STR | |
6419 | * "IP Information\n" | |
6420 | * "OSPF interface commands\n" | |
6421 | * "Authentication password (key)\n" | |
6422 | * | |
6423 | * "no ospf authentication-key", | |
6424 | * NO_STR | |
6425 | * "OSPF interface commands\n" | |
6426 | * "Authentication password (key)\n" | |
6427 | * | |
6428 | */ | |
718e3744 | 6429 | DEFUN (no_ip_ospf_authentication_key, |
813d4307 DW |
6430 | no_ip_ospf_authentication_key_authkey_addr_cmd, |
6431 | "no ip ospf authentication-key AUTH_KEY A.B.C.D", | |
718e3744 | 6432 | NO_STR |
6433 | "IP Information\n" | |
6434 | "OSPF interface commands\n" | |
6435 | "Authentication password (key)\n" | |
813d4307 | 6436 | "The OSPF password (key)") |
718e3744 | 6437 | { |
6438 | struct interface *ifp; | |
6439 | struct in_addr addr; | |
718e3744 | 6440 | struct ospf_if_params *params; |
813d4307 | 6441 | int ret; |
718e3744 | 6442 | |
6443 | ifp = vty->index; | |
6444 | params = IF_DEF_PARAMS (ifp); | |
6445 | ||
813d4307 | 6446 | if (argc == 2) |
718e3744 | 6447 | { |
813d4307 | 6448 | ret = inet_aton(argv[1], &addr); |
718e3744 | 6449 | if (!ret) |
6450 | { | |
6451 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6452 | VTY_NEWLINE); | |
6453 | return CMD_WARNING; | |
6454 | } | |
6455 | ||
6456 | params = ospf_lookup_if_params (ifp, addr); | |
6457 | if (params == NULL) | |
6458 | return CMD_SUCCESS; | |
6459 | } | |
6460 | ||
6461 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); | |
6462 | UNSET_IF_PARAM (params, auth_simple); | |
6463 | ||
6464 | if (params != IF_DEF_PARAMS (ifp)) | |
6465 | { | |
6466 | ospf_free_if_params (ifp, addr); | |
6467 | ospf_if_update_params (ifp, addr); | |
6468 | } | |
6469 | ||
6470 | return CMD_SUCCESS; | |
6471 | } | |
6472 | ||
813d4307 | 6473 | |
718e3744 | 6474 | |
718e3744 | 6475 | |
813d4307 | 6476 | |
813d4307 | 6477 | |
f412b39a DW |
6478 | /* |
6479 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6480 | * "ip ospf message-digest-key <1-255> md5 KEY", | |
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 | * | |
6488 | */ | |
718e3744 | 6489 | DEFUN (ip_ospf_message_digest_key, |
6490 | ip_ospf_message_digest_key_addr_cmd, | |
6147e2c6 | 6491 | "ip ospf message-digest-key (1-255) md5 KEY A.B.C.D", |
718e3744 | 6492 | "IP Information\n" |
6493 | "OSPF interface commands\n" | |
6494 | "Message digest authentication password (key)\n" | |
6495 | "Key ID\n" | |
6496 | "Use MD5 algorithm\n" | |
6497 | "The OSPF password (key)" | |
6498 | "Address of interface") | |
6499 | { | |
6500 | struct interface *ifp; | |
6501 | struct crypt_key *ck; | |
6502 | u_char key_id; | |
6503 | struct in_addr addr; | |
6504 | int ret; | |
6505 | struct ospf_if_params *params; | |
6506 | ||
6507 | ifp = vty->index; | |
6508 | params = IF_DEF_PARAMS (ifp); | |
6509 | ||
6510 | if (argc == 3) | |
6511 | { | |
6512 | ret = inet_aton(argv[2], &addr); | |
6513 | if (!ret) | |
6514 | { | |
6515 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6516 | VTY_NEWLINE); | |
6517 | return CMD_WARNING; | |
6518 | } | |
6519 | ||
6520 | params = ospf_get_if_params (ifp, addr); | |
6521 | ospf_if_update_params (ifp, addr); | |
6522 | } | |
6523 | ||
bf2bfafd | 6524 | key_id = strtol (argv[3]->arg, NULL, 10); |
718e3744 | 6525 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
6526 | { | |
6527 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
6528 | return CMD_WARNING; | |
6529 | } | |
6530 | ||
6531 | ck = ospf_crypt_key_new (); | |
6532 | ck->key_id = (u_char) key_id; | |
6533 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
bf2bfafd | 6534 | strncpy ((char *) ck->auth_key, argv[6]->arg, OSPF_AUTH_MD5_SIZE); |
718e3744 | 6535 | |
6536 | ospf_crypt_key_add (params->auth_crypt, ck); | |
6537 | SET_IF_PARAM (params, auth_crypt); | |
6538 | ||
6539 | return CMD_SUCCESS; | |
6540 | } | |
6541 | ||
718e3744 | 6542 | |
747e489c DW |
6543 | ALIAS_HIDDEN (ip_ospf_message_digest_key, |
6544 | ospf_message_digest_key_cmd, | |
6545 | "ospf message-digest-key <1-255> md5 KEY", | |
6546 | "OSPF interface commands\n" | |
6547 | "Message digest authentication password (key)\n" | |
6548 | "Key ID\n" | |
6549 | "Use MD5 algorithm\n" | |
6550 | "The OSPF password (key)") | |
718e3744 | 6551 | |
f412b39a DW |
6552 | /* |
6553 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6554 | * "no ip ospf message-digest-key <1-255> md5 KEY", | |
6555 | * NO_STR | |
6556 | * "IP Information\n" | |
6557 | * "OSPF interface commands\n" | |
6558 | * "Message digest authentication password (key)\n" | |
6559 | * "Key ID\n" | |
6560 | * "Use MD5 algorithm\n" | |
6561 | * "The OSPF password (key)" | |
6562 | * | |
6563 | */ | |
813d4307 DW |
6564 | DEFUN (no_ip_ospf_message_digest_key_md5, |
6565 | no_ip_ospf_message_digest_key_md5_addr_cmd, | |
6147e2c6 | 6566 | "no ip ospf message-digest-key (1-255) md5 KEY A.B.C.D", |
813d4307 DW |
6567 | NO_STR |
6568 | "IP Information\n" | |
6569 | "OSPF interface commands\n" | |
6570 | "Message digest authentication password (key)\n" | |
6571 | "Key ID\n" | |
6572 | "Use MD5 algorithm\n" | |
6573 | "The OSPF password (key)" | |
6574 | "Address of interface") | |
6575 | { | |
6576 | struct interface *ifp; | |
6577 | struct crypt_key *ck; | |
6578 | int key_id; | |
6579 | struct in_addr addr; | |
6580 | int ret; | |
6581 | struct ospf_if_params *params; | |
6582 | ||
6583 | ifp = vty->index; | |
6584 | params = IF_DEF_PARAMS (ifp); | |
6585 | ||
6586 | if (argc == 3) | |
6587 | { | |
6588 | ret = inet_aton(argv[2], &addr); | |
6589 | if (!ret) | |
6590 | { | |
6591 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6592 | VTY_NEWLINE); | |
6593 | return CMD_WARNING; | |
6594 | } | |
6595 | ||
6596 | params = ospf_lookup_if_params (ifp, addr); | |
6597 | if (params == NULL) | |
6598 | return CMD_SUCCESS; | |
6599 | } | |
6600 | ||
bf2bfafd | 6601 | key_id = strtol (argv[4]->arg, NULL, 10); |
813d4307 DW |
6602 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
6603 | if (ck == NULL) | |
6604 | { | |
6605 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6606 | return CMD_WARNING; | |
6607 | } | |
6608 | ||
6609 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6610 | ||
6611 | if (params != IF_DEF_PARAMS (ifp)) | |
6612 | { | |
6613 | ospf_free_if_params (ifp, addr); | |
6614 | ospf_if_update_params (ifp, addr); | |
6615 | } | |
6616 | ||
6617 | return CMD_SUCCESS; | |
6618 | } | |
6619 | ||
813d4307 | 6620 | |
f412b39a DW |
6621 | /* |
6622 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6623 | * "no ip ospf message-digest-key <1-255>", | |
6624 | * NO_STR | |
6625 | * "IP Information\n" | |
6626 | * "OSPF interface commands\n" | |
6627 | * "Message digest authentication password (key)\n" | |
6628 | * "Key ID\n" | |
6629 | * | |
6630 | * "no ospf message-digest-key <1-255>", | |
6631 | * NO_STR | |
6632 | * "OSPF interface commands\n" | |
6633 | * "Message digest authentication password (key)\n" | |
6634 | * "Key ID\n" | |
6635 | * | |
6636 | */ | |
718e3744 | 6637 | DEFUN (no_ip_ospf_message_digest_key, |
6638 | no_ip_ospf_message_digest_key_addr_cmd, | |
6147e2c6 | 6639 | "no ip ospf message-digest-key (1-255) A.B.C.D", |
718e3744 | 6640 | NO_STR |
6641 | "IP Information\n" | |
6642 | "OSPF interface commands\n" | |
6643 | "Message digest authentication password (key)\n" | |
6644 | "Key ID\n" | |
6645 | "Address of interface") | |
6646 | { | |
6647 | struct interface *ifp; | |
6648 | struct crypt_key *ck; | |
6649 | int key_id; | |
6650 | struct in_addr addr; | |
6651 | int ret; | |
6652 | struct ospf_if_params *params; | |
6653 | ||
6654 | ifp = vty->index; | |
6655 | params = IF_DEF_PARAMS (ifp); | |
6656 | ||
6657 | if (argc == 2) | |
6658 | { | |
bf2bfafd | 6659 | ret = inet_aton(argv[5]->arg, &addr); |
718e3744 | 6660 | if (!ret) |
6661 | { | |
6662 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6663 | VTY_NEWLINE); | |
6664 | return CMD_WARNING; | |
6665 | } | |
6666 | ||
6667 | params = ospf_lookup_if_params (ifp, addr); | |
6668 | if (params == NULL) | |
6669 | return CMD_SUCCESS; | |
6670 | } | |
6671 | ||
bf2bfafd | 6672 | key_id = strtol (argv[4]->arg, NULL, 10); |
718e3744 | 6673 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
6674 | if (ck == NULL) | |
6675 | { | |
6676 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6677 | return CMD_WARNING; | |
6678 | } | |
6679 | ||
6680 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6681 | ||
6682 | if (params != IF_DEF_PARAMS (ifp)) | |
6683 | { | |
6684 | ospf_free_if_params (ifp, addr); | |
6685 | ospf_if_update_params (ifp, addr); | |
6686 | } | |
6687 | ||
6688 | return CMD_SUCCESS; | |
6689 | } | |
6690 | ||
718e3744 | 6691 | |
718e3744 | 6692 | |
f412b39a DW |
6693 | /* |
6694 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6695 | * "ip ospf cost <1-65535>", | |
6696 | * "IP Information\n" | |
6697 | * "OSPF interface commands\n" | |
6698 | * "Interface cost\n" | |
6699 | * "Cost" | |
6700 | * | |
6701 | */ | |
718e3744 | 6702 | DEFUN (ip_ospf_cost, |
9eff36b3 | 6703 | ip_ospf_cost_u32_inet4_cmd, |
6147e2c6 | 6704 | "ip ospf cost (1-65535) A.B.C.D", |
718e3744 | 6705 | "IP Information\n" |
6706 | "OSPF interface commands\n" | |
6707 | "Interface cost\n" | |
6708 | "Cost\n" | |
6709 | "Address of interface") | |
6710 | { | |
6711 | struct interface *ifp = vty->index; | |
6712 | u_int32_t cost; | |
6713 | struct in_addr addr; | |
6714 | int ret; | |
6715 | struct ospf_if_params *params; | |
6716 | ||
6717 | params = IF_DEF_PARAMS (ifp); | |
6718 | ||
bf2bfafd | 6719 | cost = strtol (argv[3]->arg, NULL, 10); |
718e3744 | 6720 | |
6721 | /* cost range is <1-65535>. */ | |
6722 | if (cost < 1 || cost > 65535) | |
6723 | { | |
6724 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6725 | return CMD_WARNING; | |
6726 | } | |
6727 | ||
6728 | if (argc == 2) | |
6729 | { | |
bf2bfafd | 6730 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 6731 | if (!ret) |
6732 | { | |
6733 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6734 | VTY_NEWLINE); | |
6735 | return CMD_WARNING; | |
6736 | } | |
6737 | ||
6738 | params = ospf_get_if_params (ifp, addr); | |
6739 | ospf_if_update_params (ifp, addr); | |
6740 | } | |
6741 | ||
6742 | SET_IF_PARAM (params, output_cost_cmd); | |
6743 | params->output_cost_cmd = cost; | |
6744 | ||
6745 | ospf_if_recalculate_output_cost (ifp); | |
6746 | ||
6747 | return CMD_SUCCESS; | |
6748 | } | |
6749 | ||
718e3744 | 6750 | |
747e489c DW |
6751 | ALIAS_HIDDEN (ip_ospf_cost, |
6752 | ospf_cost_u32_cmd, | |
6753 | "ospf cost <1-65535>", | |
6754 | "OSPF interface commands\n" | |
6755 | "Interface cost\n" | |
6756 | "Cost") | |
6757 | ||
6758 | ALIAS_HIDDEN (ip_ospf_cost, | |
6759 | ospf_cost_u32_inet4_cmd, | |
6760 | "ospf cost <1-65535> A.B.C.D", | |
6761 | "OSPF interface commands\n" | |
6762 | "Interface cost\n" | |
6763 | "Cost\n" | |
6764 | "Address of interface") | |
9eff36b3 | 6765 | |
f412b39a DW |
6766 | /* |
6767 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6768 | * "no ospf cost A.B.C.D", | |
6769 | * NO_STR | |
6770 | * "OSPF interface commands\n" | |
6771 | * "Interface cost\n" | |
6772 | * "Address of interface" | |
6773 | * | |
6774 | * "no ospf cost", | |
6775 | * NO_STR | |
6776 | * "OSPF interface commands\n" | |
6777 | * "Interface cost\n" | |
6778 | * | |
6779 | * "no ip ospf cost", | |
6780 | * NO_STR | |
6781 | * "IP Information\n" | |
6782 | * "OSPF interface commands\n" | |
6783 | * "Interface cost\n" | |
6784 | * | |
6785 | */ | |
718e3744 | 6786 | DEFUN (no_ip_ospf_cost, |
9eff36b3 | 6787 | no_ip_ospf_cost_inet4_cmd, |
718e3744 | 6788 | "no ip ospf cost A.B.C.D", |
6789 | NO_STR | |
6790 | "IP Information\n" | |
6791 | "OSPF interface commands\n" | |
6792 | "Interface cost\n" | |
6793 | "Address of interface") | |
6794 | { | |
6795 | struct interface *ifp = vty->index; | |
6796 | struct in_addr addr; | |
6797 | int ret; | |
6798 | struct ospf_if_params *params; | |
6799 | ||
6800 | ifp = vty->index; | |
6801 | params = IF_DEF_PARAMS (ifp); | |
6802 | ||
6803 | if (argc == 1) | |
6804 | { | |
bf2bfafd | 6805 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 6806 | if (!ret) |
6807 | { | |
6808 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6809 | VTY_NEWLINE); | |
6810 | return CMD_WARNING; | |
6811 | } | |
6812 | ||
6813 | params = ospf_lookup_if_params (ifp, addr); | |
6814 | if (params == NULL) | |
6815 | return CMD_SUCCESS; | |
6816 | } | |
6817 | ||
6818 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6819 | ||
6820 | if (params != IF_DEF_PARAMS (ifp)) | |
6821 | { | |
6822 | ospf_free_if_params (ifp, addr); | |
6823 | ospf_if_update_params (ifp, addr); | |
6824 | } | |
6825 | ||
6826 | ospf_if_recalculate_output_cost (ifp); | |
6827 | ||
6828 | return CMD_SUCCESS; | |
6829 | } | |
6830 | ||
718e3744 | 6831 | |
718e3744 | 6832 | |
9eff36b3 | 6833 | |
f412b39a DW |
6834 | /* |
6835 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
6836 | * "no ospf cost <1-65535>", | |
6837 | * NO_STR | |
6838 | * "OSPF interface commands\n" | |
6839 | * "Interface cost\n" | |
6840 | * "Cost" | |
6841 | * | |
6842 | * "no ospf cost <1-65535> A.B.C.D", | |
6843 | * NO_STR | |
6844 | * "OSPF interface commands\n" | |
6845 | * "Interface cost\n" | |
6846 | * "Cost\n" | |
6847 | * "Address of interface" | |
6848 | * | |
6849 | * "no ip ospf cost <1-65535> A.B.C.D", | |
6850 | * NO_STR | |
6851 | * "IP Information\n" | |
6852 | * "OSPF interface commands\n" | |
6853 | * "Interface cost\n" | |
6854 | * "Cost\n" | |
6855 | * "Address of interface" | |
6856 | * | |
6857 | */ | |
827341b7 DO |
6858 | DEFUN (no_ip_ospf_cost2, |
6859 | no_ip_ospf_cost_u32_cmd, | |
6147e2c6 | 6860 | "no ip ospf cost (1-65535)", |
827341b7 DO |
6861 | NO_STR |
6862 | "IP Information\n" | |
6863 | "OSPF interface commands\n" | |
6864 | "Interface cost\n" | |
6865 | "Cost") | |
6866 | { | |
6867 | struct interface *ifp = vty->index; | |
6868 | struct in_addr addr; | |
6869 | u_int32_t cost; | |
6870 | int ret; | |
6871 | struct ospf_if_params *params; | |
6872 | ||
6873 | ifp = vty->index; | |
6874 | params = IF_DEF_PARAMS (ifp); | |
6875 | ||
6876 | /* According to the semantics we are mimicking "no ip ospf cost N" is | |
6877 | * always treated as "no ip ospf cost" regardless of the actual value | |
6878 | * of N already configured for the interface. Thus the first argument | |
6879 | * is always checked to be a number, but is ignored after that. | |
6880 | */ | |
bf2bfafd | 6881 | cost = strtol (argv[4]->arg, NULL, 10); |
827341b7 DO |
6882 | if (cost < 1 || cost > 65535) |
6883 | { | |
6884 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); | |
6885 | return CMD_WARNING; | |
6886 | } | |
6887 | ||
6888 | if (argc == 2) | |
6889 | { | |
6890 | ret = inet_aton(argv[1], &addr); | |
6891 | if (!ret) | |
6892 | { | |
6893 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6894 | VTY_NEWLINE); | |
6895 | return CMD_WARNING; | |
6896 | } | |
6897 | ||
6898 | params = ospf_lookup_if_params (ifp, addr); | |
6899 | if (params == NULL) | |
6900 | return CMD_SUCCESS; | |
6901 | } | |
6902 | ||
6903 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6904 | ||
6905 | if (params != IF_DEF_PARAMS (ifp)) | |
6906 | { | |
6907 | ospf_free_if_params (ifp, addr); | |
6908 | ospf_if_update_params (ifp, addr); | |
6909 | } | |
6910 | ||
6911 | ospf_if_recalculate_output_cost (ifp); | |
6912 | ||
6913 | return CMD_SUCCESS; | |
6914 | } | |
6915 | ||
827341b7 | 6916 | |
827341b7 | 6917 | |
9eff36b3 | 6918 | |
4dadc291 | 6919 | static void |
718e3744 | 6920 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6921 | { | |
6922 | struct route_node *rn; | |
6923 | struct ospf_neighbor *nbr; | |
6924 | ||
6925 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6926 | if ((nbr = rn->info)) | |
6927 | { | |
6928 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6929 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6930 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6931 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6932 | } | |
6933 | } | |
6934 | ||
f9ad937f | 6935 | static int |
6936 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6937 | const char *nbr_str, | |
6938 | const char *fast_hello_str) | |
718e3744 | 6939 | { |
6940 | struct interface *ifp = vty->index; | |
6941 | u_int32_t seconds; | |
f9ad937f | 6942 | u_char hellomult; |
718e3744 | 6943 | struct in_addr addr; |
6944 | int ret; | |
6945 | struct ospf_if_params *params; | |
6946 | struct ospf_interface *oi; | |
6947 | struct route_node *rn; | |
6948 | ||
6949 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6950 | |
6951 | if (nbr_str) | |
718e3744 | 6952 | { |
f9ad937f | 6953 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6954 | if (!ret) |
6955 | { | |
6956 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6957 | VTY_NEWLINE); | |
6958 | return CMD_WARNING; | |
6959 | } | |
6960 | ||
6961 | params = ospf_get_if_params (ifp, addr); | |
6962 | ospf_if_update_params (ifp, addr); | |
6963 | } | |
6964 | ||
f9ad937f | 6965 | if (interval_str) |
6966 | { | |
6967 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
6968 | 1, 65535); | |
6969 | ||
6970 | /* reset fast_hello too, just to be sure */ | |
6971 | UNSET_IF_PARAM (params, fast_hello); | |
6972 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6973 | } | |
6974 | else if (fast_hello_str) | |
6975 | { | |
6976 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
6977 | 1, 10); | |
6978 | /* 1s dead-interval with sub-second hellos desired */ | |
6979 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6980 | SET_IF_PARAM (params, fast_hello); | |
6981 | params->fast_hello = hellomult; | |
6982 | } | |
6983 | else | |
6984 | { | |
6985 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
6986 | VTY_NEWLINE); | |
6987 | return CMD_WARNING; | |
6988 | } | |
6989 | ||
718e3744 | 6990 | SET_IF_PARAM (params, v_wait); |
6991 | params->v_wait = seconds; | |
6992 | ||
6993 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6994 | if (nbr_str) |
718e3744 | 6995 | { |
cac3b5c4 PJ |
6996 | struct ospf *ospf; |
6997 | if ((ospf = ospf_lookup())) | |
68980084 | 6998 | { |
6999 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
7000 | if (oi) | |
7001 | ospf_nbr_timer_update (oi); | |
7002 | } | |
718e3744 | 7003 | } |
7004 | else | |
7005 | { | |
7006 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7007 | if ((oi = rn->info)) | |
7008 | ospf_nbr_timer_update (oi); | |
7009 | } | |
7010 | ||
7011 | return CMD_SUCCESS; | |
7012 | } | |
7013 | ||
f9ad937f | 7014 | |
f412b39a DW |
7015 | /* |
7016 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7017 | * "ip ospf dead-interval <1-65535>", | |
7018 | * "IP Information\n" | |
7019 | * "OSPF interface commands\n" | |
7020 | * "Interval after which a neighbor is declared dead\n" | |
7021 | * "Seconds\n" | |
7022 | * | |
7023 | */ | |
f9ad937f | 7024 | DEFUN (ip_ospf_dead_interval, |
7025 | ip_ospf_dead_interval_addr_cmd, | |
6147e2c6 | 7026 | "ip ospf dead-interval (1-65535) A.B.C.D", |
f9ad937f | 7027 | "IP Information\n" |
7028 | "OSPF interface commands\n" | |
7029 | "Interval after which a neighbor is declared dead\n" | |
7030 | "Seconds\n" | |
7031 | "Address of interface\n") | |
7032 | { | |
7033 | if (argc == 2) | |
bf2bfafd | 7034 | return ospf_vty_dead_interval_set (vty, argv[3]->arg, argv[4]->arg, NULL); |
f9ad937f | 7035 | else |
bf2bfafd | 7036 | return ospf_vty_dead_interval_set (vty, argv[3]->arg, NULL, NULL); |
f9ad937f | 7037 | } |
7038 | ||
718e3744 | 7039 | |
747e489c DW |
7040 | ALIAS_HIDDEN (ip_ospf_dead_interval, |
7041 | ospf_dead_interval_cmd, | |
7042 | "ospf dead-interval <1-65535>", | |
7043 | "OSPF interface commands\n" | |
7044 | "Interval after which a neighbor is declared dead\n" | |
7045 | "Seconds\n") | |
718e3744 | 7046 | |
f412b39a DW |
7047 | /* |
7048 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7049 | * "ip ospf dead-interval minimal hello-multiplier <1-10>", | |
7050 | * "IP Information\n" | |
7051 | * "OSPF interface commands\n" | |
7052 | * "Interval after which a neighbor is declared dead\n" | |
7053 | * "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7054 | * "Hello multiplier factor\n" | |
7055 | * "Number of Hellos to send each second\n" | |
7056 | * | |
7057 | */ | |
f9ad937f | 7058 | DEFUN (ip_ospf_dead_interval_minimal, |
7059 | ip_ospf_dead_interval_minimal_addr_cmd, | |
6147e2c6 | 7060 | "ip ospf dead-interval minimal hello-multiplier (1-10) A.B.C.D", |
f9ad937f | 7061 | "IP Information\n" |
7062 | "OSPF interface commands\n" | |
7063 | "Interval after which a neighbor is declared dead\n" | |
7064 | "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7065 | "Hello multiplier factor\n" | |
7066 | "Number of Hellos to send each second\n" | |
7067 | "Address of interface\n") | |
7068 | { | |
7069 | if (argc == 2) | |
bf2bfafd | 7070 | return ospf_vty_dead_interval_set (vty, NULL, argv[6]->arg, argv[5]->arg); |
f9ad937f | 7071 | else |
bf2bfafd | 7072 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[5]->arg); |
f9ad937f | 7073 | } |
7074 | ||
f9ad937f | 7075 | |
f412b39a DW |
7076 | /* |
7077 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7078 | * "no ospf dead-interval", | |
7079 | * NO_STR | |
7080 | * "OSPF interface commands\n" | |
7081 | * "Interval after which a neighbor is declared dead\n" | |
7082 | * | |
7083 | * "no ip ospf dead-interval minimal hello-multiplier <1-10>", | |
7084 | * NO_STR | |
7085 | * "IP Information\n" | |
7086 | * "OSPF interface commands\n" | |
7087 | * "Interval after which a neighbor is declared dead\n" | |
7088 | * "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7089 | * "Hello multiplier factor\n" | |
7090 | * "Number of Hellos to send each second\n" | |
7091 | * | |
7092 | * "no ip ospf dead-interval <1-65535>", | |
7093 | * NO_STR | |
7094 | * "IP Information\n" | |
7095 | * "OSPF interface commands\n" | |
7096 | * "Interval after which a neighbor is declared dead\n" | |
7097 | * "Seconds\n" | |
7098 | * | |
7099 | * "no ip ospf dead-interval", | |
7100 | * NO_STR | |
7101 | * "IP Information\n" | |
7102 | * "OSPF interface commands\n" | |
7103 | * "Interval after which a neighbor is declared dead\n" | |
7104 | * | |
7105 | * "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", | |
7106 | * NO_STR | |
7107 | * "IP Information\n" | |
7108 | * "OSPF interface commands\n" | |
7109 | * "Interval after which a neighbor is declared dead\n" | |
7110 | * "Minimal 1s dead-interval with fast sub-second hellos\n" | |
7111 | * "Hello multiplier factor\n" | |
7112 | * "Number of Hellos to send each second\n" | |
7113 | * "Address of interface\n" | |
7114 | * | |
7115 | */ | |
718e3744 | 7116 | DEFUN (no_ip_ospf_dead_interval, |
7117 | no_ip_ospf_dead_interval_addr_cmd, | |
6147e2c6 | 7118 | "no ip ospf dead-interval (1-65535) A.B.C.D", |
718e3744 | 7119 | NO_STR |
7120 | "IP Information\n" | |
7121 | "OSPF interface commands\n" | |
7122 | "Interval after which a neighbor is declared dead\n" | |
f9dfba8d | 7123 | "Seconds\n" |
718e3744 | 7124 | "Address of interface") |
7125 | { | |
7126 | struct interface *ifp = vty->index; | |
7127 | struct in_addr addr; | |
7128 | int ret; | |
7129 | struct ospf_if_params *params; | |
7130 | struct ospf_interface *oi; | |
7131 | struct route_node *rn; | |
020709f9 | 7132 | |
718e3744 | 7133 | ifp = vty->index; |
7134 | params = IF_DEF_PARAMS (ifp); | |
7135 | ||
f9dfba8d | 7136 | if (argc == 2) |
718e3744 | 7137 | { |
bf2bfafd | 7138 | ret = inet_aton(argv[5]->arg, &addr); |
718e3744 | 7139 | if (!ret) |
7140 | { | |
7141 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7142 | VTY_NEWLINE); | |
7143 | return CMD_WARNING; | |
7144 | } | |
7145 | ||
7146 | params = ospf_lookup_if_params (ifp, addr); | |
7147 | if (params == NULL) | |
7148 | return CMD_SUCCESS; | |
7149 | } | |
7150 | ||
7151 | UNSET_IF_PARAM (params, v_wait); | |
7152 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 7153 | |
7154 | UNSET_IF_PARAM (params, fast_hello); | |
7155 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
7156 | ||
718e3744 | 7157 | if (params != IF_DEF_PARAMS (ifp)) |
7158 | { | |
7159 | ospf_free_if_params (ifp, addr); | |
7160 | ospf_if_update_params (ifp, addr); | |
7161 | } | |
7162 | ||
7163 | /* Update timer values in neighbor structure. */ | |
7164 | if (argc == 1) | |
7165 | { | |
cac3b5c4 PJ |
7166 | struct ospf *ospf; |
7167 | ||
7168 | if ((ospf = ospf_lookup())) | |
68980084 | 7169 | { |
7170 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
7171 | if (oi) | |
7172 | ospf_nbr_timer_update (oi); | |
7173 | } | |
718e3744 | 7174 | } |
7175 | else | |
7176 | { | |
7177 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7178 | if ((oi = rn->info)) | |
7179 | ospf_nbr_timer_update (oi); | |
7180 | } | |
7181 | ||
7182 | return CMD_SUCCESS; | |
7183 | } | |
7184 | ||
f9dfba8d | 7185 | |
718e3744 | 7186 | |
718e3744 | 7187 | |
813d4307 | 7188 | |
813d4307 | 7189 | |
f412b39a DW |
7190 | /* |
7191 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7192 | * "ip ospf hello-interval <1-65535>", | |
7193 | * "IP Information\n" | |
7194 | * "OSPF interface commands\n" | |
7195 | * "Time between HELLO packets\n" | |
7196 | * "Seconds\n" | |
7197 | * | |
7198 | */ | |
718e3744 | 7199 | DEFUN (ip_ospf_hello_interval, |
7200 | ip_ospf_hello_interval_addr_cmd, | |
6147e2c6 | 7201 | "ip ospf hello-interval (1-65535) A.B.C.D", |
718e3744 | 7202 | "IP Information\n" |
7203 | "OSPF interface commands\n" | |
7204 | "Time between HELLO packets\n" | |
7205 | "Seconds\n" | |
7206 | "Address of interface") | |
7207 | { | |
7208 | struct interface *ifp = vty->index; | |
7209 | u_int32_t seconds; | |
7210 | struct in_addr addr; | |
7211 | int ret; | |
7212 | struct ospf_if_params *params; | |
7213 | ||
7214 | params = IF_DEF_PARAMS (ifp); | |
7215 | ||
bf2bfafd | 7216 | seconds = strtol (argv[3]->arg, NULL, 10); |
718e3744 | 7217 | |
7218 | /* HelloInterval range is <1-65535>. */ | |
7219 | if (seconds < 1 || seconds > 65535) | |
7220 | { | |
7221 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); | |
7222 | return CMD_WARNING; | |
7223 | } | |
7224 | ||
7225 | if (argc == 2) | |
7226 | { | |
bf2bfafd | 7227 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 7228 | if (!ret) |
7229 | { | |
7230 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7231 | VTY_NEWLINE); | |
7232 | return CMD_WARNING; | |
7233 | } | |
7234 | ||
7235 | params = ospf_get_if_params (ifp, addr); | |
7236 | ospf_if_update_params (ifp, addr); | |
7237 | } | |
7238 | ||
f9ad937f | 7239 | SET_IF_PARAM (params, v_hello); |
718e3744 | 7240 | params->v_hello = seconds; |
7241 | ||
7242 | return CMD_SUCCESS; | |
7243 | } | |
7244 | ||
718e3744 | 7245 | |
747e489c DW |
7246 | ALIAS_HIDDEN (ip_ospf_hello_interval, |
7247 | ospf_hello_interval_cmd, | |
7248 | "ospf hello-interval <1-65535>", | |
7249 | "OSPF interface commands\n" | |
7250 | "Time between HELLO packets\n" | |
7251 | "Seconds\n") | |
718e3744 | 7252 | |
f412b39a DW |
7253 | /* |
7254 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7255 | * "no ip ospf hello-interval <1-65535>", | |
7256 | * NO_STR | |
7257 | * "IP Information\n" | |
7258 | * "OSPF interface commands\n" | |
7259 | * "Time between HELLO packets\n" | |
7260 | * "Seconds\n" | |
7261 | * | |
7262 | * "no ip ospf hello-interval", | |
7263 | * NO_STR | |
7264 | * "IP Information\n" | |
7265 | * "OSPF interface commands\n" | |
7266 | * "Time between HELLO packets\n" | |
7267 | * | |
7268 | * "no ospf hello-interval <1-65535>", | |
7269 | * NO_STR | |
7270 | * "OSPF interface commands\n" | |
7271 | * "Time between HELLO packets\n" | |
7272 | * "Seconds\n" | |
7273 | * | |
7274 | */ | |
718e3744 | 7275 | DEFUN (no_ip_ospf_hello_interval, |
7276 | no_ip_ospf_hello_interval_addr_cmd, | |
6147e2c6 | 7277 | "no ip ospf hello-interval (1-65535) A.B.C.D", |
718e3744 | 7278 | NO_STR |
7279 | "IP Information\n" | |
7280 | "OSPF interface commands\n" | |
7281 | "Time between HELLO packets\n" | |
f9dfba8d | 7282 | "Seconds\n" |
718e3744 | 7283 | "Address of interface") |
7284 | { | |
7285 | struct interface *ifp = vty->index; | |
7286 | struct in_addr addr; | |
7287 | int ret; | |
7288 | struct ospf_if_params *params; | |
7289 | ||
7290 | ifp = vty->index; | |
7291 | params = IF_DEF_PARAMS (ifp); | |
7292 | ||
f9dfba8d | 7293 | if (argc == 2) |
718e3744 | 7294 | { |
bf2bfafd | 7295 | ret = inet_aton(argv[5]->arg, &addr); |
718e3744 | 7296 | if (!ret) |
7297 | { | |
7298 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7299 | VTY_NEWLINE); | |
7300 | return CMD_WARNING; | |
7301 | } | |
7302 | ||
7303 | params = ospf_lookup_if_params (ifp, addr); | |
7304 | if (params == NULL) | |
7305 | return CMD_SUCCESS; | |
7306 | } | |
7307 | ||
7308 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 7309 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 7310 | |
7311 | if (params != IF_DEF_PARAMS (ifp)) | |
7312 | { | |
7313 | ospf_free_if_params (ifp, addr); | |
7314 | ospf_if_update_params (ifp, addr); | |
7315 | } | |
7316 | ||
7317 | return CMD_SUCCESS; | |
7318 | } | |
7319 | ||
f9dfba8d | 7320 | |
718e3744 | 7321 | |
718e3744 | 7322 | |
7323 | DEFUN (ip_ospf_network, | |
7324 | ip_ospf_network_cmd, | |
6147e2c6 | 7325 | "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
718e3744 | 7326 | "IP Information\n" |
7327 | "OSPF interface commands\n" | |
7328 | "Network type\n" | |
7329 | "Specify OSPF broadcast multi-access network\n" | |
7330 | "Specify OSPF NBMA network\n" | |
7331 | "Specify OSPF point-to-multipoint network\n" | |
7332 | "Specify OSPF point-to-point network\n") | |
7333 | { | |
7334 | struct interface *ifp = vty->index; | |
7335 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7336 | struct route_node *rn; | |
4b4bda9b CF |
7337 | |
7338 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
7339 | { | |
7340 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
7341 | return CMD_WARNING; | |
7342 | } | |
7343 | ||
bf2bfafd | 7344 | if (strncmp (argv[3]->arg, "b", 1) == 0) |
718e3744 | 7345 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
bf2bfafd | 7346 | else if (strncmp (argv[3]->arg, "n", 1) == 0) |
718e3744 | 7347 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
bf2bfafd | 7348 | else if (strncmp (argv[3]->arg, "point-to-m", 10) == 0) |
718e3744 | 7349 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
bf2bfafd | 7350 | else if (strncmp (argv[3]->arg, "point-to-p", 10) == 0) |
718e3744 | 7351 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
7352 | ||
7353 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7354 | return CMD_SUCCESS; | |
7355 | ||
7356 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
7357 | ||
7358 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7359 | { | |
7360 | struct ospf_interface *oi = rn->info; | |
7361 | ||
7362 | if (!oi) | |
7363 | continue; | |
7364 | ||
7365 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7366 | ||
7367 | if (oi->state > ISM_Down) | |
7368 | { | |
7369 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7370 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7371 | } | |
7372 | } | |
7373 | ||
7374 | return CMD_SUCCESS; | |
7375 | } | |
7376 | ||
747e489c DW |
7377 | ALIAS_HIDDEN (ip_ospf_network, |
7378 | ospf_network_cmd, | |
7379 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7380 | "OSPF interface commands\n" | |
7381 | "Network type\n" | |
7382 | "Specify OSPF broadcast multi-access network\n" | |
7383 | "Specify OSPF NBMA network\n" | |
7384 | "Specify OSPF point-to-multipoint network\n" | |
7385 | "Specify OSPF point-to-point network\n") | |
718e3744 | 7386 | |
f412b39a DW |
7387 | /* |
7388 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7389 | * "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7390 | * NO_STR | |
7391 | * "OSPF interface commands\n" | |
7392 | * "Network type\n" | |
7393 | * "Specify OSPF broadcast multi-access network\n" | |
7394 | * "Specify OSPF NBMA network\n" | |
7395 | * "Specify OSPF point-to-multipoint network\n" | |
7396 | * "Specify OSPF point-to-point network\n" | |
7397 | * | |
7398 | * "no ospf network", | |
7399 | * NO_STR | |
7400 | * "OSPF interface commands\n" | |
7401 | * "Network type\n" | |
7402 | * | |
7403 | * "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", | |
7404 | * NO_STR | |
7405 | * "IP Information\n" | |
7406 | * "OSPF interface commands\n" | |
7407 | * "Network type\n" | |
7408 | * "Specify OSPF broadcast multi-access network\n" | |
7409 | * "Specify OSPF NBMA network\n" | |
7410 | * "Specify OSPF point-to-multipoint network\n" | |
7411 | * "Specify OSPF point-to-point network\n" | |
7412 | * | |
7413 | */ | |
718e3744 | 7414 | DEFUN (no_ip_ospf_network, |
7415 | no_ip_ospf_network_cmd, | |
7416 | "no ip ospf network", | |
7417 | NO_STR | |
7418 | "IP Information\n" | |
7419 | "OSPF interface commands\n" | |
7420 | "Network type\n") | |
7421 | { | |
7422 | struct interface *ifp = vty->index; | |
7423 | int old_type = IF_DEF_PARAMS (ifp)->type; | |
7424 | struct route_node *rn; | |
7425 | ||
bc18d616 | 7426 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
718e3744 | 7427 | |
7428 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
7429 | return CMD_SUCCESS; | |
7430 | ||
7431 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7432 | { | |
7433 | struct ospf_interface *oi = rn->info; | |
7434 | ||
7435 | if (!oi) | |
7436 | continue; | |
7437 | ||
7438 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
7439 | ||
7440 | if (oi->state > ISM_Down) | |
7441 | { | |
7442 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
7443 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
7444 | } | |
7445 | } | |
7446 | ||
7447 | return CMD_SUCCESS; | |
7448 | } | |
7449 | ||
813d4307 | 7450 | |
718e3744 | 7451 | |
813d4307 | 7452 | |
f412b39a DW |
7453 | /* |
7454 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7455 | * "ip ospf priority <0-255>", | |
7456 | * "IP Information\n" | |
7457 | * "OSPF interface commands\n" | |
7458 | * "Router priority\n" | |
7459 | * "Priority\n" | |
7460 | * | |
7461 | */ | |
718e3744 | 7462 | DEFUN (ip_ospf_priority, |
7463 | ip_ospf_priority_addr_cmd, | |
6147e2c6 | 7464 | "ip ospf priority (0-255) A.B.C.D", |
718e3744 | 7465 | "IP Information\n" |
7466 | "OSPF interface commands\n" | |
7467 | "Router priority\n" | |
7468 | "Priority\n" | |
7469 | "Address of interface") | |
7470 | { | |
7471 | struct interface *ifp = vty->index; | |
0798cee3 | 7472 | long priority; |
718e3744 | 7473 | struct route_node *rn; |
7474 | struct in_addr addr; | |
7475 | int ret; | |
7476 | struct ospf_if_params *params; | |
7477 | ||
7478 | params = IF_DEF_PARAMS (ifp); | |
7479 | ||
bf2bfafd | 7480 | priority = strtol (argv[3]->arg, NULL, 10); |
718e3744 | 7481 | |
7482 | /* Router Priority range is <0-255>. */ | |
7483 | if (priority < 0 || priority > 255) | |
7484 | { | |
7485 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); | |
7486 | return CMD_WARNING; | |
7487 | } | |
7488 | ||
7489 | if (argc == 2) | |
7490 | { | |
bf2bfafd | 7491 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 7492 | if (!ret) |
7493 | { | |
7494 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7495 | VTY_NEWLINE); | |
7496 | return CMD_WARNING; | |
7497 | } | |
7498 | ||
7499 | params = ospf_get_if_params (ifp, addr); | |
7500 | ospf_if_update_params (ifp, addr); | |
7501 | } | |
7502 | ||
7503 | SET_IF_PARAM (params, priority); | |
7504 | params->priority = priority; | |
7505 | ||
7506 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7507 | { | |
7508 | struct ospf_interface *oi = rn->info; | |
7509 | ||
7510 | if (!oi) | |
7511 | continue; | |
7512 | ||
7513 | ||
7514 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7515 | { | |
7516 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7517 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7518 | } | |
7519 | } | |
7520 | ||
7521 | return CMD_SUCCESS; | |
7522 | } | |
7523 | ||
718e3744 | 7524 | |
747e489c DW |
7525 | ALIAS_HIDDEN (ip_ospf_priority, |
7526 | ospf_priority_cmd, | |
7527 | "ospf priority <0-255>", | |
7528 | "OSPF interface commands\n" | |
7529 | "Router priority\n" | |
7530 | "Priority\n") | |
718e3744 | 7531 | |
f412b39a DW |
7532 | /* |
7533 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7534 | * "no ip ospf priority", | |
7535 | * NO_STR | |
7536 | * "IP Information\n" | |
7537 | * "OSPF interface commands\n" | |
7538 | * "Router priority\n" | |
7539 | * | |
7540 | * "no ip ospf priority <0-255>", | |
7541 | * NO_STR | |
7542 | * "IP Information\n" | |
7543 | * "OSPF interface commands\n" | |
7544 | * "Router priority\n" | |
7545 | * "Priority\n" | |
7546 | * | |
7547 | * "no ospf priority <0-255>", | |
7548 | * NO_STR | |
7549 | * "OSPF interface commands\n" | |
7550 | * "Router priority\n" | |
7551 | * "Priority\n" | |
7552 | * | |
7553 | */ | |
718e3744 | 7554 | DEFUN (no_ip_ospf_priority, |
7555 | no_ip_ospf_priority_addr_cmd, | |
6147e2c6 | 7556 | "no ip ospf priority (0-255) A.B.C.D", |
718e3744 | 7557 | NO_STR |
7558 | "IP Information\n" | |
7559 | "OSPF interface commands\n" | |
7560 | "Router priority\n" | |
813d4307 | 7561 | "Priority\n" |
718e3744 | 7562 | "Address of interface") |
7563 | { | |
7564 | struct interface *ifp = vty->index; | |
7565 | struct route_node *rn; | |
7566 | struct in_addr addr; | |
7567 | int ret; | |
7568 | struct ospf_if_params *params; | |
7569 | ||
7570 | ifp = vty->index; | |
7571 | params = IF_DEF_PARAMS (ifp); | |
7572 | ||
813d4307 | 7573 | if (argc == 2) |
718e3744 | 7574 | { |
bf2bfafd | 7575 | ret = inet_aton(argv[5]->arg, &addr); |
718e3744 | 7576 | if (!ret) |
7577 | { | |
7578 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7579 | VTY_NEWLINE); | |
7580 | return CMD_WARNING; | |
7581 | } | |
7582 | ||
7583 | params = ospf_lookup_if_params (ifp, addr); | |
7584 | if (params == NULL) | |
7585 | return CMD_SUCCESS; | |
7586 | } | |
7587 | ||
7588 | UNSET_IF_PARAM (params, priority); | |
7589 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
7590 | ||
7591 | if (params != IF_DEF_PARAMS (ifp)) | |
7592 | { | |
7593 | ospf_free_if_params (ifp, addr); | |
7594 | ospf_if_update_params (ifp, addr); | |
7595 | } | |
7596 | ||
7597 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
7598 | { | |
7599 | struct ospf_interface *oi = rn->info; | |
7600 | ||
7601 | if (!oi) | |
7602 | continue; | |
7603 | ||
7604 | ||
7605 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
7606 | { | |
7607 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
7608 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
7609 | } | |
7610 | } | |
7611 | ||
7612 | return CMD_SUCCESS; | |
7613 | } | |
7614 | ||
a1afa410 | 7615 | |
718e3744 | 7616 | |
718e3744 | 7617 | |
d5a5c8f0 | 7618 | |
f412b39a DW |
7619 | /* |
7620 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7621 | * "ip ospf retransmit-interval <3-65535>", | |
7622 | * "IP Information\n" | |
7623 | * "OSPF interface commands\n" | |
7624 | * "Time between retransmitting lost link state advertisements\n" | |
7625 | * "Seconds\n" | |
7626 | * | |
7627 | */ | |
718e3744 | 7628 | DEFUN (ip_ospf_retransmit_interval, |
7629 | ip_ospf_retransmit_interval_addr_cmd, | |
6147e2c6 | 7630 | "ip ospf retransmit-interval (3-65535) A.B.C.D", |
718e3744 | 7631 | "IP Information\n" |
7632 | "OSPF interface commands\n" | |
7633 | "Time between retransmitting lost link state advertisements\n" | |
7634 | "Seconds\n" | |
7635 | "Address of interface") | |
7636 | { | |
7637 | struct interface *ifp = vty->index; | |
7638 | u_int32_t seconds; | |
7639 | struct in_addr addr; | |
7640 | int ret; | |
7641 | struct ospf_if_params *params; | |
7642 | ||
7643 | params = IF_DEF_PARAMS (ifp); | |
bf2bfafd | 7644 | seconds = strtol (argv[3]->arg, NULL, 10); |
718e3744 | 7645 | |
7646 | /* Retransmit Interval range is <3-65535>. */ | |
7647 | if (seconds < 3 || seconds > 65535) | |
7648 | { | |
7649 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); | |
7650 | return CMD_WARNING; | |
7651 | } | |
7652 | ||
7653 | ||
7654 | if (argc == 2) | |
7655 | { | |
bf2bfafd | 7656 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 7657 | if (!ret) |
7658 | { | |
7659 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7660 | VTY_NEWLINE); | |
7661 | return CMD_WARNING; | |
7662 | } | |
7663 | ||
7664 | params = ospf_get_if_params (ifp, addr); | |
7665 | ospf_if_update_params (ifp, addr); | |
7666 | } | |
7667 | ||
7668 | SET_IF_PARAM (params, retransmit_interval); | |
7669 | params->retransmit_interval = seconds; | |
7670 | ||
7671 | return CMD_SUCCESS; | |
7672 | } | |
7673 | ||
718e3744 | 7674 | |
747e489c DW |
7675 | ALIAS_HIDDEN (ip_ospf_retransmit_interval, |
7676 | ospf_retransmit_interval_cmd, | |
7677 | "ospf retransmit-interval <3-65535>", | |
7678 | "OSPF interface commands\n" | |
7679 | "Time between retransmitting lost link state advertisements\n" | |
7680 | "Seconds\n") | |
718e3744 | 7681 | |
f412b39a DW |
7682 | /* |
7683 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7684 | * "no ip ospf retransmit-interval <3-65535> A.B.C.D", | |
7685 | * NO_STR | |
7686 | * "IP Information\n" | |
7687 | * "OSPF interface commands\n" | |
7688 | * "Time between retransmitting lost link state advertisements\n" | |
7689 | * "Seconds\n" | |
7690 | * "Address of interface" | |
7691 | * | |
7692 | * "no ip ospf retransmit-interval", | |
7693 | * NO_STR | |
7694 | * "IP Information\n" | |
7695 | * "OSPF interface commands\n" | |
7696 | * "Time between retransmitting lost link state advertisements\n" | |
7697 | * | |
7698 | * "no ospf retransmit-interval", | |
7699 | * NO_STR | |
7700 | * "OSPF interface commands\n" | |
7701 | * "Time between retransmitting lost link state advertisements\n" | |
7702 | * | |
7703 | */ | |
718e3744 | 7704 | DEFUN (no_ip_ospf_retransmit_interval, |
7705 | no_ip_ospf_retransmit_interval_addr_cmd, | |
7706 | "no ip ospf retransmit-interval A.B.C.D", | |
7707 | NO_STR | |
7708 | "IP Information\n" | |
7709 | "OSPF interface commands\n" | |
7710 | "Time between retransmitting lost link state advertisements\n" | |
7711 | "Address of interface") | |
7712 | { | |
7713 | struct interface *ifp = vty->index; | |
7714 | struct in_addr addr; | |
7715 | int ret; | |
7716 | struct ospf_if_params *params; | |
813d4307 | 7717 | int addr_index; |
718e3744 | 7718 | |
7719 | ifp = vty->index; | |
7720 | params = IF_DEF_PARAMS (ifp); | |
7721 | ||
813d4307 | 7722 | if (argc >= 1) |
718e3744 | 7723 | { |
813d4307 DW |
7724 | if (argc == 1) |
7725 | addr_index = 0; | |
7726 | else | |
7727 | addr_index = 1; | |
7728 | ||
7729 | ret = inet_aton(argv[addr_index], &addr); | |
718e3744 | 7730 | if (!ret) |
7731 | { | |
7732 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7733 | VTY_NEWLINE); | |
7734 | return CMD_WARNING; | |
7735 | } | |
7736 | ||
7737 | params = ospf_lookup_if_params (ifp, addr); | |
7738 | if (params == NULL) | |
7739 | return CMD_SUCCESS; | |
7740 | } | |
7741 | ||
7742 | UNSET_IF_PARAM (params, retransmit_interval); | |
7743 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7744 | ||
7745 | if (params != IF_DEF_PARAMS (ifp)) | |
7746 | { | |
7747 | ospf_free_if_params (ifp, addr); | |
7748 | ospf_if_update_params (ifp, addr); | |
7749 | } | |
7750 | ||
7751 | return CMD_SUCCESS; | |
7752 | } | |
7753 | ||
813d4307 | 7754 | |
718e3744 | 7755 | |
718e3744 | 7756 | |
813d4307 DW |
7757 | DEFUN (no_ip_ospf_retransmit_interval_sec, |
7758 | no_ip_ospf_retransmit_interval_sec_cmd, | |
6147e2c6 | 7759 | "no ip ospf retransmit-interval (3-65535)", |
813d4307 DW |
7760 | NO_STR |
7761 | "IP Information\n" | |
7762 | "OSPF interface commands\n" | |
7763 | "Time between retransmitting lost link state advertisements\n" | |
7764 | "Seconds\n") | |
7765 | { | |
7766 | struct interface *ifp = vty->index; | |
7767 | struct ospf_if_params *params; | |
7768 | ||
7769 | ifp = vty->index; | |
7770 | params = IF_DEF_PARAMS (ifp); | |
7771 | ||
7772 | UNSET_IF_PARAM (params, retransmit_interval); | |
7773 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
7774 | ||
7775 | return CMD_SUCCESS; | |
7776 | } | |
7777 | ||
7778 | ||
f412b39a DW |
7779 | /* |
7780 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7781 | * "ip ospf transmit-delay <1-65535>", | |
7782 | * "IP Information\n" | |
7783 | * "OSPF interface commands\n" | |
7784 | * "Link state transmit delay\n" | |
7785 | * "Seconds\n" | |
7786 | * | |
7787 | */ | |
718e3744 | 7788 | DEFUN (ip_ospf_transmit_delay, |
7789 | ip_ospf_transmit_delay_addr_cmd, | |
6147e2c6 | 7790 | "ip ospf transmit-delay (1-65535) A.B.C.D", |
718e3744 | 7791 | "IP Information\n" |
7792 | "OSPF interface commands\n" | |
7793 | "Link state transmit delay\n" | |
7794 | "Seconds\n" | |
7795 | "Address of interface") | |
7796 | { | |
7797 | struct interface *ifp = vty->index; | |
7798 | u_int32_t seconds; | |
7799 | struct in_addr addr; | |
7800 | int ret; | |
7801 | struct ospf_if_params *params; | |
7802 | ||
7803 | params = IF_DEF_PARAMS (ifp); | |
bf2bfafd | 7804 | seconds = strtol (argv[3]->arg, NULL, 10); |
718e3744 | 7805 | |
7806 | /* Transmit Delay range is <1-65535>. */ | |
7807 | if (seconds < 1 || seconds > 65535) | |
7808 | { | |
7809 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); | |
7810 | return CMD_WARNING; | |
7811 | } | |
7812 | ||
7813 | if (argc == 2) | |
7814 | { | |
bf2bfafd | 7815 | ret = inet_aton(argv[4]->arg, &addr); |
718e3744 | 7816 | if (!ret) |
7817 | { | |
7818 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7819 | VTY_NEWLINE); | |
7820 | return CMD_WARNING; | |
7821 | } | |
7822 | ||
7823 | params = ospf_get_if_params (ifp, addr); | |
7824 | ospf_if_update_params (ifp, addr); | |
7825 | } | |
7826 | ||
7827 | SET_IF_PARAM (params, transmit_delay); | |
7828 | params->transmit_delay = seconds; | |
7829 | ||
7830 | return CMD_SUCCESS; | |
7831 | } | |
7832 | ||
718e3744 | 7833 | |
747e489c DW |
7834 | ALIAS_HIDDEN (ip_ospf_transmit_delay, |
7835 | ospf_transmit_delay_cmd, | |
7836 | "ospf transmit-delay <1-65535>", | |
7837 | "OSPF interface commands\n" | |
7838 | "Link state transmit delay\n" | |
7839 | "Seconds\n") | |
718e3744 | 7840 | |
f412b39a DW |
7841 | /* |
7842 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7843 | * "no ospf transmit-delay", | |
7844 | * NO_STR | |
7845 | * "OSPF interface commands\n" | |
7846 | * "Link state transmit delay\n" | |
7847 | * | |
7848 | * "no ip ospf transmit-delay", | |
7849 | * NO_STR | |
7850 | * "IP Information\n" | |
7851 | * "OSPF interface commands\n" | |
7852 | * "Link state transmit delay\n" | |
7853 | * | |
7854 | * "no ip ospf transmit-delay <1-65535> A.B.C.D", | |
7855 | * NO_STR | |
7856 | * "IP Information\n" | |
7857 | * "OSPF interface commands\n" | |
7858 | * "Link state transmit delay\n" | |
7859 | * "Seconds\n" | |
7860 | * "Address of interface" | |
7861 | * | |
7862 | */ | |
718e3744 | 7863 | DEFUN (no_ip_ospf_transmit_delay, |
7864 | no_ip_ospf_transmit_delay_addr_cmd, | |
7865 | "no ip ospf transmit-delay A.B.C.D", | |
7866 | NO_STR | |
7867 | "IP Information\n" | |
7868 | "OSPF interface commands\n" | |
7869 | "Link state transmit delay\n" | |
7870 | "Address of interface") | |
7871 | { | |
7872 | struct interface *ifp = vty->index; | |
7873 | struct in_addr addr; | |
7874 | int ret; | |
7875 | struct ospf_if_params *params; | |
813d4307 | 7876 | int addr_index; |
718e3744 | 7877 | |
7878 | ifp = vty->index; | |
7879 | params = IF_DEF_PARAMS (ifp); | |
7880 | ||
813d4307 | 7881 | if (argc >= 1) |
718e3744 | 7882 | { |
813d4307 DW |
7883 | if (argc == 1) |
7884 | addr_index = 0; | |
7885 | else | |
7886 | addr_index = 1; | |
7887 | ||
7888 | ret = inet_aton(argv[addr_index], &addr); | |
718e3744 | 7889 | if (!ret) |
7890 | { | |
7891 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7892 | VTY_NEWLINE); | |
7893 | return CMD_WARNING; | |
7894 | } | |
7895 | ||
7896 | params = ospf_lookup_if_params (ifp, addr); | |
7897 | if (params == NULL) | |
7898 | return CMD_SUCCESS; | |
7899 | } | |
7900 | ||
7901 | UNSET_IF_PARAM (params, transmit_delay); | |
7902 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7903 | ||
7904 | if (params != IF_DEF_PARAMS (ifp)) | |
7905 | { | |
7906 | ospf_free_if_params (ifp, addr); | |
7907 | ospf_if_update_params (ifp, addr); | |
7908 | } | |
7909 | ||
7910 | return CMD_SUCCESS; | |
7911 | } | |
7912 | ||
813d4307 | 7913 | |
718e3744 | 7914 | |
718e3744 | 7915 | |
813d4307 DW |
7916 | DEFUN (no_ip_ospf_transmit_delay_sec, |
7917 | no_ip_ospf_transmit_delay_sec_cmd, | |
6147e2c6 | 7918 | "no ip ospf transmit-delay (1-65535)", |
813d4307 DW |
7919 | NO_STR |
7920 | "IP Information\n" | |
7921 | "OSPF interface commands\n" | |
7922 | "Link state transmit delay\n" | |
7923 | "Seconds\n" | |
7924 | "Address of interface") | |
7925 | { | |
7926 | struct interface *ifp = vty->index; | |
7927 | struct ospf_if_params *params; | |
7928 | ||
7929 | ifp = vty->index; | |
7930 | params = IF_DEF_PARAMS (ifp); | |
7931 | ||
7932 | UNSET_IF_PARAM (params, transmit_delay); | |
7933 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
7934 | ||
7935 | return CMD_SUCCESS; | |
7936 | } | |
7937 | ||
f412b39a DW |
7938 | /* |
7939 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
7940 | * "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
7941 | * "IP Information\n" | |
7942 | * "OSPF interface commands\n" | |
7943 | * "Instance ID\n" | |
7944 | * "Enable OSPF on this interface\n" | |
7945 | * "OSPF area ID in IP address format\n" | |
7946 | * "OSPF area ID as a decimal value\n" | |
7947 | * | |
7948 | */ | |
e723861d DS |
7949 | DEFUN (ip_ospf_area, |
7950 | ip_ospf_area_cmd, | |
6147e2c6 | 7951 | "ip ospf area <A.B.C.D|(0-4294967295)>", |
e723861d DS |
7952 | "IP Information\n" |
7953 | "OSPF interface commands\n" | |
7954 | "Enable OSPF on this interface\n" | |
7955 | "OSPF area ID in IP address format\n" | |
7956 | "OSPF area ID as a decimal value\n") | |
7957 | { | |
7958 | struct interface *ifp = vty->index; | |
7959 | int format, ret; | |
7960 | struct in_addr area_id; | |
7961 | struct ospf *ospf; | |
7962 | struct ospf_if_params *params; | |
7963 | struct route_node *rn; | |
7c8ff89e | 7964 | u_short instance = 0; |
e723861d | 7965 | |
7c8ff89e | 7966 | if (argc == 2) |
bf2bfafd | 7967 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
7c8ff89e DS |
7968 | |
7969 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
7970 | if (ospf == NULL) |
7971 | { | |
7c8ff89e DS |
7972 | params = IF_DEF_PARAMS (ifp); |
7973 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7974 | { | |
7975 | ospf_interface_unset (ifp); | |
7976 | ospf = ospf_lookup(); | |
7977 | ospf->if_ospf_cli_count--; | |
7978 | } | |
e723861d DS |
7979 | return CMD_SUCCESS; |
7980 | } | |
7981 | ||
7c8ff89e | 7982 | ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format); |
e723861d DS |
7983 | if (ret < 0) |
7984 | { | |
7985 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
7986 | VTY_NEWLINE); | |
7987 | return CMD_WARNING; | |
7988 | } | |
7989 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
7990 | { | |
7991 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
7992 | return CMD_WARNING; | |
7993 | } | |
7994 | ||
7995 | params = IF_DEF_PARAMS (ifp); | |
7996 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7997 | { | |
73b9f703 VK |
7998 | vty_out (vty, |
7999 | "Must remove previous area config before changing ospf area %s", | |
8000 | VTY_NEWLINE); | |
e723861d DS |
8001 | return CMD_WARNING; |
8002 | } | |
8003 | ||
8004 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
8005 | { | |
8006 | if (rn->info != NULL) | |
8007 | { | |
8008 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
8009 | return CMD_WARNING; | |
8010 | } | |
8011 | } | |
8012 | ||
8013 | /* enable ospf on this interface with area_id */ | |
8014 | ospf_interface_set (ifp, area_id); | |
8015 | ospf->if_ospf_cli_count++; | |
8016 | ||
8017 | return CMD_SUCCESS; | |
8018 | } | |
8019 | ||
7c8ff89e | 8020 | |
f412b39a DW |
8021 | /* |
8022 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8023 | * "no ip ospf area (A.B.C.D|<0-4294967295>)", | |
8024 | * NO_STR | |
8025 | * "IP Information\n" | |
8026 | * "OSPF interface commands\n" | |
8027 | * "Disable OSPF on this interface\n" | |
8028 | * "OSPF area ID in IP address format\n" | |
8029 | * "OSPF area ID as a decimal value\n" | |
8030 | * | |
8031 | */ | |
e723861d DS |
8032 | DEFUN (no_ip_ospf_area, |
8033 | no_ip_ospf_area_cmd, | |
8034 | "no ip ospf area", | |
8035 | NO_STR | |
8036 | "IP Information\n" | |
8037 | "OSPF interface commands\n" | |
8038 | "Disable OSPF on this interface\n") | |
8039 | { | |
8040 | struct interface *ifp = vty->index; | |
8041 | struct ospf *ospf; | |
8042 | struct ospf_if_params *params; | |
7c8ff89e | 8043 | u_short instance = 0; |
e723861d | 8044 | |
7c8ff89e DS |
8045 | if ((ospf = ospf_lookup_instance (instance)) == NULL) |
8046 | return CMD_SUCCESS; | |
e723861d DS |
8047 | |
8048 | params = IF_DEF_PARAMS (ifp); | |
8049 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
8050 | { | |
8051 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
8052 | return CMD_WARNING; | |
8053 | } | |
8054 | ||
8055 | ospf_interface_unset (ifp); | |
8056 | ospf->if_ospf_cli_count--; | |
8057 | return CMD_SUCCESS; | |
8058 | } | |
8059 | ||
813d4307 | 8060 | |
f412b39a DW |
8061 | /* |
8062 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8063 | * "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)", | |
8064 | * NO_STR | |
8065 | * "IP Information\n" | |
8066 | * "OSPF interface commands\n" | |
8067 | * "Instance ID\n" | |
8068 | * "Disable OSPF on this interface\n" | |
8069 | * "OSPF area ID in IP address format\n" | |
8070 | * "OSPF area ID as a decimal value\n" | |
8071 | * | |
8072 | */ | |
813d4307 | 8073 | DEFUN (no_ip_ospf_instance_area, |
7c8ff89e | 8074 | no_ip_ospf_instance_area_cmd, |
6147e2c6 | 8075 | "no ip ospf (1-65535) area", |
7c8ff89e DS |
8076 | NO_STR |
8077 | "IP Information\n" | |
8078 | "OSPF interface commands\n" | |
8079 | "Instance ID\n" | |
8080 | "Disable OSPF on this interface\n") | |
813d4307 DW |
8081 | { |
8082 | struct interface *ifp = vty->index; | |
8083 | struct ospf *ospf; | |
8084 | struct ospf_if_params *params; | |
8085 | u_short instance = 0; | |
8086 | ||
bf2bfafd | 8087 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
813d4307 DW |
8088 | |
8089 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
8090 | return CMD_SUCCESS; | |
8091 | ||
8092 | params = IF_DEF_PARAMS (ifp); | |
8093 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
8094 | { | |
8095 | vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE); | |
8096 | return CMD_WARNING; | |
8097 | } | |
8098 | ||
8099 | ospf_interface_unset (ifp); | |
8100 | ospf->if_ospf_cli_count--; | |
8101 | return CMD_SUCCESS; | |
8102 | } | |
8103 | ||
7c8ff89e | 8104 | |
6f2a6703 CF |
8105 | DEFUN (ospf_redistribute_source, |
8106 | ospf_redistribute_source_cmd, | |
6147e2c6 | 8107 | "redistribute " QUAGGA_REDIST_STR_OSPFD " [metric (0-16777214)|metric-type <1|2>|route-map WORD]", |
d1c65c21 PJ |
8108 | REDIST_STR |
8109 | QUAGGA_REDIST_HELP_STR_OSPFD | |
718e3744 | 8110 | "Metric for redistributed routes\n" |
8111 | "OSPF default metric\n" | |
8112 | "OSPF exterior metric type for redistributed routes\n" | |
8113 | "Set OSPF External Type 1 metrics\n" | |
8114 | "Set OSPF External Type 2 metrics\n" | |
8115 | "Route map reference\n" | |
8116 | "Pointer to route-map entries\n") | |
8117 | { | |
020709f9 | 8118 | struct ospf *ospf = vty->index; |
718e3744 | 8119 | int source; |
8120 | int type = -1; | |
8121 | int metric = -1; | |
7c8ff89e | 8122 | struct ospf_redist *red; |
718e3744 | 8123 | |
d8f70b86 DS |
8124 | if (!ospf) |
8125 | return CMD_SUCCESS; | |
8126 | ||
6f2a6703 CF |
8127 | if (argc < 4) |
8128 | return CMD_WARNING; /* should not happen */ | |
8129 | ||
7c8ff89e DS |
8130 | if (!ospf) |
8131 | return CMD_SUCCESS; | |
8132 | ||
718e3744 | 8133 | /* Get distribute source. */ |
bf2bfafd | 8134 | source = proto_redistnum(AFI_IP, argv[1]->arg); |
e0ca5fde | 8135 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
718e3744 | 8136 | return CMD_WARNING; |
8137 | ||
8138 | /* Get metric value. */ | |
bf2bfafd DW |
8139 | if (argv[2]->arg != NULL) |
8140 | if (!str2metric (argv[2]->arg, &metric)) | |
718e3744 | 8141 | return CMD_WARNING; |
8142 | ||
8143 | /* Get metric type. */ | |
6f2a6703 | 8144 | if (argv[2] != NULL) |
718e3744 | 8145 | if (!str2metric_type (argv[2], &type)) |
8146 | return CMD_WARNING; | |
8147 | ||
7c8ff89e DS |
8148 | red = ospf_redist_add(ospf, source, 0); |
8149 | ||
6f2a6703 | 8150 | if (argv[3] != NULL) |
7c8ff89e | 8151 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8152 | else |
7c8ff89e | 8153 | ospf_routemap_unset (red); |
718e3744 | 8154 | |
7c8ff89e | 8155 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 8156 | } |
8157 | ||
718e3744 | 8158 | DEFUN (no_ospf_redistribute_source, |
8159 | no_ospf_redistribute_source_cmd, | |
6147e2c6 | 8160 | "no redistribute " QUAGGA_REDIST_STR_OSPFD " [metric (0-16777214)|metric-type <1|2>|route-map WORD]", |
718e3744 | 8161 | NO_STR |
d1c65c21 | 8162 | REDIST_STR |
813d4307 DW |
8163 | QUAGGA_REDIST_HELP_STR_OSPFD |
8164 | "Metric for redistributed routes\n" | |
8165 | "OSPF default metric\n" | |
8166 | "OSPF exterior metric type for redistributed routes\n" | |
8167 | "Set OSPF External Type 1 metrics\n" | |
8168 | "Set OSPF External Type 2 metrics\n" | |
8169 | "Route map reference\n" | |
8170 | "Pointer to route-map entries\n") | |
718e3744 | 8171 | { |
020709f9 | 8172 | struct ospf *ospf = vty->index; |
718e3744 | 8173 | int source; |
7c8ff89e DS |
8174 | struct ospf_redist *red; |
8175 | if (!ospf) | |
8176 | return CMD_SUCCESS; | |
718e3744 | 8177 | |
bf2bfafd | 8178 | source = proto_redistnum(AFI_IP, argv[2]->arg); |
e0ca5fde | 8179 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
718e3744 | 8180 | return CMD_WARNING; |
8181 | ||
7c8ff89e DS |
8182 | red = ospf_redist_lookup(ospf, source, 0); |
8183 | if (!red) | |
8184 | return CMD_SUCCESS; | |
8185 | ||
8186 | ospf_routemap_unset (red); | |
8187 | return ospf_redistribute_unset (ospf, source, 0); | |
8188 | } | |
8189 | ||
8190 | DEFUN (ospf_redistribute_instance_source, | |
8191 | ospf_redistribute_instance_source_cmd, | |
6147e2c6 | 8192 | "redistribute <ospf|table> (1-65535) [metric (0-16777214)|metric-type <1|2>|route-map WORD]", |
7c8ff89e DS |
8193 | REDIST_STR |
8194 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8195 | "Non-main Kernel Routing Table\n" |
8196 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
8197 | "Metric for redistributed routes\n" |
8198 | "OSPF default metric\n" | |
8199 | "OSPF exterior metric type for redistributed routes\n" | |
8200 | "Set OSPF External Type 1 metrics\n" | |
8201 | "Set OSPF External Type 2 metrics\n" | |
8202 | "Route map reference\n" | |
8203 | "Pointer to route-map entries\n") | |
8204 | { | |
8205 | struct ospf *ospf = vty->index; | |
8206 | int source; | |
8207 | int type = -1; | |
8208 | int metric = -1; | |
8209 | u_short instance; | |
8210 | struct ospf_redist *red; | |
8211 | ||
d8f70b86 DS |
8212 | if (!ospf) |
8213 | return CMD_SUCCESS; | |
8214 | ||
bf2bfafd | 8215 | if (strncmp(argv[1]->arg, "o", 1) == 0) |
2d627ff5 DS |
8216 | source = ZEBRA_ROUTE_OSPF; |
8217 | else | |
8218 | source = ZEBRA_ROUTE_TABLE; | |
8219 | ||
bf2bfafd | 8220 | VTY_GET_INTEGER ("Instance ID", instance, argv[2]->arg); |
7c8ff89e DS |
8221 | |
8222 | if (!ospf) | |
8223 | return CMD_SUCCESS; | |
8224 | ||
2d627ff5 | 8225 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
8226 | { |
8227 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
8228 | VTY_NEWLINE); | |
8229 | return CMD_WARNING; | |
8230 | } | |
8231 | ||
2d627ff5 | 8232 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
8233 | { |
8234 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
8235 | VTY_NEWLINE); | |
8236 | return CMD_WARNING; | |
8237 | } | |
8238 | ||
7c8ff89e | 8239 | /* Get metric value. */ |
bf2bfafd DW |
8240 | if (argv[3]->arg != NULL) |
8241 | if (!str2metric (argv[3]->arg, &metric)) | |
7c8ff89e DS |
8242 | return CMD_WARNING; |
8243 | ||
8244 | /* Get metric type. */ | |
2d627ff5 DS |
8245 | if (argv[3] != NULL) |
8246 | if (!str2metric_type (argv[3], &type)) | |
7c8ff89e DS |
8247 | return CMD_WARNING; |
8248 | ||
8249 | red = ospf_redist_add(ospf, source, instance); | |
2d627ff5 DS |
8250 | if (argv[4] != NULL) |
8251 | ospf_routemap_set (red, argv[4]); | |
7c8ff89e DS |
8252 | else |
8253 | ospf_routemap_unset (red); | |
8254 | ||
8255 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
8256 | } | |
8257 | ||
8258 | DEFUN (no_ospf_redistribute_instance_source, | |
8259 | no_ospf_redistribute_instance_source_cmd, | |
6147e2c6 | 8260 | "no redistribute <ospf|table> (1-65535) [metric (0-16777214)|metric-type <1|2>|route-map WORD]", |
7c8ff89e DS |
8261 | NO_STR |
8262 | REDIST_STR | |
8263 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8264 | "Non-main Kernel Routing Table\n" |
8265 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
8266 | "Metric for redistributed routes\n" |
8267 | "OSPF default metric\n" | |
8268 | "OSPF exterior metric type for redistributed routes\n" | |
8269 | "Set OSPF External Type 1 metrics\n" | |
8270 | "Set OSPF External Type 2 metrics\n" | |
8271 | "Route map reference\n" | |
8272 | "Pointer to route-map entries\n") | |
8273 | { | |
8274 | struct ospf *ospf = vty->index; | |
8275 | u_int instance; | |
8276 | struct ospf_redist *red; | |
8277 | int source; | |
8278 | ||
8279 | if (!ospf) | |
8280 | return CMD_SUCCESS; | |
8281 | ||
bf2bfafd | 8282 | if (strncmp(argv[2]->arg, "o", 1) == 0) |
2d627ff5 DS |
8283 | source = ZEBRA_ROUTE_OSPF; |
8284 | else | |
8285 | source = ZEBRA_ROUTE_TABLE; | |
8286 | ||
bf2bfafd | 8287 | VTY_GET_INTEGER ("Instance ID", instance, argv[3]->arg); |
7c8ff89e | 8288 | |
2d627ff5 | 8289 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
8290 | { |
8291 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
8292 | VTY_NEWLINE); | |
8293 | return CMD_WARNING; | |
8294 | } | |
8295 | ||
2d627ff5 | 8296 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
8297 | { |
8298 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
8299 | VTY_NEWLINE); | |
8300 | return CMD_WARNING; | |
8301 | } | |
8302 | ||
7c8ff89e DS |
8303 | red = ospf_redist_lookup(ospf, source, instance); |
8304 | if (!red) | |
8305 | return CMD_SUCCESS; | |
8306 | ||
8307 | ospf_routemap_unset (red); | |
8308 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 8309 | } |
8310 | ||
8311 | DEFUN (ospf_distribute_list_out, | |
8312 | ospf_distribute_list_out_cmd, | |
d1c65c21 | 8313 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
718e3744 | 8314 | "Filter networks in routing updates\n" |
6f2a6703 CF |
8315 | "Access-list name\n" |
8316 | OUT_STR | |
8317 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 8318 | { |
020709f9 | 8319 | struct ospf *ospf = vty->index; |
6f2a6703 | 8320 | int source; |
718e3744 | 8321 | |
7c8ff89e DS |
8322 | if (!ospf) |
8323 | return CMD_SUCCESS; | |
8324 | ||
6f2a6703 | 8325 | /* Get distribute source. */ |
bf2bfafd | 8326 | source = proto_redistnum(AFI_IP, argv[4]->arg); |
6f2a6703 CF |
8327 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
8328 | return CMD_WARNING; | |
718e3744 | 8329 | |
bf2bfafd | 8330 | return ospf_distribute_list_out_set (ospf, source, argv[1]->arg); |
718e3744 | 8331 | } |
8332 | ||
6f2a6703 CF |
8333 | DEFUN (no_ospf_distribute_list_out, |
8334 | no_ospf_distribute_list_out_cmd, | |
8335 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, | |
8336 | NO_STR | |
8337 | "Filter networks in routing updates\n" | |
8338 | "Access-list name\n" | |
8339 | OUT_STR | |
8340 | QUAGGA_REDIST_HELP_STR_OSPFD) | |
718e3744 | 8341 | { |
020709f9 | 8342 | struct ospf *ospf = vty->index; |
6f2a6703 | 8343 | int source; |
020709f9 | 8344 | |
7c8ff89e DS |
8345 | if (!ospf) |
8346 | return CMD_SUCCESS; | |
8347 | ||
bf2bfafd | 8348 | source = proto_redistnum(AFI_IP, argv[5]->arg); |
6f2a6703 CF |
8349 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
8350 | return CMD_WARNING; | |
718e3744 | 8351 | |
bf2bfafd | 8352 | return ospf_distribute_list_out_unset (ospf, source, argv[2]->arg); |
718e3744 | 8353 | } |
8354 | ||
6f2a6703 CF |
8355 | /* Default information originate. */ |
8356 | DEFUN (ospf_default_information_originate, | |
8357 | ospf_default_information_originate_cmd, | |
6147e2c6 | 8358 | "default-information originate [always|metric (0-16777214)|metric-type <1|2>|route-map WORD]", |
718e3744 | 8359 | "Control distribution of default information\n" |
8360 | "Distribute a default route\n" | |
8361 | "Always advertise default route\n" | |
6f2a6703 CF |
8362 | "OSPF default metric\n" |
8363 | "OSPF metric\n" | |
718e3744 | 8364 | "OSPF metric type for default routes\n" |
8365 | "Set OSPF External Type 1 metrics\n" | |
8366 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 8367 | "Route map reference\n" |
8368 | "Pointer to route-map entries\n") | |
8369 | { | |
020709f9 | 8370 | struct ospf *ospf = vty->index; |
6f2a6703 | 8371 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 8372 | int type = -1; |
8373 | int metric = -1; | |
7c8ff89e DS |
8374 | struct ospf_redist *red; |
8375 | ||
8376 | if (!ospf) | |
8377 | return CMD_SUCCESS; | |
718e3744 | 8378 | |
6f2a6703 CF |
8379 | if (argc < 4) |
8380 | return CMD_WARNING; /* this should not happen */ | |
8381 | ||
8382 | /* Check whether "always" was specified */ | |
bf2bfafd | 8383 | if (argv[2]->arg != NULL) |
6f2a6703 | 8384 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
718e3744 | 8385 | |
7c8ff89e DS |
8386 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
8387 | ||
718e3744 | 8388 | /* Get metric value. */ |
6f2a6703 | 8389 | if (argv[1] != NULL) |
718e3744 | 8390 | if (!str2metric (argv[1], &metric)) |
8391 | return CMD_WARNING; | |
8392 | ||
718e3744 | 8393 | /* Get metric type. */ |
6f2a6703 CF |
8394 | if (argv[2] != NULL) |
8395 | if (!str2metric_type (argv[2], &type)) | |
718e3744 | 8396 | return CMD_WARNING; |
8397 | ||
6f2a6703 | 8398 | if (argv[3] != NULL) |
7c8ff89e | 8399 | ospf_routemap_set (red, argv[3]); |
718e3744 | 8400 | else |
7c8ff89e | 8401 | ospf_routemap_unset (red); |
718e3744 | 8402 | |
6f2a6703 CF |
8403 | return ospf_redistribute_default_set (ospf, default_originate, |
8404 | type, metric); | |
718e3744 | 8405 | } |
8406 | ||
8407 | DEFUN (no_ospf_default_information_originate, | |
8408 | no_ospf_default_information_originate_cmd, | |
6147e2c6 | 8409 | "no default-information originate [always|metric (0-16777214)|metric-type <1|2>|route-map WORD]", |
718e3744 | 8410 | NO_STR |
8411 | "Control distribution of default information\n" | |
813d4307 DW |
8412 | "Distribute a default route\n" |
8413 | "Always advertise default route\n" | |
8414 | "OSPF default metric\n" | |
8415 | "OSPF metric\n" | |
8416 | "OSPF metric type for default routes\n" | |
8417 | "Set OSPF External Type 1 metrics\n" | |
8418 | "Set OSPF External Type 2 metrics\n" | |
8419 | "Route map reference\n" | |
8420 | "Pointer to route-map entries\n") | |
718e3744 | 8421 | { |
68980084 | 8422 | struct ospf *ospf = vty->index; |
718e3744 | 8423 | struct prefix_ipv4 p; |
7c8ff89e DS |
8424 | struct ospf_external *ext; |
8425 | struct ospf_redist *red; | |
718e3744 | 8426 | |
7c8ff89e DS |
8427 | if (!ospf) |
8428 | return CMD_SUCCESS; | |
8429 | ||
718e3744 | 8430 | p.family = AF_INET; |
8431 | p.prefix.s_addr = 0; | |
8432 | p.prefixlen = 0; | |
8433 | ||
5339cfdb | 8434 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 8435 | |
7c8ff89e DS |
8436 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
8437 | EXTERNAL_INFO (ext)) { | |
8438 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
8439 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 8440 | } |
8441 | ||
7c8ff89e DS |
8442 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8443 | if (!red) | |
8444 | return CMD_SUCCESS; | |
8445 | ||
8446 | ospf_routemap_unset (red); | |
020709f9 | 8447 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 8448 | } |
8449 | ||
8450 | DEFUN (ospf_default_metric, | |
8451 | ospf_default_metric_cmd, | |
6147e2c6 | 8452 | "default-metric (0-16777214)", |
718e3744 | 8453 | "Set metric of redistributed routes\n" |
8454 | "Default metric\n") | |
8455 | { | |
68980084 | 8456 | struct ospf *ospf = vty->index; |
718e3744 | 8457 | int metric = -1; |
8458 | ||
7c8ff89e DS |
8459 | if (!ospf) |
8460 | return CMD_SUCCESS; | |
8461 | ||
bf2bfafd | 8462 | if (!str2metric (argv[1]->arg, &metric)) |
718e3744 | 8463 | return CMD_WARNING; |
8464 | ||
68980084 | 8465 | ospf->default_metric = metric; |
718e3744 | 8466 | |
8467 | return CMD_SUCCESS; | |
8468 | } | |
8469 | ||
f412b39a DW |
8470 | /* |
8471 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8472 | * "no default-metric <0-16777214>", | |
8473 | * NO_STR | |
8474 | * "Set metric of redistributed routes\n" | |
8475 | * "Default metric\n" | |
8476 | * | |
8477 | */ | |
718e3744 | 8478 | DEFUN (no_ospf_default_metric, |
8479 | no_ospf_default_metric_cmd, | |
8480 | "no default-metric", | |
8481 | NO_STR | |
8482 | "Set metric of redistributed routes\n") | |
8483 | { | |
68980084 | 8484 | struct ospf *ospf = vty->index; |
8485 | ||
7c8ff89e DS |
8486 | if (!ospf) |
8487 | return CMD_SUCCESS; | |
8488 | ||
68980084 | 8489 | ospf->default_metric = -1; |
8490 | ||
718e3744 | 8491 | return CMD_SUCCESS; |
8492 | } | |
8493 | ||
718e3744 | 8494 | |
8495 | DEFUN (ospf_distance, | |
8496 | ospf_distance_cmd, | |
6147e2c6 | 8497 | "distance (1-255)", |
718e3744 | 8498 | "Define an administrative distance\n" |
8499 | "OSPF Administrative distance\n") | |
8500 | { | |
68980084 | 8501 | struct ospf *ospf = vty->index; |
8502 | ||
7c8ff89e DS |
8503 | if (!ospf) |
8504 | return CMD_SUCCESS; | |
8505 | ||
bf2bfafd | 8506 | ospf->distance_all = atoi (argv[1]->arg); |
68980084 | 8507 | |
718e3744 | 8508 | return CMD_SUCCESS; |
8509 | } | |
8510 | ||
8511 | DEFUN (no_ospf_distance, | |
8512 | no_ospf_distance_cmd, | |
6147e2c6 | 8513 | "no distance (1-255)", |
718e3744 | 8514 | NO_STR |
8515 | "Define an administrative distance\n" | |
8516 | "OSPF Administrative distance\n") | |
8517 | { | |
68980084 | 8518 | struct ospf *ospf = vty->index; |
8519 | ||
7c8ff89e DS |
8520 | if (!ospf) |
8521 | return CMD_SUCCESS; | |
8522 | ||
68980084 | 8523 | ospf->distance_all = 0; |
8524 | ||
718e3744 | 8525 | return CMD_SUCCESS; |
8526 | } | |
8527 | ||
8528 | DEFUN (no_ospf_distance_ospf, | |
8529 | no_ospf_distance_ospf_cmd, | |
6147e2c6 | 8530 | "no distance ospf [intra-area (1-255)|inter-area (1-255)|external (1-255)]", |
718e3744 | 8531 | NO_STR |
8532 | "Define an administrative distance\n" | |
8533 | "OSPF Administrative distance\n" | |
718e3744 | 8534 | "Intra-area routes\n" |
813d4307 | 8535 | "Distance for intra-area routes\n" |
718e3744 | 8536 | "Inter-area routes\n" |
813d4307 DW |
8537 | "Distance for inter-area routes\n" |
8538 | "External routes\n" | |
8539 | "Distance for external routes\n") | |
718e3744 | 8540 | { |
68980084 | 8541 | struct ospf *ospf = vty->index; |
8542 | ||
d8f70b86 DS |
8543 | if (!ospf) |
8544 | return CMD_SUCCESS; | |
8545 | ||
6f2a6703 CF |
8546 | if (argc < 3) |
8547 | return CMD_WARNING; | |
718e3744 | 8548 | |
7c8ff89e DS |
8549 | if (!ospf) |
8550 | return CMD_SUCCESS; | |
8551 | ||
bf2bfafd | 8552 | if (argv[3]->arg != NULL) |
6f2a6703 | 8553 | ospf->distance_intra = 0; |
68980084 | 8554 | |
6f2a6703 CF |
8555 | if (argv[1] != NULL) |
8556 | ospf->distance_inter = 0; | |
68980084 | 8557 | |
6f2a6703 CF |
8558 | if (argv[2] != NULL) |
8559 | ospf->distance_external = 0; | |
718e3744 | 8560 | |
bf2bfafd | 8561 | if (argv[3]->arg || argv[1] || argv[2]) |
6f2a6703 | 8562 | return CMD_SUCCESS; |
68980084 | 8563 | |
6f2a6703 CF |
8564 | /* If no arguments are given, clear all distance information */ |
8565 | ospf->distance_intra = 0; | |
8566 | ospf->distance_inter = 0; | |
8567 | ospf->distance_external = 0; | |
68980084 | 8568 | |
718e3744 | 8569 | return CMD_SUCCESS; |
8570 | } | |
8571 | ||
6f2a6703 CF |
8572 | DEFUN (ospf_distance_ospf, |
8573 | ospf_distance_ospf_cmd, | |
6147e2c6 | 8574 | "distance ospf [intra-area (1-255)|inter-area (1-255)|external (1-255)]", |
718e3744 | 8575 | "Define an administrative distance\n" |
8576 | "OSPF Administrative distance\n" | |
718e3744 | 8577 | "Intra-area routes\n" |
8578 | "Distance for intra-area routes\n" | |
718e3744 | 8579 | "Inter-area routes\n" |
8580 | "Distance for inter-area routes\n" | |
8581 | "External routes\n" | |
718e3744 | 8582 | "Distance for external routes\n") |
8583 | { | |
68980084 | 8584 | struct ospf *ospf = vty->index; |
8585 | ||
d8f70b86 DS |
8586 | if (!ospf) |
8587 | return CMD_SUCCESS; | |
8588 | ||
6f2a6703 CF |
8589 | if (argc < 3) /* should not happen */ |
8590 | return CMD_WARNING; | |
68980084 | 8591 | |
bf2bfafd | 8592 | if (!argv[2]->arg && !argv[1] && !argv[2]) |
6f2a6703 CF |
8593 | { |
8594 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", | |
8595 | VTY_NEWLINE); | |
8596 | return CMD_WARNING; | |
8597 | } | |
68980084 | 8598 | |
bf2bfafd DW |
8599 | if (argv[2]->arg != NULL) |
8600 | ospf->distance_intra = atoi(argv[2]->arg); | |
718e3744 | 8601 | |
6f2a6703 CF |
8602 | if (argv[1] != NULL) |
8603 | ospf->distance_inter = atoi(argv[1]); | |
68980084 | 8604 | |
6f2a6703 CF |
8605 | if (argv[2] != NULL) |
8606 | ospf->distance_external = atoi(argv[2]); | |
68980084 | 8607 | |
718e3744 | 8608 | return CMD_SUCCESS; |
8609 | } | |
8610 | ||
8611 | DEFUN (ospf_distance_source, | |
8612 | ospf_distance_source_cmd, | |
6147e2c6 | 8613 | "distance (1-255) A.B.C.D/M", |
718e3744 | 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 | ||
bf2bfafd | 8623 | ospf_distance_set (vty, ospf, argv[1]->arg, argv[2]->arg, NULL); |
68980084 | 8624 | |
718e3744 | 8625 | return CMD_SUCCESS; |
8626 | } | |
8627 | ||
8628 | DEFUN (no_ospf_distance_source, | |
8629 | no_ospf_distance_source_cmd, | |
6147e2c6 | 8630 | "no distance (1-255) A.B.C.D/M", |
718e3744 | 8631 | NO_STR |
8632 | "Administrative distance\n" | |
8633 | "Distance value\n" | |
8634 | "IP source prefix\n") | |
8635 | { | |
020709f9 | 8636 | struct ospf *ospf = vty->index; |
8637 | ||
7c8ff89e DS |
8638 | if (!ospf) |
8639 | return CMD_SUCCESS; | |
8640 | ||
bf2bfafd | 8641 | ospf_distance_unset (vty, ospf, argv[2]->arg, argv[3]->arg, NULL); |
020709f9 | 8642 | |
718e3744 | 8643 | return CMD_SUCCESS; |
8644 | } | |
8645 | ||
8646 | DEFUN (ospf_distance_source_access_list, | |
8647 | ospf_distance_source_access_list_cmd, | |
6147e2c6 | 8648 | "distance (1-255) A.B.C.D/M WORD", |
718e3744 | 8649 | "Administrative distance\n" |
8650 | "Distance value\n" | |
8651 | "IP source prefix\n" | |
8652 | "Access list name\n") | |
8653 | { | |
020709f9 | 8654 | struct ospf *ospf = vty->index; |
8655 | ||
7c8ff89e DS |
8656 | if (!ospf) |
8657 | return CMD_SUCCESS; | |
8658 | ||
bf2bfafd | 8659 | ospf_distance_set (vty, ospf, argv[1]->arg, argv[2]->arg, argv[3]->arg); |
020709f9 | 8660 | |
718e3744 | 8661 | return CMD_SUCCESS; |
8662 | } | |
8663 | ||
8664 | DEFUN (no_ospf_distance_source_access_list, | |
8665 | no_ospf_distance_source_access_list_cmd, | |
6147e2c6 | 8666 | "no distance (1-255) A.B.C.D/M WORD", |
718e3744 | 8667 | NO_STR |
8668 | "Administrative distance\n" | |
8669 | "Distance value\n" | |
8670 | "IP source prefix\n" | |
8671 | "Access list name\n") | |
8672 | { | |
020709f9 | 8673 | struct ospf *ospf = vty->index; |
8674 | ||
7c8ff89e DS |
8675 | if (!ospf) |
8676 | return CMD_SUCCESS; | |
8677 | ||
bf2bfafd | 8678 | ospf_distance_unset (vty, ospf, argv[2]->arg, argv[3]->arg, argv[4]->arg); |
020709f9 | 8679 | |
718e3744 | 8680 | return CMD_SUCCESS; |
8681 | } | |
8682 | ||
f412b39a DW |
8683 | /* |
8684 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8685 | * "ip ospf mtu-ignore", | |
8686 | * "IP Information\n" | |
8687 | * "OSPF interface commands\n" | |
8688 | * "Disable mtu mismatch detection\n" | |
8689 | * | |
8690 | */ | |
ba682537 | 8691 | DEFUN (ip_ospf_mtu_ignore, |
8692 | ip_ospf_mtu_ignore_addr_cmd, | |
8693 | "ip ospf mtu-ignore A.B.C.D", | |
8694 | "IP Information\n" | |
8695 | "OSPF interface commands\n" | |
8696 | "Disable mtu mismatch detection\n" | |
8697 | "Address of interface") | |
8698 | { | |
8699 | struct interface *ifp = vty->index; | |
8700 | struct in_addr addr; | |
8701 | int ret; | |
8702 | ||
8703 | struct ospf_if_params *params; | |
8704 | params = IF_DEF_PARAMS (ifp); | |
8705 | ||
8706 | if (argc == 1) | |
8707 | { | |
bf2bfafd | 8708 | ret = inet_aton(argv[3]->arg, &addr); |
ba682537 | 8709 | if (!ret) |
8710 | { | |
8711 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8712 | VTY_NEWLINE); | |
8713 | return CMD_WARNING; | |
8714 | } | |
8715 | params = ospf_get_if_params (ifp, addr); | |
8716 | ospf_if_update_params (ifp, addr); | |
8717 | } | |
8718 | params->mtu_ignore = 1; | |
8719 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8720 | SET_IF_PARAM (params, mtu_ignore); | |
8721 | else | |
8722 | { | |
8723 | UNSET_IF_PARAM (params, mtu_ignore); | |
8724 | if (params != IF_DEF_PARAMS (ifp)) | |
8725 | { | |
8726 | ospf_free_if_params (ifp, addr); | |
8727 | ospf_if_update_params (ifp, addr); | |
8728 | } | |
8729 | } | |
8730 | return CMD_SUCCESS; | |
8731 | } | |
8732 | ||
ba682537 | 8733 | |
8734 | ||
f412b39a DW |
8735 | /* |
8736 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8737 | * "no ip ospf mtu-ignore", | |
8738 | * "IP Information\n" | |
8739 | * "OSPF interface commands\n" | |
8740 | * "Disable mtu mismatch detection\n" | |
8741 | * | |
8742 | */ | |
ba682537 | 8743 | DEFUN (no_ip_ospf_mtu_ignore, |
8744 | no_ip_ospf_mtu_ignore_addr_cmd, | |
8745 | "no ip ospf mtu-ignore A.B.C.D", | |
8746 | "IP Information\n" | |
8747 | "OSPF interface commands\n" | |
8748 | "Disable mtu mismatch detection\n" | |
8749 | "Address of interface") | |
8750 | { | |
8751 | struct interface *ifp = vty->index; | |
8752 | struct in_addr addr; | |
8753 | int ret; | |
8754 | ||
8755 | struct ospf_if_params *params; | |
8756 | params = IF_DEF_PARAMS (ifp); | |
8757 | ||
8758 | if (argc == 1) | |
8759 | { | |
bf2bfafd | 8760 | ret = inet_aton(argv[4]->arg, &addr); |
ba682537 | 8761 | if (!ret) |
8762 | { | |
8763 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
8764 | VTY_NEWLINE); | |
8765 | return CMD_WARNING; | |
8766 | } | |
8767 | params = ospf_get_if_params (ifp, addr); | |
8768 | ospf_if_update_params (ifp, addr); | |
8769 | } | |
8770 | params->mtu_ignore = 0; | |
8771 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8772 | SET_IF_PARAM (params, mtu_ignore); | |
8773 | else | |
8774 | { | |
8775 | UNSET_IF_PARAM (params, mtu_ignore); | |
8776 | if (params != IF_DEF_PARAMS (ifp)) | |
8777 | { | |
8778 | ospf_free_if_params (ifp, addr); | |
8779 | ospf_if_update_params (ifp, addr); | |
8780 | } | |
8781 | } | |
8782 | return CMD_SUCCESS; | |
8783 | } | |
8784 | ||
6b0655a2 | 8785 | |
88d6cf37 | 8786 | DEFUN (ospf_max_metric_router_lsa_admin, |
8787 | ospf_max_metric_router_lsa_admin_cmd, | |
8788 | "max-metric router-lsa administrative", | |
8789 | "OSPF maximum / infinite-distance metric\n" | |
8790 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8791 | "Administratively applied, for an indefinite period\n") | |
8792 | { | |
8793 | struct listnode *ln; | |
8794 | struct ospf_area *area; | |
8795 | struct ospf *ospf = vty->index; | |
ba682537 | 8796 | |
7c8ff89e DS |
8797 | if (!ospf) |
8798 | return CMD_SUCCESS; | |
8799 | ||
88d6cf37 | 8800 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8801 | { | |
8802 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8803 | ||
8804 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 8805 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8806 | } |
4ba4fc85 AB |
8807 | |
8808 | /* Allows for areas configured later to get the property */ | |
8809 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
8810 | ||
88d6cf37 | 8811 | return CMD_SUCCESS; |
8812 | } | |
8813 | ||
8814 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
8815 | no_ospf_max_metric_router_lsa_admin_cmd, | |
8816 | "no max-metric router-lsa administrative", | |
8817 | NO_STR | |
8818 | "OSPF maximum / infinite-distance metric\n" | |
8819 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8820 | "Administratively applied, for an indefinite period\n") | |
8821 | { | |
8822 | struct listnode *ln; | |
8823 | struct ospf_area *area; | |
8824 | struct ospf *ospf = vty->index; | |
8825 | ||
7c8ff89e DS |
8826 | if (!ospf) |
8827 | return CMD_SUCCESS; | |
8828 | ||
88d6cf37 | 8829 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
8830 | { | |
8831 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
8832 | ||
8833 | /* Don't trample on the start-up stub timer */ | |
8834 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
8835 | && !area->t_stub_router) | |
8836 | { | |
8837 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8838 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8839 | } |
8840 | } | |
4ba4fc85 | 8841 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 8842 | return CMD_SUCCESS; |
8843 | } | |
8844 | ||
8845 | DEFUN (ospf_max_metric_router_lsa_startup, | |
8846 | ospf_max_metric_router_lsa_startup_cmd, | |
6147e2c6 | 8847 | "max-metric router-lsa on-startup (5-86400)", |
88d6cf37 | 8848 | "OSPF maximum / infinite-distance metric\n" |
8849 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8850 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8851 | "Time (seconds) to advertise self as stub-router\n") | |
8852 | { | |
8853 | unsigned int seconds; | |
8854 | struct ospf *ospf = vty->index; | |
8855 | ||
7c8ff89e DS |
8856 | if (!ospf) |
8857 | return CMD_SUCCESS; | |
8858 | ||
88d6cf37 | 8859 | if (argc != 1) |
8860 | { | |
8861 | vty_out (vty, "%% Must supply stub-router period"); | |
8862 | return CMD_WARNING; | |
8863 | } | |
8864 | ||
bf2bfafd | 8865 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[3]->arg); |
88d6cf37 | 8866 | |
8867 | ospf->stub_router_startup_time = seconds; | |
8868 | ||
8869 | return CMD_SUCCESS; | |
8870 | } | |
8871 | ||
f412b39a DW |
8872 | /* |
8873 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8874 | * "no max-metric router-lsa on-startup", | |
8875 | * NO_STR | |
8876 | * "OSPF maximum / infinite-distance metric\n" | |
8877 | * "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8878 | * "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8879 | * | |
8880 | */ | |
88d6cf37 | 8881 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
8882 | no_ospf_max_metric_router_lsa_startup_cmd, | |
6147e2c6 | 8883 | "no max-metric router-lsa on-startup (5-86400)", |
88d6cf37 | 8884 | NO_STR |
8885 | "OSPF maximum / infinite-distance metric\n" | |
8886 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8887 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
8888 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 8889 | { |
8890 | struct listnode *ln; | |
8891 | struct ospf_area *area; | |
8892 | struct ospf *ospf = vty->index; | |
8893 | ||
7c8ff89e DS |
8894 | if (!ospf) |
8895 | return CMD_SUCCESS; | |
8896 | ||
88d6cf37 | 8897 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8898 | ||
8899 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8900 | { | |
8901 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
8902 | OSPF_TIMER_OFF (area->t_stub_router); | |
8903 | ||
8904 | /* Don't trample on admin stub routed */ | |
8905 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8906 | { | |
8907 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 8908 | ospf_router_lsa_update_area (area); |
88d6cf37 | 8909 | } |
8910 | } | |
8911 | return CMD_SUCCESS; | |
8912 | } | |
8913 | ||
a1afa410 | 8914 | |
88d6cf37 | 8915 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
8916 | ospf_max_metric_router_lsa_shutdown_cmd, | |
6147e2c6 | 8917 | "max-metric router-lsa on-shutdown (5-100)", |
88d6cf37 | 8918 | "OSPF maximum / infinite-distance metric\n" |
8919 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8920 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
8921 | "Time (seconds) to wait till full shutdown\n") | |
8922 | { | |
8923 | unsigned int seconds; | |
8924 | struct ospf *ospf = vty->index; | |
8925 | ||
7c8ff89e DS |
8926 | if (!ospf) |
8927 | return CMD_SUCCESS; | |
8928 | ||
88d6cf37 | 8929 | if (argc != 1) |
8930 | { | |
8931 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
8932 | return CMD_WARNING; | |
8933 | } | |
8934 | ||
bf2bfafd | 8935 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[3]->arg); |
88d6cf37 | 8936 | |
8937 | ospf->stub_router_shutdown_time = seconds; | |
8938 | ||
8939 | return CMD_SUCCESS; | |
8940 | } | |
8941 | ||
f412b39a DW |
8942 | /* |
8943 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
8944 | * "no max-metric router-lsa on-shutdown", | |
8945 | * NO_STR | |
8946 | * "OSPF maximum / infinite-distance metric\n" | |
8947 | * "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8948 | * "Advertise stub-router prior to full shutdown of OSPF\n"); | |
8949 | * | |
8950 | * static void | |
8951 | * config_write_stub_router (struct vty *vty, struct ospf *ospf | |
8952 | * | |
8953 | */ | |
88d6cf37 | 8954 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
8955 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
6147e2c6 | 8956 | "no max-metric router-lsa on-shutdown (5-100)", |
88d6cf37 | 8957 | NO_STR |
8958 | "OSPF maximum / infinite-distance metric\n" | |
8959 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8960 | "Advertise stub-router prior to full shutdown of OSPF\n" |
8961 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 8962 | { |
8963 | struct ospf *ospf = vty->index; | |
8964 | ||
7c8ff89e DS |
8965 | if (!ospf) |
8966 | return CMD_SUCCESS; | |
8967 | ||
88d6cf37 | 8968 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8969 | ||
8970 | return CMD_SUCCESS; | |
8971 | } | |
8972 | ||
88d6cf37 | 8973 | { |
8974 | struct listnode *ln; | |
8975 | struct ospf_area *area; | |
8976 | ||
8977 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8978 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
8979 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
8980 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8981 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
8982 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
8983 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
8984 | { | |
8985 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
8986 | { | |
8987 | vty_out (vty, " max-metric router-lsa administrative%s", | |
8988 | VTY_NEWLINE); | |
8989 | break; | |
8990 | } | |
8991 | } | |
8992 | return; | |
8993 | } | |
6b0655a2 | 8994 | |
4dadc291 | 8995 | static void |
718e3744 | 8996 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
8997 | { | |
8998 | struct route_node *rn; | |
8999 | struct ospf_route *or; | |
1eb8ef25 | 9000 | struct listnode *pnode, *pnnode; |
718e3744 | 9001 | struct ospf_path *path; |
9002 | ||
9003 | vty_out (vty, "============ OSPF network routing table ============%s", | |
9004 | VTY_NEWLINE); | |
9005 | ||
9006 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
9007 | if ((or = rn->info) != NULL) | |
9008 | { | |
9009 | char buf1[19]; | |
9010 | snprintf (buf1, 19, "%s/%d", | |
9011 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
9012 | ||
9013 | switch (or->path_type) | |
9014 | { | |
9015 | case OSPF_PATH_INTER_AREA: | |
9016 | if (or->type == OSPF_DESTINATION_NETWORK) | |
9017 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
9018 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
9019 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
9020 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
9021 | break; | |
9022 | case OSPF_PATH_INTRA_AREA: | |
9023 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
9024 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
9025 | break; | |
9026 | default: | |
9027 | break; | |
9028 | } | |
9029 | ||
9030 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 9031 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 9032 | { |
a8ba847f | 9033 | if (if_lookup_by_index(path->ifindex)) |
96735eea | 9034 | { |
9035 | if (path->nexthop.s_addr == 0) | |
9036 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f | 9037 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 9038 | else |
9039 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
9040 | inet_ntoa (path->nexthop), |
9041 | ifindex2ifname (path->ifindex), VTY_NEWLINE); | |
96735eea | 9042 | } |
9043 | } | |
718e3744 | 9044 | } |
9045 | vty_out (vty, "%s", VTY_NEWLINE); | |
9046 | } | |
9047 | ||
4dadc291 | 9048 | static void |
718e3744 | 9049 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
9050 | { | |
9051 | struct route_node *rn; | |
9052 | struct ospf_route *or; | |
1eb8ef25 | 9053 | struct listnode *pnode; |
9054 | struct listnode *node; | |
718e3744 | 9055 | struct ospf_path *path; |
9056 | ||
9057 | vty_out (vty, "============ OSPF router routing table =============%s", | |
9058 | VTY_NEWLINE); | |
9059 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
9060 | if (rn->info) | |
9061 | { | |
9062 | int flag = 0; | |
9063 | ||
9064 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
9065 | ||
1eb8ef25 | 9066 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
9067 | { | |
9068 | if (flag++) | |
9069 | vty_out (vty, "%24s", ""); | |
9070 | ||
9071 | /* Show path. */ | |
9072 | vty_out (vty, "%s [%d] area: %s", | |
9073 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
9074 | or->cost, inet_ntoa (or->u.std.area_id)); | |
9075 | /* Show flags. */ | |
9076 | vty_out (vty, "%s%s%s", | |
9077 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
9078 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
9079 | VTY_NEWLINE); | |
9080 | ||
9081 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
9082 | { | |
a8ba847f | 9083 | if (if_lookup_by_index(path->ifindex)) |
54bedb55 | 9084 | { |
9085 | if (path->nexthop.s_addr == 0) | |
9086 | vty_out (vty, "%24s directly attached to %s%s", | |
a8ba847f JT |
9087 | "", ifindex2ifname (path->ifindex), |
9088 | VTY_NEWLINE); | |
54bedb55 | 9089 | else |
9090 | vty_out (vty, "%24s via %s, %s%s", "", | |
9091 | inet_ntoa (path->nexthop), | |
a8ba847f JT |
9092 | ifindex2ifname (path->ifindex), |
9093 | VTY_NEWLINE); | |
54bedb55 | 9094 | } |
1eb8ef25 | 9095 | } |
9096 | } | |
718e3744 | 9097 | } |
9098 | vty_out (vty, "%s", VTY_NEWLINE); | |
9099 | } | |
9100 | ||
4dadc291 | 9101 | static void |
718e3744 | 9102 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
9103 | { | |
9104 | struct route_node *rn; | |
9105 | struct ospf_route *er; | |
1eb8ef25 | 9106 | struct listnode *pnode, *pnnode; |
718e3744 | 9107 | struct ospf_path *path; |
9108 | ||
9109 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
9110 | VTY_NEWLINE); | |
9111 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
9112 | if ((er = rn->info) != NULL) | |
9113 | { | |
9114 | char buf1[19]; | |
9115 | snprintf (buf1, 19, "%s/%d", | |
9116 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
9117 | ||
9118 | switch (er->path_type) | |
9119 | { | |
9120 | case OSPF_PATH_TYPE1_EXTERNAL: | |
9121 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, | |
9122 | er->cost, er->u.ext.tag, VTY_NEWLINE); | |
9123 | break; | |
9124 | case OSPF_PATH_TYPE2_EXTERNAL: | |
9125 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, | |
9126 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); | |
9127 | break; | |
9128 | } | |
9129 | ||
1eb8ef25 | 9130 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 9131 | { |
a8ba847f | 9132 | if (if_lookup_by_index(path->ifindex)) |
718e3744 | 9133 | { |
9134 | if (path->nexthop.s_addr == 0) | |
96735eea | 9135 | vty_out (vty, "%24s directly attached to %s%s", |
a8ba847f | 9136 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
96735eea | 9137 | else |
9138 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f JT |
9139 | inet_ntoa (path->nexthop), |
9140 | ifindex2ifname (path->ifindex), | |
96735eea | 9141 | VTY_NEWLINE); |
718e3744 | 9142 | } |
9143 | } | |
9144 | } | |
9145 | vty_out (vty, "%s", VTY_NEWLINE); | |
9146 | } | |
9147 | ||
7c8ff89e DS |
9148 | static int |
9149 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 9150 | { |
7c8ff89e DS |
9151 | if (ospf->instance) |
9152 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
9153 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9154 | |
68980084 | 9155 | if (ospf->new_table == NULL) |
718e3744 | 9156 | { |
9157 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
9158 | return CMD_SUCCESS; | |
9159 | } | |
9160 | ||
9161 | /* Show Network routes. | |
020709f9 | 9162 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 9163 | |
9164 | /* Show Router routes. */ | |
68980084 | 9165 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 9166 | |
7c8ff89e DS |
9167 | vty_out (vty, "%s", VTY_NEWLINE); |
9168 | ||
718e3744 | 9169 | return CMD_SUCCESS; |
9170 | } | |
718e3744 | 9171 | |
7c8ff89e DS |
9172 | DEFUN (show_ip_ospf_border_routers, |
9173 | show_ip_ospf_border_routers_cmd, | |
9174 | "show ip ospf border-routers", | |
718e3744 | 9175 | SHOW_STR |
9176 | IP_STR | |
9177 | "OSPF information\n" | |
7c8ff89e | 9178 | "Show all the ABR's and ASBR's\n") |
718e3744 | 9179 | { |
020709f9 | 9180 | struct ospf *ospf; |
68980084 | 9181 | |
0bad4851 | 9182 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9183 | return CMD_SUCCESS; |
9184 | ||
9185 | return show_ip_ospf_border_routers_common(vty, ospf); | |
9186 | } | |
9187 | ||
9188 | DEFUN (show_ip_ospf_instance_border_routers, | |
9189 | show_ip_ospf_instance_border_routers_cmd, | |
6147e2c6 | 9190 | "show ip ospf (1-65535) border-routers", |
7c8ff89e DS |
9191 | SHOW_STR |
9192 | IP_STR | |
9193 | "OSPF information\n" | |
9194 | "Instance ID\n" | |
9195 | "Show all the ABR's and ASBR's\n") | |
9196 | { | |
9197 | struct ospf *ospf; | |
9198 | u_short instance = 0; | |
9199 | ||
bf2bfafd | 9200 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 9201 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9202 | return CMD_SUCCESS; |
9203 | ||
9204 | return show_ip_ospf_border_routers_common(vty, ospf); | |
9205 | } | |
9206 | ||
9207 | static int | |
9208 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
9209 | { | |
9210 | if (ospf->instance) | |
9211 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
9212 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 9213 | |
68980084 | 9214 | if (ospf->new_table == NULL) |
718e3744 | 9215 | { |
9216 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
9217 | return CMD_SUCCESS; | |
9218 | } | |
9219 | ||
9220 | /* Show Network routes. */ | |
68980084 | 9221 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 9222 | |
9223 | /* Show Router routes. */ | |
68980084 | 9224 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 9225 | |
9226 | /* Show AS External routes. */ | |
68980084 | 9227 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 9228 | |
7c8ff89e DS |
9229 | vty_out (vty, "%s", VTY_NEWLINE); |
9230 | ||
718e3744 | 9231 | return CMD_SUCCESS; |
9232 | } | |
9233 | ||
7c8ff89e DS |
9234 | DEFUN (show_ip_ospf_route, |
9235 | show_ip_ospf_route_cmd, | |
9236 | "show ip ospf route", | |
9237 | SHOW_STR | |
9238 | IP_STR | |
9239 | "OSPF information\n" | |
9240 | "OSPF routing table\n") | |
9241 | { | |
9242 | struct ospf *ospf; | |
9243 | ||
0bad4851 | 9244 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9245 | return CMD_SUCCESS; |
9246 | ||
9247 | return show_ip_ospf_route_common(vty, ospf); | |
9248 | } | |
9249 | ||
9250 | DEFUN (show_ip_ospf_instance_route, | |
9251 | show_ip_ospf_instance_route_cmd, | |
6147e2c6 | 9252 | "show ip ospf (1-65535) route", |
7c8ff89e DS |
9253 | SHOW_STR |
9254 | IP_STR | |
9255 | "OSPF information\n" | |
9256 | "Instance ID\n" | |
9257 | "OSPF routing table\n") | |
9258 | { | |
9259 | struct ospf *ospf; | |
9260 | u_short instance = 0; | |
9261 | ||
bf2bfafd | 9262 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
0bad4851 | 9263 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
9264 | return CMD_SUCCESS; |
9265 | ||
9266 | return show_ip_ospf_route_common(vty, ospf); | |
9267 | } | |
6b0655a2 | 9268 | |
eb1ce605 | 9269 | const char *ospf_abr_type_str[] = |
718e3744 | 9270 | { |
9271 | "unknown", | |
9272 | "standard", | |
9273 | "ibm", | |
9274 | "cisco", | |
9275 | "shortcut" | |
9276 | }; | |
9277 | ||
eb1ce605 | 9278 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 9279 | { |
9280 | "default", | |
9281 | "enable", | |
9282 | "disable" | |
9283 | }; | |
9284 | ||
9285 | ||
4dadc291 | 9286 | static void |
718e3744 | 9287 | area_id2str (char *buf, int length, struct ospf_area *area) |
9288 | { | |
9289 | memset (buf, 0, length); | |
9290 | ||
9291 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
9292 | strncpy (buf, inet_ntoa (area->area_id), length); | |
9293 | else | |
9294 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); | |
9295 | } | |
9296 | ||
6b0655a2 | 9297 | |
eb1ce605 | 9298 | const char *ospf_int_type_str[] = |
718e3744 | 9299 | { |
9300 | "unknown", /* should never be used. */ | |
9301 | "point-to-point", | |
9302 | "broadcast", | |
9303 | "non-broadcast", | |
9304 | "point-to-multipoint", | |
9305 | "virtual-link", /* should never be used. */ | |
9306 | "loopback" | |
9307 | }; | |
9308 | ||
9309 | /* Configuration write function for ospfd. */ | |
4dadc291 | 9310 | static int |
718e3744 | 9311 | config_write_interface (struct vty *vty) |
9312 | { | |
52dc7ee6 | 9313 | struct listnode *n1, *n2; |
718e3744 | 9314 | struct interface *ifp; |
9315 | struct crypt_key *ck; | |
9316 | int write = 0; | |
9317 | struct route_node *rn = NULL; | |
9318 | struct ospf_if_params *params; | |
7c8ff89e | 9319 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 9320 | |
b2d7c082 | 9321 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp)) |
718e3744 | 9322 | { |
718e3744 | 9323 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
9324 | continue; | |
9325 | ||
84361d61 DS |
9326 | if (ifp->ifindex == IFINDEX_DELETED) |
9327 | continue; | |
9328 | ||
718e3744 | 9329 | vty_out (vty, "!%s", VTY_NEWLINE); |
9330 | vty_out (vty, "interface %s%s", ifp->name, | |
9331 | VTY_NEWLINE); | |
9332 | if (ifp->desc) | |
9333 | vty_out (vty, " description %s%s", ifp->desc, | |
9334 | VTY_NEWLINE); | |
9335 | ||
9336 | write++; | |
9337 | ||
9338 | params = IF_DEF_PARAMS (ifp); | |
9339 | ||
9340 | do { | |
9341 | /* Interface Network print. */ | |
9342 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 9343 | params->type != OSPF_IFTYPE_LOOPBACK) |
9344 | { | |
bc18d616 | 9345 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 9346 | { |
9347 | vty_out (vty, " ip ospf network %s", | |
9348 | ospf_int_type_str[params->type]); | |
9349 | if (params != IF_DEF_PARAMS (ifp)) | |
9350 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9351 | vty_out (vty, "%s", VTY_NEWLINE); | |
9352 | } | |
718e3744 | 9353 | } |
9354 | ||
9355 | /* OSPF interface authentication print */ | |
9356 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
9357 | params->auth_type != OSPF_AUTH_NOTSET) | |
9358 | { | |
eb1ce605 | 9359 | const char *auth_str; |
718e3744 | 9360 | |
9361 | /* Translation tables are not that much help here due to syntax | |
9362 | of the simple option */ | |
9363 | switch (params->auth_type) | |
9364 | { | |
9365 | ||
9366 | case OSPF_AUTH_NULL: | |
9367 | auth_str = " null"; | |
9368 | break; | |
9369 | ||
9370 | case OSPF_AUTH_SIMPLE: | |
9371 | auth_str = ""; | |
9372 | break; | |
9373 | ||
9374 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
9375 | auth_str = " message-digest"; | |
9376 | break; | |
9377 | ||
9378 | default: | |
9379 | auth_str = ""; | |
9380 | break; | |
9381 | } | |
9382 | ||
9383 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
9384 | if (params != IF_DEF_PARAMS (ifp)) | |
9385 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9386 | vty_out (vty, "%s", VTY_NEWLINE); | |
9387 | } | |
9388 | ||
9389 | /* Simple Authentication Password print. */ | |
9390 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
9391 | params->auth_simple[0] != '\0') | |
9392 | { | |
9393 | vty_out (vty, " ip ospf authentication-key %s", | |
9394 | params->auth_simple); | |
9395 | if (params != IF_DEF_PARAMS (ifp)) | |
9396 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9397 | vty_out (vty, "%s", VTY_NEWLINE); | |
9398 | } | |
9399 | ||
9400 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 9401 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 9402 | { |
718e3744 | 9403 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 9404 | ck->key_id, ck->auth_key); |
718e3744 | 9405 | if (params != IF_DEF_PARAMS (ifp)) |
9406 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9407 | vty_out (vty, "%s", VTY_NEWLINE); | |
9408 | } | |
9409 | ||
9410 | /* Interface Output Cost print. */ | |
9411 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
9412 | { | |
9413 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
9414 | if (params != IF_DEF_PARAMS (ifp)) | |
9415 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9416 | vty_out (vty, "%s", VTY_NEWLINE); | |
9417 | } | |
9418 | ||
9419 | /* Hello Interval print. */ | |
9420 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
9421 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
9422 | { | |
9423 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
9424 | if (params != IF_DEF_PARAMS (ifp)) | |
9425 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9426 | vty_out (vty, "%s", VTY_NEWLINE); | |
9427 | } | |
9428 | ||
9429 | ||
9430 | /* Router Dead Interval print. */ | |
9431 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
9432 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
9433 | { | |
f9ad937f | 9434 | vty_out (vty, " ip ospf dead-interval "); |
9435 | ||
9436 | /* fast hello ? */ | |
9437 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
9438 | vty_out (vty, "minimal hello-multiplier %d", | |
9439 | params->fast_hello); | |
9440 | else | |
9441 | vty_out (vty, "%u", params->v_wait); | |
9442 | ||
718e3744 | 9443 | if (params != IF_DEF_PARAMS (ifp)) |
9444 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9445 | vty_out (vty, "%s", VTY_NEWLINE); | |
9446 | } | |
9447 | ||
9448 | /* Router Priority print. */ | |
9449 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
9450 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
9451 | { | |
9452 | vty_out (vty, " ip ospf priority %u", params->priority); | |
9453 | if (params != IF_DEF_PARAMS (ifp)) | |
9454 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9455 | vty_out (vty, "%s", VTY_NEWLINE); | |
9456 | } | |
9457 | ||
9458 | /* Retransmit Interval print. */ | |
9459 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
9460 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
9461 | { | |
9462 | vty_out (vty, " ip ospf retransmit-interval %u", | |
9463 | params->retransmit_interval); | |
9464 | if (params != IF_DEF_PARAMS (ifp)) | |
9465 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9466 | vty_out (vty, "%s", VTY_NEWLINE); | |
9467 | } | |
9468 | ||
9469 | /* Transmit Delay print. */ | |
9470 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
9471 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9472 | { | |
9473 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
9474 | if (params != IF_DEF_PARAMS (ifp)) | |
9475 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9476 | vty_out (vty, "%s", VTY_NEWLINE); | |
9477 | } | |
9478 | ||
953cde65 JT |
9479 | /* Area print. */ |
9480 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
9481 | { | |
9482 | if (ospf->instance) | |
9483 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
9484 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
9485 | else | |
9486 | vty_out (vty, " ip ospf area %s%s", | |
9487 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
9488 | ||
9489 | } | |
9490 | ||
d5a5c8f0 | 9491 | /* bfd print. */ |
7f342629 | 9492 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 9493 | |
ba682537 | 9494 | /* MTU ignore print. */ |
9495 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
9496 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
9497 | { | |
9498 | if (params->mtu_ignore == 0) | |
9499 | vty_out (vty, " no ip ospf mtu-ignore"); | |
9500 | else | |
9501 | vty_out (vty, " ip ospf mtu-ignore"); | |
9502 | if (params != IF_DEF_PARAMS (ifp)) | |
9503 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
9504 | vty_out (vty, "%s", VTY_NEWLINE); | |
9505 | } | |
9506 | ||
9507 | ||
718e3744 | 9508 | while (1) |
9509 | { | |
9510 | if (rn == NULL) | |
9511 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
9512 | else | |
9513 | rn = route_next (rn); | |
9514 | ||
9515 | if (rn == NULL) | |
9516 | break; | |
9517 | params = rn->info; | |
9518 | if (params != NULL) | |
9519 | break; | |
9520 | } | |
9521 | } while (rn); | |
9522 | ||
718e3744 | 9523 | ospf_opaque_config_write_if (vty, ifp); |
718e3744 | 9524 | } |
9525 | ||
9526 | return write; | |
9527 | } | |
9528 | ||
4dadc291 | 9529 | static int |
68980084 | 9530 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9531 | { |
9532 | struct route_node *rn; | |
9533 | u_char buf[INET_ADDRSTRLEN]; | |
9534 | ||
9535 | /* `network area' print. */ | |
68980084 | 9536 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 9537 | if (rn->info) |
9538 | { | |
9539 | struct ospf_network *n = rn->info; | |
9540 | ||
9541 | memset (buf, 0, INET_ADDRSTRLEN); | |
9542 | ||
9543 | /* Create Area ID string by specified Area ID format. */ | |
9544 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9545 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 9546 | else |
c9e52be3 | 9547 | sprintf ((char *) buf, "%lu", |
718e3744 | 9548 | (unsigned long int) ntohl (n->area_id.s_addr)); |
9549 | ||
9550 | /* Network print. */ | |
9551 | vty_out (vty, " network %s/%d area %s%s", | |
9552 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9553 | buf, VTY_NEWLINE); | |
9554 | } | |
9555 | ||
9556 | return 0; | |
9557 | } | |
9558 | ||
4dadc291 | 9559 | static int |
68980084 | 9560 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 9561 | { |
52dc7ee6 | 9562 | struct listnode *node; |
1eb8ef25 | 9563 | struct ospf_area *area; |
718e3744 | 9564 | u_char buf[INET_ADDRSTRLEN]; |
9565 | ||
9566 | /* Area configuration print. */ | |
1eb8ef25 | 9567 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 9568 | { |
718e3744 | 9569 | struct route_node *rn1; |
9570 | ||
c9e52be3 | 9571 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
718e3744 | 9572 | |
9573 | if (area->auth_type != OSPF_AUTH_NULL) | |
9574 | { | |
9575 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
9576 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
9577 | else | |
9578 | vty_out (vty, " area %s authentication message-digest%s", | |
9579 | buf, VTY_NEWLINE); | |
9580 | } | |
9581 | ||
9582 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
9583 | vty_out (vty, " area %s shortcut %s%s", buf, | |
9584 | ospf_shortcut_mode_str[area->shortcut_configured], | |
9585 | VTY_NEWLINE); | |
9586 | ||
9587 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 9588 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 9589 | ) |
9590 | { | |
b0a053be | 9591 | if (area->external_routing == OSPF_AREA_STUB) |
9592 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 9593 | else if (area->external_routing == OSPF_AREA_NSSA) |
9594 | { | |
9595 | vty_out (vty, " area %s nssa", buf); | |
9596 | switch (area->NSSATranslatorRole) | |
9597 | { | |
9598 | case OSPF_NSSA_ROLE_NEVER: | |
9599 | vty_out (vty, " translate-never"); | |
9600 | break; | |
9601 | case OSPF_NSSA_ROLE_ALWAYS: | |
9602 | vty_out (vty, " translate-always"); | |
9603 | break; | |
9604 | case OSPF_NSSA_ROLE_CANDIDATE: | |
9605 | default: | |
9606 | vty_out (vty, " translate-candidate"); | |
9607 | } | |
9608 | } | |
718e3744 | 9609 | |
9610 | if (area->no_summary) | |
9611 | vty_out (vty, " no-summary"); | |
9612 | ||
9613 | vty_out (vty, "%s", VTY_NEWLINE); | |
9614 | ||
9615 | if (area->default_cost != 1) | |
9616 | vty_out (vty, " area %s default-cost %d%s", buf, | |
9617 | area->default_cost, VTY_NEWLINE); | |
9618 | } | |
9619 | ||
9620 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
9621 | if (rn1->info) | |
9622 | { | |
9623 | struct ospf_area_range *range = rn1->info; | |
9624 | ||
9625 | vty_out (vty, " area %s range %s/%d", buf, | |
9626 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
9627 | ||
6c835671 | 9628 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 9629 | vty_out (vty, " cost %d", range->cost_config); |
9630 | ||
9631 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
9632 | vty_out (vty, " not-advertise"); | |
9633 | ||
9634 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
9635 | vty_out (vty, " substitute %s/%d", | |
9636 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
9637 | ||
9638 | vty_out (vty, "%s", VTY_NEWLINE); | |
9639 | } | |
9640 | ||
9641 | if (EXPORT_NAME (area)) | |
9642 | vty_out (vty, " area %s export-list %s%s", buf, | |
9643 | EXPORT_NAME (area), VTY_NEWLINE); | |
9644 | ||
9645 | if (IMPORT_NAME (area)) | |
9646 | vty_out (vty, " area %s import-list %s%s", buf, | |
9647 | IMPORT_NAME (area), VTY_NEWLINE); | |
9648 | ||
9649 | if (PREFIX_NAME_IN (area)) | |
9650 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
9651 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
9652 | ||
9653 | if (PREFIX_NAME_OUT (area)) | |
9654 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
9655 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
9656 | } | |
9657 | ||
9658 | return 0; | |
9659 | } | |
9660 | ||
4dadc291 | 9661 | static int |
68980084 | 9662 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 9663 | { |
9664 | struct ospf_nbr_nbma *nbr_nbma; | |
9665 | struct route_node *rn; | |
9666 | ||
9667 | /* Static Neighbor configuration print. */ | |
68980084 | 9668 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 9669 | if ((nbr_nbma = rn->info)) |
9670 | { | |
9671 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
9672 | ||
9673 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
9674 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
9675 | ||
9676 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
9677 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
9678 | ||
9679 | vty_out (vty, "%s", VTY_NEWLINE); | |
9680 | } | |
9681 | ||
9682 | return 0; | |
9683 | } | |
9684 | ||
4dadc291 | 9685 | static int |
68980084 | 9686 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 9687 | { |
52dc7ee6 | 9688 | struct listnode *node; |
1eb8ef25 | 9689 | struct ospf_vl_data *vl_data; |
718e3744 | 9690 | u_char buf[INET_ADDRSTRLEN]; |
9691 | ||
9692 | /* Virtual-Link print */ | |
1eb8ef25 | 9693 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 9694 | { |
52dc7ee6 | 9695 | struct listnode *n2; |
718e3744 | 9696 | struct crypt_key *ck; |
718e3744 | 9697 | struct ospf_interface *oi; |
9698 | ||
9699 | if (vl_data != NULL) | |
9700 | { | |
9701 | memset (buf, 0, INET_ADDRSTRLEN); | |
9702 | ||
9703 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) | |
c9e52be3 | 9704 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
718e3744 | 9705 | else |
c9e52be3 | 9706 | sprintf ((char *) buf, "%lu", |
718e3744 | 9707 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
9708 | oi = vl_data->vl_oi; | |
9709 | ||
9710 | /* timers */ | |
9711 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
9712 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
9713 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
9714 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
9715 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
9716 | buf, | |
9717 | inet_ntoa (vl_data->vl_peer), | |
9718 | OSPF_IF_PARAM (oi, v_hello), | |
9719 | OSPF_IF_PARAM (oi, retransmit_interval), | |
9720 | OSPF_IF_PARAM (oi, transmit_delay), | |
9721 | OSPF_IF_PARAM (oi, v_wait), | |
9722 | VTY_NEWLINE); | |
9723 | else | |
9724 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
9725 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
9726 | /* Auth key */ | |
9727 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
9728 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
9729 | buf, | |
9730 | inet_ntoa (vl_data->vl_peer), | |
9731 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
9732 | VTY_NEWLINE); | |
9733 | /* md5 keys */ | |
1eb8ef25 | 9734 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
9735 | n2, ck)) | |
9736 | vty_out (vty, " area %s virtual-link %s" | |
9737 | " message-digest-key %d md5 %s%s", | |
9738 | buf, | |
9739 | inet_ntoa (vl_data->vl_peer), | |
9740 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 9741 | |
9742 | } | |
9743 | } | |
9744 | ||
9745 | return 0; | |
9746 | } | |
9747 | ||
6b0655a2 | 9748 | |
4dadc291 | 9749 | static int |
68980084 | 9750 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9751 | { |
9752 | int type; | |
9753 | ||
9754 | /* redistribute print. */ | |
9755 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
9756 | { |
9757 | struct list *red_list; | |
9758 | struct listnode *node; | |
9759 | struct ospf_redist *red; | |
718e3744 | 9760 | |
7c8ff89e DS |
9761 | red_list = ospf->redist[type]; |
9762 | if (!red_list) | |
9763 | continue; | |
9764 | ||
9765 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
9766 | { | |
9767 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
9768 | if (red->instance) | |
9769 | vty_out (vty, " %d", red->instance); | |
9770 | ||
9771 | if (red->dmetric.value >= 0) | |
9772 | vty_out (vty, " metric %d", red->dmetric.value); | |
9773 | ||
9774 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9775 | vty_out (vty, " metric-type 1"); | |
9776 | ||
9777 | if (ROUTEMAP_NAME (red)) | |
9778 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
9779 | ||
9780 | vty_out (vty, "%s", VTY_NEWLINE); | |
9781 | } | |
9782 | } | |
718e3744 | 9783 | |
9784 | return 0; | |
9785 | } | |
9786 | ||
4dadc291 | 9787 | static int |
68980084 | 9788 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 9789 | { |
68980084 | 9790 | if (ospf->default_metric != -1) |
9791 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 9792 | VTY_NEWLINE); |
9793 | return 0; | |
9794 | } | |
9795 | ||
4dadc291 | 9796 | static int |
68980084 | 9797 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 9798 | { |
9799 | int type; | |
7c8ff89e | 9800 | struct ospf_redist *red; |
718e3744 | 9801 | |
68980084 | 9802 | if (ospf) |
718e3744 | 9803 | { |
9804 | /* distribute-list print. */ | |
9805 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 9806 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 9807 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 9808 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 9809 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 9810 | |
9811 | /* default-information print. */ | |
68980084 | 9812 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 9813 | { |
c42c177d | 9814 | vty_out (vty, " default-information originate"); |
9815 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
9816 | vty_out (vty, " always"); | |
718e3744 | 9817 | |
7c8ff89e DS |
9818 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
9819 | if (red) | |
9820 | { | |
9821 | if (red->dmetric.value >= 0) | |
9822 | vty_out (vty, " metric %d", | |
9823 | red->dmetric.value); | |
9824 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
9825 | vty_out (vty, " metric-type 1"); | |
9826 | ||
9827 | if (ROUTEMAP_NAME (red)) | |
9828 | vty_out (vty, " route-map %s", | |
9829 | ROUTEMAP_NAME (red)); | |
9830 | } | |
718e3744 | 9831 | |
9832 | vty_out (vty, "%s", VTY_NEWLINE); | |
9833 | } | |
9834 | ||
9835 | } | |
9836 | ||
9837 | return 0; | |
9838 | } | |
9839 | ||
4dadc291 | 9840 | static int |
68980084 | 9841 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 9842 | { |
9843 | struct route_node *rn; | |
9844 | struct ospf_distance *odistance; | |
9845 | ||
68980084 | 9846 | if (ospf->distance_all) |
9847 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 9848 | |
68980084 | 9849 | if (ospf->distance_intra |
9850 | || ospf->distance_inter | |
9851 | || ospf->distance_external) | |
718e3744 | 9852 | { |
9853 | vty_out (vty, " distance ospf"); | |
9854 | ||
68980084 | 9855 | if (ospf->distance_intra) |
9856 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
9857 | if (ospf->distance_inter) | |
9858 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
9859 | if (ospf->distance_external) | |
9860 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 9861 | |
9862 | vty_out (vty, "%s", VTY_NEWLINE); | |
9863 | } | |
9864 | ||
68980084 | 9865 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 9866 | if ((odistance = rn->info) != NULL) |
9867 | { | |
9868 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
9869 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
9870 | odistance->access_list ? odistance->access_list : "", | |
9871 | VTY_NEWLINE); | |
9872 | } | |
9873 | return 0; | |
9874 | } | |
9875 | ||
9876 | /* OSPF configuration write function. */ | |
4dadc291 | 9877 | static int |
718e3744 | 9878 | ospf_config_write (struct vty *vty) |
9879 | { | |
020709f9 | 9880 | struct ospf *ospf; |
1eb8ef25 | 9881 | struct interface *ifp; |
9882 | struct ospf_interface *oi; | |
52dc7ee6 | 9883 | struct listnode *node; |
718e3744 | 9884 | int write = 0; |
9885 | ||
020709f9 | 9886 | ospf = ospf_lookup (); |
0bad4851 | 9887 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 9888 | { |
9889 | /* `router ospf' print. */ | |
7c8ff89e DS |
9890 | if (ospf->instance) |
9891 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
9892 | else | |
9893 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 9894 | |
9895 | write++; | |
9896 | ||
68980084 | 9897 | if (!ospf->networks) |
718e3744 | 9898 | return write; |
9899 | ||
9900 | /* Router ID print. */ | |
68980084 | 9901 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 9902 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 9903 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 9904 | |
9905 | /* ABR type print. */ | |
d57834f6 | 9906 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 9907 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 9908 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 9909 | |
d7e60dd7 AS |
9910 | /* log-adjacency-changes flag print. */ |
9911 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
9912 | { | |
d7e60dd7 | 9913 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
692c7954 | 9914 | vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE); |
d7e60dd7 | 9915 | } |
692c7954 DW |
9916 | else |
9917 | { | |
9918 | vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE); | |
9919 | } | |
d7e60dd7 | 9920 | |
718e3744 | 9921 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 9922 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 9923 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
9924 | ||
9925 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 9926 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 9927 | { |
9928 | vty_out (vty, "! Important: ensure reference bandwidth " | |
9929 | "is consistent across all routers%s", VTY_NEWLINE); | |
9930 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
70bd3c43 | 9931 | ospf->ref_bandwidth, VTY_NEWLINE); |
f9ad937f | 9932 | } |
718e3744 | 9933 | |
9934 | /* SPF timers print. */ | |
68980084 | 9935 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 9936 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
9937 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
9938 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 9939 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 9940 | ospf->spf_max_holdtime, VTY_NEWLINE); |
b6927875 DS |
9941 | |
9942 | /* LSA timers print. */ | |
ac7424f9 MR |
9943 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
9944 | vty_out (vty, " timers throttle lsa all %d%s", | |
9945 | ospf->min_ls_interval, VTY_NEWLINE); | |
9946 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
b6927875 | 9947 | vty_out (vty, " timers lsa min-arrival %d%s", |
ac7424f9 | 9948 | ospf->min_ls_arrival, VTY_NEWLINE); |
b6927875 | 9949 | |
2f8f370e | 9950 | /* Write multiplier print. */ |
e8f45e82 | 9951 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 9952 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 9953 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 9954 | |
88d6cf37 | 9955 | /* Max-metric router-lsa print */ |
9956 | config_write_stub_router (vty, ospf); | |
9957 | ||
718e3744 | 9958 | /* SPF refresh parameters print. */ |
68980084 | 9959 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 9960 | vty_out (vty, " refresh timer %d%s", |
68980084 | 9961 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 9962 | |
9963 | /* Redistribute information print. */ | |
68980084 | 9964 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 9965 | |
9966 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
9967 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
9968 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
9969 | ||
1eb8ef25 | 9970 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
9971 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
9972 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
9973 | ospf->passive_interface_default) | |
9974 | { | |
9975 | vty_out (vty, " %spassive-interface %s%s", | |
9976 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
9977 | ifp->name, VTY_NEWLINE); | |
9978 | } | |
1eb8ef25 | 9979 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
9980 | { |
9981 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
9982 | continue; | |
9983 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
9984 | passive_interface)) | |
9985 | { | |
9986 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
9987 | continue; | |
9988 | } | |
9989 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
9990 | continue; | |
9991 | ||
9992 | vty_out (vty, " %spassive-interface %s %s%s", | |
9993 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 9994 | oi->ifp->name, |
9995 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 9996 | } |
718e3744 | 9997 | |
9998 | /* Network area print. */ | |
68980084 | 9999 | config_write_network_area (vty, ospf); |
718e3744 | 10000 | |
10001 | /* Area config print. */ | |
68980084 | 10002 | config_write_ospf_area (vty, ospf); |
718e3744 | 10003 | |
10004 | /* static neighbor print. */ | |
68980084 | 10005 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 10006 | |
10007 | /* Virtual-Link print. */ | |
68980084 | 10008 | config_write_virtual_link (vty, ospf); |
718e3744 | 10009 | |
10010 | /* Default metric configuration. */ | |
68980084 | 10011 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 10012 | |
10013 | /* Distribute-list and default-information print. */ | |
68980084 | 10014 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 10015 | |
10016 | /* Distance configuration. */ | |
68980084 | 10017 | config_write_ospf_distance (vty, ospf); |
718e3744 | 10018 | |
68980084 | 10019 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 10020 | } |
10021 | ||
10022 | return write; | |
10023 | } | |
10024 | ||
10025 | void | |
4dadc291 | 10026 | ospf_vty_show_init (void) |
718e3744 | 10027 | { |
10028 | /* "show ip ospf" commands. */ | |
10029 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
10030 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); | |
10031 | ||
7c8ff89e DS |
10032 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
10033 | install_element (ENABLE_NODE, &show_ip_ospf_instance_cmd); | |
10034 | ||
718e3744 | 10035 | /* "show ip ospf database" commands. */ |
718e3744 | 10036 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
718e3744 | 10037 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
718e3744 | 10038 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
718e3744 | 10039 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
10040 | ||
7c8ff89e | 10041 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); |
7c8ff89e | 10042 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); |
7c8ff89e | 10043 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); |
7c8ff89e DS |
10044 | install_element (ENABLE_NODE, &show_ip_ospf_instance_database_cmd); |
10045 | ||
718e3744 | 10046 | /* "show ip ospf interface" commands. */ |
10047 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
10048 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); | |
10049 | ||
7c8ff89e DS |
10050 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
10051 | install_element (ENABLE_NODE, &show_ip_ospf_instance_interface_cmd); | |
10052 | ||
718e3744 | 10053 | /* "show ip ospf neighbor" commands. */ |
10054 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
10055 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
10056 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
10057 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
10058 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
10059 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
10060 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
10061 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
10062 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); | |
10063 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); | |
10064 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
10065 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
10066 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); | |
10067 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); | |
10068 | ||
7c8ff89e DS |
10069 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
10070 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
10071 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
10072 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
10073 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
10074 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
10075 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
10076 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); | |
10077 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
10078 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
10079 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
10080 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
10081 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
10082 | install_element (ENABLE_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
10083 | ||
718e3744 | 10084 | /* "show ip ospf route" commands. */ |
10085 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
10086 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 10087 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
10088 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); | |
7c8ff89e DS |
10089 | |
10090 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
10091 | install_element (ENABLE_NODE, &show_ip_ospf_instance_route_cmd); | |
10092 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
10093 | install_element (ENABLE_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
718e3744 | 10094 | } |
10095 | ||
6b0655a2 | 10096 | |
718e3744 | 10097 | /* ospfd's interface node. */ |
7fc626de | 10098 | static struct cmd_node interface_node = |
718e3744 | 10099 | { |
10100 | INTERFACE_NODE, | |
10101 | "%s(config-if)# ", | |
10102 | 1 | |
10103 | }; | |
10104 | ||
10105 | /* Initialization of OSPF interface. */ | |
4dadc291 | 10106 | static void |
10107 | ospf_vty_if_init (void) | |
718e3744 | 10108 | { |
10109 | /* Install interface node. */ | |
10110 | install_node (&interface_node, config_write_interface); | |
10111 | ||
10112 | install_element (CONFIG_NODE, &interface_cmd); | |
32d2463c | 10113 | install_element (CONFIG_NODE, &no_interface_cmd); |
718e3744 | 10114 | install_default (INTERFACE_NODE); |
10115 | ||
10116 | /* "description" commands. */ | |
10117 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
10118 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
10119 | ||
10120 | /* "ip ospf authentication" commands. */ | |
10121 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
718e3744 | 10122 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
b4a039bf | 10123 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
718e3744 | 10124 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
718e3744 | 10125 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
813d4307 | 10126 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); |
718e3744 | 10127 | |
10128 | /* "ip ospf message-digest-key" commands. */ | |
10129 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); | |
718e3744 | 10130 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
813d4307 | 10131 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd); |
718e3744 | 10132 | |
10133 | /* "ip ospf cost" commands. */ | |
9eff36b3 | 10134 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
827341b7 | 10135 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
9eff36b3 | 10136 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
718e3744 | 10137 | |
ba682537 | 10138 | /* "ip ospf mtu-ignore" commands. */ |
10139 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
ba682537 | 10140 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
ba682537 | 10141 | |
718e3744 | 10142 | /* "ip ospf dead-interval" commands. */ |
10143 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); | |
f9ad937f | 10144 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
718e3744 | 10145 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
f9ad937f | 10146 | |
718e3744 | 10147 | /* "ip ospf hello-interval" commands. */ |
10148 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); | |
718e3744 | 10149 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
718e3744 | 10150 | |
10151 | /* "ip ospf network" commands. */ | |
10152 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
10153 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
10154 | ||
10155 | /* "ip ospf priority" commands. */ | |
10156 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); | |
813d4307 | 10157 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
718e3744 | 10158 | |
10159 | /* "ip ospf retransmit-interval" commands. */ | |
10160 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
718e3744 | 10161 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
813d4307 | 10162 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_cmd); |
718e3744 | 10163 | |
10164 | /* "ip ospf transmit-delay" commands. */ | |
10165 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
718e3744 | 10166 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
813d4307 | 10167 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_cmd); |
718e3744 | 10168 | |
953cde65 JT |
10169 | /* "ip ospf area" commands. */ |
10170 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
10171 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
953cde65 | 10172 | install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd); |
953cde65 | 10173 | |
718e3744 | 10174 | /* These commands are compatibitliy for previous version. */ |
10175 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
718e3744 | 10176 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
9eff36b3 DO |
10177 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
10178 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); | |
718e3744 | 10179 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
718e3744 | 10180 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
718e3744 | 10181 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
718e3744 | 10182 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
718e3744 | 10183 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
718e3744 | 10184 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
718e3744 | 10185 | } |
10186 | ||
4dadc291 | 10187 | static void |
10188 | ospf_vty_zebra_init (void) | |
718e3744 | 10189 | { |
718e3744 | 10190 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 10191 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
10192 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
10193 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 10194 | |
10195 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
10196 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
10197 | ||
718e3744 | 10198 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 10199 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
10200 | ||
10201 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
10202 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
718e3744 | 10203 | |
10204 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
10205 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
10206 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 10207 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 10208 | #if 0 |
10209 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
10210 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
10211 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
10212 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
10213 | #endif /* 0 */ | |
10214 | } | |
10215 | ||
7fc626de | 10216 | static struct cmd_node ospf_node = |
718e3744 | 10217 | { |
10218 | OSPF_NODE, | |
10219 | "%s(config-router)# ", | |
10220 | 1 | |
10221 | }; | |
10222 | ||
09f35f8c DS |
10223 | static void |
10224 | ospf_interface_clear (struct interface *ifp) | |
10225 | { | |
10226 | if (!if_is_operative (ifp)) return; | |
10227 | ||
10228 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
10229 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); | |
10230 | ||
10231 | ospf_if_reset(ifp); | |
10232 | } | |
10233 | ||
10234 | DEFUN (clear_ip_ospf_interface, | |
10235 | clear_ip_ospf_interface_cmd, | |
10236 | "clear ip ospf interface [IFNAME]", | |
10237 | CLEAR_STR | |
10238 | IP_STR | |
10239 | "OSPF information\n" | |
10240 | "Interface information\n" | |
10241 | "Interface name\n") | |
10242 | { | |
10243 | struct interface *ifp; | |
10244 | struct listnode *node; | |
10245 | ||
10246 | if (argc == 0) /* Clear all the ospfv2 interfaces. */ | |
10247 | { | |
b2d7c082 | 10248 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
09f35f8c DS |
10249 | ospf_interface_clear(ifp); |
10250 | } | |
10251 | else /* Interface name is specified. */ | |
10252 | { | |
bf2bfafd | 10253 | if ((ifp = if_lookup_by_name (argv[4]->arg)) == NULL) |
09f35f8c DS |
10254 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
10255 | else | |
10256 | ospf_interface_clear(ifp); | |
10257 | } | |
10258 | ||
10259 | return CMD_SUCCESS; | |
10260 | } | |
10261 | ||
10262 | void | |
10263 | ospf_vty_clear_init (void) | |
10264 | { | |
10265 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
10266 | } | |
10267 | ||
6b0655a2 | 10268 | |
718e3744 | 10269 | /* Install OSPF related vty commands. */ |
10270 | void | |
4dadc291 | 10271 | ospf_vty_init (void) |
718e3744 | 10272 | { |
10273 | /* Install ospf top node. */ | |
10274 | install_node (&ospf_node, ospf_config_write); | |
10275 | ||
10276 | /* "router ospf" commands. */ | |
10277 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
10278 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
10279 | ||
7c8ff89e | 10280 | |
718e3744 | 10281 | install_default (OSPF_NODE); |
10282 | ||
10283 | /* "ospf router-id" commands. */ | |
10284 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
747e489c | 10285 | install_element (OSPF_NODE, &ospf_router_id_old_cmd); |
718e3744 | 10286 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
718e3744 | 10287 | |
10288 | /* "passive-interface" commands. */ | |
a2c62831 | 10289 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
a2c62831 | 10290 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
718e3744 | 10291 | |
10292 | /* "ospf abr-type" commands. */ | |
10293 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
10294 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
10295 | ||
d7e60dd7 AS |
10296 | /* "ospf log-adjacency-changes" commands. */ |
10297 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
10298 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
10299 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
10300 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
10301 | ||
718e3744 | 10302 | /* "ospf rfc1583-compatible" commands. */ |
718e3744 | 10303 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
10304 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
10305 | ||
10306 | /* "network area" commands. */ | |
a2c62831 | 10307 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
10308 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 10309 | |
10310 | /* "area authentication" commands. */ | |
a2c62831 | 10311 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
10312 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
10313 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 10314 | |
10315 | /* "area range" commands. */ | |
a2c62831 | 10316 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
a2c62831 | 10317 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
10318 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
a2c62831 | 10319 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
10320 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 10321 | |
10322 | /* "area virtual-link" commands. */ | |
a2c62831 | 10323 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
10324 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); | |
718e3744 | 10325 | |
718e3744 | 10326 | |
718e3744 | 10327 | |
718e3744 | 10328 | |
718e3744 | 10329 | |
718e3744 | 10330 | |
718e3744 | 10331 | |
718e3744 | 10332 | |
718e3744 | 10333 | |
718e3744 | 10334 | |
10335 | /* "area stub" commands. */ | |
a2c62831 | 10336 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
10337 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
10338 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
10339 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 10340 | |
718e3744 | 10341 | /* "area nssa" commands. */ |
a2c62831 | 10342 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
10343 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
10344 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
10345 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
10346 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
718e3744 | 10347 | |
a2c62831 | 10348 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
10349 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 10350 | |
a2c62831 | 10351 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
10352 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 10353 | |
a2c62831 | 10354 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
10355 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 10356 | |
a2c62831 | 10357 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
10358 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 10359 | |
a2c62831 | 10360 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
10361 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 10362 | |
10363 | /* SPF timer commands */ | |
d24f6e2a | 10364 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
10365 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
10366 | ||
b6927875 | 10367 | /* LSA timers commands */ |
ac7424f9 MR |
10368 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
10369 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
10370 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); | |
10371 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
b6927875 DS |
10372 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
10373 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
b6927875 | 10374 | |
88d6cf37 | 10375 | /* refresh timer commands */ |
a2c62831 | 10376 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
10377 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
718e3744 | 10378 | |
88d6cf37 | 10379 | /* max-metric commands */ |
10380 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
10381 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
10382 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
10383 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
10384 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
10385 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
10386 | ||
10387 | /* reference bandwidth commands */ | |
a2c62831 | 10388 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
10389 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
718e3744 | 10390 | |
10391 | /* "neighbor" commands. */ | |
a2c62831 | 10392 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
a2c62831 | 10393 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
a2c62831 | 10394 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
718e3744 | 10395 | |
2f8f370e DS |
10396 | /* write multiplier commands */ |
10397 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
10398 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); | |
10399 | ||
718e3744 | 10400 | /* Init interface related vty commands. */ |
10401 | ospf_vty_if_init (); | |
10402 | ||
10403 | /* Init zebra related vty commands. */ | |
10404 | ospf_vty_zebra_init (); | |
10405 | } |