]>
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 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
7ec4159b | 23 | #include <string.h> |
718e3744 | 24 | |
cbf3e3eb | 25 | #include "monotime.h" |
718e3744 | 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> |
8efe88ea | 36 | #include "defaults.h" |
718e3744 | 37 | |
38 | #include "ospfd/ospfd.h" | |
39 | #include "ospfd/ospf_asbr.h" | |
40 | #include "ospfd/ospf_lsa.h" | |
41 | #include "ospfd/ospf_lsdb.h" | |
42 | #include "ospfd/ospf_ism.h" | |
43 | #include "ospfd/ospf_interface.h" | |
44 | #include "ospfd/ospf_nsm.h" | |
45 | #include "ospfd/ospf_neighbor.h" | |
46 | #include "ospfd/ospf_flood.h" | |
47 | #include "ospfd/ospf_abr.h" | |
48 | #include "ospfd/ospf_spf.h" | |
49 | #include "ospfd/ospf_route.h" | |
50 | #include "ospfd/ospf_zebra.h" | |
51 | /*#include "ospfd/ospf_routemap.h" */ | |
52 | #include "ospfd/ospf_vty.h" | |
53 | #include "ospfd/ospf_dump.h" | |
7f342629 | 54 | #include "ospfd/ospf_bfd.h" |
718e3744 | 55 | |
30a2231a | 56 | static const char *ospf_network_type_str[] = |
718e3744 | 57 | { |
58 | "Null", | |
59 | "POINTOPOINT", | |
60 | "BROADCAST", | |
61 | "NBMA", | |
62 | "POINTOMULTIPOINT", | |
63 | "VIRTUALLINK", | |
64 | "LOOPBACK" | |
65 | }; | |
66 | ||
718e3744 | 67 | /* Utility functions. */ |
16f1b9ee | 68 | int |
86573dcb | 69 | str2area_id (const char *str, struct in_addr *area_id, int *area_id_fmt) |
718e3744 | 70 | { |
86573dcb | 71 | char *ep; |
718e3744 | 72 | |
86573dcb QY |
73 | area_id->s_addr = htonl (strtoul (str, &ep, 10)); |
74 | if (*ep && !inet_aton (str, area_id)) | |
75 | return -1; | |
718e3744 | 76 | |
86573dcb | 77 | *area_id_fmt = *ep ? OSPF_AREA_ID_FMT_DOTTEDQUAD : OSPF_AREA_ID_FMT_DECIMAL; |
718e3744 | 78 | |
79 | return 0; | |
80 | } | |
81 | ||
86573dcb QY |
82 | void |
83 | area_id2str (char *buf, int length, struct in_addr *area_id, int area_id_fmt) | |
84 | { | |
85 | memset (buf, 0, length); | |
86 | ||
87 | if (area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) | |
88 | strncpy (buf, inet_ntoa (*area_id), length); | |
89 | else | |
90 | sprintf (buf, "%lu", (unsigned long) ntohl (area_id->s_addr)); | |
91 | } | |
6b0655a2 | 92 | |
4dadc291 | 93 | static int |
6c835671 | 94 | str2metric (const char *str, int *metric) |
718e3744 | 95 | { |
96 | /* Sanity check. */ | |
97 | if (str == NULL) | |
98 | return 0; | |
99 | ||
100 | *metric = strtol (str, NULL, 10); | |
101 | if (*metric < 0 && *metric > 16777214) | |
102 | { | |
103 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ | |
104 | return 0; | |
105 | } | |
106 | ||
107 | return 1; | |
108 | } | |
109 | ||
4dadc291 | 110 | static int |
6c835671 | 111 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 112 | { |
113 | /* Sanity check. */ | |
114 | if (str == NULL) | |
115 | return 0; | |
116 | ||
117 | if (strncmp (str, "1", 1) == 0) | |
118 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
119 | else if (strncmp (str, "2", 1) == 0) | |
120 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
121 | else | |
122 | return 0; | |
123 | ||
124 | return 1; | |
125 | } | |
126 | ||
127 | int | |
128 | ospf_oi_count (struct interface *ifp) | |
129 | { | |
130 | struct route_node *rn; | |
131 | int i = 0; | |
132 | ||
133 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
134 | if (rn->info) | |
135 | i++; | |
136 | ||
137 | return i; | |
138 | } | |
139 | ||
505e5056 | 140 | DEFUN_NOSH (router_ospf, |
718e3744 | 141 | router_ospf_cmd, |
7a7be519 | 142 | "router ospf [(1-65535)]", |
718e3744 | 143 | "Enable a routing process\n" |
7a7be519 | 144 | "Start OSPF configuration\n" |
145 | "Instance ID\n") | |
718e3744 | 146 | { |
7c8ff89e DS |
147 | struct ospf *ospf; |
148 | u_short instance = 0; | |
149 | ||
150 | ospf = ospf_lookup(); | |
151 | if (!ospf) | |
152 | { | |
153 | vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE); | |
154 | return CMD_WARNING; | |
155 | } | |
156 | ||
7a7be519 | 157 | if (argc > 2) |
158 | VTY_GET_INTEGER ("Instance", instance, argv[2]->arg); | |
7c8ff89e | 159 | |
52c6b0e2 | 160 | /* The following logic to set the vty qobj index is in place to be able |
7c8ff89e DS |
161 | to ignore the commands which dont belong to this instance. */ |
162 | if (ospf->instance != instance) | |
cdc2d765 | 163 | VTY_PUSH_CONTEXT_NULL(OSPF_NODE); |
7c8ff89e | 164 | else |
0bad4851 DS |
165 | { |
166 | if (IS_DEBUG_OSPF_EVENT) | |
167 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
168 | ospf->oi_running = 1; | |
52c6b0e2 | 169 | VTY_PUSH_CONTEXT(OSPF_NODE, ospf); |
0bad4851 DS |
170 | ospf_router_id_update (ospf); |
171 | } | |
718e3744 | 172 | |
173 | return CMD_SUCCESS; | |
174 | } | |
175 | ||
176 | DEFUN (no_router_ospf, | |
177 | no_router_ospf_cmd, | |
7a7be519 | 178 | "no router ospf [(1-65535)]", |
718e3744 | 179 | NO_STR |
180 | "Enable a routing process\n" | |
7a7be519 | 181 | "Start OSPF configuration\n" |
182 | "Instance ID\n") | |
718e3744 | 183 | { |
020709f9 | 184 | struct ospf *ospf; |
7c8ff89e | 185 | u_short instance = 0; |
020709f9 | 186 | |
7a7be519 | 187 | if (argc > 3) |
bf2bfafd | 188 | VTY_GET_INTEGER ("Instance", instance, argv[3]->arg); |
7c8ff89e DS |
189 | |
190 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
191 | return CMD_SUCCESS; | |
718e3744 | 192 | |
020709f9 | 193 | ospf_finish (ospf); |
718e3744 | 194 | |
195 | return CMD_SUCCESS; | |
196 | } | |
197 | ||
7c8ff89e | 198 | |
718e3744 | 199 | DEFUN (ospf_router_id, |
200 | ospf_router_id_cmd, | |
201 | "ospf router-id A.B.C.D", | |
202 | "OSPF specific commands\n" | |
203 | "router-id for the OSPF process\n" | |
204 | "OSPF router-id in IP address format\n") | |
205 | { | |
cdc2d765 | 206 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 207 | int idx_ipv4 = 2; |
2c19a6ec DS |
208 | struct listnode *node; |
209 | struct ospf_area *area; | |
718e3744 | 210 | struct in_addr router_id; |
68980084 | 211 | int ret; |
718e3744 | 212 | |
8d769265 | 213 | ret = inet_aton (argv[idx_ipv4]->arg, &router_id); |
718e3744 | 214 | if (!ret) |
215 | { | |
216 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
217 | return CMD_WARNING; | |
218 | } | |
219 | ||
68980084 | 220 | ospf->router_id_static = router_id; |
2c19a6ec DS |
221 | |
222 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
223 | if (area->full_nbrs) | |
224 | { | |
225 | vty_out (vty, "For this router-id change to take effect," | |
226 | " save config and restart ospfd%s", VTY_NEWLINE); | |
227 | return CMD_SUCCESS; | |
228 | } | |
229 | ||
b29800a6 | 230 | ospf_router_id_update (ospf); |
231 | ||
718e3744 | 232 | return CMD_SUCCESS; |
233 | } | |
234 | ||
7a7be519 | 235 | DEFUN_HIDDEN (ospf_router_id_old, |
747e489c DW |
236 | ospf_router_id_old_cmd, |
237 | "router-id A.B.C.D", | |
238 | "router-id for the OSPF process\n" | |
239 | "OSPF router-id in IP address format\n") | |
7a7be519 | 240 | { |
cdc2d765 | 241 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 242 | int idx_ipv4 = 1; |
7a7be519 | 243 | struct listnode *node; |
244 | struct ospf_area *area; | |
245 | struct in_addr router_id; | |
246 | int ret; | |
247 | ||
7a7be519 | 248 | ret = inet_aton (argv[idx_ipv4]->arg, &router_id); |
249 | if (!ret) | |
250 | { | |
251 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); | |
252 | return CMD_WARNING; | |
253 | } | |
254 | ||
255 | ospf->router_id_static = router_id; | |
256 | ||
257 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
258 | if (area->full_nbrs) | |
259 | { | |
260 | vty_out (vty, "For this router-id change to take effect," | |
261 | " save config and restart ospfd%s", VTY_NEWLINE); | |
262 | return CMD_SUCCESS; | |
263 | } | |
264 | ||
265 | ospf_router_id_update (ospf); | |
266 | ||
267 | return CMD_SUCCESS; | |
268 | } | |
747e489c | 269 | |
718e3744 | 270 | DEFUN (no_ospf_router_id, |
271 | no_ospf_router_id_cmd, | |
7a7be519 | 272 | "no ospf router-id [A.B.C.D]", |
718e3744 | 273 | NO_STR |
274 | "OSPF specific commands\n" | |
7a7be519 | 275 | "router-id for the OSPF process\n" |
276 | "OSPF router-id in IP address format\n") | |
718e3744 | 277 | { |
cdc2d765 | 278 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
2c19a6ec DS |
279 | struct listnode *node; |
280 | struct ospf_area *area; | |
68980084 | 281 | |
282 | ospf->router_id_static.s_addr = 0; | |
718e3744 | 283 | |
2c19a6ec DS |
284 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
285 | if (area->full_nbrs) | |
286 | { | |
287 | vty_out (vty, "For this router-id change to take effect," | |
288 | " save config and restart ospfd%s", VTY_NEWLINE); | |
289 | return CMD_SUCCESS; | |
290 | } | |
291 | ||
68980084 | 292 | ospf_router_id_update (ospf); |
718e3744 | 293 | |
294 | return CMD_SUCCESS; | |
295 | } | |
296 | ||
718e3744 | 297 | |
7ffa8fa2 | 298 | static void |
43540886 | 299 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
300 | { |
301 | struct listnode *ln; | |
302 | struct interface *ifp; | |
303 | struct ospf_interface *oi; | |
304 | ||
43540886 AS |
305 | ospf->passive_interface_default = newval; |
306 | ||
7ffa8fa2 PJ |
307 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
308 | { | |
309 | if (ifp && | |
310 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
311 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
312 | } | |
313 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
314 | { | |
315 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
316 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
317 | /* update multicast memberships */ |
318 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
319 | } |
320 | } | |
321 | ||
322 | static void | |
f842f166 PJ |
323 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
324 | struct ospf_if_params *params, u_char value, | |
325 | struct in_addr addr) | |
7ffa8fa2 PJ |
326 | { |
327 | u_char dflt; | |
328 | ||
329 | params->passive_interface = value; | |
330 | if (params != IF_DEF_PARAMS (ifp)) | |
331 | { | |
332 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
333 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
334 | else | |
335 | dflt = ospf->passive_interface_default; | |
336 | ||
337 | if (value != dflt) | |
338 | SET_IF_PARAM (params, passive_interface); | |
339 | else | |
340 | UNSET_IF_PARAM (params, passive_interface); | |
341 | ||
342 | ospf_free_if_params (ifp, addr); | |
343 | ospf_if_update_params (ifp, addr); | |
344 | } | |
f842f166 PJ |
345 | } |
346 | ||
347 | static void | |
348 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
349 | struct ospf_if_params *params, u_char value) | |
350 | { | |
351 | params->passive_interface = value; | |
352 | if (params == IF_DEF_PARAMS (ifp)) | |
7ffa8fa2 PJ |
353 | { |
354 | if (value != ospf->passive_interface_default) | |
355 | SET_IF_PARAM (params, passive_interface); | |
356 | else | |
357 | UNSET_IF_PARAM (params, passive_interface); | |
358 | } | |
359 | } | |
360 | ||
a2c62831 | 361 | DEFUN (ospf_passive_interface, |
362 | ospf_passive_interface_addr_cmd, | |
7a7be519 | 363 | "passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 364 | "Suppress routing updates on an interface\n" |
7a7be519 | 365 | "Interface's name\n" |
3a2d747c | 366 | "IPv4 address\n" |
7a7be519 | 367 | "Suppress routing updates on interfaces by default\n") |
718e3744 | 368 | { |
cdc2d765 | 369 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 370 | int idx_ipv4 = 2; |
7ffa8fa2 | 371 | struct interface *ifp; |
cb2af5d0 | 372 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
7ffa8fa2 PJ |
373 | int ret; |
374 | struct ospf_if_params *params; | |
375 | struct route_node *rn; | |
718e3744 | 376 | |
7a7be519 | 377 | if (strcmp (argv[1]->text, "default") == 0) |
43540886 AS |
378 | { |
379 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
380 | return CMD_SUCCESS; | |
381 | } | |
382 | ||
92a57eb2 | 383 | ifp = if_get_by_name (argv[1]->arg, VRF_DEFAULT); |
718e3744 | 384 | |
385 | params = IF_DEF_PARAMS (ifp); | |
386 | ||
7a7be519 | 387 | if (argc == 3) |
718e3744 | 388 | { |
7a7be519 | 389 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
43540886 AS |
390 | if (!ret) |
391 | { | |
392 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
393 | VTY_NEWLINE); | |
394 | return CMD_WARNING; | |
395 | } | |
396 | ||
397 | params = ospf_get_if_params (ifp, addr); | |
398 | ospf_if_update_params (ifp, addr); | |
f842f166 PJ |
399 | ospf_passive_interface_update_addr (ospf, ifp, params, |
400 | OSPF_IF_PASSIVE, addr); | |
7ffa8fa2 | 401 | } |
f842f166 PJ |
402 | |
403 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); | |
43540886 | 404 | |
ba6454ec | 405 | /* XXX We should call ospf_if_set_multicast on exactly those |
406 | * interfaces for which the passive property changed. It is too much | |
407 | * work to determine this set, so we do this for every interface. | |
408 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
409 | * record of joined groups to avoid systems calls if the desired | |
410 | * memberships match the current memership. | |
411 | */ | |
7ffa8fa2 | 412 | |
ba6454ec | 413 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
414 | { | |
415 | struct ospf_interface *oi = rn->info; | |
416 | ||
417 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 418 | ospf_if_set_multicast(oi); |
ba6454ec | 419 | } |
420 | /* | |
421 | * XXX It is not clear what state transitions the interface needs to | |
422 | * undergo when going from active to passive. Fixing this will | |
423 | * require precise identification of interfaces having such a | |
424 | * transition. | |
425 | */ | |
426 | ||
718e3744 | 427 | return CMD_SUCCESS; |
428 | } | |
429 | ||
a2c62831 | 430 | DEFUN (no_ospf_passive_interface, |
431 | no_ospf_passive_interface_addr_cmd, | |
7a7be519 | 432 | "no passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 433 | NO_STR |
434 | "Allow routing updates on an interface\n" | |
7a7be519 | 435 | "Interface's name\n" |
3a2d747c | 436 | "IPv4 address\n" |
7a7be519 | 437 | "Allow routing updates on interfaces by default\n") |
718e3744 | 438 | { |
cdc2d765 | 439 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 440 | int idx_ipv4 = 3; |
718e3744 | 441 | struct interface *ifp; |
cb2af5d0 | 442 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
718e3744 | 443 | struct ospf_if_params *params; |
444 | int ret; | |
ba6454ec | 445 | struct route_node *rn; |
43540886 | 446 | |
7a7be519 | 447 | if (strcmp (argv[2]->text, "default") == 0) |
43540886 AS |
448 | { |
449 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
450 | return CMD_SUCCESS; | |
451 | } | |
718e3744 | 452 | |
92a57eb2 | 453 | ifp = if_get_by_name (argv[2]->arg, VRF_DEFAULT); |
718e3744 | 454 | |
455 | params = IF_DEF_PARAMS (ifp); | |
456 | ||
7a7be519 | 457 | if (argc == 4) |
718e3744 | 458 | { |
7a7be519 | 459 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
43540886 AS |
460 | if (!ret) |
461 | { | |
462 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
463 | VTY_NEWLINE); | |
464 | return CMD_WARNING; | |
465 | } | |
466 | ||
467 | params = ospf_lookup_if_params (ifp, addr); | |
468 | if (params == NULL) | |
469 | return CMD_SUCCESS; | |
f842f166 PJ |
470 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
471 | addr); | |
718e3744 | 472 | } |
f842f166 PJ |
473 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
474 | ||
ba6454ec | 475 | /* XXX We should call ospf_if_set_multicast on exactly those |
476 | * interfaces for which the passive property changed. It is too much | |
477 | * work to determine this set, so we do this for every interface. | |
478 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
479 | * record of joined groups to avoid systems calls if the desired | |
480 | * memberships match the current memership. | |
481 | */ | |
482 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
483 | { | |
484 | struct ospf_interface *oi = rn->info; | |
485 | ||
486 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
487 | ospf_if_set_multicast(oi); | |
488 | } | |
489 | ||
718e3744 | 490 | return CMD_SUCCESS; |
491 | } | |
492 | ||
718e3744 | 493 | |
7ffa8fa2 | 494 | |
a2c62831 | 495 | DEFUN (ospf_network_area, |
496 | ospf_network_area_cmd, | |
6147e2c6 | 497 | "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 498 | "Enable routing on an IP network\n" |
499 | "OSPF network prefix\n" | |
500 | "Set the OSPF area ID\n" | |
501 | "OSPF area ID in IP address format\n" | |
502 | "OSPF area ID as a decimal value\n") | |
503 | { | |
cdc2d765 | 504 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
505 | int idx_ipv4_prefixlen = 1; |
506 | int idx_ipv4_number = 3; | |
718e3744 | 507 | struct prefix_ipv4 p; |
508 | struct in_addr area_id; | |
509 | int ret, format; | |
510 | ||
7c8ff89e DS |
511 | if (ospf->instance) |
512 | { | |
513 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
514 | VTY_NEWLINE); | |
515 | return CMD_WARNING; | |
516 | } | |
517 | ||
953cde65 JT |
518 | if (ospf->if_ospf_cli_count > 0) |
519 | { | |
520 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
521 | VTY_NEWLINE); | |
522 | return CMD_WARNING; | |
523 | } | |
524 | ||
718e3744 | 525 | /* Get network prefix and Area ID. */ |
8d769265 DW |
526 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); |
527 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); | |
718e3744 | 528 | |
86573dcb | 529 | ret = ospf_network_set (ospf, &p, area_id, format); |
718e3744 | 530 | if (ret == 0) |
531 | { | |
532 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); | |
533 | return CMD_WARNING; | |
534 | } | |
535 | ||
536 | return CMD_SUCCESS; | |
537 | } | |
538 | ||
a2c62831 | 539 | DEFUN (no_ospf_network_area, |
540 | no_ospf_network_area_cmd, | |
6147e2c6 | 541 | "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 542 | NO_STR |
543 | "Enable routing on an IP network\n" | |
544 | "OSPF network prefix\n" | |
545 | "Set the OSPF area ID\n" | |
546 | "OSPF area ID in IP address format\n" | |
547 | "OSPF area ID as a decimal value\n") | |
548 | { | |
cdc2d765 | 549 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
550 | int idx_ipv4_prefixlen = 2; |
551 | int idx_ipv4_number = 4; | |
718e3744 | 552 | struct prefix_ipv4 p; |
553 | struct in_addr area_id; | |
554 | int ret, format; | |
555 | ||
7c8ff89e DS |
556 | if (ospf->instance) |
557 | { | |
558 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
559 | VTY_NEWLINE); | |
560 | return CMD_WARNING; | |
561 | } | |
562 | ||
718e3744 | 563 | /* Get network prefix and Area ID. */ |
8d769265 DW |
564 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[idx_ipv4_prefixlen]->arg); |
565 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); | |
718e3744 | 566 | |
567 | ret = ospf_network_unset (ospf, &p, area_id); | |
568 | if (ret == 0) | |
569 | { | |
570 | vty_out (vty, "Can't find specified network area configuration.%s", | |
571 | VTY_NEWLINE); | |
572 | return CMD_WARNING; | |
573 | } | |
574 | ||
575 | return CMD_SUCCESS; | |
576 | } | |
577 | ||
a2c62831 | 578 | DEFUN (ospf_area_range, |
579 | ospf_area_range_cmd, | |
7a7be519 | 580 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]", |
718e3744 | 581 | "OSPF area parameters\n" |
582 | "OSPF area ID in IP address format\n" | |
583 | "OSPF area ID as a decimal value\n" | |
584 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 585 | "Area range prefix\n" |
586 | "Advertise this range (default)\n" | |
587 | "User specified metric for this range\n" | |
588 | "Advertised metric for this range\n") | |
718e3744 | 589 | { |
cdc2d765 | 590 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
591 | int idx_ipv4_number = 1; |
592 | int idx_ipv4_prefixlen = 3; | |
7a7be519 | 593 | int idx_cost = 6; |
718e3744 | 594 | struct prefix_ipv4 p; |
595 | struct in_addr area_id; | |
596 | int format; | |
597 | u_int32_t cost; | |
598 | ||
8d769265 DW |
599 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
600 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
718e3744 | 601 | |
602 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
7a7be519 | 603 | if (argc > 5) |
718e3744 | 604 | { |
7a7be519 | 605 | VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); |
718e3744 | 606 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
607 | } | |
608 | ||
609 | return CMD_SUCCESS; | |
610 | } | |
611 | ||
7a7be519 | 612 | DEFUN (ospf_area_range_cost, |
613 | ospf_area_range_cost_cmd, | |
614 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)", | |
615 | "OSPF area parameters\n" | |
616 | "OSPF area ID in IP address format\n" | |
617 | "OSPF area ID as a decimal value\n" | |
618 | "Summarize routes matching address/mask (border routers only)\n" | |
619 | "Area range prefix\n" | |
620 | "User specified metric for this range\n" | |
621 | "Advertised metric for this range\n") | |
622 | { | |
cdc2d765 | 623 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 624 | int idx_ipv4_number = 1; |
625 | int idx_ipv4_prefixlen = 3; | |
626 | int idx_cost = 5; | |
7a7be519 | 627 | struct prefix_ipv4 p; |
628 | struct in_addr area_id; | |
629 | int format; | |
630 | u_int32_t cost; | |
631 | ||
7a7be519 | 632 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
633 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
634 | ||
635 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
86573dcb | 636 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 637 | |
7a7be519 | 638 | VTY_GET_INTEGER ("range cost", cost, argv[idx_cost]->arg); |
639 | ospf_area_range_cost_set (ospf, area_id, &p, cost); | |
718e3744 | 640 | |
7a7be519 | 641 | return CMD_SUCCESS; |
642 | } | |
718e3744 | 643 | |
a2c62831 | 644 | DEFUN (ospf_area_range_not_advertise, |
645 | ospf_area_range_not_advertise_cmd, | |
6147e2c6 | 646 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise", |
718e3744 | 647 | "OSPF area parameters\n" |
648 | "OSPF area ID in IP address format\n" | |
649 | "OSPF area ID as a decimal value\n" | |
650 | "Summarize routes matching address/mask (border routers only)\n" | |
651 | "Area range prefix\n" | |
652 | "DoNotAdvertise this range\n") | |
653 | { | |
cdc2d765 | 654 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
655 | int idx_ipv4_number = 1; |
656 | int idx_ipv4_prefixlen = 3; | |
718e3744 | 657 | struct prefix_ipv4 p; |
658 | struct in_addr area_id; | |
659 | int format; | |
660 | ||
8d769265 DW |
661 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
662 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
718e3744 | 663 | |
664 | ospf_area_range_set (ospf, area_id, &p, 0); | |
86573dcb | 665 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 666 | |
667 | return CMD_SUCCESS; | |
668 | } | |
669 | ||
a2c62831 | 670 | DEFUN (no_ospf_area_range, |
671 | no_ospf_area_range_cmd, | |
3a2d747c | 672 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]", |
718e3744 | 673 | NO_STR |
674 | "OSPF area parameters\n" | |
675 | "OSPF area ID in IP address format\n" | |
676 | "OSPF area ID as a decimal value\n" | |
677 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 678 | "Area range prefix\n" |
3a2d747c QY |
679 | "User specified metric for this range\n" |
680 | "Advertised metric for this range\n" | |
7a7be519 | 681 | "Advertise this range (default)\n" |
3a2d747c QY |
682 | "User specified metric for this range\n" |
683 | "Advertised metric for this range\n" | |
7a7be519 | 684 | "DoNotAdvertise this range\n") |
718e3744 | 685 | { |
cdc2d765 | 686 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
687 | int idx_ipv4_number = 2; |
688 | int idx_ipv4_prefixlen = 4; | |
718e3744 | 689 | struct prefix_ipv4 p; |
690 | struct in_addr area_id; | |
691 | int format; | |
692 | ||
8d769265 DW |
693 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
694 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
718e3744 | 695 | |
696 | ospf_area_range_unset (ospf, area_id, &p); | |
697 | ||
698 | return CMD_SUCCESS; | |
699 | } | |
700 | ||
a2c62831 | 701 | DEFUN (ospf_area_range_substitute, |
702 | ospf_area_range_substitute_cmd, | |
6147e2c6 | 703 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 704 | "OSPF area parameters\n" |
705 | "OSPF area ID in IP address format\n" | |
706 | "OSPF area ID as a decimal value\n" | |
707 | "Summarize routes matching address/mask (border routers only)\n" | |
708 | "Area range prefix\n" | |
709 | "Announce area range as another prefix\n" | |
710 | "Network prefix to be announced instead of range\n") | |
711 | { | |
cdc2d765 | 712 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
713 | int idx_ipv4_number = 1; |
714 | int idx_ipv4_prefixlen = 3; | |
715 | int idx_ipv4_prefixlen_2 = 5; | |
718e3744 | 716 | struct prefix_ipv4 p, s; |
717 | struct in_addr area_id; | |
718 | int format; | |
719 | ||
8d769265 DW |
720 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
721 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
722 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); | |
718e3744 | 723 | |
724 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
86573dcb | 725 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 726 | |
727 | return CMD_SUCCESS; | |
728 | } | |
729 | ||
a2c62831 | 730 | DEFUN (no_ospf_area_range_substitute, |
731 | no_ospf_area_range_substitute_cmd, | |
6147e2c6 | 732 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 733 | NO_STR |
734 | "OSPF area parameters\n" | |
735 | "OSPF area ID in IP address format\n" | |
736 | "OSPF area ID as a decimal value\n" | |
737 | "Summarize routes matching address/mask (border routers only)\n" | |
738 | "Area range prefix\n" | |
739 | "Announce area range as another prefix\n" | |
740 | "Network prefix to be announced instead of range\n") | |
741 | { | |
cdc2d765 | 742 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
743 | int idx_ipv4_number = 2; |
744 | int idx_ipv4_prefixlen = 4; | |
745 | int idx_ipv4_prefixlen_2 = 6; | |
718e3744 | 746 | struct prefix_ipv4 p, s; |
747 | struct in_addr area_id; | |
748 | int format; | |
749 | ||
8d769265 DW |
750 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
751 | VTY_GET_IPV4_PREFIX ("area range", p, argv[idx_ipv4_prefixlen]->arg); | |
752 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[idx_ipv4_prefixlen_2]->arg); | |
718e3744 | 753 | |
754 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
755 | ||
756 | return CMD_SUCCESS; | |
757 | } | |
758 | ||
6b0655a2 | 759 | |
718e3744 | 760 | /* Command Handler Logic in VLink stuff is delicate!! |
761 | ||
762 | ALTER AT YOUR OWN RISK!!!! | |
763 | ||
764 | Various dummy values are used to represent 'NoChange' state for | |
765 | VLink configuration NOT being changed by a VLink command, and | |
766 | special syntax is used within the command strings so that the | |
767 | typed in command verbs can be seen in the configuration command | |
768 | bacckend handler. This is to drastically reduce the verbeage | |
769 | required to coe up with a reasonably compatible Cisco VLink command | |
770 | ||
771 | - Matthew Grant <grantma@anathoth.gen.nz> | |
772 | Wed, 21 Feb 2001 15:13:52 +1300 | |
773 | */ | |
774 | ||
718e3744 | 775 | /* Configuration data for virtual links |
776 | */ | |
777 | struct ospf_vl_config_data { | |
778 | struct vty *vty; /* vty stuff */ | |
779 | struct in_addr area_id; /* area ID from command line */ | |
86573dcb | 780 | int area_id_fmt; /* command line area ID format */ |
718e3744 | 781 | struct in_addr vl_peer; /* command line vl_peer */ |
782 | int auth_type; /* Authehntication type, if given */ | |
783 | char *auth_key; /* simple password if present */ | |
784 | int crypto_key_id; /* Cryptographic key ID */ | |
785 | char *md5_key; /* MD5 authentication key */ | |
786 | int hello_interval; /* Obvious what these are... */ | |
787 | int retransmit_interval; | |
788 | int transmit_delay; | |
789 | int dead_interval; | |
790 | }; | |
791 | ||
4dadc291 | 792 | static void |
718e3744 | 793 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
794 | struct vty *vty) | |
795 | { | |
796 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
797 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
798 | vl_config->vty = vty; | |
799 | } | |
800 | ||
4dadc291 | 801 | static struct ospf_vl_data * |
68980084 | 802 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 803 | { |
804 | struct ospf_area *area; | |
805 | struct ospf_vl_data *vl_data; | |
806 | struct vty *vty; | |
807 | struct in_addr area_id; | |
808 | ||
809 | vty = vl_config->vty; | |
810 | area_id = vl_config->area_id; | |
811 | ||
812 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
813 | { | |
814 | vty_out (vty, | |
815 | "Configuring VLs over the backbone is not allowed%s", | |
816 | VTY_NEWLINE); | |
817 | return NULL; | |
818 | } | |
86573dcb QY |
819 | area = ospf_area_get (ospf, area_id); |
820 | ospf_area_display_format_set (ospf, area, vl_config->area_id_fmt); | |
718e3744 | 821 | |
822 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
823 | { | |
86573dcb | 824 | if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) |
718e3744 | 825 | vty_out (vty, "Area %s is %s%s", |
826 | inet_ntoa (area_id), | |
718e3744 | 827 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 828 | VTY_NEWLINE); |
829 | else | |
830 | vty_out (vty, "Area %ld is %s%s", | |
831 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 832 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
718e3744 | 833 | VTY_NEWLINE); |
834 | return NULL; | |
835 | } | |
836 | ||
9c27ef9b | 837 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 838 | { |
839 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
840 | if (vl_data->vl_oi == NULL) | |
841 | { | |
68980084 | 842 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
843 | ospf_vl_add (ospf, vl_data); | |
d3a9c768 | 844 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 845 | } |
846 | } | |
847 | return vl_data; | |
848 | } | |
849 | ||
850 | ||
4dadc291 | 851 | static int |
718e3744 | 852 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
853 | struct ospf_vl_config_data *vl_config) | |
854 | { | |
855 | struct crypt_key *ck; | |
856 | struct vty *vty; | |
857 | struct interface *ifp = vl_data->vl_oi->ifp; | |
858 | ||
859 | vty = vl_config->vty; | |
860 | ||
861 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
862 | { | |
863 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
864 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
865 | } | |
866 | ||
867 | if (vl_config->auth_key) | |
868 | { | |
869 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 870 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 871 | OSPF_AUTH_SIMPLE_SIZE); |
872 | } | |
873 | else if (vl_config->md5_key) | |
874 | { | |
875 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
876 | != NULL) | |
877 | { | |
878 | vty_out (vty, "OSPF: Key %d already exists%s", | |
879 | vl_config->crypto_key_id, VTY_NEWLINE); | |
880 | return CMD_WARNING; | |
881 | } | |
882 | ck = ospf_crypt_key_new (); | |
883 | ck->key_id = vl_config->crypto_key_id; | |
884 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 885 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 886 | |
887 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
888 | } | |
889 | else if (vl_config->crypto_key_id != 0) | |
890 | { | |
891 | /* Delete a key */ | |
892 | ||
893 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
894 | vl_config->crypto_key_id) == NULL) | |
895 | { | |
896 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
897 | vl_config->crypto_key_id, VTY_NEWLINE); | |
898 | return CMD_WARNING; | |
899 | } | |
900 | ||
901 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
902 | ||
903 | } | |
904 | ||
905 | return CMD_SUCCESS; | |
906 | } | |
907 | ||
4dadc291 | 908 | static int |
718e3744 | 909 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
910 | struct ospf_vl_config_data *vl_config) | |
911 | { | |
c8cdf5c7 | 912 | struct interface *ifp = vl_data->vl_oi->ifp; |
718e3744 | 913 | /* Virtual Link data initialised to defaults, so only set |
914 | if a value given */ | |
915 | if (vl_config->hello_interval) | |
916 | { | |
917 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
918 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
919 | } | |
920 | ||
921 | if (vl_config->dead_interval) | |
922 | { | |
923 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
924 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
925 | } | |
926 | ||
927 | if (vl_config->retransmit_interval) | |
928 | { | |
929 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
930 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
931 | } | |
932 | ||
933 | if (vl_config->transmit_delay) | |
934 | { | |
935 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
936 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
937 | } | |
938 | ||
939 | return CMD_SUCCESS; | |
940 | } | |
941 | ||
942 | ||
718e3744 | 943 | /* The business end of all of the above */ |
4dadc291 | 944 | static int |
68980084 | 945 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 946 | { |
947 | struct ospf_vl_data *vl_data; | |
948 | int ret; | |
949 | ||
68980084 | 950 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 951 | if (!vl_data) |
952 | return CMD_WARNING; | |
953 | ||
954 | /* Process this one first as it can have a fatal result, which can | |
955 | only logically occur if the virtual link exists already | |
956 | Thus a command error does not result in a change to the | |
957 | running configuration such as unexpectedly altered timer | |
958 | values etc.*/ | |
959 | ret = ospf_vl_set_security (vl_data, vl_config); | |
960 | if (ret != CMD_SUCCESS) | |
961 | return ret; | |
962 | ||
963 | /* Set any time based parameters, these area already range checked */ | |
964 | ||
965 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
966 | if (ret != CMD_SUCCESS) | |
967 | return ret; | |
968 | ||
969 | return CMD_SUCCESS; | |
970 | ||
971 | } | |
972 | ||
973 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
974 | */ | |
975 | #define VLINK_HELPSTR_IPADDR \ | |
976 | "OSPF area parameters\n" \ | |
977 | "OSPF area ID in IP address format\n" \ | |
978 | "OSPF area ID as a decimal value\n" \ | |
979 | "Configure a virtual link\n" \ | |
980 | "Router ID of the remote ABR\n" | |
981 | ||
982 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
983 | "Enable authentication on this virtual link\n" \ | |
984 | "dummy string \n" | |
985 | ||
986 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
987 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
988 | "Use null authentication\n" \ | |
989 | "Use message-digest authentication\n" | |
990 | ||
991 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
992 | "Time between HELLO packets\n" \ | |
993 | "Time between retransmitting lost link state advertisements\n" \ | |
994 | "Link state transmit delay\n" \ | |
99a522c7 | 995 | "Interval time after which a neighbor is declared down\n" |
718e3744 | 996 | |
997 | #define VLINK_HELPSTR_TIME_PARAM \ | |
998 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ | |
999 | "Seconds\n" | |
1000 | ||
1001 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1002 | "Authentication password (key)\n" \ | |
1003 | "The OSPF password (key)" | |
1004 | ||
1005 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1006 | "Message digest authentication password (key)\n" \ | |
1007 | "dummy string \n" \ | |
1008 | "Key ID\n" \ | |
1009 | "Use MD5 algorithm\n" \ | |
1010 | "The OSPF password (key)" | |
1011 | ||
a2c62831 | 1012 | DEFUN (ospf_area_vlink, |
1013 | ospf_area_vlink_cmd, | |
22b27e95 | 1014 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", |
7a7be519 | 1015 | VLINK_HELPSTR_IPADDR |
1016 | "Enable authentication on this virtual link\n" \ | |
1017 | "Use null authentication\n" \ | |
1018 | "Use message-digest authentication\n" | |
1019 | "Message digest authentication password (key)\n" \ | |
1020 | "Key ID\n" \ | |
1021 | "Use MD5 algorithm\n" \ | |
1022 | "The OSPF password (key)") | |
718e3744 | 1023 | { |
cdc2d765 | 1024 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1025 | int idx_ipv4_number = 1; |
1026 | int idx_ipv4 = 3; | |
718e3744 | 1027 | struct ospf_vl_config_data vl_config; |
1028 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1029 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1030 | int i; | |
1031 | int ret; | |
7c8ff89e | 1032 | |
718e3744 | 1033 | ospf_vl_config_data_init(&vl_config, vty); |
1034 | ||
1035 | /* Read off first 2 parameters and check them */ | |
86573dcb QY |
1036 | ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, |
1037 | &vl_config.area_id_fmt); | |
718e3744 | 1038 | if (ret < 0) |
1039 | { | |
1040 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1041 | return CMD_WARNING; | |
1042 | } | |
1043 | ||
8d769265 | 1044 | ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); |
718e3744 | 1045 | if (! ret) |
1046 | { | |
1047 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1048 | VTY_NEWLINE); | |
1049 | return CMD_WARNING; | |
1050 | } | |
1051 | ||
7a7be519 | 1052 | if (argc <=4) |
718e3744 | 1053 | { |
1054 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1055 | ||
68980084 | 1056 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1057 | } |
1058 | ||
1059 | /* Deal with other parameters */ | |
7a7be519 | 1060 | for (i=5; i < argc; i++) |
718e3744 | 1061 | { |
1062 | ||
7a7be519 | 1063 | /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */ |
718e3744 | 1064 | |
7a7be519 | 1065 | switch (argv[i]->arg[0]) |
718e3744 | 1066 | { |
1067 | ||
1068 | case 'a': | |
7a7be519 | 1069 | if (i >5 || strncmp (argv[i]->arg, "authentication-", 15) == 0) |
718e3744 | 1070 | { |
1071 | /* authentication-key - this option can occur anywhere on | |
1072 | command line. At start of command line | |
1073 | must check for authentication option. */ | |
1074 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
7a7be519 | 1075 | strncpy (auth_key, argv[i+1]->text, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 1076 | vl_config.auth_key = auth_key; |
1077 | i++; | |
1078 | } | |
7a7be519 | 1079 | else if (strncmp (argv[i]->arg, "authentication", 14) == 0) |
718e3744 | 1080 | { |
1081 | /* authentication - this option can only occur at start | |
1082 | of command line */ | |
1083 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1084 | if ((i+1) < argc) | |
1085 | { | |
7a7be519 | 1086 | if (strncmp (argv[i+1]->arg, "n", 1) == 0) |
718e3744 | 1087 | { |
1088 | /* "authentication null" */ | |
1089 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1090 | i++; | |
1091 | } | |
7a7be519 | 1092 | else if (strncmp (argv[i+1]->arg, "m", 1) == 0 |
1093 | && strcmp (argv[i+1]->arg, "message-digest-") != 0) | |
718e3744 | 1094 | { |
1095 | /* "authentication message-digest" */ | |
1096 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1097 | i++; | |
1098 | } | |
1099 | } | |
1100 | } | |
1101 | break; | |
1102 | ||
1103 | case 'm': | |
1104 | /* message-digest-key */ | |
1105 | i++; | |
effe821e DS |
1106 | if (i < argc) |
1107 | { | |
1108 | vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); | |
1109 | if (vl_config.crypto_key_id < 0) | |
1110 | return CMD_WARNING; | |
1111 | i++; | |
1112 | if (i < argc) | |
1113 | { | |
1114 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1115 | strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); | |
1116 | vl_config.md5_key = md5_key; | |
1117 | } | |
1118 | } | |
1119 | else | |
1120 | vl_config.md5_key = NULL; | |
718e3744 | 1121 | break; |
7a7be519 | 1122 | } |
1123 | } | |
1124 | ||
1125 | ||
1126 | /* Action configuration */ | |
1127 | ||
1128 | return ospf_vl_set (ospf, &vl_config); | |
1129 | ||
1130 | } | |
1131 | ||
1132 | DEFUN (ospf_area_vlink_intervals, | |
1133 | ospf_area_vlink_intervals_cmd, | |
bc7d452f QY |
1134 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D" |
1135 | "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1136 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1137 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1138 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1139 | "]]]", | |
7a7be519 | 1140 | VLINK_HELPSTR_IPADDR |
1141 | VLINK_HELPSTR_TIME_PARAM | |
1142 | VLINK_HELPSTR_TIME_PARAM | |
1143 | VLINK_HELPSTR_TIME_PARAM | |
1144 | VLINK_HELPSTR_TIME_PARAM) | |
1145 | { | |
cdc2d765 | 1146 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 1147 | struct ospf_vl_config_data vl_config; |
bc7d452f | 1148 | int ret = 0; |
7a7be519 | 1149 | |
7a7be519 | 1150 | ospf_vl_config_data_init(&vl_config, vty); |
1151 | ||
bc7d452f QY |
1152 | char *area_id = argv[1]->arg; |
1153 | char *router_id = argv[3]->arg; | |
1154 | ||
86573dcb | 1155 | ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); |
7a7be519 | 1156 | if (ret < 0) |
1157 | { | |
1158 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1159 | return CMD_WARNING; | |
1160 | } | |
1161 | ||
bc7d452f | 1162 | ret = inet_aton (router_id, &vl_config.vl_peer); |
7a7be519 | 1163 | if (! ret) |
1164 | { | |
bc7d452f | 1165 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); |
7a7be519 | 1166 | return CMD_WARNING; |
1167 | } | |
bc7d452f | 1168 | for (unsigned int i = 0; i < 4; i++) |
7a7be519 | 1169 | { |
bc7d452f QY |
1170 | int idx = 0; |
1171 | if (argv_find (argv, argc, "hello-interval", &idx)) | |
1172 | vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10); | |
1173 | else if (argv_find (argv, argc, "retransmit-interval", &idx)) | |
1174 | vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10); | |
1175 | else if (argv_find (argv, argc, "transmit-delay", &idx)) | |
1176 | vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10); | |
1177 | else if (argv_find (argv, argc, "dead-interval", &idx)) | |
1178 | vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10); | |
7a7be519 | 1179 | } |
1180 | ||
718e3744 | 1181 | /* Action configuration */ |
68980084 | 1182 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1183 | } |
1184 | ||
a2c62831 | 1185 | DEFUN (no_ospf_area_vlink, |
1186 | no_ospf_area_vlink_cmd, | |
bc7d452f | 1187 | "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", |
718e3744 | 1188 | NO_STR |
7a7be519 | 1189 | VLINK_HELPSTR_IPADDR |
1190 | "Enable authentication on this virtual link\n" \ | |
1191 | "Use null authentication\n" \ | |
1192 | "Use message-digest authentication\n" | |
1193 | "Message digest authentication password (key)\n" \ | |
1194 | "Key ID\n" \ | |
1195 | "Use MD5 algorithm\n" \ | |
1196 | "The OSPF password (key)") | |
718e3744 | 1197 | { |
cdc2d765 | 1198 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1199 | int idx_ipv4_number = 2; |
1200 | int idx_ipv4 = 4; | |
718e3744 | 1201 | struct ospf_area *area; |
1202 | struct ospf_vl_config_data vl_config; | |
1203 | struct ospf_vl_data *vl_data = NULL; | |
1204 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1205 | int i; | |
1206 | int ret, format; | |
1207 | ||
1208 | ospf_vl_config_data_init(&vl_config, vty); | |
1209 | ||
86573dcb | 1210 | ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); |
718e3744 | 1211 | if (ret < 0) |
1212 | { | |
1213 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1214 | return CMD_WARNING; | |
1215 | } | |
1216 | ||
68980084 | 1217 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1218 | if (!area) |
1219 | { | |
1220 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); | |
1221 | return CMD_WARNING; | |
1222 | } | |
1223 | ||
8d769265 | 1224 | ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); |
718e3744 | 1225 | if (! ret) |
1226 | { | |
1227 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1228 | VTY_NEWLINE); | |
1229 | return CMD_WARNING; | |
1230 | } | |
1231 | ||
7a7be519 | 1232 | if (argc <=5) |
718e3744 | 1233 | { |
1234 | /* Basic VLink no command */ | |
1235 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1236 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1237 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1238 | |
68980084 | 1239 | ospf_area_check_free (ospf, vl_config.area_id); |
7a7be519 | 1240 | |
718e3744 | 1241 | return CMD_SUCCESS; |
1242 | } | |
1243 | ||
1244 | /* If we are down here, we are reseting parameters */ | |
1245 | ||
1246 | /* Deal with other parameters */ | |
effe821e | 1247 | for (i=6; i < argc; i++) |
718e3744 | 1248 | { |
718e3744 | 1249 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
1250 | ||
7a7be519 | 1251 | switch (argv[i]->arg[0]) |
718e3744 | 1252 | { |
1253 | ||
1254 | case 'a': | |
7a7be519 | 1255 | if (i > 2 || strncmp (argv[i]->text, "authentication-", 15) == 0) |
718e3744 | 1256 | { |
1257 | /* authentication-key - this option can occur anywhere on | |
1258 | command line. At start of command line | |
1259 | must check for authentication option. */ | |
1260 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1261 | vl_config.auth_key = auth_key; | |
1262 | } | |
7a7be519 | 1263 | else if (strncmp (argv[i]->text, "authentication", 14) == 0) |
718e3744 | 1264 | { |
1265 | /* authentication - this option can only occur at start | |
1266 | of command line */ | |
1267 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1268 | } | |
1269 | break; | |
1270 | ||
1271 | case 'm': | |
1272 | /* message-digest-key */ | |
1273 | /* Delete one key */ | |
1274 | i++; | |
36da0665 DS |
1275 | if (i < argc) |
1276 | { | |
b6f1faf0 | 1277 | vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); |
36da0665 DS |
1278 | if (vl_config.crypto_key_id < 0) |
1279 | return CMD_WARNING; | |
1280 | vl_config.md5_key = NULL; | |
1281 | } | |
1282 | else | |
718e3744 | 1283 | return CMD_WARNING; |
718e3744 | 1284 | break; |
1285 | ||
7a7be519 | 1286 | } |
1287 | } | |
1288 | ||
1289 | ||
1290 | /* Action configuration */ | |
1291 | ||
1292 | return ospf_vl_set (ospf, &vl_config); | |
1293 | } | |
1294 | ||
1295 | DEFUN (no_ospf_area_vlink_intervals, | |
1296 | no_ospf_area_vlink_intervals_cmd, | |
bc7d452f QY |
1297 | "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D" |
1298 | "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1299 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1300 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1301 | "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)" | |
1302 | "]]]", | |
3a2d747c | 1303 | NO_STR |
7a7be519 | 1304 | VLINK_HELPSTR_IPADDR |
1305 | VLINK_HELPSTR_TIME_PARAM | |
1306 | VLINK_HELPSTR_TIME_PARAM | |
1307 | VLINK_HELPSTR_TIME_PARAM | |
1308 | VLINK_HELPSTR_TIME_PARAM) | |
1309 | { | |
cdc2d765 | 1310 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 1311 | struct ospf_vl_config_data vl_config; |
bc7d452f | 1312 | int ret = 0; |
7a7be519 | 1313 | |
7a7be519 | 1314 | ospf_vl_config_data_init(&vl_config, vty); |
1315 | ||
bc7d452f QY |
1316 | char *area_id = argv[2]->arg; |
1317 | char *router_id = argv[4]->arg; | |
1318 | ||
86573dcb | 1319 | ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); |
7a7be519 | 1320 | if (ret < 0) |
1321 | { | |
1322 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); | |
1323 | return CMD_WARNING; | |
1324 | } | |
1325 | ||
bc7d452f | 1326 | ret = inet_aton (router_id, &vl_config.vl_peer); |
7a7be519 | 1327 | if (! ret) |
1328 | { | |
bc7d452f | 1329 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); |
7a7be519 | 1330 | return CMD_WARNING; |
1331 | } | |
1332 | ||
bc7d452f | 1333 | for (unsigned int i = 0; i < 4; i++) |
7a7be519 | 1334 | { |
bc7d452f QY |
1335 | int idx = 0; |
1336 | if (argv_find (argv, argc, "hello-interval", &idx)) | |
1337 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1338 | else if (argv_find (argv, argc, "retransmit-interval", &idx)) | |
1339 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1340 | else if (argv_find (argv, argc, "transmit-delay", &idx)) | |
1341 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1342 | else if (argv_find (argv, argc, "dead-interval", &idx)) | |
1343 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
718e3744 | 1344 | } |
1345 | ||
718e3744 | 1346 | /* Action configuration */ |
68980084 | 1347 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1348 | } |
1349 | ||
a2c62831 | 1350 | DEFUN (ospf_area_shortcut, |
1351 | ospf_area_shortcut_cmd, | |
6147e2c6 | 1352 | "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>", |
718e3744 | 1353 | "OSPF area parameters\n" |
1354 | "OSPF area ID in IP address format\n" | |
1355 | "OSPF area ID as a decimal value\n" | |
1356 | "Configure the area's shortcutting mode\n" | |
1357 | "Set default shortcutting behavior\n" | |
1358 | "Enable shortcutting through the area\n" | |
1359 | "Disable shortcutting through the area\n") | |
1360 | { | |
cdc2d765 | 1361 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1362 | int idx_ipv4_number = 1; |
1363 | int idx_enable_disable = 3; | |
718e3744 | 1364 | struct ospf_area *area; |
1365 | struct in_addr area_id; | |
1366 | int mode; | |
1367 | int format; | |
1368 | ||
8d769265 | 1369 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1370 | |
86573dcb QY |
1371 | area = ospf_area_get (ospf, area_id); |
1372 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1373 | |
8d769265 | 1374 | if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0) |
718e3744 | 1375 | mode = OSPF_SHORTCUT_DEFAULT; |
8d769265 | 1376 | else if (strncmp (argv[idx_enable_disable]->arg, "di", 2) == 0) |
718e3744 | 1377 | mode = OSPF_SHORTCUT_DISABLE; |
8d769265 | 1378 | else if (strncmp (argv[idx_enable_disable]->arg, "e", 1) == 0) |
718e3744 | 1379 | mode = OSPF_SHORTCUT_ENABLE; |
1380 | else | |
1381 | return CMD_WARNING; | |
1382 | ||
68980084 | 1383 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1384 | |
68980084 | 1385 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1386 | vty_out (vty, "Shortcut area setting will take effect " |
1387 | "only when the router is configured as Shortcut ABR%s", | |
1388 | VTY_NEWLINE); | |
1389 | ||
1390 | return CMD_SUCCESS; | |
1391 | } | |
1392 | ||
a2c62831 | 1393 | DEFUN (no_ospf_area_shortcut, |
1394 | no_ospf_area_shortcut_cmd, | |
6147e2c6 | 1395 | "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>", |
718e3744 | 1396 | NO_STR |
1397 | "OSPF area parameters\n" | |
1398 | "OSPF area ID in IP address format\n" | |
1399 | "OSPF area ID as a decimal value\n" | |
1400 | "Deconfigure the area's shortcutting mode\n" | |
1401 | "Deconfigure enabled shortcutting through the area\n" | |
1402 | "Deconfigure disabled shortcutting through the area\n") | |
1403 | { | |
cdc2d765 | 1404 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1405 | int idx_ipv4_number = 2; |
718e3744 | 1406 | struct ospf_area *area; |
1407 | struct in_addr area_id; | |
1408 | int format; | |
1409 | ||
8d769265 | 1410 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1411 | |
68980084 | 1412 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1413 | if (!area) |
1414 | return CMD_SUCCESS; | |
1415 | ||
68980084 | 1416 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1417 | |
1418 | return CMD_SUCCESS; | |
1419 | } | |
1420 | ||
6b0655a2 | 1421 | |
a2c62831 | 1422 | DEFUN (ospf_area_stub, |
1423 | ospf_area_stub_cmd, | |
6147e2c6 | 1424 | "area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1425 | "OSPF area parameters\n" |
1426 | "OSPF area ID in IP address format\n" | |
1427 | "OSPF area ID as a decimal value\n" | |
1428 | "Configure OSPF area as stub\n") | |
1429 | { | |
cdc2d765 | 1430 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1431 | int idx_ipv4_number = 1; |
718e3744 | 1432 | struct in_addr area_id; |
1433 | int ret, format; | |
1434 | ||
8d769265 | 1435 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1436 | |
1437 | ret = ospf_area_stub_set (ospf, area_id); | |
86573dcb | 1438 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 1439 | if (ret == 0) |
1440 | { | |
1441 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1442 | VTY_NEWLINE); | |
1443 | return CMD_WARNING; | |
1444 | } | |
1445 | ||
1446 | ospf_area_no_summary_unset (ospf, area_id); | |
1447 | ||
1448 | return CMD_SUCCESS; | |
1449 | } | |
1450 | ||
a2c62831 | 1451 | DEFUN (ospf_area_stub_no_summary, |
1452 | ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1453 | "area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1454 | "OSPF stub parameters\n" |
1455 | "OSPF area ID in IP address format\n" | |
1456 | "OSPF area ID as a decimal value\n" | |
1457 | "Configure OSPF area as stub\n" | |
1458 | "Do not inject inter-area routes into stub\n") | |
1459 | { | |
cdc2d765 | 1460 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1461 | int idx_ipv4_number = 1; |
718e3744 | 1462 | struct in_addr area_id; |
1463 | int ret, format; | |
1464 | ||
8d769265 | 1465 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1466 | |
1467 | ret = ospf_area_stub_set (ospf, area_id); | |
86573dcb | 1468 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 1469 | if (ret == 0) |
1470 | { | |
b0a053be | 1471 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
718e3744 | 1472 | VTY_NEWLINE); |
1473 | return CMD_WARNING; | |
1474 | } | |
1475 | ||
1476 | ospf_area_no_summary_set (ospf, area_id); | |
1477 | ||
1478 | return CMD_SUCCESS; | |
1479 | } | |
1480 | ||
a2c62831 | 1481 | DEFUN (no_ospf_area_stub, |
1482 | no_ospf_area_stub_cmd, | |
6147e2c6 | 1483 | "no area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1484 | NO_STR |
1485 | "OSPF area parameters\n" | |
1486 | "OSPF area ID in IP address format\n" | |
1487 | "OSPF area ID as a decimal value\n" | |
1488 | "Configure OSPF area as stub\n") | |
1489 | { | |
cdc2d765 | 1490 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1491 | int idx_ipv4_number = 2; |
718e3744 | 1492 | struct in_addr area_id; |
1493 | int format; | |
1494 | ||
8d769265 | 1495 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1496 | |
1497 | ospf_area_stub_unset (ospf, area_id); | |
1498 | ospf_area_no_summary_unset (ospf, area_id); | |
1499 | ||
1500 | return CMD_SUCCESS; | |
1501 | } | |
1502 | ||
a2c62831 | 1503 | DEFUN (no_ospf_area_stub_no_summary, |
1504 | no_ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1505 | "no area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1506 | NO_STR |
1507 | "OSPF area parameters\n" | |
1508 | "OSPF area ID in IP address format\n" | |
1509 | "OSPF area ID as a decimal value\n" | |
1510 | "Configure OSPF area as stub\n" | |
1511 | "Do not inject inter-area routes into area\n") | |
1512 | { | |
cdc2d765 | 1513 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1514 | int idx_ipv4_number = 2; |
718e3744 | 1515 | struct in_addr area_id; |
1516 | int format; | |
1517 | ||
8d769265 | 1518 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1519 | ospf_area_no_summary_unset (ospf, area_id); |
1520 | ||
1521 | return CMD_SUCCESS; | |
1522 | } | |
1523 | ||
4dadc291 | 1524 | static int |
7a7be519 | 1525 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, |
6c835671 | 1526 | int nosum) |
718e3744 | 1527 | { |
cdc2d765 | 1528 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 1529 | struct in_addr area_id; |
1530 | int ret, format; | |
1531 | ||
7a7be519 | 1532 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg); |
718e3744 | 1533 | |
1534 | ret = ospf_area_nssa_set (ospf, area_id); | |
86573dcb | 1535 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 1536 | if (ret == 0) |
1537 | { | |
1538 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1539 | VTY_NEWLINE); | |
1540 | return CMD_WARNING; | |
1541 | } | |
1542 | ||
313605cb | 1543 | if (argc > 3) |
718e3744 | 1544 | { |
7a7be519 | 1545 | if (strncmp (argv[3]->text, "translate-c", 11) == 0) |
b0a053be | 1546 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1547 | OSPF_NSSA_ROLE_CANDIDATE); |
7a7be519 | 1548 | else if (strncmp (argv[3]->text, "translate-n", 11) == 0) |
b0a053be | 1549 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1550 | OSPF_NSSA_ROLE_NEVER); |
7a7be519 | 1551 | else if (strncmp (argv[3]->text, "translate-a", 11) == 0) |
b0a053be | 1552 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1553 | OSPF_NSSA_ROLE_ALWAYS); |
1554 | } | |
b0a053be | 1555 | else |
1556 | { | |
1557 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1558 | OSPF_NSSA_ROLE_CANDIDATE); | |
1559 | } | |
718e3744 | 1560 | |
b0a053be | 1561 | if (nosum) |
718e3744 | 1562 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1563 | else |
1564 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1565 | |
b0a053be | 1566 | ospf_schedule_abr_task (ospf); |
1567 | ||
718e3744 | 1568 | return CMD_SUCCESS; |
1569 | } | |
1570 | ||
b0a053be | 1571 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1572 | ospf_area_nssa_translate_no_summary_cmd, |
6147e2c6 | 1573 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary", |
718e3744 | 1574 | "OSPF area parameters\n" |
1575 | "OSPF area ID in IP address format\n" | |
1576 | "OSPF area ID as a decimal value\n" | |
1577 | "Configure OSPF area as nssa\n" | |
1578 | "Configure NSSA-ABR for translate election (default)\n" | |
1579 | "Configure NSSA-ABR to never translate\n" | |
1580 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1581 | "Do not inject inter-area routes into nssa\n") |
1582 | { | |
1583 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1584 | } | |
718e3744 | 1585 | |
b0a053be | 1586 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1587 | ospf_area_nssa_translate_cmd, |
6147e2c6 | 1588 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>", |
718e3744 | 1589 | "OSPF area parameters\n" |
1590 | "OSPF area ID in IP address format\n" | |
1591 | "OSPF area ID as a decimal value\n" | |
1592 | "Configure OSPF area as nssa\n" | |
1593 | "Configure NSSA-ABR for translate election (default)\n" | |
1594 | "Configure NSSA-ABR to never translate\n" | |
1595 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1596 | { |
1597 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1598 | } | |
1599 | ||
1600 | DEFUN (ospf_area_nssa, | |
1601 | ospf_area_nssa_cmd, | |
6147e2c6 | 1602 | "area <A.B.C.D|(0-4294967295)> nssa", |
b0a053be | 1603 | "OSPF area parameters\n" |
1604 | "OSPF area ID in IP address format\n" | |
1605 | "OSPF area ID as a decimal value\n" | |
1606 | "Configure OSPF area as nssa\n") | |
1607 | { | |
1608 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1609 | } | |
718e3744 | 1610 | |
a2c62831 | 1611 | DEFUN (ospf_area_nssa_no_summary, |
1612 | ospf_area_nssa_no_summary_cmd, | |
6147e2c6 | 1613 | "area <A.B.C.D|(0-4294967295)> nssa no-summary", |
718e3744 | 1614 | "OSPF area parameters\n" |
1615 | "OSPF area ID in IP address format\n" | |
1616 | "OSPF area ID as a decimal value\n" | |
1617 | "Configure OSPF area as nssa\n" | |
1618 | "Do not inject inter-area routes into nssa\n") | |
1619 | { | |
b0a053be | 1620 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1621 | } |
1622 | ||
a2c62831 | 1623 | DEFUN (no_ospf_area_nssa, |
1624 | no_ospf_area_nssa_cmd, | |
7a7be519 | 1625 | "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]", |
718e3744 | 1626 | NO_STR |
1627 | "OSPF area parameters\n" | |
1628 | "OSPF area ID in IP address format\n" | |
1629 | "OSPF area ID as a decimal value\n" | |
7a7be519 | 1630 | "Configure OSPF area as nssa\n" |
1631 | "Configure NSSA-ABR for translate election (default)\n" | |
1632 | "Configure NSSA-ABR to never translate\n" | |
1633 | "Configure NSSA-ABR to always translate\n" | |
1634 | "Do not inject inter-area routes into nssa\n") | |
22b27e95 | 1635 | { |
cdc2d765 | 1636 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1637 | int idx_ipv4_number = 2; |
718e3744 | 1638 | struct in_addr area_id; |
1639 | int format; | |
1640 | ||
8d769265 | 1641 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1642 | |
1643 | ospf_area_nssa_unset (ospf, area_id); | |
1644 | ospf_area_no_summary_unset (ospf, area_id); | |
1645 | ||
b0a053be | 1646 | ospf_schedule_abr_task (ospf); |
1647 | ||
718e3744 | 1648 | return CMD_SUCCESS; |
1649 | } | |
1650 | ||
718e3744 | 1651 | |
a2c62831 | 1652 | DEFUN (ospf_area_default_cost, |
1653 | ospf_area_default_cost_cmd, | |
6147e2c6 | 1654 | "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1655 | "OSPF area parameters\n" |
1656 | "OSPF area ID in IP address format\n" | |
1657 | "OSPF area ID as a decimal value\n" | |
1658 | "Set the summary-default cost of a NSSA or stub area\n" | |
1659 | "Stub's advertised default summary cost\n") | |
1660 | { | |
cdc2d765 | 1661 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1662 | int idx_ipv4_number = 1; |
1663 | int idx_number = 3; | |
718e3744 | 1664 | struct ospf_area *area; |
1665 | struct in_addr area_id; | |
1666 | u_int32_t cost; | |
1667 | int format; | |
ba682537 | 1668 | struct prefix_ipv4 p; |
718e3744 | 1669 | |
8d769265 DW |
1670 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); |
1671 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[idx_number]->arg, 0, 16777215); | |
718e3744 | 1672 | |
86573dcb QY |
1673 | area = ospf_area_get (ospf, area_id); |
1674 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1675 | |
1676 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1677 | { | |
1678 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1679 | return CMD_WARNING; | |
1680 | } | |
1681 | ||
1682 | area->default_cost = cost; | |
1683 | ||
ba682537 | 1684 | p.family = AF_INET; |
1685 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1686 | p.prefixlen = 0; | |
1687 | if (IS_DEBUG_OSPF_EVENT) | |
1688 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1689 | "announcing 0.0.0.0/0 to area %s", | |
1690 | inet_ntoa (area->area_id)); | |
1691 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1692 | ||
718e3744 | 1693 | return CMD_SUCCESS; |
1694 | } | |
1695 | ||
a2c62831 | 1696 | DEFUN (no_ospf_area_default_cost, |
1697 | no_ospf_area_default_cost_cmd, | |
6147e2c6 | 1698 | "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1699 | NO_STR |
1700 | "OSPF area parameters\n" | |
1701 | "OSPF area ID in IP address format\n" | |
1702 | "OSPF area ID as a decimal value\n" | |
1703 | "Set the summary-default cost of a NSSA or stub area\n" | |
1704 | "Stub's advertised default summary cost\n") | |
1705 | { | |
cdc2d765 | 1706 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1707 | int idx_ipv4_number = 2; |
1708 | int idx_number = 4; | |
718e3744 | 1709 | struct ospf_area *area; |
1710 | struct in_addr area_id; | |
718e3744 | 1711 | int format; |
ba682537 | 1712 | struct prefix_ipv4 p; |
718e3744 | 1713 | |
8d769265 DW |
1714 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); |
1715 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[idx_number]->arg, 0, OSPF_LS_INFINITY); | |
718e3744 | 1716 | |
68980084 | 1717 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1718 | if (area == NULL) |
1719 | return CMD_SUCCESS; | |
1720 | ||
1721 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1722 | { | |
1723 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); | |
1724 | return CMD_WARNING; | |
1725 | } | |
1726 | ||
1727 | area->default_cost = 1; | |
1728 | ||
ba682537 | 1729 | p.family = AF_INET; |
1730 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1731 | p.prefixlen = 0; | |
1732 | if (IS_DEBUG_OSPF_EVENT) | |
1733 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1734 | "announcing 0.0.0.0/0 to area %s", | |
1735 | inet_ntoa (area->area_id)); | |
1736 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1737 | ||
1738 | ||
68980084 | 1739 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1740 | |
1741 | return CMD_SUCCESS; | |
1742 | } | |
1743 | ||
a2c62831 | 1744 | DEFUN (ospf_area_export_list, |
1745 | ospf_area_export_list_cmd, | |
6147e2c6 | 1746 | "area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1747 | "OSPF area parameters\n" |
1748 | "OSPF area ID in IP address format\n" | |
1749 | "OSPF area ID as a decimal value\n" | |
1750 | "Set the filter for networks announced to other areas\n" | |
1751 | "Name of the access-list\n") | |
1752 | { | |
cdc2d765 | 1753 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1754 | int idx_ipv4_number = 1; |
718e3744 | 1755 | struct ospf_area *area; |
1756 | struct in_addr area_id; | |
1757 | int format; | |
1758 | ||
8d769265 | 1759 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1760 | |
86573dcb QY |
1761 | area = ospf_area_get (ospf, area_id); |
1762 | ospf_area_display_format_set (ospf, area, format); | |
7a7be519 | 1763 | ospf_area_export_list_set (ospf, area, argv[3]->arg); |
718e3744 | 1764 | |
1765 | return CMD_SUCCESS; | |
1766 | } | |
1767 | ||
a2c62831 | 1768 | DEFUN (no_ospf_area_export_list, |
1769 | no_ospf_area_export_list_cmd, | |
6147e2c6 | 1770 | "no area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1771 | NO_STR |
1772 | "OSPF area parameters\n" | |
1773 | "OSPF area ID in IP address format\n" | |
1774 | "OSPF area ID as a decimal value\n" | |
1775 | "Unset the filter for networks announced to other areas\n" | |
1776 | "Name of the access-list\n") | |
1777 | { | |
cdc2d765 | 1778 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1779 | int idx_ipv4_number = 2; |
718e3744 | 1780 | struct ospf_area *area; |
1781 | struct in_addr area_id; | |
1782 | int format; | |
1783 | ||
8d769265 | 1784 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1785 | |
68980084 | 1786 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1787 | if (area == NULL) |
1788 | return CMD_SUCCESS; | |
1789 | ||
68980084 | 1790 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 1791 | |
1792 | return CMD_SUCCESS; | |
1793 | } | |
1794 | ||
1795 | ||
a2c62831 | 1796 | DEFUN (ospf_area_import_list, |
1797 | ospf_area_import_list_cmd, | |
6147e2c6 | 1798 | "area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1799 | "OSPF area parameters\n" |
1800 | "OSPF area ID in IP address format\n" | |
1801 | "OSPF area ID as a decimal value\n" | |
1802 | "Set the filter for networks from other areas announced to the specified one\n" | |
1803 | "Name of the access-list\n") | |
1804 | { | |
cdc2d765 | 1805 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1806 | int idx_ipv4_number = 1; |
718e3744 | 1807 | struct ospf_area *area; |
1808 | struct in_addr area_id; | |
1809 | int format; | |
1810 | ||
8d769265 | 1811 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1812 | |
86573dcb QY |
1813 | area = ospf_area_get (ospf, area_id); |
1814 | ospf_area_display_format_set (ospf, area, format); | |
7a7be519 | 1815 | ospf_area_import_list_set (ospf, area, argv[3]->arg); |
718e3744 | 1816 | |
1817 | return CMD_SUCCESS; | |
1818 | } | |
1819 | ||
a2c62831 | 1820 | DEFUN (no_ospf_area_import_list, |
1821 | no_ospf_area_import_list_cmd, | |
6147e2c6 | 1822 | "no area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1823 | NO_STR |
1824 | "OSPF area parameters\n" | |
1825 | "OSPF area ID in IP address format\n" | |
1826 | "OSPF area ID as a decimal value\n" | |
1827 | "Unset the filter for networks announced to other areas\n" | |
1828 | "Name of the access-list\n") | |
1829 | { | |
cdc2d765 | 1830 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1831 | int idx_ipv4_number = 2; |
718e3744 | 1832 | struct ospf_area *area; |
1833 | struct in_addr area_id; | |
1834 | int format; | |
1835 | ||
8d769265 | 1836 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1837 | |
68980084 | 1838 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1839 | if (area == NULL) |
1840 | return CMD_SUCCESS; | |
1841 | ||
68980084 | 1842 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 1843 | |
1844 | return CMD_SUCCESS; | |
1845 | } | |
1846 | ||
a2c62831 | 1847 | DEFUN (ospf_area_filter_list, |
1848 | ospf_area_filter_list_cmd, | |
6147e2c6 | 1849 | "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1850 | "OSPF area parameters\n" |
1851 | "OSPF area ID in IP address format\n" | |
1852 | "OSPF area ID as a decimal value\n" | |
1853 | "Filter networks between OSPF areas\n" | |
1854 | "Filter prefixes between OSPF areas\n" | |
1855 | "Name of an IP prefix-list\n" | |
1856 | "Filter networks sent to this area\n" | |
1857 | "Filter networks sent from this area\n") | |
1858 | { | |
cdc2d765 | 1859 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1860 | int idx_ipv4_number = 1; |
1861 | int idx_word = 4; | |
1862 | int idx_in_out = 5; | |
718e3744 | 1863 | struct ospf_area *area; |
1864 | struct in_addr area_id; | |
1865 | struct prefix_list *plist; | |
1866 | int format; | |
1867 | ||
8d769265 | 1868 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1869 | |
86573dcb QY |
1870 | area = ospf_area_get (ospf, area_id); |
1871 | ospf_area_display_format_set (ospf, area, format); | |
8d769265 DW |
1872 | plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg); |
1873 | if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) | |
718e3744 | 1874 | { |
1875 | PREFIX_LIST_IN (area) = plist; | |
1876 | if (PREFIX_NAME_IN (area)) | |
1877 | free (PREFIX_NAME_IN (area)); | |
1878 | ||
8d769265 | 1879 | PREFIX_NAME_IN (area) = strdup (argv[idx_word]->arg); |
68980084 | 1880 | ospf_schedule_abr_task (ospf); |
718e3744 | 1881 | } |
1882 | else | |
1883 | { | |
1884 | PREFIX_LIST_OUT (area) = plist; | |
1885 | if (PREFIX_NAME_OUT (area)) | |
1886 | free (PREFIX_NAME_OUT (area)); | |
1887 | ||
8d769265 | 1888 | PREFIX_NAME_OUT (area) = strdup (argv[idx_word]->arg); |
68980084 | 1889 | ospf_schedule_abr_task (ospf); |
718e3744 | 1890 | } |
1891 | ||
1892 | return CMD_SUCCESS; | |
1893 | } | |
1894 | ||
a2c62831 | 1895 | DEFUN (no_ospf_area_filter_list, |
1896 | no_ospf_area_filter_list_cmd, | |
6147e2c6 | 1897 | "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1898 | NO_STR |
1899 | "OSPF area parameters\n" | |
1900 | "OSPF area ID in IP address format\n" | |
1901 | "OSPF area ID as a decimal value\n" | |
1902 | "Filter networks between OSPF areas\n" | |
1903 | "Filter prefixes between OSPF areas\n" | |
1904 | "Name of an IP prefix-list\n" | |
1905 | "Filter networks sent to this area\n" | |
1906 | "Filter networks sent from this area\n") | |
1907 | { | |
cdc2d765 | 1908 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1909 | int idx_ipv4_number = 2; |
1910 | int idx_word = 5; | |
1911 | int idx_in_out = 6; | |
718e3744 | 1912 | struct ospf_area *area; |
1913 | struct in_addr area_id; | |
718e3744 | 1914 | int format; |
1915 | ||
8d769265 | 1916 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1917 | |
1a8ec2b9 PJ |
1918 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
1919 | return CMD_SUCCESS; | |
1920 | ||
8d769265 | 1921 | if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) |
718e3744 | 1922 | { |
1923 | if (PREFIX_NAME_IN (area)) | |
8d769265 | 1924 | if (strcmp (PREFIX_NAME_IN (area), argv[idx_word]->arg) != 0) |
718e3744 | 1925 | return CMD_SUCCESS; |
1926 | ||
1927 | PREFIX_LIST_IN (area) = NULL; | |
1928 | if (PREFIX_NAME_IN (area)) | |
1929 | free (PREFIX_NAME_IN (area)); | |
1930 | ||
1931 | PREFIX_NAME_IN (area) = NULL; | |
1932 | ||
68980084 | 1933 | ospf_schedule_abr_task (ospf); |
718e3744 | 1934 | } |
1935 | else | |
1936 | { | |
1937 | if (PREFIX_NAME_OUT (area)) | |
8d769265 | 1938 | if (strcmp (PREFIX_NAME_OUT (area), argv[idx_word]->arg) != 0) |
718e3744 | 1939 | return CMD_SUCCESS; |
1940 | ||
1941 | PREFIX_LIST_OUT (area) = NULL; | |
1942 | if (PREFIX_NAME_OUT (area)) | |
1943 | free (PREFIX_NAME_OUT (area)); | |
1944 | ||
1945 | PREFIX_NAME_OUT (area) = NULL; | |
1946 | ||
68980084 | 1947 | ospf_schedule_abr_task (ospf); |
718e3744 | 1948 | } |
1949 | ||
1950 | return CMD_SUCCESS; | |
1951 | } | |
1952 | ||
6b0655a2 | 1953 | |
a2c62831 | 1954 | DEFUN (ospf_area_authentication_message_digest, |
1955 | ospf_area_authentication_message_digest_cmd, | |
6147e2c6 | 1956 | "area <A.B.C.D|(0-4294967295)> authentication message-digest", |
718e3744 | 1957 | "OSPF area parameters\n" |
2b00515a CF |
1958 | "OSPF area ID in IP address format\n" |
1959 | "OSPF area ID as a decimal value\n" | |
718e3744 | 1960 | "Enable authentication\n" |
1961 | "Use message-digest authentication\n") | |
1962 | { | |
cdc2d765 | 1963 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1964 | int idx_ipv4_number = 1; |
718e3744 | 1965 | struct ospf_area *area; |
1966 | struct in_addr area_id; | |
1967 | int format; | |
1968 | ||
8d769265 | 1969 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1970 | |
86573dcb QY |
1971 | area = ospf_area_get (ospf, area_id); |
1972 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1973 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
1974 | ||
1975 | return CMD_SUCCESS; | |
1976 | } | |
1977 | ||
a2c62831 | 1978 | DEFUN (ospf_area_authentication, |
1979 | ospf_area_authentication_cmd, | |
6147e2c6 | 1980 | "area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 1981 | "OSPF area parameters\n" |
1982 | "OSPF area ID in IP address format\n" | |
1983 | "OSPF area ID as a decimal value\n" | |
1984 | "Enable authentication\n") | |
1985 | { | |
cdc2d765 | 1986 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1987 | int idx_ipv4_number = 1; |
718e3744 | 1988 | struct ospf_area *area; |
1989 | struct in_addr area_id; | |
1990 | int format; | |
1991 | ||
8d769265 | 1992 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1993 | |
86573dcb QY |
1994 | area = ospf_area_get (ospf, area_id); |
1995 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1996 | area->auth_type = OSPF_AUTH_SIMPLE; |
1997 | ||
1998 | return CMD_SUCCESS; | |
1999 | } | |
2000 | ||
a2c62831 | 2001 | DEFUN (no_ospf_area_authentication, |
2002 | no_ospf_area_authentication_cmd, | |
6147e2c6 | 2003 | "no area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 2004 | NO_STR |
2005 | "OSPF area parameters\n" | |
2006 | "OSPF area ID in IP address format\n" | |
2007 | "OSPF area ID as a decimal value\n" | |
2008 | "Enable authentication\n") | |
2009 | { | |
cdc2d765 | 2010 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2011 | int idx_ipv4_number = 2; |
718e3744 | 2012 | struct ospf_area *area; |
2013 | struct in_addr area_id; | |
2014 | int format; | |
2015 | ||
8d769265 | 2016 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 2017 | |
68980084 | 2018 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2019 | if (area == NULL) |
2020 | return CMD_SUCCESS; | |
2021 | ||
2022 | area->auth_type = OSPF_AUTH_NULL; | |
2023 | ||
68980084 | 2024 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2025 | |
2026 | return CMD_SUCCESS; | |
2027 | } | |
2028 | ||
6b0655a2 | 2029 | |
718e3744 | 2030 | DEFUN (ospf_abr_type, |
2031 | ospf_abr_type_cmd, | |
6147e2c6 | 2032 | "ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2033 | "OSPF specific commands\n" |
2034 | "Set OSPF ABR type\n" | |
2035 | "Alternative ABR, cisco implementation\n" | |
2036 | "Alternative ABR, IBM implementation\n" | |
2037 | "Shortcut ABR\n" | |
2038 | "Standard behavior (RFC2328)\n") | |
2039 | { | |
cdc2d765 | 2040 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2041 | int idx_vendor = 2; |
718e3744 | 2042 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2043 | ||
8d769265 | 2044 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) |
718e3744 | 2045 | abr_type = OSPF_ABR_CISCO; |
8d769265 | 2046 | else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) |
718e3744 | 2047 | abr_type = OSPF_ABR_IBM; |
8d769265 | 2048 | else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) |
718e3744 | 2049 | abr_type = OSPF_ABR_SHORTCUT; |
8d769265 | 2050 | else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) |
718e3744 | 2051 | abr_type = OSPF_ABR_STAND; |
2052 | else | |
2053 | return CMD_WARNING; | |
2054 | ||
2055 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2056 | if (ospf->abr_type != abr_type) |
718e3744 | 2057 | { |
68980084 | 2058 | ospf->abr_type = abr_type; |
2059 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2060 | } |
2061 | ||
2062 | return CMD_SUCCESS; | |
2063 | } | |
2064 | ||
2065 | DEFUN (no_ospf_abr_type, | |
2066 | no_ospf_abr_type_cmd, | |
6147e2c6 | 2067 | "no ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2068 | NO_STR |
2069 | "OSPF specific commands\n" | |
2070 | "Set OSPF ABR type\n" | |
2071 | "Alternative ABR, cisco implementation\n" | |
2072 | "Alternative ABR, IBM implementation\n" | |
3a2d747c QY |
2073 | "Shortcut ABR\n" |
2074 | "Standard ABR\n") | |
718e3744 | 2075 | { |
cdc2d765 | 2076 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2077 | int idx_vendor = 3; |
718e3744 | 2078 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2079 | ||
8d769265 | 2080 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) |
718e3744 | 2081 | abr_type = OSPF_ABR_CISCO; |
8d769265 | 2082 | else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) |
718e3744 | 2083 | abr_type = OSPF_ABR_IBM; |
8d769265 | 2084 | else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) |
718e3744 | 2085 | abr_type = OSPF_ABR_SHORTCUT; |
8d769265 | 2086 | else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) |
04d23314 | 2087 | abr_type = OSPF_ABR_STAND; |
718e3744 | 2088 | else |
2089 | return CMD_WARNING; | |
2090 | ||
2091 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2092 | if (ospf->abr_type == abr_type) |
718e3744 | 2093 | { |
d57834f6 | 2094 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2095 | ospf_schedule_abr_task (ospf); |
718e3744 | 2096 | } |
2097 | ||
2098 | return CMD_SUCCESS; | |
2099 | } | |
2100 | ||
d7e60dd7 AS |
2101 | DEFUN (ospf_log_adjacency_changes, |
2102 | ospf_log_adjacency_changes_cmd, | |
2103 | "log-adjacency-changes", | |
2104 | "Log changes in adjacency state\n") | |
2105 | { | |
cdc2d765 | 2106 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2107 | |
2108 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
692c7954 | 2109 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
d7e60dd7 AS |
2110 | return CMD_SUCCESS; |
2111 | } | |
2112 | ||
2113 | DEFUN (ospf_log_adjacency_changes_detail, | |
2114 | ospf_log_adjacency_changes_detail_cmd, | |
2115 | "log-adjacency-changes detail", | |
2116 | "Log changes in adjacency state\n" | |
2117 | "Log all state changes\n") | |
2118 | { | |
cdc2d765 | 2119 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2120 | |
2121 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2122 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2123 | return CMD_SUCCESS; | |
2124 | } | |
2125 | ||
2126 | DEFUN (no_ospf_log_adjacency_changes, | |
2127 | no_ospf_log_adjacency_changes_cmd, | |
2128 | "no log-adjacency-changes", | |
2129 | NO_STR | |
2130 | "Log changes in adjacency state\n") | |
2131 | { | |
cdc2d765 | 2132 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2133 | |
2134 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2135 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2136 | return CMD_SUCCESS; | |
2137 | } | |
2138 | ||
2139 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2140 | no_ospf_log_adjacency_changes_detail_cmd, | |
2141 | "no log-adjacency-changes detail", | |
2142 | NO_STR | |
2143 | "Log changes in adjacency state\n" | |
2144 | "Log all state changes\n") | |
2145 | { | |
cdc2d765 | 2146 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2147 | |
2148 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2149 | return CMD_SUCCESS; | |
2150 | } | |
2151 | ||
718e3744 | 2152 | DEFUN (ospf_compatible_rfc1583, |
2153 | ospf_compatible_rfc1583_cmd, | |
2154 | "compatible rfc1583", | |
2155 | "OSPF compatibility list\n" | |
2156 | "compatible with RFC 1583\n") | |
2157 | { | |
cdc2d765 | 2158 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 2159 | |
2160 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
2161 | { | |
2162 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2163 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2164 | } |
2165 | return CMD_SUCCESS; | |
2166 | } | |
2167 | ||
2168 | DEFUN (no_ospf_compatible_rfc1583, | |
2169 | no_ospf_compatible_rfc1583_cmd, | |
2170 | "no compatible rfc1583", | |
2171 | NO_STR | |
2172 | "OSPF compatibility list\n" | |
2173 | "compatible with RFC 1583\n") | |
2174 | { | |
cdc2d765 | 2175 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 2176 | |
2177 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
2178 | { | |
2179 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2180 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2181 | } |
2182 | return CMD_SUCCESS; | |
2183 | } | |
2184 | ||
7a7be519 | 2185 | ALIAS (ospf_compatible_rfc1583, |
2186 | ospf_rfc1583_flag_cmd, | |
2187 | "ospf rfc1583compatibility", | |
2188 | "OSPF specific commands\n" | |
2189 | "Enable the RFC1583Compatibility flag\n") | |
718e3744 | 2190 | |
7a7be519 | 2191 | ALIAS (no_ospf_compatible_rfc1583, |
2192 | no_ospf_rfc1583_flag_cmd, | |
2193 | "no ospf rfc1583compatibility", | |
2194 | NO_STR | |
2195 | "OSPF specific commands\n" | |
2196 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2197 | |
d24f6e2a | 2198 | static int |
2199 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2200 | unsigned int hold, | |
2201 | unsigned int max) | |
2202 | { | |
cdc2d765 | 2203 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7c8ff89e | 2204 | |
d24f6e2a | 2205 | ospf->spf_delay = delay; |
2206 | ospf->spf_holdtime = hold; | |
2207 | ospf->spf_max_holdtime = max; | |
2208 | ||
2209 | return CMD_SUCCESS; | |
2210 | } | |
718e3744 | 2211 | |
ac7424f9 MR |
2212 | DEFUN (ospf_timers_min_ls_interval, |
2213 | ospf_timers_min_ls_interval_cmd, | |
6147e2c6 | 2214 | "timers throttle lsa all (0-5000)", |
ac7424f9 MR |
2215 | "Adjust routing timers\n" |
2216 | "Throttling adaptive timer\n" | |
2217 | "LSA delay between transmissions\n" | |
813d4307 | 2218 | "All LSA types\n" |
ac7424f9 MR |
2219 | "Delay (msec) between sending LSAs\n") |
2220 | { | |
cdc2d765 | 2221 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2222 | int idx_number = 4; |
ac7424f9 MR |
2223 | unsigned int interval; |
2224 | ||
2225 | if (argc != 1) | |
2226 | { | |
2227 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2228 | return CMD_WARNING; | |
2229 | } | |
2230 | ||
8d769265 | 2231 | VTY_GET_INTEGER ("LSA interval", interval, argv[idx_number]->arg); |
ac7424f9 MR |
2232 | |
2233 | ospf->min_ls_interval = interval; | |
2234 | ||
2235 | return CMD_SUCCESS; | |
2236 | } | |
2237 | ||
2238 | DEFUN (no_ospf_timers_min_ls_interval, | |
2239 | no_ospf_timers_min_ls_interval_cmd, | |
7a7be519 | 2240 | "no timers throttle lsa all [(0-5000)]", |
ac7424f9 MR |
2241 | NO_STR |
2242 | "Adjust routing timers\n" | |
2243 | "Throttling adaptive timer\n" | |
813d4307 | 2244 | "LSA delay between transmissions\n" |
7a7be519 | 2245 | "All LSA types\n" |
2246 | "Delay (msec) between sending LSAs\n") | |
ac7424f9 | 2247 | { |
cdc2d765 | 2248 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
ac7424f9 MR |
2249 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; |
2250 | ||
2251 | return CMD_SUCCESS; | |
2252 | } | |
2253 | ||
813d4307 | 2254 | |
ac7424f9 MR |
2255 | DEFUN (ospf_timers_min_ls_arrival, |
2256 | ospf_timers_min_ls_arrival_cmd, | |
6147e2c6 | 2257 | "timers lsa arrival (0-1000)", |
ac7424f9 MR |
2258 | "Adjust routing timers\n" |
2259 | "Throttling link state advertisement delays\n" | |
2260 | "OSPF minimum arrival interval delay\n" | |
2261 | "Delay (msec) between accepted LSAs\n") | |
2262 | { | |
cdc2d765 | 2263 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2264 | int idx_number = 3; |
ac7424f9 MR |
2265 | unsigned int arrival; |
2266 | ||
2267 | if (argc != 1) | |
2268 | { | |
2269 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2270 | return CMD_WARNING; | |
2271 | } | |
2272 | ||
8d769265 | 2273 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[idx_number]->arg, 0, 1000); |
ac7424f9 MR |
2274 | |
2275 | ospf->min_ls_arrival = arrival; | |
2276 | ||
2277 | return CMD_SUCCESS; | |
2278 | } | |
2279 | ||
2280 | DEFUN (no_ospf_timers_min_ls_arrival, | |
2281 | no_ospf_timers_min_ls_arrival_cmd, | |
7a7be519 | 2282 | "no timers lsa arrival [(0-1000)]", |
ac7424f9 MR |
2283 | NO_STR |
2284 | "Adjust routing timers\n" | |
2285 | "Throttling link state advertisement delays\n" | |
7a7be519 | 2286 | "OSPF minimum arrival interval delay\n" |
2287 | "Delay (msec) between accepted LSAs\n") | |
ac7424f9 | 2288 | { |
cdc2d765 | 2289 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d8f70b86 | 2290 | |
ac7424f9 MR |
2291 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
2292 | ||
2293 | return CMD_SUCCESS; | |
2294 | } | |
2295 | ||
813d4307 | 2296 | |
d24f6e2a | 2297 | DEFUN (ospf_timers_throttle_spf, |
2298 | ospf_timers_throttle_spf_cmd, | |
6147e2c6 | 2299 | "timers throttle spf (0-600000) (0-600000) (0-600000)", |
d24f6e2a | 2300 | "Adjust routing timers\n" |
2301 | "Throttling adaptive timer\n" | |
2302 | "OSPF SPF timers\n" | |
2303 | "Delay (msec) from first change received till SPF calculation\n" | |
2304 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2305 | "Maximum hold time (msec)\n") | |
2306 | { | |
8d769265 DW |
2307 | int idx_number = 3; |
2308 | int idx_number_2 = 4; | |
2309 | int idx_number_3 = 5; | |
d24f6e2a | 2310 | unsigned int delay, hold, max; |
2311 | ||
2312 | if (argc != 3) | |
2313 | { | |
2314 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); | |
2315 | return CMD_WARNING; | |
2316 | } | |
2317 | ||
8d769265 DW |
2318 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000); |
2319 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000); | |
2320 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000); | |
d24f6e2a | 2321 | |
2322 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2323 | } | |
2324 | ||
d24f6e2a | 2325 | DEFUN (no_ospf_timers_throttle_spf, |
2326 | no_ospf_timers_throttle_spf_cmd, | |
7a7be519 | 2327 | "no timers throttle spf [(0-600000)(0-600000)(0-600000)]", |
718e3744 | 2328 | NO_STR |
2329 | "Adjust routing timers\n" | |
d24f6e2a | 2330 | "Throttling adaptive timer\n" |
7a7be519 | 2331 | "OSPF SPF timers\n" |
2332 | "Delay (msec) from first change received till SPF calculation\n" | |
2333 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2334 | "Maximum hold time (msec)\n") | |
22b27e95 | 2335 | { |
d24f6e2a | 2336 | return ospf_timers_spf_set (vty, |
2337 | OSPF_SPF_DELAY_DEFAULT, | |
2338 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2339 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2340 | } |
2341 | ||
b4a039bf | 2342 | |
b6927875 DS |
2343 | DEFUN (ospf_timers_lsa, |
2344 | ospf_timers_lsa_cmd, | |
6147e2c6 | 2345 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
2346 | "Adjust routing timers\n" |
2347 | "OSPF LSA timers\n" | |
2348 | "Minimum delay in receiving new version of a LSA\n" | |
2349 | "Delay in milliseconds\n") | |
2350 | { | |
cdc2d765 | 2351 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2352 | int idx_number = 3; |
b6927875 | 2353 | unsigned int minarrival; |
b6927875 | 2354 | |
b6927875 DS |
2355 | if (argc != 1) |
2356 | { | |
2357 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); | |
2358 | return CMD_WARNING; | |
2359 | } | |
2360 | ||
8d769265 | 2361 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg); |
b6927875 | 2362 | |
ac7424f9 | 2363 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2364 | |
2365 | return CMD_SUCCESS; | |
2366 | } | |
2367 | ||
2368 | DEFUN (no_ospf_timers_lsa, | |
2369 | no_ospf_timers_lsa_cmd, | |
7a7be519 | 2370 | "no timers lsa min-arrival [(0-600000)]", |
b6927875 DS |
2371 | NO_STR |
2372 | "Adjust routing timers\n" | |
2373 | "OSPF LSA timers\n" | |
7a7be519 | 2374 | "Minimum delay in receiving new version of a LSA\n" |
2375 | "Delay in milliseconds\n") | |
b6927875 | 2376 | { |
cdc2d765 | 2377 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
b6927875 | 2378 | unsigned int minarrival; |
b6927875 | 2379 | |
7a7be519 | 2380 | if (argc > 4) |
b6927875 | 2381 | { |
7a7be519 | 2382 | VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[4]->arg); |
b6927875 | 2383 | |
ac7424f9 | 2384 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2385 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2386 | return CMD_SUCCESS; | |
2387 | } | |
2388 | ||
ac7424f9 | 2389 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2390 | |
2391 | return CMD_SUCCESS; | |
2392 | } | |
2393 | ||
a2c62831 | 2394 | DEFUN (ospf_neighbor, |
2395 | ospf_neighbor_cmd, | |
7a7be519 | 2396 | "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]", |
718e3744 | 2397 | NEIGHBOR_STR |
7a7be519 | 2398 | "Neighbor IP address\n" |
2399 | "Neighbor Priority\n" | |
2400 | "Priority\n" | |
2401 | "Dead Neighbor Polling interval\n" | |
2402 | "Seconds\n") | |
718e3744 | 2403 | { |
cdc2d765 | 2404 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2405 | int idx_ipv4 = 1; |
7a7be519 | 2406 | int idx_pri = 3; |
2407 | int idx_poll = 5; | |
718e3744 | 2408 | struct in_addr nbr_addr; |
eb1ce605 | 2409 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2410 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2411 | |
8d769265 | 2412 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2413 | |
718e3744 | 2414 | if (argc > 2) |
7a7be519 | 2415 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); |
2416 | ||
2417 | if (argc > 4) | |
2418 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); | |
718e3744 | 2419 | |
2420 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
7a7be519 | 2421 | |
718e3744 | 2422 | if (argc > 2) |
7a7be519 | 2423 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
2424 | ||
2425 | if (argc > 4) | |
1a61ad10 | 2426 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2427 | |
2428 | return CMD_SUCCESS; | |
2429 | } | |
2430 | ||
a2c62831 | 2431 | DEFUN (ospf_neighbor_poll_interval, |
2432 | ospf_neighbor_poll_interval_cmd, | |
7a7be519 | 2433 | "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", |
718e3744 | 2434 | NEIGHBOR_STR |
2435 | "Neighbor IP address\n" | |
2436 | "Dead Neighbor Polling interval\n" | |
7a7be519 | 2437 | "Seconds\n" |
2438 | "OSPF priority of non-broadcast neighbor\n" | |
2439 | "Priority\n") | |
22b27e95 | 2440 | { |
cdc2d765 | 2441 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2442 | int idx_ipv4 = 1; |
7a7be519 | 2443 | int idx_poll = 3; |
2444 | int idx_pri = 5; | |
718e3744 | 2445 | struct in_addr nbr_addr; |
eb1ce605 | 2446 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2447 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2448 | |
8d769265 | 2449 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2450 | |
7a7be519 | 2451 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[idx_poll]->arg, 1, 65535); |
718e3744 | 2452 | |
7a7be519 | 2453 | if (argc > 4) |
2454 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[idx_pri]->arg, 0, 255); | |
718e3744 | 2455 | |
2456 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
7a7be519 | 2457 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
2458 | ||
2459 | if (argc > 4) | |
718e3744 | 2460 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
2461 | ||
2462 | return CMD_SUCCESS; | |
2463 | } | |
2464 | ||
a2c62831 | 2465 | DEFUN (no_ospf_neighbor, |
2466 | no_ospf_neighbor_cmd, | |
7a7be519 | 2467 | "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]", |
718e3744 | 2468 | NO_STR |
2469 | NEIGHBOR_STR | |
7a7be519 | 2470 | "Neighbor IP address\n" |
2471 | "Neighbor Priority\n" | |
2472 | "Priority\n" | |
2473 | "Dead Neighbor Polling interval\n" | |
2474 | "Seconds\n") | |
718e3744 | 2475 | { |
cdc2d765 | 2476 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2477 | int idx_ipv4 = 2; |
718e3744 | 2478 | struct in_addr nbr_addr; |
718e3744 | 2479 | |
8d769265 | 2480 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2481 | |
0798cee3 | 2482 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2483 | |
2484 | return CMD_SUCCESS; | |
2485 | } | |
2486 | ||
7a7be519 | 2487 | DEFUN (no_ospf_neighbor_poll, |
2488 | no_ospf_neighbor_poll_cmd, | |
2489 | "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", | |
2490 | NO_STR | |
2491 | NEIGHBOR_STR | |
2492 | "Neighbor IP address\n" | |
2493 | "Dead Neighbor Polling interval\n" | |
2494 | "Seconds\n" | |
2495 | "Neighbor Priority\n" | |
2496 | "Priority\n") | |
2497 | { | |
cdc2d765 | 2498 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 2499 | int idx_ipv4 = 2; |
7a7be519 | 2500 | struct in_addr nbr_addr; |
2501 | ||
7a7be519 | 2502 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[idx_ipv4]->arg); |
718e3744 | 2503 | |
7a7be519 | 2504 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
813d4307 | 2505 | |
7a7be519 | 2506 | return CMD_SUCCESS; |
2507 | } | |
718e3744 | 2508 | |
bf2bfafd DW |
2509 | DEFUN (ospf_refresh_timer, |
2510 | ospf_refresh_timer_cmd, | |
6147e2c6 | 2511 | "refresh timer (10-1800)", |
718e3744 | 2512 | "Adjust refresh parameters\n" |
2513 | "Set refresh timer\n" | |
2514 | "Timer value in seconds\n") | |
2515 | { | |
cdc2d765 | 2516 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2517 | int idx_number = 2; |
eb1ce605 | 2518 | unsigned int interval; |
7c8ff89e | 2519 | |
8d769265 | 2520 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); |
535c84b1 | 2521 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; |
718e3744 | 2522 | |
2523 | ospf_timers_refresh_set (ospf, interval); | |
2524 | ||
2525 | return CMD_SUCCESS; | |
2526 | } | |
2527 | ||
bf2bfafd DW |
2528 | DEFUN (no_ospf_refresh_timer, |
2529 | no_ospf_refresh_timer_val_cmd, | |
7a7be519 | 2530 | "no refresh timer [(10-1800)]", |
3a2d747c | 2531 | NO_STR |
718e3744 | 2532 | "Adjust refresh parameters\n" |
2533 | "Unset refresh timer\n" | |
2534 | "Timer value in seconds\n") | |
2535 | { | |
cdc2d765 | 2536 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2537 | int idx_number = 3; |
eb1ce605 | 2538 | unsigned int interval; |
718e3744 | 2539 | |
2540 | if (argc == 1) | |
2541 | { | |
8d769265 | 2542 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[idx_number]->arg, 10, 1800); |
718e3744 | 2543 | |
2544 | if (ospf->lsa_refresh_interval != interval || | |
2545 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2546 | return CMD_SUCCESS; | |
2547 | } | |
2548 | ||
2549 | ospf_timers_refresh_unset (ospf); | |
2550 | ||
2551 | return CMD_SUCCESS; | |
2552 | } | |
2553 | ||
718e3744 | 2554 | |
a2c62831 | 2555 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2556 | ospf_auto_cost_reference_bandwidth_cmd, | |
6147e2c6 | 2557 | "auto-cost reference-bandwidth (1-4294967)", |
718e3744 | 2558 | "Calculate OSPF interface cost according to bandwidth\n" |
2559 | "Use reference bandwidth method to assign OSPF cost\n" | |
2560 | "The reference bandwidth in terms of Mbits per second\n") | |
2561 | { | |
cdc2d765 | 2562 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2563 | int idx_number = 2; |
718e3744 | 2564 | u_int32_t refbw; |
52dc7ee6 | 2565 | struct listnode *node; |
1eb8ef25 | 2566 | struct interface *ifp; |
718e3744 | 2567 | |
8d769265 | 2568 | refbw = strtol (argv[idx_number]->arg, NULL, 10); |
718e3744 | 2569 | if (refbw < 1 || refbw > 4294967) |
2570 | { | |
2571 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); | |
2572 | return CMD_WARNING; | |
2573 | } | |
2574 | ||
2575 | /* If reference bandwidth is changed. */ | |
70bd3c43 | 2576 | if ((refbw) == ospf->ref_bandwidth) |
718e3744 | 2577 | return CMD_SUCCESS; |
2578 | ||
70bd3c43 | 2579 | ospf->ref_bandwidth = refbw; |
1eb8ef25 | 2580 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2581 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2582 | |
2583 | return CMD_SUCCESS; | |
2584 | } | |
2585 | ||
a2c62831 | 2586 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2587 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
7a7be519 | 2588 | "no auto-cost reference-bandwidth [(1-4294967)]", |
718e3744 | 2589 | NO_STR |
2590 | "Calculate OSPF interface cost according to bandwidth\n" | |
7a7be519 | 2591 | "Use reference bandwidth method to assign OSPF cost\n" |
2592 | "The reference bandwidth in terms of Mbits per second\n") | |
718e3744 | 2593 | { |
cdc2d765 | 2594 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
1eb8ef25 | 2595 | struct listnode *node, *nnode; |
2596 | struct interface *ifp; | |
718e3744 | 2597 | |
68980084 | 2598 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2599 | return CMD_SUCCESS; |
2600 | ||
68980084 | 2601 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
718e3744 | 2602 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
2603 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); | |
2604 | ||
1eb8ef25 | 2605 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2606 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2607 | |
2608 | return CMD_SUCCESS; | |
2609 | } | |
2610 | ||
2f8f370e DS |
2611 | DEFUN (ospf_write_multiplier, |
2612 | ospf_write_multiplier_cmd, | |
6147e2c6 | 2613 | "ospf write-multiplier (1-100)", |
e8f45e82 DS |
2614 | "OSPF specific commands\n" |
2615 | "Write multiplier\n" | |
2616 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2617 | { |
cdc2d765 | 2618 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 2619 | int idx_number; |
e8f45e82 | 2620 | u_int32_t write_oi_count; |
2f8f370e | 2621 | |
7a7be519 | 2622 | if (argc == 3) |
2623 | idx_number = 2; | |
2624 | else | |
2625 | idx_number = 1; | |
2626 | ||
8d769265 | 2627 | write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); |
e8f45e82 | 2628 | if (write_oi_count < 1 || write_oi_count > 100) |
2f8f370e DS |
2629 | { |
2630 | vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE); | |
2631 | return CMD_WARNING; | |
2632 | } | |
2633 | ||
e8f45e82 | 2634 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2635 | return CMD_SUCCESS; |
2636 | } | |
2637 | ||
7a7be519 | 2638 | ALIAS (ospf_write_multiplier, |
2639 | write_multiplier_cmd, | |
2640 | "write-multiplier (1-100)", | |
2641 | "Write multiplier\n" | |
2642 | "Maximum number of interface serviced per write\n") | |
e8f45e82 | 2643 | |
2f8f370e DS |
2644 | DEFUN (no_ospf_write_multiplier, |
2645 | no_ospf_write_multiplier_cmd, | |
6147e2c6 | 2646 | "no ospf write-multiplier (1-100)", |
2f8f370e | 2647 | NO_STR |
e8f45e82 | 2648 | "OSPF specific commands\n" |
813d4307 DW |
2649 | "Write multiplier\n" |
2650 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2651 | { |
cdc2d765 | 2652 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
2f8f370e | 2653 | |
e8f45e82 | 2654 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
2655 | return CMD_SUCCESS; |
2656 | } | |
2657 | ||
7a7be519 | 2658 | ALIAS (no_ospf_write_multiplier, |
2659 | no_write_multiplier_cmd, | |
2660 | "no write-multiplier (1-100)", | |
2661 | NO_STR | |
2662 | "Write multiplier\n" | |
2663 | "Maximum number of interface serviced per write\n") | |
813d4307 | 2664 | |
eb1ce605 | 2665 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 2666 | { |
2667 | "Unknown", | |
2668 | "Standard (RFC2328)", | |
2669 | "Alternative IBM", | |
2670 | "Alternative Cisco", | |
2671 | "Alternative Shortcut" | |
2672 | }; | |
2673 | ||
eb1ce605 | 2674 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 2675 | { |
2676 | "Default", | |
2677 | "Enabled", | |
2678 | "Disabled" | |
2679 | }; | |
2680 | ||
4dadc291 | 2681 | static void |
ca08c43d | 2682 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 2683 | { |
ca08c43d DS |
2684 | json_object *json_area = NULL; |
2685 | ||
2686 | if (use_json) | |
2687 | json_area = json_object_new_object(); | |
2688 | ||
718e3744 | 2689 | /* Show Area ID. */ |
ca08c43d DS |
2690 | if (!use_json) |
2691 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 2692 | |
2693 | /* Show Area type/mode. */ | |
2694 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
2695 | { |
2696 | if (use_json) | |
2697 | json_object_boolean_true_add(json_area, "backbone"); | |
2698 | else | |
2699 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); | |
2700 | } | |
718e3744 | 2701 | else |
2702 | { | |
ca08c43d DS |
2703 | if (use_json) |
2704 | { | |
2705 | if (area->external_routing == OSPF_AREA_STUB) | |
2706 | { | |
2707 | if (area->no_summary) | |
2708 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
2709 | if (area->shortcut_configured) | |
2710 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
2711 | } | |
2712 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2713 | { | |
2714 | if (area->no_summary) | |
2715 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
2716 | if (area->shortcut_configured) | |
2717 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
2718 | } | |
2719 | ||
2720 | json_object_string_add(json_area,"shortcuttingMode", | |
2721 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
2722 | if (area->shortcut_capability) | |
2723 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
2724 | } | |
2725 | else | |
2726 | { | |
2727 | if (area->external_routing == OSPF_AREA_STUB) | |
2728 | vty_out (vty, " (Stub%s%s)", | |
2729 | area->no_summary ? ", no summary" : "", | |
2730 | area->shortcut_configured ? "; " : ""); | |
2731 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2732 | vty_out (vty, " (NSSA%s%s)", | |
2733 | area->no_summary ? ", no summary" : "", | |
2734 | area->shortcut_configured ? "; " : ""); | |
2735 | ||
2736 | vty_out (vty, "%s", VTY_NEWLINE); | |
2737 | vty_out (vty, " Shortcutting mode: %s", | |
2738 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
2739 | vty_out (vty, ", S-bit consensus: %s%s", | |
2740 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); | |
2741 | } | |
2742 | } | |
2743 | ||
2744 | /* Show number of interfaces */ | |
2745 | if (use_json) | |
2746 | { | |
3ac237f8 MS |
2747 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
2748 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 2749 | } |
ca08c43d DS |
2750 | else |
2751 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
2752 | "Active: %d%s", listcount (area->oiflist), | |
2753 | area->act_ints, VTY_NEWLINE); | |
718e3744 | 2754 | |
718e3744 | 2755 | if (area->external_routing == OSPF_AREA_NSSA) |
2756 | { | |
ca08c43d DS |
2757 | if (use_json) |
2758 | { | |
2759 | json_object_boolean_true_add(json_area, "nssa"); | |
2760 | if (! IS_OSPF_ABR (area->ospf)) | |
2761 | json_object_boolean_false_add(json_area, "abr"); | |
2762 | else if (area->NSSATranslatorState) | |
2763 | { | |
2764 | json_object_boolean_true_add(json_area, "abr"); | |
2765 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2766 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
2767 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
2768 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
2769 | } | |
2770 | else | |
2771 | { | |
2772 | json_object_boolean_true_add(json_area, "abr"); | |
2773 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2774 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
2775 | else | |
2776 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
2777 | } | |
2778 | } | |
718e3744 | 2779 | else |
ca08c43d DS |
2780 | { |
2781 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); | |
2782 | if (! IS_OSPF_ABR (area->ospf)) | |
2783 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
2784 | VTY_NEWLINE); | |
2785 | else if (area->NSSATranslatorState) | |
2786 | { | |
2787 | vty_out (vty, " We are an ABR and "); | |
2788 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2789 | vty_out (vty, "the NSSA Elected Translator. %s", | |
2790 | VTY_NEWLINE); | |
2791 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
2792 | vty_out (vty, "always an NSSA Translator. %s", | |
2793 | VTY_NEWLINE); | |
2794 | } | |
2795 | else | |
2796 | { | |
2797 | vty_out (vty, " We are an ABR, but "); | |
2798 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2799 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
2800 | VTY_NEWLINE); | |
2801 | else | |
2802 | vty_out (vty, "never an NSSA Translator. %s", | |
2803 | VTY_NEWLINE); | |
2804 | } | |
2805 | } | |
718e3744 | 2806 | } |
ca08c43d | 2807 | |
88d6cf37 | 2808 | /* Stub-router state for this area */ |
2809 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
2810 | { | |
649654ab | 2811 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
2812 | |
2813 | if (use_json) | |
2814 | { | |
2815 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
2816 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2817 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
2818 | if (area->t_stub_router) | |
2819 | { | |
cbf3e3eb DL |
2820 | long time_store; |
2821 | time_store = monotime_until(&area->t_stub_router->u.sands, NULL) / 1000LL; | |
ca08c43d DS |
2822 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); |
2823 | } | |
2824 | } | |
2825 | else | |
2826 | { | |
2827 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
2828 | VTY_NEWLINE); | |
2829 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2830 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
2831 | VTY_NEWLINE); | |
2832 | if (area->t_stub_router) | |
2833 | vty_out (vty, " Active from startup, %s remaining%s", | |
2834 | ospf_timer_dump (area->t_stub_router, timebuf, | |
2835 | sizeof(timebuf)), VTY_NEWLINE); | |
2836 | } | |
2837 | } | |
2838 | ||
2839 | if (use_json) | |
2840 | { | |
2841 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 2842 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
2843 | |
2844 | /* Show authentication type. */ | |
2845 | if (area->auth_type == OSPF_AUTH_NULL) | |
2846 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
2847 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
2848 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
2849 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
2850 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
2851 | ||
2852 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 2853 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
2854 | |
2855 | /* Show SPF calculation times. */ | |
3ac237f8 | 2856 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
2857 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
2858 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
2859 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
2860 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
2861 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
2862 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
2863 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
2864 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2865 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2866 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
2867 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 2868 | } |
ca08c43d DS |
2869 | else |
2870 | { | |
2871 | /* Show number of fully adjacent neighbors. */ | |
2872 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
2873 | " %d%s", area->full_nbrs, VTY_NEWLINE); | |
2874 | ||
2875 | /* Show authentication type. */ | |
2876 | vty_out (vty, " Area has "); | |
2877 | if (area->auth_type == OSPF_AUTH_NULL) | |
2878 | vty_out (vty, "no authentication%s", VTY_NEWLINE); | |
2879 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
2880 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); | |
2881 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
2882 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); | |
2883 | ||
2884 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
2885 | vty_out (vty, " Number of full virtual adjacencies going through" | |
2886 | " this area: %d%s", area->full_vls, VTY_NEWLINE); | |
2887 | ||
2888 | /* Show SPF calculation times. */ | |
2889 | vty_out (vty, " SPF algorithm executed %d times%s", | |
2890 | area->spf_calculation, VTY_NEWLINE); | |
2891 | ||
2892 | /* Show number of LSA. */ | |
2893 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); | |
2894 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", | |
2895 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
2896 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); | |
2897 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", | |
2898 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
2899 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); | |
2900 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", | |
2901 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
2902 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); | |
2903 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", | |
2904 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
2905 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); | |
2906 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", | |
2907 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
2908 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); | |
2909 | } | |
2910 | ||
ca08c43d DS |
2911 | if (use_json) |
2912 | { | |
2913 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2914 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2915 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2916 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2917 | } | |
2918 | else | |
2919 | { | |
2920 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
2921 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
2922 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); | |
2923 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", | |
2924 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
2925 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); | |
2926 | } | |
ca08c43d DS |
2927 | |
2928 | if (use_json) | |
2929 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
2930 | else | |
2931 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 2932 | } |
2933 | ||
7c8ff89e | 2934 | static int |
ca08c43d | 2935 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 2936 | { |
1eb8ef25 | 2937 | struct listnode *node, *nnode; |
718e3744 | 2938 | struct ospf_area * area; |
d24f6e2a | 2939 | struct timeval result; |
649654ab | 2940 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
2941 | json_object *json = NULL; |
2942 | json_object *json_areas = NULL; | |
2943 | ||
2944 | if (use_json) | |
0cad6e26 DS |
2945 | { |
2946 | json = json_object_new_object(); | |
2947 | json_areas = json_object_new_object(); | |
2948 | } | |
718e3744 | 2949 | |
7c8ff89e | 2950 | if (ospf->instance) |
ca08c43d DS |
2951 | { |
2952 | if (use_json) | |
2953 | { | |
2954 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
2955 | } | |
2956 | else | |
2957 | { | |
2958 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
2959 | VTY_NEWLINE, VTY_NEWLINE); | |
2960 | } | |
2961 | } | |
718e3744 | 2962 | |
2963 | /* Show Router ID. */ | |
ca08c43d DS |
2964 | if (use_json) |
2965 | { | |
2966 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
2967 | } | |
2968 | else | |
2969 | { | |
2970 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
2971 | inet_ntoa (ospf->router_id), | |
2972 | VTY_NEWLINE); | |
2973 | } | |
7c8ff89e | 2974 | |
88d6cf37 | 2975 | /* Graceful shutdown */ |
c9c93d50 | 2976 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
2977 | { |
2978 | if (use_json) | |
2979 | { | |
cbf3e3eb DL |
2980 | long time_store; |
2981 | time_store = monotime_until(&ospf->t_deferred_shutdown->u.sands, NULL) / 1000LL; | |
ca08c43d DS |
2982 | json_object_int_add(json, "deferredShutdownMsecs", time_store); |
2983 | } | |
2984 | else | |
2985 | { | |
2986 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
2987 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
2988 | timebuf, sizeof (timebuf)), VTY_NEWLINE); | |
2989 | } | |
2990 | } | |
2991 | ||
718e3744 | 2992 | /* Show capability. */ |
ca08c43d DS |
2993 | if (use_json) |
2994 | { | |
2995 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
2996 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
2997 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
2998 | { | |
2999 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
3000 | } | |
3001 | } | |
3002 | else | |
3003 | { | |
3004 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); | |
3005 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); | |
3006 | vty_out (vty, " RFC1583Compatibility flag is %s%s", | |
3007 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
3008 | "enabled" : "disabled", VTY_NEWLINE); | |
3009 | } | |
3010 | ||
ca08c43d DS |
3011 | if (use_json) |
3012 | { | |
3013 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
3014 | { | |
3015 | json_object_boolean_true_add(json, "opaqueCapable"); | |
3016 | } | |
ca08c43d DS |
3017 | } |
3018 | else | |
3019 | { | |
801e0e14 | 3020 | vty_out (vty, " OpaqueCapability flag is %s%s", |
ca08c43d | 3021 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", |
ca08c43d DS |
3022 | VTY_NEWLINE); |
3023 | } | |
ca08c43d | 3024 | |
88d6cf37 | 3025 | /* Show stub-router configuration */ |
3026 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3027 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3028 | { | |
ca08c43d DS |
3029 | if (use_json) |
3030 | { | |
3031 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3032 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3033 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3034 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3035 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3036 | } | |
3037 | else | |
3038 | { | |
3039 | vty_out (vty, " Stub router advertisement is configured%s", | |
3040 | VTY_NEWLINE); | |
3041 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3042 | vty_out (vty, " Enabled for %us after start-up%s", | |
3043 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
3044 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3045 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
3046 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
3047 | } | |
88d6cf37 | 3048 | } |
ca08c43d | 3049 | |
718e3744 | 3050 | /* Show SPF timers. */ |
ca08c43d DS |
3051 | if (use_json) |
3052 | { | |
3053 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3054 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3055 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3056 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3057 | } |
3058 | else | |
ca08c43d DS |
3059 | { |
3060 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3061 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3062 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3063 | " Hold time multiplier is currently %d%s", | |
3064 | ospf->spf_delay, VTY_NEWLINE, | |
3065 | ospf->spf_holdtime, VTY_NEWLINE, | |
3066 | ospf->spf_max_holdtime, VTY_NEWLINE, | |
3067 | ospf->spf_hold_multiplier, VTY_NEWLINE); | |
3068 | } | |
b6927875 | 3069 | |
ca08c43d DS |
3070 | if (use_json) |
3071 | { | |
3072 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3073 | { | |
cbf3e3eb | 3074 | long time_store = 0; |
ca08c43d | 3075 | |
cbf3e3eb | 3076 | time_store = monotime_since(&ospf->ts_spf, NULL) / 1000LL; |
ca08c43d DS |
3077 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); |
3078 | ||
3079 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3080 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3081 | } | |
3082 | else | |
3083 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3084 | } | |
3085 | else | |
3086 | { | |
3087 | vty_out (vty, " SPF algorithm "); | |
3088 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3089 | { | |
cbf3e3eb | 3090 | monotime_since(&ospf->ts_spf, &result); |
ca08c43d DS |
3091 | vty_out (vty, "last executed %s ago%s", |
3092 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
3093 | VTY_NEWLINE); | |
3094 | vty_out (vty, " Last SPF duration %s%s", | |
3095 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
3096 | VTY_NEWLINE); | |
3097 | } | |
3098 | else | |
3099 | vty_out (vty, "has not been run%s", VTY_NEWLINE); | |
3100 | } | |
3101 | ||
3102 | if (use_json) | |
3103 | { | |
ca08c43d DS |
3104 | if (ospf->t_spf_calc) |
3105 | { | |
cbf3e3eb DL |
3106 | long time_store; |
3107 | time_store = monotime_until(&ospf->t_spf_calc->u.sands, NULL) / 1000LL; | |
ca08c43d DS |
3108 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); |
3109 | } | |
3110 | ||
ac7424f9 MR |
3111 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3112 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3113 | /* Show write multiplier values */ |
3114 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3115 | /* Show refresh parameters. */ | |
54b7214f | 3116 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000); |
ca08c43d DS |
3117 | } |
3118 | else | |
3119 | { | |
3120 | vty_out (vty, " SPF timer %s%s%s", | |
3121 | (ospf->t_spf_calc ? "due in " : "is "), | |
3122 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
3123 | VTY_NEWLINE); | |
3124 | ||
ac7424f9 MR |
3125 | vty_out (vty, " LSA minimum interval %d msecs%s", |
3126 | ospf->min_ls_interval, VTY_NEWLINE); | |
ca08c43d | 3127 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
ac7424f9 | 3128 | ospf->min_ls_arrival, VTY_NEWLINE); |
ca08c43d DS |
3129 | |
3130 | /* Show write multiplier values */ | |
3131 | vty_out (vty, " Write Multiplier set to %d %s", | |
3132 | ospf->write_oi_count, VTY_NEWLINE); | |
3133 | ||
3134 | /* Show refresh parameters. */ | |
3135 | vty_out (vty, " Refresh timer %d secs%s", | |
3136 | ospf->lsa_refresh_interval, VTY_NEWLINE); | |
3137 | } | |
2f8f370e | 3138 | |
718e3744 | 3139 | /* Show ABR/ASBR flags. */ |
68980084 | 3140 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3141 | { |
3142 | if (use_json) | |
3143 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3144 | else | |
3145 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
3146 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); | |
3147 | } | |
68980084 | 3148 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3149 | { |
3150 | if (use_json) | |
3151 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3152 | else | |
3153 | vty_out (vty, " This router is an ASBR " | |
3154 | "(injecting external routing information)%s", VTY_NEWLINE); | |
3155 | } | |
718e3744 | 3156 | |
3157 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3158 | if (use_json) |
3159 | { | |
3ac237f8 | 3160 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3161 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3162 | json_object_int_add(json, "lsaExternalChecksum", | |
3163 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3164 | } | |
3165 | else | |
3166 | { | |
3167 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3168 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3169 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); | |
3170 | } | |
3171 | ||
ca08c43d DS |
3172 | if (use_json) |
3173 | { | |
3ac237f8 | 3174 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3175 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3176 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3177 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3178 | } | |
3179 | else | |
3180 | { | |
3181 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3182 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3183 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); | |
3184 | } | |
ca08c43d | 3185 | |
718e3744 | 3186 | /* Show number of areas attached. */ |
ca08c43d | 3187 | if (use_json) |
3ac237f8 | 3188 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3189 | else |
3190 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
3191 | listcount (ospf->areas), VTY_NEWLINE); | |
d7e60dd7 AS |
3192 | |
3193 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3194 | { | |
3195 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3196 | { |
3197 | if (use_json) | |
3198 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3199 | else | |
3200 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); | |
3201 | } | |
d7e60dd7 | 3202 | else |
ca08c43d DS |
3203 | { |
3204 | if (use_json) | |
3205 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3206 | else | |
3207 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); | |
3208 | } | |
d7e60dd7 | 3209 | } |
718e3744 | 3210 | /* Show each area status. */ |
1eb8ef25 | 3211 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3212 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3213 | ||
3214 | if (use_json) | |
3215 | { | |
3216 | json_object_object_add(json, "areas", json_areas); | |
2aac5767 | 3217 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
ca08c43d DS |
3218 | json_object_free(json); |
3219 | } | |
3220 | else | |
3221 | vty_out (vty, "%s",VTY_NEWLINE); | |
718e3744 | 3222 | |
3223 | return CMD_SUCCESS; | |
3224 | } | |
3225 | ||
7c8ff89e DS |
3226 | DEFUN (show_ip_ospf, |
3227 | show_ip_ospf_cmd, | |
b162fa78 | 3228 | "show ip ospf [json]", |
7c8ff89e DS |
3229 | SHOW_STR |
3230 | IP_STR | |
ca08c43d | 3231 | "OSPF information\n" |
9973d184 | 3232 | JSON_STR) |
7c8ff89e DS |
3233 | { |
3234 | struct ospf *ospf; | |
db7c8528 | 3235 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3236 | |
0bad4851 | 3237 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3238 | return CMD_SUCCESS; |
3239 | ||
db7c8528 | 3240 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3241 | } |
3242 | ||
3243 | DEFUN (show_ip_ospf_instance, | |
3244 | show_ip_ospf_instance_cmd, | |
6147e2c6 | 3245 | "show ip ospf (1-65535) [json]", |
7c8ff89e DS |
3246 | SHOW_STR |
3247 | IP_STR | |
3248 | "OSPF information\n" | |
ca08c43d | 3249 | "Instance ID\n" |
9973d184 | 3250 | JSON_STR) |
7c8ff89e | 3251 | { |
8d769265 | 3252 | int idx_number = 3; |
7c8ff89e DS |
3253 | struct ospf *ospf; |
3254 | u_short instance = 0; | |
db7c8528 | 3255 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3256 | |
8d769265 | 3257 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3258 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3259 | return CMD_SUCCESS; |
3260 | ||
db7c8528 | 3261 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3262 | } |
3263 | ||
fd651fa6 | 3264 | static void |
7ec4159b DS |
3265 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3266 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3267 | { |
fd651fa6 | 3268 | int is_up; |
718e3744 | 3269 | struct ospf_neighbor *nbr; |
718e3744 | 3270 | struct route_node *rn; |
718e3744 | 3271 | |
718e3744 | 3272 | /* Is interface up? */ |
7ec4159b DS |
3273 | if (use_json) |
3274 | { | |
3275 | is_up = if_is_operative(ifp); | |
3276 | if (is_up) | |
3277 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3278 | else | |
3279 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3280 | ||
3281 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3282 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
70bd3c43 | 3283 | json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth); |
7ec4159b DS |
3284 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); |
3285 | } | |
3286 | else | |
3287 | { | |
3288 | vty_out (vty, "%s is %s%s", ifp->name, | |
3289 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); | |
70bd3c43 | 3290 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s", |
7ec4159b DS |
3291 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
3292 | VTY_NEWLINE); | |
3293 | } | |
718e3744 | 3294 | |
3295 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3296 | if (use_json) |
718e3744 | 3297 | { |
7ec4159b DS |
3298 | if (ospf_oi_count(ifp) == 0) |
3299 | { | |
3300 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3301 | return; | |
3302 | } | |
3303 | else if (!is_up) | |
3304 | { | |
3305 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3306 | return; | |
3307 | } | |
3308 | else | |
3309 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3310 | } |
7ec4159b | 3311 | else |
fd651fa6 | 3312 | { |
7ec4159b DS |
3313 | if (ospf_oi_count(ifp) == 0) |
3314 | { | |
3315 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); | |
3316 | return; | |
3317 | } | |
3318 | else if (!is_up) | |
3319 | { | |
3320 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
3321 | VTY_NEWLINE); | |
3322 | return; | |
3323 | } | |
fd651fa6 | 3324 | } |
3325 | ||
718e3744 | 3326 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3327 | { | |
3328 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3329 | |
718e3744 | 3330 | if (oi == NULL) |
7ec4159b DS |
3331 | continue; |
3332 | ||
525c1839 DS |
3333 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3334 | { | |
7ec4159b DS |
3335 | if (use_json) |
3336 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3337 | else | |
3338 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3339 | } |
3340 | else | |
9c27ef9b | 3341 | { |
525c1839 | 3342 | /* Show OSPF interface information. */ |
7ec4159b DS |
3343 | if (use_json) |
3344 | { | |
3345 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3346 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3347 | } | |
3348 | else | |
3349 | vty_out (vty, " Internet Address %s/%d,", | |
3350 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3351 | |
3352 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3353 | { | |
3354 | struct in_addr *dest; | |
3355 | const char *dstr; | |
3356 | ||
3357 | if (CONNECTED_PEER(oi->connected) | |
3358 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3359 | dstr = "Peer"; | |
3360 | else | |
3361 | dstr = "Broadcast"; | |
3362 | ||
3363 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3364 | * * * * * informative than the local interface that is being used |
3365 | * * * * */ | |
525c1839 DS |
3366 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3367 | dest = &oi->vl_data->peer_addr; | |
3368 | else | |
3369 | dest = &oi->connected->destination->u.prefix4; | |
3370 | ||
7ec4159b DS |
3371 | if (use_json) |
3372 | { | |
3373 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3374 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3375 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3376 | else | |
3377 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3378 | } | |
3379 | else | |
3380 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3381 | } |
9c27ef9b | 3382 | } |
7ec4159b DS |
3383 | if (use_json) |
3384 | { | |
3385 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3386 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3387 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3388 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3389 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3390 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3391 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
3392 | json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state)); | |
3393 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); | |
3394 | } | |
3395 | else | |
3396 | { | |
3397 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), | |
3398 | VTY_NEWLINE); | |
3fb9cd6e | 3399 | |
7ec4159b DS |
3400 | vty_out (vty, " MTU mismatch detection:%s%s", |
3401 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); | |
ba682537 | 3402 | |
7ec4159b DS |
3403 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
3404 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3405 | oi->output_cost, VTY_NEWLINE); | |
718e3744 | 3406 | |
7ec4159b DS |
3407 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
3408 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), | |
3409 | PRIORITY (oi), VTY_NEWLINE); | |
3410 | } | |
718e3744 | 3411 | |
3412 | /* Show DR information. */ | |
3413 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3414 | { |
3415 | if (!use_json) | |
3416 | vty_out (vty, " No backup designated router on this network%s", | |
3417 | VTY_NEWLINE); | |
3418 | } | |
718e3744 | 3419 | else |
7ec4159b DS |
3420 | { |
3421 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3422 | if (nbr == NULL) | |
3423 | { | |
3424 | if (!use_json) | |
3425 | vty_out (vty, " No backup designated router on this network%s", | |
3426 | VTY_NEWLINE); | |
3427 | } | |
3428 | else | |
3429 | { | |
3430 | if (use_json) | |
3431 | { | |
3432 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3433 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3434 | } | |
3435 | else | |
3436 | { | |
3437 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3438 | inet_ntoa (nbr->router_id)); | |
3439 | vty_out (vty, " Interface Address %s%s", | |
3440 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
3441 | } | |
3442 | } | |
3443 | } | |
525c1839 | 3444 | |
7eb5b47e | 3445 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3446 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3447 | { |
7ec4159b DS |
3448 | if (use_json) |
3449 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3450 | else | |
3451 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
3452 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); | |
3453 | } | |
3454 | ||
3455 | if (use_json) | |
3456 | { | |
3457 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3458 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3459 | { | |
3460 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3461 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3462 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3463 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3464 | } | |
429ac78c PJ |
3465 | } |
3466 | else | |
7ec4159b DS |
3467 | { |
3468 | vty_out (vty, " Multicast group memberships:"); | |
3469 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3470 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3471 | { | |
3472 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3473 | vty_out (vty, " OSPFAllRouters"); | |
3474 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3475 | vty_out (vty, " OSPFDesignatedRouters"); | |
3476 | } | |
3477 | else | |
3478 | vty_out (vty, " <None>"); | |
3479 | vty_out (vty, "%s", VTY_NEWLINE); | |
3480 | } | |
ba6454ec | 3481 | |
7ec4159b DS |
3482 | if (use_json) |
3483 | { | |
3484 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3485 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3486 | else | |
3487 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3488 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3489 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3490 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3491 | } | |
f9ad937f | 3492 | else |
7ec4159b DS |
3493 | { |
3494 | vty_out (vty, " Timer intervals configured,"); | |
3495 | vty_out (vty, " Hello "); | |
3496 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3497 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3498 | else | |
3499 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3500 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3501 | OSPF_IF_PARAM (oi, v_wait), | |
3502 | OSPF_IF_PARAM (oi, v_wait), | |
3503 | OSPF_IF_PARAM (oi, retransmit_interval), | |
3504 | VTY_NEWLINE); | |
3505 | } | |
3506 | ||
7ffa8fa2 | 3507 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3508 | { |
7ec4159b DS |
3509 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3510 | if (use_json) | |
3511 | { | |
cbf3e3eb DL |
3512 | long time_store = 0; |
3513 | if (oi->t_hello) | |
3514 | time_store = monotime_until(&oi->t_hello->u.sands, NULL) / 1000LL; | |
7ec4159b DS |
3515 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); |
3516 | } | |
3517 | else | |
3518 | vty_out (vty, " Hello due in %s%s", | |
3519 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
3520 | VTY_NEWLINE); | |
f9ad937f | 3521 | } |
7ffa8fa2 | 3522 | else /* passive-interface is set */ |
7ec4159b DS |
3523 | { |
3524 | if (use_json) | |
3525 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3526 | else | |
3527 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); | |
3528 | } | |
3529 | ||
3530 | if (use_json) | |
3531 | { | |
3532 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3533 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3534 | } | |
3535 | else | |
3536 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3537 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
3538 | VTY_NEWLINE); | |
68fe91d6 | 3539 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3540 | } |
3541 | } | |
3542 | ||
7c8ff89e | 3543 | static int |
7ec4159b | 3544 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
7a7be519 | 3545 | struct cmd_token **argv, int iface_argv, u_char use_json) |
718e3744 | 3546 | { |
3547 | struct interface *ifp; | |
52dc7ee6 | 3548 | struct listnode *node; |
7ec4159b DS |
3549 | json_object *json = NULL; |
3550 | json_object *json_interface_sub = NULL; | |
3551 | ||
3552 | if (use_json) | |
3553 | { | |
3554 | json = json_object_new_object(); | |
3555 | json_interface_sub = json_object_new_object(); | |
3556 | } | |
718e3744 | 3557 | |
7c8ff89e | 3558 | if (ospf->instance) |
7ec4159b DS |
3559 | { |
3560 | if (use_json) | |
3561 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3562 | else | |
3563 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3564 | VTY_NEWLINE, VTY_NEWLINE); | |
3565 | } | |
7c8ff89e | 3566 | |
6be4da3d | 3567 | if (argc == iface_argv) |
7ec4159b DS |
3568 | { |
3569 | /* Show All Interfaces.*/ | |
b2d7c082 | 3570 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3571 | { |
3572 | if (ospf_oi_count(ifp)) | |
3573 | { | |
3574 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
b8dfa544 DS |
3575 | if (use_json) |
3576 | json_object_object_add (json, ifp->name, json_interface_sub); | |
7ec4159b DS |
3577 | } |
3578 | } | |
3579 | } | |
718e3744 | 3580 | else |
3581 | { | |
7c8ff89e | 3582 | /* Interface name is specified. */ |
1306c09a | 3583 | if ((ifp = if_lookup_by_name (argv[iface_argv]->arg, VRF_DEFAULT)) == NULL) |
7ec4159b DS |
3584 | { |
3585 | if (use_json) | |
3586 | json_object_boolean_true_add(json, "noSuchIface"); | |
3587 | else | |
3588 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); | |
3589 | } | |
718e3744 | 3590 | else |
7ec4159b DS |
3591 | { |
3592 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); | |
3593 | if (use_json) | |
3594 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3595 | } | |
718e3744 | 3596 | } |
3597 | ||
7ec4159b DS |
3598 | if (use_json) |
3599 | { | |
2aac5767 | 3600 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
7ec4159b DS |
3601 | json_object_free(json); |
3602 | } | |
3603 | else | |
3604 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3605 | |
718e3744 | 3606 | return CMD_SUCCESS; |
3607 | } | |
3608 | ||
7c8ff89e DS |
3609 | DEFUN (show_ip_ospf_interface, |
3610 | show_ip_ospf_interface_cmd, | |
b162fa78 | 3611 | "show ip ospf interface [INTERFACE] [json]", |
7c8ff89e DS |
3612 | SHOW_STR |
3613 | IP_STR | |
3614 | "OSPF information\n" | |
3615 | "Interface information\n" | |
7ec4159b | 3616 | "Interface name\n" |
9973d184 | 3617 | JSON_STR) |
7c8ff89e DS |
3618 | { |
3619 | struct ospf *ospf; | |
db7c8528 | 3620 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3621 | |
0bad4851 | 3622 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3623 | return CMD_SUCCESS; |
3624 | ||
6be4da3d DS |
3625 | if (uj) |
3626 | argc--; | |
3627 | ||
3628 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 4, uj); | |
7c8ff89e DS |
3629 | } |
3630 | ||
3631 | DEFUN (show_ip_ospf_instance_interface, | |
3632 | show_ip_ospf_instance_interface_cmd, | |
6147e2c6 | 3633 | "show ip ospf (1-65535) interface [INTERFACE] [json]", |
7c8ff89e DS |
3634 | SHOW_STR |
3635 | IP_STR | |
3636 | "OSPF information\n" | |
3637 | "Instance ID\n" | |
3638 | "Interface information\n" | |
7ec4159b | 3639 | "Interface name\n" |
9973d184 | 3640 | JSON_STR) |
7c8ff89e | 3641 | { |
8d769265 | 3642 | int idx_number = 3; |
7c8ff89e DS |
3643 | struct ospf *ospf; |
3644 | u_short instance = 0; | |
db7c8528 | 3645 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3646 | |
8d769265 | 3647 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3648 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3649 | return CMD_SUCCESS; |
3650 | ||
6be4da3d DS |
3651 | if (uj) |
3652 | argc--; | |
3653 | ||
3654 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 5, uj); | |
7c8ff89e DS |
3655 | } |
3656 | ||
d24f6e2a | 3657 | static void |
3658 | show_ip_ospf_neighbour_header (struct vty *vty) | |
3659 | { | |
490578f3 | 3660 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
d24f6e2a | 3661 | VTY_NEWLINE, |
3662 | "Neighbor ID", "Pri", "State", "Dead Time", | |
3663 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
3664 | VTY_NEWLINE); | |
3665 | } | |
3666 | ||
4dadc291 | 3667 | static void |
91756b38 | 3668 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 3669 | { |
3670 | struct route_node *rn; | |
3671 | struct ospf_neighbor *nbr; | |
3672 | char msgbuf[16]; | |
649654ab | 3673 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 3674 | json_object *json_neighbor = NULL; |
718e3744 | 3675 | |
3676 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
3677 | { |
3678 | if ((nbr = rn->info)) | |
3679 | { | |
3680 | /* Do not show myself. */ | |
3681 | if (nbr != oi->nbr_self) | |
3682 | { | |
3683 | /* Down state is not shown. */ | |
3684 | if (nbr->state != NSM_Down) | |
3685 | { | |
3686 | if (use_json) | |
3687 | { | |
3688 | json_neighbor = json_object_new_object(); | |
3689 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3690 | ||
cbf3e3eb | 3691 | long time_store; |
91756b38 | 3692 | |
cbf3e3eb | 3693 | time_store = monotime_until(&nbr->t_inactivity->u.sands, NULL) / 1000LL; |
91756b38 DS |
3694 | |
3695 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
3696 | json_object_string_add (json_neighbor, "state", msgbuf); | |
3697 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
3698 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
3699 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
3700 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
3701 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
3702 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
3703 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
3704 | json_object_object_add(json, "neighbor", json_neighbor); | |
3705 | else | |
3706 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
3707 | } | |
3708 | else | |
3709 | { | |
3710 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3711 | ||
3712 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
3713 | vty_out (vty, "%-15s %3d %-15s ", | |
3714 | "-", nbr->priority, | |
3715 | msgbuf); | |
3716 | else | |
3717 | vty_out (vty, "%-15s %3d %-15s ", | |
3718 | inet_ntoa (nbr->router_id), nbr->priority, | |
3719 | msgbuf); | |
3720 | ||
3721 | vty_out (vty, "%9s ", | |
3722 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
3723 | sizeof(timebuf))); | |
3724 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
3725 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
3726 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
3727 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
3728 | VTY_NEWLINE); | |
3729 | } | |
3730 | } | |
3731 | } | |
3732 | } | |
3733 | } | |
718e3744 | 3734 | } |
3735 | ||
7c8ff89e | 3736 | static int |
91756b38 | 3737 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3738 | { |
1eb8ef25 | 3739 | struct ospf_interface *oi; |
52dc7ee6 | 3740 | struct listnode *node; |
91756b38 | 3741 | json_object *json = NULL; |
718e3744 | 3742 | |
91756b38 DS |
3743 | if (use_json) |
3744 | json = json_object_new_object(); | |
3745 | else | |
3746 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 3747 | |
91756b38 DS |
3748 | if (ospf->instance) |
3749 | { | |
3750 | if (use_json) | |
3751 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3752 | else | |
3753 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3754 | VTY_NEWLINE, VTY_NEWLINE); | |
3755 | } | |
718e3744 | 3756 | |
1eb8ef25 | 3757 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 3758 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3759 | |
91756b38 DS |
3760 | if (use_json) |
3761 | { | |
2aac5767 | 3762 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
3763 | json_object_free(json); |
3764 | } | |
3765 | else | |
3766 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3767 | |
718e3744 | 3768 | return CMD_SUCCESS; |
3769 | } | |
3770 | ||
7c8ff89e DS |
3771 | DEFUN (show_ip_ospf_neighbor, |
3772 | show_ip_ospf_neighbor_cmd, | |
b162fa78 | 3773 | "show ip ospf neighbor [json]", |
718e3744 | 3774 | SHOW_STR |
3775 | IP_STR | |
3776 | "OSPF information\n" | |
91756b38 | 3777 | "Neighbor list\n" |
9973d184 | 3778 | JSON_STR) |
718e3744 | 3779 | { |
7c8ff89e | 3780 | struct ospf *ospf; |
db7c8528 | 3781 | u_char uj = use_json(argc, argv); |
718e3744 | 3782 | |
0bad4851 | 3783 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3784 | return CMD_SUCCESS; |
3785 | ||
db7c8528 | 3786 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
3787 | } |
3788 | ||
3789 | ||
3790 | DEFUN (show_ip_ospf_instance_neighbor, | |
3791 | show_ip_ospf_instance_neighbor_cmd, | |
6147e2c6 | 3792 | "show ip ospf (1-65535) neighbor [json]", |
7c8ff89e DS |
3793 | SHOW_STR |
3794 | IP_STR | |
3795 | "OSPF information\n" | |
3796 | "Instance ID\n" | |
91756b38 | 3797 | "Neighbor list\n" |
9973d184 | 3798 | JSON_STR) |
7c8ff89e | 3799 | { |
8d769265 | 3800 | int idx_number = 3; |
7c8ff89e DS |
3801 | struct ospf *ospf; |
3802 | u_short instance = 0; | |
db7c8528 | 3803 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3804 | |
8d769265 | 3805 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3806 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3807 | return CMD_SUCCESS; |
3808 | ||
db7c8528 | 3809 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
3810 | } |
3811 | ||
3812 | static int | |
91756b38 | 3813 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
3814 | { |
3815 | struct listnode *node; | |
3816 | struct ospf_interface *oi; | |
91756b38 DS |
3817 | json_object *json = NULL; |
3818 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 3819 | |
91756b38 DS |
3820 | if (use_json) |
3821 | { | |
3822 | json = json_object_new_object(); | |
3823 | json_neighbor_sub = json_object_new_object(); | |
3824 | } | |
3825 | else | |
3826 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 3827 | |
91756b38 DS |
3828 | if (ospf->instance) |
3829 | { | |
3830 | if (use_json) | |
3831 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3832 | else | |
3833 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3834 | VTY_NEWLINE, VTY_NEWLINE); | |
3835 | } | |
7c8ff89e DS |
3836 | |
3837 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
3838 | { | |
52dc7ee6 | 3839 | struct listnode *nbr_node; |
1eb8ef25 | 3840 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 3841 | |
91756b38 | 3842 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3843 | |
91756b38 DS |
3844 | /* print Down neighbor status */ |
3845 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
3846 | { | |
3847 | if (nbr_nbma->nbr == NULL | |
3848 | || nbr_nbma->nbr->state == NSM_Down) | |
3849 | { | |
3850 | if (use_json) | |
3851 | { | |
3852 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
3853 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
3854 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
3855 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
3856 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
3857 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
3858 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
3859 | } | |
3860 | else | |
3861 | { | |
3862 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
3863 | "-", nbr_nbma->priority, "Down", "-"); | |
3864 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
3865 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
3866 | 0, 0, 0, VTY_NEWLINE); | |
3867 | } | |
3868 | } | |
3869 | } | |
718e3744 | 3870 | } |
3871 | ||
91756b38 DS |
3872 | if (use_json) |
3873 | { | |
2aac5767 | 3874 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
3875 | json_object_free(json); |
3876 | } | |
3877 | else | |
3878 | vty_out (vty, "%s", VTY_NEWLINE); | |
7c8ff89e | 3879 | |
718e3744 | 3880 | return CMD_SUCCESS; |
3881 | } | |
3882 | ||
7c8ff89e DS |
3883 | DEFUN (show_ip_ospf_neighbor_all, |
3884 | show_ip_ospf_neighbor_all_cmd, | |
b162fa78 | 3885 | "show ip ospf neighbor all [json]", |
718e3744 | 3886 | SHOW_STR |
3887 | IP_STR | |
3888 | "OSPF information\n" | |
3889 | "Neighbor list\n" | |
91756b38 | 3890 | "include down status neighbor\n" |
9973d184 | 3891 | JSON_STR) |
7c8ff89e DS |
3892 | { |
3893 | struct ospf *ospf; | |
db7c8528 | 3894 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3895 | |
0bad4851 | 3896 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3897 | return CMD_SUCCESS; |
3898 | ||
db7c8528 | 3899 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
3900 | } |
3901 | ||
3902 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
3903 | show_ip_ospf_instance_neighbor_all_cmd, | |
6147e2c6 | 3904 | "show ip ospf (1-65535) neighbor all [json]", |
7c8ff89e DS |
3905 | SHOW_STR |
3906 | IP_STR | |
3907 | "OSPF information\n" | |
3908 | "Instance ID\n" | |
3909 | "Neighbor list\n" | |
91756b38 | 3910 | "include down status neighbor\n" |
9973d184 | 3911 | JSON_STR) |
718e3744 | 3912 | { |
8d769265 | 3913 | int idx_number = 3; |
020709f9 | 3914 | struct ospf *ospf; |
7c8ff89e | 3915 | u_short instance = 0; |
db7c8528 | 3916 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3917 | |
8d769265 | 3918 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 3919 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3920 | return CMD_SUCCESS; |
3921 | ||
db7c8528 | 3922 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
3923 | } |
3924 | ||
3925 | static int | |
3926 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
7a7be519 | 3927 | struct cmd_token **argv, u_char use_json) |
7c8ff89e | 3928 | { |
bb5b7552 | 3929 | struct interface *ifp; |
3930 | struct route_node *rn; | |
91756b38 DS |
3931 | json_object *json = NULL; |
3932 | ||
3933 | if (use_json) | |
3934 | json = json_object_new_object(); | |
3935 | else | |
3936 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
3937 | |
3938 | if (ospf->instance) | |
91756b38 DS |
3939 | { |
3940 | if (use_json) | |
3941 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3942 | else | |
3943 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
3944 | VTY_NEWLINE, VTY_NEWLINE); | |
3945 | } | |
7c8ff89e | 3946 | |
1306c09a | 3947 | ifp = if_lookup_by_name (argv[arg_base]->arg, VRF_DEFAULT); |
bb5b7552 | 3948 | if (!ifp) |
718e3744 | 3949 | { |
91756b38 DS |
3950 | if (use_json) |
3951 | json_object_boolean_true_add(json, "noSuchIface"); | |
3952 | else | |
3953 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 3954 | return CMD_WARNING; |
3955 | } | |
d24f6e2a | 3956 | |
bb5b7552 | 3957 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 3958 | { |
bb5b7552 | 3959 | struct ospf_interface *oi = rn->info; |
3960 | ||
3961 | if (oi == NULL) | |
91756b38 | 3962 | continue; |
bb5b7552 | 3963 | |
91756b38 | 3964 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3965 | } |
3966 | ||
91756b38 DS |
3967 | if (use_json) |
3968 | { | |
2aac5767 | 3969 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
91756b38 DS |
3970 | json_object_free(json); |
3971 | } | |
3972 | else | |
3973 | vty_out (vty, "%s", VTY_NEWLINE); | |
3974 | ||
718e3744 | 3975 | return CMD_SUCCESS; |
3976 | } | |
3977 | ||
7c8ff89e DS |
3978 | DEFUN (show_ip_ospf_neighbor_int, |
3979 | show_ip_ospf_neighbor_int_cmd, | |
b162fa78 | 3980 | "show ip ospf neighbor IFNAME [json]", |
7c8ff89e DS |
3981 | SHOW_STR |
3982 | IP_STR | |
3983 | "OSPF information\n" | |
3984 | "Neighbor list\n" | |
91756b38 | 3985 | "Interface name\n" |
9973d184 | 3986 | JSON_STR) |
7c8ff89e DS |
3987 | { |
3988 | struct ospf *ospf; | |
db7c8528 | 3989 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3990 | |
0bad4851 | 3991 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3992 | return CMD_SUCCESS; |
3993 | ||
db7c8528 | 3994 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
3995 | } |
3996 | ||
3997 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
3998 | show_ip_ospf_instance_neighbor_int_cmd, | |
6147e2c6 | 3999 | "show ip ospf (1-65535) neighbor IFNAME [json]", |
7c8ff89e DS |
4000 | SHOW_STR |
4001 | IP_STR | |
4002 | "OSPF information\n" | |
4003 | "Instance ID\n" | |
4004 | "Neighbor list\n" | |
91756b38 | 4005 | "Interface name\n" |
9973d184 | 4006 | JSON_STR) |
7c8ff89e | 4007 | { |
8d769265 | 4008 | int idx_number = 3; |
7c8ff89e DS |
4009 | struct ospf *ospf; |
4010 | u_short instance = 0; | |
db7c8528 | 4011 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4012 | |
8d769265 | 4013 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4014 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4015 | return CMD_SUCCESS; |
4016 | ||
db7c8528 | 4017 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4018 | } |
4019 | ||
4dadc291 | 4020 | static void |
3ac237f8 MS |
4021 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4022 | u_char use_json, json_object *json) | |
718e3744 | 4023 | { |
649654ab | 4024 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4025 | json_object *json_sub = NULL; |
718e3744 | 4026 | |
3ac237f8 MS |
4027 | if (use_json) |
4028 | json_sub = json_object_new_object(); | |
4029 | else /* Show neighbor ID. */ | |
4030 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4031 | |
4032 | /* Show interface address. */ | |
3ac237f8 MS |
4033 | if (use_json) |
4034 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4035 | else | |
4036 | vty_out (vty, " interface address %s%s", | |
4037 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); | |
4038 | ||
718e3744 | 4039 | /* Show Area ID. */ |
3ac237f8 MS |
4040 | if (use_json) |
4041 | { | |
4042 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4043 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4044 | } | |
4045 | else | |
4046 | vty_out (vty, " In the area %s via interface %s%s", | |
4047 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); | |
4048 | ||
718e3744 | 4049 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4050 | if (use_json) |
4051 | { | |
4052 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4053 | json_object_string_add(json_sub, "nbrState", "down"); | |
4054 | } | |
4055 | else | |
4056 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4057 | nbr_nbma->priority, "Down"); | |
4058 | ||
718e3744 | 4059 | /* Show state changes. */ |
3ac237f8 MS |
4060 | if (use_json) |
4061 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4062 | else | |
4063 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); | |
718e3744 | 4064 | |
4065 | /* Show PollInterval */ | |
3ac237f8 MS |
4066 | if (use_json) |
4067 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4068 | else | |
4069 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); | |
718e3744 | 4070 | |
4071 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4072 | if (use_json) |
4073 | { | |
cbf3e3eb DL |
4074 | long time_store; |
4075 | time_store = monotime_until(&nbr_nbma->t_poll->u.sands, NULL) / 1000LL; | |
3ac237f8 MS |
4076 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); |
4077 | } | |
4078 | else | |
4079 | vty_out (vty, " Poll timer due in %s%s", | |
4080 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
4081 | VTY_NEWLINE); | |
718e3744 | 4082 | |
4083 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4084 | if (use_json) |
4085 | { | |
4086 | if (nbr_nbma->t_poll != NULL) | |
4087 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4088 | } | |
4089 | else | |
4090 | vty_out (vty, " Thread Poll Timer %s%s", | |
4091 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); | |
4092 | ||
4093 | if (use_json) | |
4094 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4095 | } |
4096 | ||
4dadc291 | 4097 | static void |
718e3744 | 4098 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4099 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4100 | { |
649654ab | 4101 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4102 | json_object *json_sub = NULL; |
718e3744 | 4103 | |
3ac237f8 MS |
4104 | if (use_json) |
4105 | json_sub = json_object_new_object(); | |
718e3744 | 4106 | else |
3ac237f8 MS |
4107 | { |
4108 | /* Show neighbor ID. */ | |
4109 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4110 | vty_out (vty, " Neighbor %s,", "-"); | |
4111 | else | |
4112 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4113 | } | |
718e3744 | 4114 | |
4115 | /* Show interface address. */ | |
3ac237f8 MS |
4116 | if (use_json) |
4117 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4118 | else | |
4119 | vty_out (vty, " interface address %s%s", | |
4120 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); | |
4121 | ||
718e3744 | 4122 | /* Show Area ID. */ |
3ac237f8 MS |
4123 | if (use_json) |
4124 | { | |
4125 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4126 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4127 | } | |
4128 | else | |
4129 | vty_out (vty, " In the area %s via interface %s%s", | |
4130 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); | |
4131 | ||
718e3744 | 4132 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4133 | if (use_json) |
4134 | { | |
4135 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4136 | json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4137 | } | |
4138 | else | |
4139 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4140 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); | |
4141 | ||
718e3744 | 4142 | /* Show state changes. */ |
3ac237f8 MS |
4143 | if (use_json) |
4144 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4145 | else | |
4146 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); | |
4147 | ||
3fed4160 | 4148 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4149 | { |
cbf3e3eb DL |
4150 | struct timeval res; |
4151 | long time_store; | |
4152 | ||
4153 | time_store = monotime_since(&nbr->ts_last_progress, &res) / 1000LL; | |
3ac237f8 MS |
4154 | if (use_json) |
4155 | { | |
3ac237f8 MS |
4156 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store); |
4157 | } | |
4158 | else | |
4159 | { | |
4160 | vty_out (vty, " Most recent state change statistics:%s", | |
4161 | VTY_NEWLINE); | |
4162 | vty_out (vty, " Progressive change %s ago%s", | |
4163 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4164 | VTY_NEWLINE); | |
4165 | } | |
3fed4160 | 4166 | } |
3ac237f8 | 4167 | |
3fed4160 PJ |
4168 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4169 | { | |
cbf3e3eb DL |
4170 | struct timeval res; |
4171 | long time_store; | |
4172 | ||
4173 | time_store = monotime_since(&nbr->ts_last_regress, &res) / 1000LL; | |
3ac237f8 MS |
4174 | if (use_json) |
4175 | { | |
3ac237f8 MS |
4176 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); |
4177 | if (nbr->last_regress_str) | |
4178 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4179 | } | |
4180 | else | |
4181 | { | |
4182 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4183 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4184 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
4185 | VTY_NEWLINE); | |
4186 | } | |
90c33177 | 4187 | } |
3ac237f8 | 4188 | |
718e3744 | 4189 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4190 | if (use_json) |
4191 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4192 | else | |
4193 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4194 | ||
718e3744 | 4195 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4196 | if (use_json) |
4197 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4198 | else | |
4199 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); | |
4200 | ||
718e3744 | 4201 | /* Show options. */ |
3ac237f8 MS |
4202 | if (use_json) |
4203 | { | |
4204 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4205 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4206 | } | |
4207 | else | |
4208 | vty_out (vty, " Options %d %s%s", nbr->options, | |
4209 | ospf_options_dump (nbr->options), VTY_NEWLINE); | |
4210 | ||
718e3744 | 4211 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4212 | if (use_json) |
4213 | { | |
45d430e8 DS |
4214 | if (nbr->t_inactivity) |
4215 | { | |
cbf3e3eb DL |
4216 | long time_store; |
4217 | time_store = monotime_until(&nbr->t_inactivity->u.sands, NULL) / 1000LL; | |
45d430e8 DS |
4218 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); |
4219 | } | |
4220 | else | |
4221 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", -1); | |
3ac237f8 MS |
4222 | } |
4223 | else | |
4224 | vty_out (vty, " Dead timer due in %s%s", | |
4225 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
4226 | VTY_NEWLINE); | |
4227 | ||
718e3744 | 4228 | /* Show Database Summary list. */ |
3ac237f8 MS |
4229 | if (use_json) |
4230 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4231 | else | |
4232 | vty_out (vty, " Database Summary List %d%s", | |
4233 | ospf_db_summary_count (nbr), VTY_NEWLINE); | |
4234 | ||
718e3744 | 4235 | /* Show Link State Request list. */ |
3ac237f8 MS |
4236 | if (use_json) |
4237 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4238 | else | |
4239 | vty_out (vty, " Link State Request List %ld%s", | |
4240 | ospf_ls_request_count (nbr), VTY_NEWLINE); | |
4241 | ||
718e3744 | 4242 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4243 | if (use_json) |
4244 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4245 | else | |
4246 | vty_out (vty, " Link State Retransmission List %ld%s", | |
4247 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); | |
4248 | ||
718e3744 | 4249 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4250 | if (use_json) |
4251 | { | |
4252 | if (nbr->t_inactivity != NULL) | |
4253 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4254 | } | |
4255 | else | |
4256 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
4257 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); | |
4258 | ||
718e3744 | 4259 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4260 | if (use_json) |
4261 | { | |
4262 | if (nbr->t_db_desc != NULL) | |
4263 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4264 | } | |
4265 | else | |
4266 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
4267 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); | |
4268 | ||
718e3744 | 4269 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4270 | if (use_json) |
4271 | { | |
4272 | if (nbr->t_ls_req != NULL) | |
4273 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4274 | } | |
4275 | else | |
4276 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
4277 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); | |
4278 | ||
718e3744 | 4279 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4280 | if (use_json) |
4281 | { | |
4282 | if (nbr->t_ls_upd != NULL) | |
4283 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4284 | } | |
4285 | else | |
4286 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
4287 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); | |
4288 | ||
4289 | if (use_json) | |
4290 | { | |
4291 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4292 | json_object_object_add(json, "noNbrId", json_sub); | |
4293 | else | |
4294 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4295 | } | |
68fe91d6 | 4296 | |
4297 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4298 | } |
4299 | ||
7c8ff89e DS |
4300 | static int |
4301 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 4302 | int arg_base, struct cmd_token **argv, u_char use_json) |
718e3744 | 4303 | { |
52dc7ee6 | 4304 | struct listnode *node; |
718e3744 | 4305 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4306 | struct ospf_interface *oi; |
718e3744 | 4307 | struct in_addr router_id; |
4308 | int ret; | |
3ac237f8 MS |
4309 | json_object *json = NULL; |
4310 | ||
4311 | if (use_json) | |
4312 | json = json_object_new_object(); | |
718e3744 | 4313 | |
7c8ff89e | 4314 | if (ospf->instance) |
3ac237f8 MS |
4315 | { |
4316 | if (use_json) | |
4317 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4318 | else | |
4319 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4320 | VTY_NEWLINE, VTY_NEWLINE); | |
4321 | } | |
7c8ff89e | 4322 | |
7a7be519 | 4323 | ret = inet_aton (argv[arg_base]->arg, &router_id); |
718e3744 | 4324 | if (!ret) |
4325 | { | |
3ac237f8 MS |
4326 | if (!use_json) |
4327 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); | |
718e3744 | 4328 | return CMD_WARNING; |
4329 | } | |
4330 | ||
1eb8ef25 | 4331 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4332 | { |
4333 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4334 | { | |
4335 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4336 | } | |
4337 | } | |
4338 | ||
4339 | if (use_json) | |
4340 | { | |
2aac5767 | 4341 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4342 | json_object_free(json); |
4343 | } | |
4344 | else | |
4345 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4346 | |
718e3744 | 4347 | return CMD_SUCCESS; |
4348 | } | |
4349 | ||
7c8ff89e DS |
4350 | DEFUN (show_ip_ospf_neighbor_id, |
4351 | show_ip_ospf_neighbor_id_cmd, | |
b162fa78 | 4352 | "show ip ospf neighbor A.B.C.D [json]", |
718e3744 | 4353 | SHOW_STR |
4354 | IP_STR | |
4355 | "OSPF information\n" | |
4356 | "Neighbor list\n" | |
3ac237f8 | 4357 | "Neighbor ID\n" |
9973d184 | 4358 | JSON_STR) |
718e3744 | 4359 | { |
020709f9 | 4360 | struct ospf *ospf; |
db7c8528 | 4361 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4362 | |
0bad4851 | 4363 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4364 | return CMD_SUCCESS; |
4365 | ||
db7c8528 | 4366 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4367 | } |
4368 | ||
4369 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4370 | show_ip_ospf_instance_neighbor_id_cmd, | |
6147e2c6 | 4371 | "show ip ospf (1-65535) neighbor A.B.C.D [json]", |
7c8ff89e DS |
4372 | SHOW_STR |
4373 | IP_STR | |
4374 | "OSPF information\n" | |
4375 | "Instance ID\n" | |
4376 | "Neighbor list\n" | |
3ac237f8 | 4377 | "Neighbor ID\n" |
9973d184 | 4378 | JSON_STR) |
7c8ff89e | 4379 | { |
8d769265 | 4380 | int idx_number = 3; |
7c8ff89e DS |
4381 | struct ospf *ospf; |
4382 | u_short instance = 0; | |
db7c8528 | 4383 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4384 | |
8d769265 | 4385 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4386 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4387 | return CMD_SUCCESS; |
4388 | ||
db7c8528 | 4389 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4390 | } |
4391 | ||
4392 | static int | |
3ac237f8 | 4393 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4394 | { |
1eb8ef25 | 4395 | struct ospf_interface *oi; |
52dc7ee6 | 4396 | struct listnode *node; |
3ac237f8 MS |
4397 | json_object *json = NULL; |
4398 | ||
4399 | if (use_json) | |
4400 | json = json_object_new_object(); | |
718e3744 | 4401 | |
7c8ff89e | 4402 | if (ospf->instance) |
3ac237f8 MS |
4403 | { |
4404 | if (use_json) | |
4405 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4406 | else | |
4407 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4408 | VTY_NEWLINE, VTY_NEWLINE); | |
4409 | } | |
718e3744 | 4410 | |
1eb8ef25 | 4411 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4412 | { |
718e3744 | 4413 | struct route_node *rn; |
4414 | struct ospf_neighbor *nbr; | |
4415 | ||
4416 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4417 | { |
4418 | if ((nbr = rn->info)) | |
4419 | { | |
4420 | if (nbr != oi->nbr_self) | |
4421 | { | |
4422 | if (nbr->state != NSM_Down) | |
4423 | { | |
4424 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4425 | } | |
4426 | } | |
4427 | } | |
4428 | } | |
718e3744 | 4429 | } |
4430 | ||
3ac237f8 MS |
4431 | if (use_json) |
4432 | { | |
2aac5767 | 4433 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4434 | json_object_free(json); |
4435 | } | |
4436 | else | |
4437 | vty_out (vty, "%s", VTY_NEWLINE); | |
4438 | ||
718e3744 | 4439 | return CMD_SUCCESS; |
4440 | } | |
4441 | ||
7c8ff89e DS |
4442 | DEFUN (show_ip_ospf_neighbor_detail, |
4443 | show_ip_ospf_neighbor_detail_cmd, | |
b162fa78 | 4444 | "show ip ospf neighbor detail [json]", |
718e3744 | 4445 | SHOW_STR |
4446 | IP_STR | |
4447 | "OSPF information\n" | |
4448 | "Neighbor list\n" | |
3ac237f8 | 4449 | "detail of all neighbors\n" |
9973d184 | 4450 | JSON_STR) |
718e3744 | 4451 | { |
020709f9 | 4452 | struct ospf *ospf; |
db7c8528 | 4453 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4454 | |
0bad4851 | 4455 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4456 | return CMD_SUCCESS; |
4457 | ||
db7c8528 | 4458 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4459 | } |
4460 | ||
4461 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4462 | show_ip_ospf_instance_neighbor_detail_cmd, | |
6147e2c6 | 4463 | "show ip ospf (1-65535) neighbor detail [json]", |
7c8ff89e DS |
4464 | SHOW_STR |
4465 | IP_STR | |
4466 | "OSPF information\n" | |
4467 | "Instance ID\n" | |
4468 | "Neighbor list\n" | |
3ac237f8 | 4469 | "detail of all neighbors\n" |
9973d184 | 4470 | JSON_STR) |
7c8ff89e | 4471 | { |
8d769265 | 4472 | int idx_number = 3; |
7c8ff89e DS |
4473 | struct ospf *ospf; |
4474 | u_short instance = 0; | |
db7c8528 | 4475 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4476 | |
8d769265 | 4477 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4478 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4479 | return CMD_SUCCESS; |
4480 | ||
db7c8528 | 4481 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4482 | } |
4483 | ||
4484 | static int | |
3ac237f8 | 4485 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4486 | { |
52dc7ee6 | 4487 | struct listnode *node; |
1eb8ef25 | 4488 | struct ospf_interface *oi; |
3ac237f8 MS |
4489 | json_object *json = NULL; |
4490 | ||
4491 | if (use_json) | |
4492 | json = json_object_new_object(); | |
718e3744 | 4493 | |
7c8ff89e | 4494 | if (ospf->instance) |
3ac237f8 MS |
4495 | { |
4496 | if (use_json) | |
4497 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4498 | else | |
4499 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4500 | VTY_NEWLINE, VTY_NEWLINE); | |
4501 | } | |
718e3744 | 4502 | |
1eb8ef25 | 4503 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4504 | { |
718e3744 | 4505 | struct route_node *rn; |
4506 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4507 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4508 | |
4509 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4510 | if ((nbr = rn->info)) | |
4511 | if (nbr != oi->nbr_self) | |
a452df33 | 4512 | if (nbr->state != NSM_Down) |
3ac237f8 | 4513 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4514 | |
4515 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4516 | { |
4517 | struct listnode *nd; | |
718e3744 | 4518 | |
3ac237f8 MS |
4519 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4520 | { | |
4521 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4522 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4523 | } | |
4524 | } | |
4525 | } | |
4526 | ||
4527 | if (use_json) | |
4528 | { | |
2aac5767 | 4529 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4530 | json_object_free(json); |
4531 | } | |
4532 | else | |
4533 | { | |
4534 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4535 | } |
4536 | ||
4537 | return CMD_SUCCESS; | |
4538 | } | |
4539 | ||
7c8ff89e DS |
4540 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4541 | show_ip_ospf_neighbor_detail_all_cmd, | |
b162fa78 | 4542 | "show ip ospf neighbor detail all [json]", |
718e3744 | 4543 | SHOW_STR |
4544 | IP_STR | |
4545 | "OSPF information\n" | |
4546 | "Neighbor list\n" | |
7c8ff89e | 4547 | "detail of all neighbors\n" |
3ac237f8 | 4548 | "include down status neighbor\n" |
9973d184 | 4549 | JSON_STR) |
718e3744 | 4550 | { |
020709f9 | 4551 | struct ospf *ospf; |
db7c8528 | 4552 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4553 | |
0bad4851 | 4554 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4555 | return CMD_SUCCESS; |
4556 | ||
db7c8528 | 4557 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4558 | } |
4559 | ||
4560 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4561 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
6147e2c6 | 4562 | "show ip ospf (1-65535) neighbor detail all [json]", |
7c8ff89e DS |
4563 | SHOW_STR |
4564 | IP_STR | |
4565 | "OSPF information\n" | |
4566 | "Instance ID\n" | |
4567 | "Neighbor list\n" | |
4568 | "detail of all neighbors\n" | |
3ac237f8 | 4569 | "include down status neighbor\n" |
9973d184 | 4570 | JSON_STR) |
7c8ff89e | 4571 | { |
8d769265 | 4572 | int idx_number = 3; |
7c8ff89e DS |
4573 | struct ospf *ospf; |
4574 | u_short instance = 0; | |
db7c8528 | 4575 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4576 | |
8d769265 | 4577 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4578 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4579 | return CMD_SUCCESS; |
4580 | ||
db7c8528 | 4581 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4582 | } |
4583 | ||
4584 | static int | |
4585 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 4586 | int arg_base, struct cmd_token **argv, u_char use_json) |
7c8ff89e | 4587 | { |
718e3744 | 4588 | struct ospf_interface *oi; |
bb5b7552 | 4589 | struct interface *ifp; |
4590 | struct route_node *rn, *nrn; | |
4591 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4592 | json_object *json = NULL; |
4593 | ||
4594 | if (use_json) | |
4595 | json = json_object_new_object(); | |
bb5b7552 | 4596 | |
7c8ff89e | 4597 | if (ospf->instance) |
3ac237f8 MS |
4598 | { |
4599 | if (use_json) | |
4600 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4601 | else | |
4602 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
4603 | VTY_NEWLINE, VTY_NEWLINE); | |
4604 | } | |
7c8ff89e | 4605 | |
1306c09a | 4606 | ifp = if_lookup_by_name (argv[arg_base]->arg, VRF_DEFAULT); |
bb5b7552 | 4607 | if (!ifp) |
718e3744 | 4608 | { |
3ac237f8 MS |
4609 | if (!use_json) |
4610 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); | |
718e3744 | 4611 | return CMD_WARNING; |
4612 | } | |
4613 | ||
bb5b7552 | 4614 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
4615 | { |
4616 | if ((oi = rn->info)) | |
4617 | { | |
4618 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
4619 | { | |
4620 | if ((nbr = nrn->info)) | |
4621 | { | |
4622 | if (nbr != oi->nbr_self) | |
4623 | { | |
4624 | if (nbr->state != NSM_Down) | |
4625 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4626 | } | |
4627 | } | |
4628 | } | |
4629 | } | |
4630 | } | |
4631 | ||
4632 | if (use_json) | |
4633 | { | |
2aac5767 | 4634 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
3ac237f8 MS |
4635 | json_object_free(json); |
4636 | } | |
4637 | else | |
4638 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 4639 | |
4640 | return CMD_SUCCESS; | |
4641 | } | |
4642 | ||
7c8ff89e DS |
4643 | DEFUN (show_ip_ospf_neighbor_int_detail, |
4644 | show_ip_ospf_neighbor_int_detail_cmd, | |
b162fa78 | 4645 | "show ip ospf neighbor IFNAME detail [json]", |
7c8ff89e DS |
4646 | SHOW_STR |
4647 | IP_STR | |
4648 | "OSPF information\n" | |
4649 | "Neighbor list\n" | |
4650 | "Interface name\n" | |
3ac237f8 | 4651 | "detail of all neighbors\n" |
9973d184 | 4652 | JSON_STR) |
7c8ff89e DS |
4653 | { |
4654 | struct ospf *ospf; | |
db7c8528 | 4655 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4656 | |
0bad4851 | 4657 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4658 | return CMD_SUCCESS; |
4659 | ||
db7c8528 | 4660 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4661 | } |
4662 | ||
4663 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
4664 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
6147e2c6 | 4665 | "show ip ospf (1-65535) neighbor IFNAME detail [json]", |
7c8ff89e DS |
4666 | SHOW_STR |
4667 | IP_STR | |
4668 | "OSPF information\n" | |
4669 | "Instance ID\n" | |
4670 | "Neighbor list\n" | |
4671 | "Interface name\n" | |
3ac237f8 | 4672 | "detail of all neighbors\n" |
9973d184 | 4673 | JSON_STR) |
7c8ff89e | 4674 | { |
8d769265 | 4675 | int idx_number = 3; |
7c8ff89e DS |
4676 | struct ospf *ospf; |
4677 | u_short instance = 0; | |
db7c8528 | 4678 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4679 | |
8d769265 | 4680 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 4681 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4682 | return CMD_SUCCESS; |
4683 | ||
db7c8528 | 4684 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); |
7c8ff89e | 4685 | } |
6b0655a2 | 4686 | |
718e3744 | 4687 | /* Show functions */ |
4dadc291 | 4688 | static int |
020709f9 | 4689 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 4690 | { |
718e3744 | 4691 | struct router_lsa *rl; |
4692 | struct summary_lsa *sl; | |
4693 | struct as_external_lsa *asel; | |
4694 | struct prefix_ipv4 p; | |
4695 | ||
4696 | if (lsa != NULL) | |
4697 | /* If self option is set, check LSA self flag. */ | |
4698 | if (self == 0 || IS_LSA_SELF (lsa)) | |
4699 | { | |
4700 | /* LSA common part show. */ | |
4701 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
4702 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
4703 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
4704 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
4705 | /* LSA specific part show. */ | |
4706 | switch (lsa->data->type) | |
4707 | { | |
4708 | case OSPF_ROUTER_LSA: | |
4709 | rl = (struct router_lsa *) lsa->data; | |
4710 | vty_out (vty, " %-d", ntohs (rl->links)); | |
4711 | break; | |
4712 | case OSPF_SUMMARY_LSA: | |
4713 | sl = (struct summary_lsa *) lsa->data; | |
4714 | ||
4715 | p.family = AF_INET; | |
4716 | p.prefix = sl->header.id; | |
4717 | p.prefixlen = ip_masklen (sl->mask); | |
4718 | apply_mask_ipv4 (&p); | |
4719 | ||
4720 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
4721 | break; | |
4722 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 4723 | case OSPF_AS_NSSA_LSA: |
718e3744 | 4724 | asel = (struct as_external_lsa *) lsa->data; |
4725 | ||
4726 | p.family = AF_INET; | |
4727 | p.prefix = asel->header.id; | |
4728 | p.prefixlen = ip_masklen (asel->mask); | |
4729 | apply_mask_ipv4 (&p); | |
4730 | ||
4731 | vty_out (vty, " %s %s/%d [0x%lx]", | |
4732 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
4733 | inet_ntoa (p.prefix), p.prefixlen, | |
4734 | (u_long)ntohl (asel->e[0].route_tag)); | |
4735 | break; | |
4736 | case OSPF_NETWORK_LSA: | |
4737 | case OSPF_ASBR_SUMMARY_LSA: | |
718e3744 | 4738 | case OSPF_OPAQUE_LINK_LSA: |
4739 | case OSPF_OPAQUE_AREA_LSA: | |
4740 | case OSPF_OPAQUE_AS_LSA: | |
718e3744 | 4741 | default: |
4742 | break; | |
4743 | } | |
4744 | vty_out (vty, VTY_NEWLINE); | |
4745 | } | |
4746 | ||
4747 | return 0; | |
4748 | } | |
4749 | ||
8b6a15b2 | 4750 | static const char *show_database_desc[] = |
718e3744 | 4751 | { |
4752 | "unknown", | |
4753 | "Router Link States", | |
4754 | "Net Link States", | |
4755 | "Summary Link States", | |
4756 | "ASBR-Summary Link States", | |
4757 | "AS External Link States", | |
718e3744 | 4758 | "Group Membership LSA", |
4759 | "NSSA-external Link States", | |
718e3744 | 4760 | "Type-8 LSA", |
4761 | "Link-Local Opaque-LSA", | |
4762 | "Area-Local Opaque-LSA", | |
4763 | "AS-external Opaque-LSA", | |
718e3744 | 4764 | }; |
4765 | ||
8b6a15b2 | 4766 | static const char *show_database_header[] = |
718e3744 | 4767 | { |
4768 | "", | |
4769 | "Link ID ADV Router Age Seq# CkSum Link count", | |
4770 | "Link ID ADV Router Age Seq# CkSum", | |
4771 | "Link ID ADV Router Age Seq# CkSum Route", | |
4772 | "Link ID ADV Router Age Seq# CkSum", | |
4773 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4774 | " --- header for Group Member ----", |
4775 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4776 | " --- type-8 ---", |
4777 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4778 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4779 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
718e3744 | 4780 | }; |
4781 | ||
4dadc291 | 4782 | static void |
718e3744 | 4783 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
4784 | { | |
4785 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 4786 | |
718e3744 | 4787 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
4957f494 | 4788 | vty_out (vty, " Options: 0x%-2x : %s%s", |
4789 | lsa->data->options, | |
4790 | ospf_options_dump(lsa->data->options), | |
4791 | VTY_NEWLINE); | |
4792 | vty_out (vty, " LS Flags: 0x%-2x %s%s", | |
9d526037 | 4793 | lsa->flags, |
4957f494 | 4794 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
4795 | VTY_NEWLINE); | |
718e3744 | 4796 | |
4797 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
4798 | { | |
4799 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
4800 | ||
4801 | if (rlsa->flags) | |
4802 | vty_out (vty, " :%s%s%s%s", | |
4803 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
4804 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
4805 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
4806 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
4807 | ||
4808 | vty_out (vty, "%s", VTY_NEWLINE); | |
4809 | } | |
4810 | vty_out (vty, " LS Type: %s%s", | |
4811 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); | |
4812 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), | |
4813 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); | |
4814 | vty_out (vty, " Advertising Router: %s%s", | |
4815 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
4816 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), | |
4817 | VTY_NEWLINE); | |
4818 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), | |
4819 | VTY_NEWLINE); | |
4820 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); | |
4821 | } | |
4822 | ||
eb1ce605 | 4823 | const char *link_type_desc[] = |
718e3744 | 4824 | { |
4825 | "(null)", | |
4826 | "another Router (point-to-point)", | |
4827 | "a Transit Network", | |
4828 | "Stub Network", | |
4829 | "a Virtual Link", | |
4830 | }; | |
4831 | ||
eb1ce605 | 4832 | const char *link_id_desc[] = |
718e3744 | 4833 | { |
4834 | "(null)", | |
4835 | "Neighboring Router ID", | |
4836 | "Designated Router address", | |
68980084 | 4837 | "Net", |
718e3744 | 4838 | "Neighboring Router ID", |
4839 | }; | |
4840 | ||
eb1ce605 | 4841 | const char *link_data_desc[] = |
718e3744 | 4842 | { |
4843 | "(null)", | |
4844 | "Router Interface address", | |
4845 | "Router Interface address", | |
4846 | "Network Mask", | |
4847 | "Router Interface address", | |
4848 | }; | |
4849 | ||
4850 | /* Show router-LSA each Link information. */ | |
4dadc291 | 4851 | static void |
718e3744 | 4852 | show_ip_ospf_database_router_links (struct vty *vty, |
4853 | struct router_lsa *rl) | |
4854 | { | |
b07c4cb3 DS |
4855 | int len, type; |
4856 | unsigned int i; | |
718e3744 | 4857 | |
4858 | len = ntohs (rl->header.length) - 4; | |
4859 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
4860 | { | |
4861 | type = rl->link[i].type; | |
4862 | ||
4863 | vty_out (vty, " Link connected to: %s%s", | |
4864 | link_type_desc[type], VTY_NEWLINE); | |
4865 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], | |
4866 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); | |
4867 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], | |
4868 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); | |
4869 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); | |
4870 | vty_out (vty, " TOS 0 Metric: %d%s", | |
4871 | ntohs (rl->link[i].metric), VTY_NEWLINE); | |
4872 | vty_out (vty, "%s", VTY_NEWLINE); | |
4873 | } | |
4874 | } | |
4875 | ||
4876 | /* Show router-LSA detail information. */ | |
4dadc291 | 4877 | static int |
718e3744 | 4878 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4879 | { | |
4880 | if (lsa != NULL) | |
4881 | { | |
4882 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
4883 | ||
4884 | show_ip_ospf_database_header (vty, lsa); | |
4885 | ||
4886 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
4887 | VTY_NEWLINE, VTY_NEWLINE); | |
4888 | ||
4889 | show_ip_ospf_database_router_links (vty, rl); | |
b0a053be | 4890 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 4891 | } |
4892 | ||
4893 | return 0; | |
4894 | } | |
4895 | ||
4896 | /* Show network-LSA detail information. */ | |
4dadc291 | 4897 | static int |
718e3744 | 4898 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4899 | { | |
4900 | int length, i; | |
4901 | ||
4902 | if (lsa != NULL) | |
4903 | { | |
4904 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
4905 | ||
4906 | show_ip_ospf_database_header (vty, lsa); | |
4907 | ||
4908 | vty_out (vty, " Network Mask: /%d%s", | |
4909 | ip_masklen (nl->mask), VTY_NEWLINE); | |
4910 | ||
4911 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
4912 | ||
4913 | for (i = 0; length > 0; i++, length -= 4) | |
4914 | vty_out (vty, " Attached Router: %s%s", | |
4915 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); | |
4916 | ||
4917 | vty_out (vty, "%s", VTY_NEWLINE); | |
4918 | } | |
4919 | ||
4920 | return 0; | |
4921 | } | |
4922 | ||
4923 | /* Show summary-LSA detail information. */ | |
4dadc291 | 4924 | static int |
718e3744 | 4925 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4926 | { | |
4927 | if (lsa != NULL) | |
4928 | { | |
4929 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
4930 | ||
4931 | show_ip_ospf_database_header (vty, lsa); | |
4932 | ||
4933 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
4934 | VTY_NEWLINE); | |
4935 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
4936 | VTY_NEWLINE); | |
b0a053be | 4937 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 4938 | } |
4939 | ||
4940 | return 0; | |
4941 | } | |
4942 | ||
4943 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 4944 | static int |
718e3744 | 4945 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4946 | { | |
4947 | if (lsa != NULL) | |
4948 | { | |
4949 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
4950 | ||
4951 | show_ip_ospf_database_header (vty, lsa); | |
4952 | ||
4953 | vty_out (vty, " Network Mask: /%d%s", | |
4954 | ip_masklen (sl->mask), VTY_NEWLINE); | |
4955 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), | |
4956 | VTY_NEWLINE); | |
b0a053be | 4957 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 4958 | } |
4959 | ||
4960 | return 0; | |
4961 | } | |
4962 | ||
4963 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 4964 | static int |
718e3744 | 4965 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4966 | { | |
4967 | if (lsa != NULL) | |
4968 | { | |
4969 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4970 | ||
4971 | show_ip_ospf_database_header (vty, lsa); | |
4972 | ||
4973 | vty_out (vty, " Network Mask: /%d%s", | |
4974 | ip_masklen (al->mask), VTY_NEWLINE); | |
4975 | vty_out (vty, " Metric Type: %s%s", | |
4976 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
4977 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
4978 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
4979 | vty_out (vty, " Metric: %d%s", | |
4980 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
4981 | vty_out (vty, " Forward Address: %s%s", | |
4982 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
4983 | ||
dc9ffce8 CF |
4984 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
4985 | (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 4986 | } |
4987 | ||
4988 | return 0; | |
4989 | } | |
075e12f5 | 4990 | #if 0 |
4dadc291 | 4991 | static int |
718e3744 | 4992 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
4993 | { | |
4994 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4995 | ||
4996 | /* show_ip_ospf_database_header (vty, lsa); */ | |
4997 | ||
2a42e285 | 4998 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 4999 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5000 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5001 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5002 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5003 | zlog_debug( " TOS: 0%s", "\n"); |
5004 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5005 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5006 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5007 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5008 | ||
dc9ffce8 CF |
5009 | zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5010 | (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n"); | |
718e3744 | 5011 | |
5012 | return 0; | |
5013 | } | |
075e12f5 | 5014 | #endif |
718e3744 | 5015 | /* Show AS-NSSA-LSA detail information. */ |
4dadc291 | 5016 | static int |
718e3744 | 5017 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5018 | { | |
5019 | if (lsa != NULL) | |
5020 | { | |
5021 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5022 | ||
5023 | show_ip_ospf_database_header (vty, lsa); | |
5024 | ||
5025 | vty_out (vty, " Network Mask: /%d%s", | |
5026 | ip_masklen (al->mask), VTY_NEWLINE); | |
5027 | vty_out (vty, " Metric Type: %s%s", | |
5028 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
5029 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); | |
5030 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); | |
5031 | vty_out (vty, " Metric: %d%s", | |
5032 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); | |
5033 | vty_out (vty, " NSSA: Forward Address: %s%s", | |
5034 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); | |
5035 | ||
dc9ffce8 CF |
5036 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5037 | (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 5038 | } |
5039 | ||
5040 | return 0; | |
5041 | } | |
5042 | ||
4dadc291 | 5043 | static int |
718e3744 | 5044 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5045 | { | |
5046 | return 0; | |
5047 | } | |
5048 | ||
4dadc291 | 5049 | static int |
718e3744 | 5050 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5051 | { | |
5052 | if (lsa != NULL) | |
5053 | { | |
5054 | show_ip_ospf_database_header (vty, lsa); | |
5055 | show_opaque_info_detail (vty, lsa); | |
5056 | ||
5057 | vty_out (vty, "%s", VTY_NEWLINE); | |
5058 | } | |
5059 | return 0; | |
5060 | } | |
718e3744 | 5061 | |
5062 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5063 | { | |
5064 | NULL, | |
5065 | show_router_lsa_detail, | |
5066 | show_network_lsa_detail, | |
5067 | show_summary_lsa_detail, | |
5068 | show_summary_asbr_lsa_detail, | |
5069 | show_as_external_lsa_detail, | |
718e3744 | 5070 | show_func_dummy, |
5071 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5072 | NULL, /* type-8 */ |
5073 | show_opaque_lsa_detail, | |
5074 | show_opaque_lsa_detail, | |
5075 | show_opaque_lsa_detail, | |
718e3744 | 5076 | }; |
5077 | ||
4dadc291 | 5078 | static void |
718e3744 | 5079 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5080 | struct in_addr *adv_router) | |
5081 | { | |
5082 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5083 | lp->family = 0; | |
5084 | if (id == NULL) | |
5085 | lp->prefixlen = 0; | |
5086 | else if (adv_router == NULL) | |
5087 | { | |
5088 | lp->prefixlen = 32; | |
5089 | lp->id = *id; | |
5090 | } | |
5091 | else | |
5092 | { | |
5093 | lp->prefixlen = 64; | |
5094 | lp->id = *id; | |
5095 | lp->adv_router = *adv_router; | |
5096 | } | |
5097 | } | |
5098 | ||
4dadc291 | 5099 | static void |
718e3744 | 5100 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5101 | struct in_addr *id, struct in_addr *adv_router) | |
5102 | { | |
5103 | struct prefix_ls lp; | |
5104 | struct route_node *rn, *start; | |
5105 | struct ospf_lsa *lsa; | |
5106 | ||
5107 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5108 | start = route_node_get (rt, (struct prefix *) &lp); | |
5109 | if (start) | |
5110 | { | |
5111 | route_lock_node (start); | |
5112 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5113 | if ((lsa = rn->info)) | |
5114 | { | |
718e3744 | 5115 | if (show_function[lsa->data->type] != NULL) |
5116 | show_function[lsa->data->type] (vty, lsa); | |
5117 | } | |
5118 | route_unlock_node (start); | |
5119 | } | |
5120 | } | |
5121 | ||
5122 | /* Show detail LSA information | |
5123 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5124 | static void |
020709f9 | 5125 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5126 | struct in_addr *id, struct in_addr *adv_router) |
5127 | { | |
52dc7ee6 | 5128 | struct listnode *node; |
1eb8ef25 | 5129 | struct ospf_area *area; |
5130 | ||
718e3744 | 5131 | switch (type) |
5132 | { | |
5133 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5134 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5135 | vty_out (vty, " %s %s%s", |
5136 | show_database_desc[type], | |
5137 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5138 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5139 | break; |
5140 | default: | |
1eb8ef25 | 5141 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5142 | { |
718e3744 | 5143 | vty_out (vty, "%s %s (Area %s)%s%s", |
5144 | VTY_NEWLINE, show_database_desc[type], | |
5145 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5146 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); | |
5147 | } | |
5148 | break; | |
5149 | } | |
5150 | } | |
5151 | ||
4dadc291 | 5152 | static void |
718e3744 | 5153 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5154 | struct in_addr *adv_router) | |
5155 | { | |
5156 | struct route_node *rn; | |
5157 | struct ospf_lsa *lsa; | |
5158 | ||
5159 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5160 | if ((lsa = rn->info)) | |
5161 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5162 | { | |
718e3744 | 5163 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5164 | continue; | |
718e3744 | 5165 | if (show_function[lsa->data->type] != NULL) |
5166 | show_function[lsa->data->type] (vty, lsa); | |
5167 | } | |
5168 | } | |
5169 | ||
5170 | /* Show detail LSA information. */ | |
4dadc291 | 5171 | static void |
020709f9 | 5172 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5173 | struct in_addr *adv_router) |
5174 | { | |
52dc7ee6 | 5175 | struct listnode *node; |
1eb8ef25 | 5176 | struct ospf_area *area; |
718e3744 | 5177 | |
5178 | switch (type) | |
5179 | { | |
5180 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5181 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5182 | vty_out (vty, " %s %s%s", |
5183 | show_database_desc[type], | |
5184 | VTY_NEWLINE, VTY_NEWLINE); | |
68980084 | 5185 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5186 | adv_router); |
5187 | break; | |
5188 | default: | |
1eb8ef25 | 5189 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5190 | { |
718e3744 | 5191 | vty_out (vty, "%s %s (Area %s)%s%s", |
5192 | VTY_NEWLINE, show_database_desc[type], | |
5193 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); | |
5194 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), | |
5195 | adv_router); | |
5196 | } | |
5197 | break; | |
5198 | } | |
5199 | } | |
5200 | ||
4dadc291 | 5201 | static void |
020709f9 | 5202 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5203 | { |
020709f9 | 5204 | struct ospf_lsa *lsa; |
5205 | struct route_node *rn; | |
1eb8ef25 | 5206 | struct ospf_area *area; |
52dc7ee6 | 5207 | struct listnode *node; |
718e3744 | 5208 | int type; |
5209 | ||
1eb8ef25 | 5210 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5211 | { |
718e3744 | 5212 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5213 | { | |
5214 | switch (type) | |
5215 | { | |
5216 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5217 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5218 | continue; |
5219 | default: | |
5220 | break; | |
5221 | } | |
5222 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5223 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5224 | { | |
5225 | vty_out (vty, " %s (Area %s)%s%s", | |
5226 | show_database_desc[type], | |
5227 | ospf_area_desc_string (area), | |
5228 | VTY_NEWLINE, VTY_NEWLINE); | |
5229 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); | |
5230 | ||
020709f9 | 5231 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5232 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5233 | |
5234 | vty_out (vty, "%s", VTY_NEWLINE); | |
5235 | } | |
5236 | } | |
5237 | } | |
5238 | ||
5239 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5240 | { | |
5241 | switch (type) | |
5242 | { | |
5243 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5244 | case OSPF_OPAQUE_AS_LSA: |
e8e1946e | 5245 | break; |
718e3744 | 5246 | default: |
5247 | continue; | |
5248 | } | |
68980084 | 5249 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5250 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5251 | { |
5252 | vty_out (vty, " %s%s%s", | |
5253 | show_database_desc[type], | |
5254 | VTY_NEWLINE, VTY_NEWLINE); | |
5255 | vty_out (vty, "%s%s", show_database_header[type], | |
5256 | VTY_NEWLINE); | |
020709f9 | 5257 | |
5258 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5259 | show_lsa_summary (vty, lsa, self); | |
5260 | ||
718e3744 | 5261 | vty_out (vty, "%s", VTY_NEWLINE); |
5262 | } | |
5263 | } | |
5264 | ||
5265 | vty_out (vty, "%s", VTY_NEWLINE); | |
5266 | } | |
5267 | ||
4dadc291 | 5268 | static void |
020709f9 | 5269 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5270 | { |
91e6a0e5 | 5271 | struct route_node *rn; |
718e3744 | 5272 | |
5273 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
5274 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
5275 | ||
91e6a0e5 | 5276 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5277 | { |
91e6a0e5 DD |
5278 | struct ospf_lsa *lsa; |
5279 | ||
5280 | if ((lsa = rn->info) != NULL) | |
5281 | { | |
5282 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); | |
5283 | vty_out (vty, "Link State ID: %s%s", | |
5284 | inet_ntoa (lsa->data->id), VTY_NEWLINE); | |
5285 | vty_out (vty, "Advertising Router: %s%s", | |
5286 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); | |
5287 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); | |
5288 | vty_out (vty, "%s", VTY_NEWLINE); | |
5289 | } | |
1eb8ef25 | 5290 | } |
718e3744 | 5291 | } |
5292 | ||
718e3744 | 5293 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5294 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5295 | |
718e3744 | 5296 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
5297 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
5298 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
5299 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
718e3744 | 5300 | |
718e3744 | 5301 | #define OSPF_LSA_TYPES_DESC \ |
5302 | "ASBR summary link states\n" \ | |
5303 | "External link states\n" \ | |
5304 | "Network link states\n" \ | |
5305 | "Router link states\n" \ | |
5306 | "Network summary link states\n" \ | |
5307 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5308 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5309 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5310 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5311 | ||
7c8ff89e DS |
5312 | static int |
5313 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 5314 | int arg_base, int argc, struct cmd_token **argv) |
718e3744 | 5315 | { |
7a7be519 | 5316 | int idx_type = 4; |
718e3744 | 5317 | int type, ret; |
5318 | struct in_addr id, adv_router; | |
5319 | ||
7c8ff89e DS |
5320 | if (ospf->instance) |
5321 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5322 | VTY_NEWLINE); | |
718e3744 | 5323 | |
5324 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5325 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5326 | |
5327 | /* Show all LSA. */ | |
7a7be519 | 5328 | if (argc == arg_base + 4) |
718e3744 | 5329 | { |
020709f9 | 5330 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5331 | return CMD_SUCCESS; |
5332 | } | |
5333 | ||
5334 | /* Set database type to show. */ | |
7a7be519 | 5335 | if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) |
718e3744 | 5336 | type = OSPF_ROUTER_LSA; |
7a7be519 | 5337 | else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) |
718e3744 | 5338 | type = OSPF_NETWORK_LSA; |
7a7be519 | 5339 | else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) |
718e3744 | 5340 | type = OSPF_AS_NSSA_LSA; |
7a7be519 | 5341 | else if (strncmp (argv[arg_base + idx_type]->text, "su", 2) == 0) |
718e3744 | 5342 | type = OSPF_SUMMARY_LSA; |
7a7be519 | 5343 | else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) |
718e3744 | 5344 | type = OSPF_ASBR_SUMMARY_LSA; |
7a7be519 | 5345 | else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) |
718e3744 | 5346 | type = OSPF_AS_EXTERNAL_LSA; |
7a7be519 | 5347 | else if (strncmp (argv[arg_base + idx_type]->text, "se", 2) == 0) |
718e3744 | 5348 | { |
020709f9 | 5349 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5350 | return CMD_SUCCESS; |
5351 | } | |
7a7be519 | 5352 | else if (strncmp (argv[arg_base + idx_type]->text, "m", 1) == 0) |
718e3744 | 5353 | { |
020709f9 | 5354 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5355 | return CMD_SUCCESS; |
5356 | } | |
7a7be519 | 5357 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) |
718e3744 | 5358 | type = OSPF_OPAQUE_LINK_LSA; |
7a7be519 | 5359 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) |
718e3744 | 5360 | type = OSPF_OPAQUE_AREA_LSA; |
7a7be519 | 5361 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) |
718e3744 | 5362 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5363 | else |
5364 | return CMD_WARNING; | |
5365 | ||
5366 | /* `show ip ospf database LSA'. */ | |
7a7be519 | 5367 | if (argc == arg_base + 5) |
020709f9 | 5368 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7a7be519 | 5369 | else if (argc >= arg_base + 6) |
718e3744 | 5370 | { |
7a7be519 | 5371 | ret = inet_aton (argv[arg_base + 5]->arg, &id); |
718e3744 | 5372 | if (!ret) |
5373 | return CMD_WARNING; | |
5374 | ||
5375 | /* `show ip ospf database LSA ID'. */ | |
7a7be519 | 5376 | if (argc == arg_base + 6) |
020709f9 | 5377 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5378 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7a7be519 | 5379 | else if (argc == arg_base + 7) |
718e3744 | 5380 | { |
7a7be519 | 5381 | if (strncmp (argv[arg_base + 6]->text, "s", 1) == 0) |
68980084 | 5382 | adv_router = ospf->router_id; |
718e3744 | 5383 | else |
5384 | { | |
7a7be519 | 5385 | ret = inet_aton (argv[arg_base + 7]->arg, &adv_router); |
718e3744 | 5386 | if (!ret) |
5387 | return CMD_WARNING; | |
5388 | } | |
020709f9 | 5389 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5390 | } |
5391 | } | |
5392 | ||
5393 | return CMD_SUCCESS; | |
5394 | } | |
5395 | ||
7a7be519 | 5396 | DEFUN (show_ip_ospf_database_max, |
5397 | show_ip_ospf_database_max_cmd, | |
5398 | "show ip ospf database <max-age|self-originate>", | |
5399 | SHOW_STR | |
5400 | IP_STR | |
5401 | "OSPF information\n" | |
5402 | "Database summary\n" | |
5403 | "LSAs in MaxAge list\n" | |
5404 | "Self-originated link states\n") | |
5405 | { | |
5406 | struct ospf *ospf; | |
f412b39a | 5407 | |
7a7be519 | 5408 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
5409 | return CMD_SUCCESS; | |
f412b39a | 5410 | |
7a7be519 | 5411 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); |
5412 | } | |
f412b39a | 5413 | |
f412b39a DW |
5414 | DEFUN (show_ip_ospf_instance_database, |
5415 | show_ip_ospf_instance_database_cmd, | |
3a2d747c | 5416 | "show ip ospf [(1-65535)] database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]", |
718e3744 | 5417 | SHOW_STR |
5418 | IP_STR | |
5419 | "OSPF information\n" | |
7c8ff89e | 5420 | "Instance ID\n" |
7a7be519 | 5421 | "Database summary\n" |
5422 | OSPF_LSA_TYPES_DESC | |
5423 | "Link State ID (as an IP address)\n" | |
5424 | "Self-originated link states\n" | |
5425 | "Advertising Router link states\n" | |
5426 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
5427 | { |
5428 | struct ospf *ospf; | |
5429 | u_short instance = 0; | |
5430 | ||
3a2d747c QY |
5431 | int idx = 0; |
5432 | if (argv_find (argv, argc, "(1-65535)", &idx)) | |
5433 | { | |
5434 | VTY_GET_INTEGER ("Instance", instance, argv[idx]->arg); | |
5435 | ospf = ospf_lookup_instance (instance); | |
5436 | } | |
5437 | else { | |
5438 | ospf = ospf_lookup(); | |
5439 | } | |
7c8ff89e | 5440 | |
3a2d747c | 5441 | if (!ospf || !ospf->oi_running) |
7c8ff89e DS |
5442 | return CMD_SUCCESS; |
5443 | ||
3a2d747c | 5444 | return (show_ip_ospf_database_common(vty, ospf, idx ? 1 : 0, argc, argv)); |
7c8ff89e DS |
5445 | } |
5446 | ||
7a7be519 | 5447 | DEFUN (show_ip_ospf_instance_database_max, |
5448 | show_ip_ospf_instance_database_max_cmd, | |
5449 | "show ip ospf (1-65535) database <max-age|self-originate>", | |
5450 | SHOW_STR | |
5451 | IP_STR | |
5452 | "OSPF information\n" | |
5453 | "Instance ID\n" | |
5454 | "Database summary\n" | |
5455 | "LSAs in MaxAge list\n" | |
5456 | "Self-originated link states\n") | |
5457 | { | |
5458 | int idx_number = 3; | |
5459 | struct ospf *ospf; | |
5460 | u_short instance = 0; | |
7c8ff89e | 5461 | |
7a7be519 | 5462 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
7c8ff89e | 5463 | |
7a7be519 | 5464 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
5465 | return CMD_SUCCESS; | |
7c8ff89e | 5466 | |
7a7be519 | 5467 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); |
5468 | } | |
7c8ff89e DS |
5469 | |
5470 | ||
5471 | static int | |
5472 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 5473 | int arg_base, int argc, struct cmd_token **argv) |
718e3744 | 5474 | { |
7a7be519 | 5475 | int idx_type = 4; |
718e3744 | 5476 | int type, ret; |
5477 | struct in_addr adv_router; | |
5478 | ||
7c8ff89e DS |
5479 | if (ospf->instance) |
5480 | vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance, | |
5481 | VTY_NEWLINE); | |
718e3744 | 5482 | |
5483 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, | |
68980084 | 5484 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
718e3744 | 5485 | |
7a7be519 | 5486 | if (argc != arg_base + 7) |
718e3744 | 5487 | return CMD_WARNING; |
5488 | ||
5489 | /* Set database type to show. */ | |
7a7be519 | 5490 | if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) |
718e3744 | 5491 | type = OSPF_ROUTER_LSA; |
7a7be519 | 5492 | else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) |
718e3744 | 5493 | type = OSPF_NETWORK_LSA; |
7a7be519 | 5494 | else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) |
718e3744 | 5495 | type = OSPF_AS_NSSA_LSA; |
7a7be519 | 5496 | else if (strncmp (argv[arg_base + idx_type]->text, "s", 1) == 0) |
718e3744 | 5497 | type = OSPF_SUMMARY_LSA; |
7a7be519 | 5498 | else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) |
718e3744 | 5499 | type = OSPF_ASBR_SUMMARY_LSA; |
7a7be519 | 5500 | else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) |
718e3744 | 5501 | type = OSPF_AS_EXTERNAL_LSA; |
7a7be519 | 5502 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) |
718e3744 | 5503 | type = OSPF_OPAQUE_LINK_LSA; |
7a7be519 | 5504 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) |
718e3744 | 5505 | type = OSPF_OPAQUE_AREA_LSA; |
7a7be519 | 5506 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) |
718e3744 | 5507 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5508 | else |
5509 | return CMD_WARNING; | |
5510 | ||
7c8ff89e | 5511 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
7a7be519 | 5512 | if (strncmp (argv[arg_base + 5]->text, "s", 1) == 0) |
7c8ff89e DS |
5513 | adv_router = ospf->router_id; |
5514 | else | |
5515 | { | |
7a7be519 | 5516 | ret = inet_aton (argv[arg_base + 6]->arg, &adv_router); |
7c8ff89e DS |
5517 | if (!ret) |
5518 | return CMD_WARNING; | |
5519 | } | |
5520 | ||
5521 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5522 | ||
5523 | return CMD_SUCCESS; | |
5524 | } | |
5525 | ||
5526 | DEFUN (show_ip_ospf_database_type_adv_router, | |
5527 | show_ip_ospf_database_type_adv_router_cmd, | |
7a7be519 | 5528 | "show ip ospf database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", |
7c8ff89e DS |
5529 | SHOW_STR |
5530 | IP_STR | |
5531 | "OSPF information\n" | |
5532 | "Database summary\n" | |
5533 | OSPF_LSA_TYPES_DESC | |
5534 | "Advertising Router link states\n" | |
16cedbb0 QY |
5535 | "Advertising Router (as an IP address)\n" |
5536 | "Self-originated link states\n") | |
7c8ff89e DS |
5537 | { |
5538 | struct ospf *ospf; | |
5539 | ||
0bad4851 | 5540 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
5541 | return CMD_SUCCESS; |
5542 | ||
5543 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); | |
5544 | } | |
5545 | ||
7c8ff89e DS |
5546 | DEFUN (show_ip_ospf_instance_database_type_adv_router, |
5547 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
7a7be519 | 5548 | "show ip ospf (1-65535) database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", |
7c8ff89e DS |
5549 | SHOW_STR |
5550 | IP_STR | |
5551 | "OSPF information\n" | |
5552 | "Instance ID\n" | |
5553 | "Database summary\n" | |
5554 | OSPF_LSA_TYPES_DESC | |
5555 | "Advertising Router link states\n" | |
3a2d747c QY |
5556 | "Advertising Router (as an IP address)\n" |
5557 | "Self-originated link states\n") | |
7c8ff89e | 5558 | { |
8d769265 | 5559 | int idx_number = 3; |
7c8ff89e DS |
5560 | struct ospf *ospf; |
5561 | u_short instance = 0; | |
5562 | ||
8d769265 | 5563 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
718e3744 | 5564 | |
0bad4851 | 5565 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e | 5566 | return CMD_SUCCESS; |
718e3744 | 5567 | |
7c8ff89e | 5568 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); |
718e3744 | 5569 | } |
5570 | ||
718e3744 | 5571 | DEFUN (ip_ospf_authentication_args, |
5572 | ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 5573 | "ip ospf authentication <null|message-digest> [A.B.C.D]", |
718e3744 | 5574 | "IP Information\n" |
5575 | "OSPF interface commands\n" | |
5576 | "Enable authentication on this interface\n" | |
5577 | "Use null authentication\n" | |
5578 | "Use message-digest authentication\n" | |
7a7be519 | 5579 | "Address of interface\n") |
718e3744 | 5580 | { |
cdc2d765 | 5581 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 DW |
5582 | int idx_encryption = 3; |
5583 | int idx_ipv4 = 4; | |
718e3744 | 5584 | struct in_addr addr; |
5585 | int ret; | |
5586 | struct ospf_if_params *params; | |
5587 | ||
718e3744 | 5588 | params = IF_DEF_PARAMS (ifp); |
5589 | ||
7a7be519 | 5590 | if (argc == 5) |
718e3744 | 5591 | { |
8d769265 | 5592 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5593 | if (!ret) |
5594 | { | |
5595 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5596 | VTY_NEWLINE); | |
5597 | return CMD_WARNING; | |
5598 | } | |
5599 | ||
5600 | params = ospf_get_if_params (ifp, addr); | |
5601 | ospf_if_update_params (ifp, addr); | |
5602 | } | |
5603 | ||
5604 | /* Handle null authentication */ | |
8d769265 | 5605 | if ( argv[idx_encryption]->arg[0] == 'n' ) |
718e3744 | 5606 | { |
5607 | SET_IF_PARAM (params, auth_type); | |
5608 | params->auth_type = OSPF_AUTH_NULL; | |
5609 | return CMD_SUCCESS; | |
5610 | } | |
5611 | ||
5612 | /* Handle message-digest authentication */ | |
8d769265 | 5613 | if ( argv[idx_encryption]->arg[0] == 'm' ) |
718e3744 | 5614 | { |
5615 | SET_IF_PARAM (params, auth_type); | |
5616 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5617 | return CMD_SUCCESS; | |
5618 | } | |
5619 | ||
5620 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); | |
5621 | return CMD_WARNING; | |
5622 | } | |
5623 | ||
718e3744 | 5624 | DEFUN (ip_ospf_authentication, |
5625 | ip_ospf_authentication_addr_cmd, | |
7a7be519 | 5626 | "ip ospf authentication [A.B.C.D]", |
718e3744 | 5627 | "IP Information\n" |
5628 | "OSPF interface commands\n" | |
5629 | "Enable authentication on this interface\n" | |
5630 | "Address of interface") | |
5631 | { | |
cdc2d765 | 5632 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 5633 | int idx_ipv4 = 3; |
718e3744 | 5634 | struct in_addr addr; |
5635 | int ret; | |
5636 | struct ospf_if_params *params; | |
5637 | ||
718e3744 | 5638 | params = IF_DEF_PARAMS (ifp); |
5639 | ||
7a7be519 | 5640 | if (argc == 4) |
718e3744 | 5641 | { |
8d769265 | 5642 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5643 | if (!ret) |
5644 | { | |
5645 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5646 | VTY_NEWLINE); | |
5647 | return CMD_WARNING; | |
5648 | } | |
5649 | ||
5650 | params = ospf_get_if_params (ifp, addr); | |
5651 | ospf_if_update_params (ifp, addr); | |
5652 | } | |
5653 | ||
5654 | SET_IF_PARAM (params, auth_type); | |
5655 | params->auth_type = OSPF_AUTH_SIMPLE; | |
5656 | ||
5657 | return CMD_SUCCESS; | |
5658 | } | |
5659 | ||
b4a039bf DS |
5660 | DEFUN (no_ip_ospf_authentication_args, |
5661 | no_ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 5662 | "no ip ospf authentication <null|message-digest> [A.B.C.D]", |
b4a039bf DS |
5663 | NO_STR |
5664 | "IP Information\n" | |
5665 | "OSPF interface commands\n" | |
5666 | "Enable authentication on this interface\n" | |
5667 | "Use null authentication\n" | |
5668 | "Use message-digest authentication\n" | |
5669 | "Address of interface") | |
5670 | { | |
cdc2d765 | 5671 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 DW |
5672 | int idx_encryption = 4; |
5673 | int idx_ipv4 = 5; | |
b4a039bf DS |
5674 | struct in_addr addr; |
5675 | int ret; | |
5676 | struct ospf_if_params *params; | |
5677 | struct route_node *rn; | |
5678 | int auth_type; | |
5679 | ||
b4a039bf DS |
5680 | params = IF_DEF_PARAMS (ifp); |
5681 | ||
7a7be519 | 5682 | if (argc == 6) |
b4a039bf | 5683 | { |
8d769265 | 5684 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
b4a039bf DS |
5685 | if (!ret) |
5686 | { | |
5687 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5688 | VTY_NEWLINE); | |
5689 | return CMD_WARNING; | |
5690 | } | |
5691 | ||
5692 | params = ospf_lookup_if_params (ifp, addr); | |
5693 | if (params == NULL) | |
5694 | { | |
5695 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
5696 | return CMD_WARNING; | |
5697 | } | |
5698 | params->auth_type = OSPF_AUTH_NOTSET; | |
5699 | UNSET_IF_PARAM (params, auth_type); | |
5700 | if (params != IF_DEF_PARAMS (ifp)) | |
5701 | { | |
5702 | ospf_free_if_params (ifp, addr); | |
5703 | ospf_if_update_params (ifp, addr); | |
5704 | } | |
5705 | } | |
5706 | else | |
5707 | { | |
8d769265 | 5708 | if ( argv[idx_encryption]->arg[0] == 'n' ) |
b4a039bf DS |
5709 | { |
5710 | auth_type = OSPF_AUTH_NULL; | |
5711 | } | |
8d769265 | 5712 | else if ( argv[idx_encryption]->arg[0] == 'm' ) |
b4a039bf DS |
5713 | { |
5714 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5715 | } | |
5716 | else | |
5717 | { | |
5718 | vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE); | |
5719 | return CMD_WARNING; | |
5720 | } | |
5721 | /* | |
5722 | * Here we have a case where the user has entered | |
5723 | * 'no ip ospf authentication (null | message_digest )' | |
5724 | * we need to find if we have any ip addresses underneath it that | |
5725 | * correspond to the associated type. | |
5726 | */ | |
813d4307 DW |
5727 | if (params->auth_type == auth_type) |
5728 | { | |
5729 | params->auth_type = OSPF_AUTH_NOTSET; | |
5730 | UNSET_IF_PARAM (params, auth_type); | |
5731 | } | |
5732 | ||
b4a039bf DS |
5733 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
5734 | { | |
5735 | if ((params = rn->info)) | |
5736 | { | |
5737 | if (params->auth_type == auth_type) | |
5738 | { | |
5739 | params->auth_type = OSPF_AUTH_NOTSET; | |
5740 | UNSET_IF_PARAM (params, auth_type); | |
5741 | if (params != IF_DEF_PARAMS (ifp)) | |
5742 | { | |
5743 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
5744 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
5745 | } | |
5746 | } | |
5747 | } | |
5748 | } | |
5749 | } | |
5750 | ||
5751 | return CMD_SUCCESS; | |
5752 | } | |
5753 | ||
718e3744 | 5754 | DEFUN (no_ip_ospf_authentication, |
5755 | no_ip_ospf_authentication_addr_cmd, | |
7a7be519 | 5756 | "no ip ospf authentication [A.B.C.D]", |
718e3744 | 5757 | NO_STR |
5758 | "IP Information\n" | |
5759 | "OSPF interface commands\n" | |
5760 | "Enable authentication on this interface\n" | |
5761 | "Address of interface") | |
5762 | { | |
cdc2d765 | 5763 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 5764 | int idx_ipv4 = 4; |
718e3744 | 5765 | struct in_addr addr; |
5766 | int ret; | |
5767 | struct ospf_if_params *params; | |
b4a039bf DS |
5768 | struct route_node *rn; |
5769 | ||
718e3744 | 5770 | params = IF_DEF_PARAMS (ifp); |
5771 | ||
7a7be519 | 5772 | if (argc == 5) |
718e3744 | 5773 | { |
8d769265 | 5774 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5775 | if (!ret) |
5776 | { | |
5777 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5778 | VTY_NEWLINE); | |
5779 | return CMD_WARNING; | |
5780 | } | |
5781 | ||
5782 | params = ospf_lookup_if_params (ifp, addr); | |
5783 | if (params == NULL) | |
b4a039bf DS |
5784 | { |
5785 | vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE); | |
5786 | return CMD_WARNING; | |
5787 | } | |
718e3744 | 5788 | |
b4a039bf DS |
5789 | params->auth_type = OSPF_AUTH_NOTSET; |
5790 | UNSET_IF_PARAM (params, auth_type); | |
5791 | if (params != IF_DEF_PARAMS (ifp)) | |
5792 | { | |
5793 | ospf_free_if_params (ifp, addr); | |
5794 | ospf_if_update_params (ifp, addr); | |
5795 | } | |
5796 | } | |
5797 | else | |
718e3744 | 5798 | { |
b4a039bf DS |
5799 | /* |
5800 | * When a user enters 'no ip ospf authentication' | |
5801 | * We should remove all authentication types from | |
5802 | * the interface. | |
5803 | */ | |
813d4307 DW |
5804 | if ((params->auth_type == OSPF_AUTH_NULL) || |
5805 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
5806 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
5807 | { | |
5808 | params->auth_type = OSPF_AUTH_NOTSET; | |
5809 | UNSET_IF_PARAM (params, auth_type); | |
5810 | } | |
5811 | ||
b4a039bf DS |
5812 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
5813 | { | |
5814 | if ((params = rn->info)) | |
5815 | { | |
813d4307 | 5816 | |
b4a039bf DS |
5817 | if ((params->auth_type == OSPF_AUTH_NULL) || |
5818 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
5819 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
5820 | { | |
5821 | params->auth_type = OSPF_AUTH_NOTSET; | |
5822 | UNSET_IF_PARAM (params, auth_type); | |
5823 | if (params != IF_DEF_PARAMS (ifp)) | |
5824 | { | |
5825 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
5826 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
5827 | } | |
5828 | } | |
5829 | } | |
5830 | } | |
718e3744 | 5831 | } |
5832 | ||
5833 | return CMD_SUCCESS; | |
5834 | } | |
5835 | ||
0d829fa7 | 5836 | |
718e3744 | 5837 | DEFUN (ip_ospf_authentication_key, |
5838 | ip_ospf_authentication_key_addr_cmd, | |
7a7be519 | 5839 | "ip ospf authentication-key AUTH_KEY [A.B.C.D]", |
718e3744 | 5840 | "IP Information\n" |
5841 | "OSPF interface commands\n" | |
5842 | "Authentication password (key)\n" | |
5843 | "The OSPF password (key)\n" | |
5844 | "Address of interface") | |
5845 | { | |
cdc2d765 | 5846 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 5847 | int idx = 0; |
718e3744 | 5848 | struct in_addr addr; |
718e3744 | 5849 | struct ospf_if_params *params; |
5850 | ||
718e3744 | 5851 | params = IF_DEF_PARAMS (ifp); |
5852 | ||
0d829fa7 | 5853 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 5854 | { |
0d829fa7 | 5855 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 5856 | { |
5857 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5858 | VTY_NEWLINE); | |
5859 | return CMD_WARNING; | |
5860 | } | |
5861 | ||
5862 | params = ospf_get_if_params (ifp, addr); | |
5863 | ospf_if_update_params (ifp, addr); | |
5864 | } | |
5865 | ||
718e3744 | 5866 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
7a7be519 | 5867 | strncpy ((char *) params->auth_simple, argv[3]->arg, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 5868 | SET_IF_PARAM (params, auth_simple); |
5869 | ||
5870 | return CMD_SUCCESS; | |
5871 | } | |
5872 | ||
7a7be519 | 5873 | DEFUN_HIDDEN (ospf_authentication_key, |
747e489c | 5874 | ospf_authentication_key_cmd, |
0d829fa7 | 5875 | "ospf authentication-key AUTH_KEY [A.B.C.D]", |
747e489c DW |
5876 | "OSPF interface commands\n" |
5877 | "Authentication password (key)\n" | |
0d829fa7 QY |
5878 | "The OSPF password (key)\n" |
5879 | "Address of interface\n") | |
718e3744 | 5880 | { |
0d829fa7 | 5881 | return ip_ospf_authentication_key (self, vty, argc, argv); |
718e3744 | 5882 | } |
5883 | ||
7a7be519 | 5884 | DEFUN (no_ip_ospf_authentication_key, |
5885 | no_ip_ospf_authentication_key_authkey_addr_cmd, | |
5886 | "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
5887 | NO_STR | |
5888 | "IP Information\n" | |
5889 | "OSPF interface commands\n" | |
5890 | "Authentication password (key)\n" | |
5891 | "The OSPF password (key)") | |
5892 | { | |
cdc2d765 | 5893 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 5894 | int idx = 0; |
7a7be519 | 5895 | struct in_addr addr; |
5896 | struct ospf_if_params *params; | |
7a7be519 | 5897 | params = IF_DEF_PARAMS (ifp); |
5898 | ||
0d829fa7 | 5899 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 5900 | { |
0d829fa7 | 5901 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 5902 | { |
5903 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5904 | VTY_NEWLINE); | |
5905 | return CMD_WARNING; | |
5906 | } | |
813d4307 | 5907 | |
7a7be519 | 5908 | params = ospf_lookup_if_params (ifp, addr); |
5909 | if (params == NULL) | |
5910 | return CMD_SUCCESS; | |
5911 | } | |
718e3744 | 5912 | |
7a7be519 | 5913 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
5914 | UNSET_IF_PARAM (params, auth_simple); | |
718e3744 | 5915 | |
7a7be519 | 5916 | if (params != IF_DEF_PARAMS (ifp)) |
5917 | { | |
5918 | ospf_free_if_params (ifp, addr); | |
5919 | ospf_if_update_params (ifp, addr); | |
5920 | } | |
813d4307 | 5921 | |
7a7be519 | 5922 | return CMD_SUCCESS; |
5923 | } | |
813d4307 | 5924 | |
0d829fa7 QY |
5925 | DEFUN_HIDDEN (no_ospf_authentication_key, |
5926 | no_ospf_authentication_key_authkey_addr_cmd, | |
5927 | "no ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
5928 | NO_STR | |
5929 | "OSPF interface commands\n" | |
5930 | "Authentication password (key)\n" | |
5931 | "The OSPF password (key)") | |
5932 | { | |
5933 | return no_ip_ospf_authentication_key (self, vty, argc, argv); | |
5934 | } | |
5935 | ||
718e3744 | 5936 | DEFUN (ip_ospf_message_digest_key, |
537eae3f | 5937 | ip_ospf_message_digest_key_cmd, |
7a7be519 | 5938 | "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
718e3744 | 5939 | "IP Information\n" |
5940 | "OSPF interface commands\n" | |
5941 | "Message digest authentication password (key)\n" | |
5942 | "Key ID\n" | |
5943 | "Use MD5 algorithm\n" | |
fefa0d82 QY |
5944 | "The OSPF password (key)\n" |
5945 | "Address of interface\n") | |
718e3744 | 5946 | { |
cdc2d765 | 5947 | VTY_DECLVAR_CONTEXT(interface, ifp); |
718e3744 | 5948 | struct crypt_key *ck; |
5949 | u_char key_id; | |
5950 | struct in_addr addr; | |
718e3744 | 5951 | struct ospf_if_params *params; |
5952 | ||
718e3744 | 5953 | params = IF_DEF_PARAMS (ifp); |
fefa0d82 QY |
5954 | int idx = 0; |
5955 | ||
5956 | argv_find (argv, argc, "(1-255)", &idx); | |
0d829fa7 | 5957 | char *keyid = argv[idx]->arg; |
fefa0d82 QY |
5958 | argv_find (argv, argc, "KEY", &idx); |
5959 | char *cryptkey = argv[idx]->arg; | |
718e3744 | 5960 | |
0d829fa7 | 5961 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 5962 | { |
0d829fa7 | 5963 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 5964 | { |
5965 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
5966 | VTY_NEWLINE); | |
5967 | return CMD_WARNING; | |
5968 | } | |
5969 | ||
5970 | params = ospf_get_if_params (ifp, addr); | |
5971 | ospf_if_update_params (ifp, addr); | |
5972 | } | |
5973 | ||
fefa0d82 | 5974 | key_id = strtol (keyid, NULL, 10); |
718e3744 | 5975 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
5976 | { | |
5977 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); | |
5978 | return CMD_WARNING; | |
5979 | } | |
5980 | ||
5981 | ck = ospf_crypt_key_new (); | |
5982 | ck->key_id = (u_char) key_id; | |
5983 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
fefa0d82 | 5984 | strncpy ((char *) ck->auth_key, cryptkey, OSPF_AUTH_MD5_SIZE); |
718e3744 | 5985 | |
5986 | ospf_crypt_key_add (params->auth_crypt, ck); | |
5987 | SET_IF_PARAM (params, auth_crypt); | |
5988 | ||
5989 | return CMD_SUCCESS; | |
5990 | } | |
5991 | ||
7a7be519 | 5992 | DEFUN_HIDDEN (ospf_message_digest_key, |
747e489c | 5993 | ospf_message_digest_key_cmd, |
0d829fa7 | 5994 | "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
747e489c DW |
5995 | "OSPF interface commands\n" |
5996 | "Message digest authentication password (key)\n" | |
5997 | "Key ID\n" | |
5998 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
5999 | "The OSPF password (key)\n" |
6000 | "Address of interface\n") | |
7a7be519 | 6001 | { |
0d829fa7 | 6002 | return ip_ospf_message_digest_key (self, vty, argc, argv); |
7a7be519 | 6003 | } |
718e3744 | 6004 | |
537eae3f QY |
6005 | DEFUN (no_ip_ospf_message_digest_key, |
6006 | no_ip_ospf_message_digest_key_cmd, | |
0d829fa7 | 6007 | "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
813d4307 DW |
6008 | NO_STR |
6009 | "IP Information\n" | |
6010 | "OSPF interface commands\n" | |
6011 | "Message digest authentication password (key)\n" | |
6012 | "Key ID\n" | |
6013 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
6014 | "The OSPF password (key)\n" |
6015 | "Address of interface\n") | |
813d4307 | 6016 | { |
cdc2d765 | 6017 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6018 | int idx = 0; |
813d4307 DW |
6019 | struct crypt_key *ck; |
6020 | int key_id; | |
6021 | struct in_addr addr; | |
813d4307 | 6022 | struct ospf_if_params *params; |
813d4307 DW |
6023 | params = IF_DEF_PARAMS (ifp); |
6024 | ||
0d829fa7 QY |
6025 | argv_find (argv, argc, "(1-255)", &idx); |
6026 | char *keyid = argv[idx]->arg; | |
7a7be519 | 6027 | |
0d829fa7 | 6028 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 6029 | { |
0d829fa7 | 6030 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 6031 | { |
6032 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6033 | VTY_NEWLINE); | |
6034 | return CMD_WARNING; | |
6035 | } | |
6036 | ||
6037 | params = ospf_lookup_if_params (ifp, addr); | |
6038 | if (params == NULL) | |
6039 | return CMD_SUCCESS; | |
6040 | } | |
6041 | ||
0d829fa7 | 6042 | key_id = strtol (keyid, NULL, 10); |
7a7be519 | 6043 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
6044 | if (ck == NULL) | |
6045 | { | |
6046 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); | |
6047 | return CMD_WARNING; | |
6048 | } | |
6049 | ||
6050 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6051 | ||
6052 | if (params != IF_DEF_PARAMS (ifp)) | |
6053 | { | |
6054 | ospf_free_if_params (ifp, addr); | |
6055 | ospf_if_update_params (ifp, addr); | |
6056 | } | |
6057 | ||
6058 | return CMD_SUCCESS; | |
6059 | } | |
813d4307 | 6060 | |
0d829fa7 | 6061 | DEFUN_HIDDEN (no_ospf_message_digest_key, |
537eae3f | 6062 | no_ospf_message_digest_key_cmd, |
0d829fa7 QY |
6063 | "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
6064 | NO_STR | |
6065 | "OSPF interface commands\n" | |
6066 | "Message digest authentication password (key)\n" | |
6067 | "Key ID\n" | |
6068 | "Address of interface") | |
718e3744 | 6069 | { |
537eae3f | 6070 | return no_ip_ospf_message_digest_key (self, vty, argc, argv); |
718e3744 | 6071 | } |
6072 | ||
718e3744 | 6073 | DEFUN (ip_ospf_cost, |
5c2fc921 | 6074 | ip_ospf_cost_cmd, |
7a7be519 | 6075 | "ip ospf cost (1-65535) [A.B.C.D]", |
718e3744 | 6076 | "IP Information\n" |
6077 | "OSPF interface commands\n" | |
6078 | "Interface cost\n" | |
6079 | "Cost\n" | |
5c2fc921 | 6080 | "Address of interface\n") |
718e3744 | 6081 | { |
cdc2d765 | 6082 | VTY_DECLVAR_CONTEXT(interface, ifp); |
5c2fc921 | 6083 | int idx = 0; |
718e3744 | 6084 | u_int32_t cost; |
6085 | struct in_addr addr; | |
718e3744 | 6086 | struct ospf_if_params *params; |
718e3744 | 6087 | params = IF_DEF_PARAMS (ifp); |
6088 | ||
5c2fc921 QY |
6089 | // get arguments |
6090 | char *coststr = NULL, *ifaddr = NULL; | |
6091 | coststr = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL; | |
6092 | ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 6093 | |
5c2fc921 | 6094 | cost = strtol (coststr, NULL, 10); |
718e3744 | 6095 | |
5c2fc921 | 6096 | if (ifaddr) |
718e3744 | 6097 | { |
5c2fc921 | 6098 | if(!inet_aton(ifaddr, &addr)) |
718e3744 | 6099 | { |
6100 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6101 | VTY_NEWLINE); | |
6102 | return CMD_WARNING; | |
6103 | } | |
6104 | ||
6105 | params = ospf_get_if_params (ifp, addr); | |
6106 | ospf_if_update_params (ifp, addr); | |
6107 | } | |
6108 | ||
6109 | SET_IF_PARAM (params, output_cost_cmd); | |
6110 | params->output_cost_cmd = cost; | |
6111 | ||
6112 | ospf_if_recalculate_output_cost (ifp); | |
5c2fc921 | 6113 | |
718e3744 | 6114 | return CMD_SUCCESS; |
6115 | } | |
6116 | ||
7a7be519 | 6117 | DEFUN_HIDDEN (ospf_cost, |
5c2fc921 QY |
6118 | ospf_cost_cmd, |
6119 | "ospf cost (1-65535) [A.B.C.D]", | |
747e489c DW |
6120 | "OSPF interface commands\n" |
6121 | "Interface cost\n" | |
6122 | "Cost\n" | |
5c2fc921 | 6123 | "Address of interface\n") |
7a7be519 | 6124 | { |
5c2fc921 | 6125 | return ip_ospf_cost (self, vty, argc, argv); |
7a7be519 | 6126 | } |
9eff36b3 | 6127 | |
718e3744 | 6128 | DEFUN (no_ip_ospf_cost, |
5c2fc921 QY |
6129 | no_ip_ospf_cost_cmd, |
6130 | "no ip ospf cost [(1-65535)] [A.B.C.D]", | |
718e3744 | 6131 | NO_STR |
718e3744 | 6132 | "OSPF interface commands\n" |
6133 | "Interface cost\n" | |
6134 | "Address of interface") | |
6135 | { | |
cdc2d765 | 6136 | VTY_DECLVAR_CONTEXT(interface, ifp); |
5c2fc921 | 6137 | int idx = 0; |
718e3744 | 6138 | struct in_addr addr; |
718e3744 | 6139 | struct ospf_if_params *params; |
7a7be519 | 6140 | |
718e3744 | 6141 | params = IF_DEF_PARAMS (ifp); |
6142 | ||
5c2fc921 QY |
6143 | // get arguments |
6144 | char *ifaddr = NULL; | |
6145 | ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 6146 | |
7a7be519 | 6147 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
6148 | * always treated as "no ip ospf cost" regardless of the actual value | |
5c2fc921 | 6149 | * of N already configured for the interface. Thus ignore cost. */ |
7a7be519 | 6150 | |
5c2fc921 | 6151 | if (ifaddr) |
7a7be519 | 6152 | { |
5c2fc921 | 6153 | if (!inet_aton(ifaddr, &addr)) |
7a7be519 | 6154 | { |
6155 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6156 | VTY_NEWLINE); | |
6157 | return CMD_WARNING; | |
6158 | } | |
6159 | ||
6160 | params = ospf_lookup_if_params (ifp, addr); | |
6161 | if (params == NULL) | |
6162 | return CMD_SUCCESS; | |
6163 | } | |
6164 | ||
6165 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6166 | ||
6167 | if (params != IF_DEF_PARAMS (ifp)) | |
6168 | { | |
6169 | ospf_free_if_params (ifp, addr); | |
6170 | ospf_if_update_params (ifp, addr); | |
6171 | } | |
6172 | ||
6173 | ospf_if_recalculate_output_cost (ifp); | |
6174 | ||
6175 | return CMD_SUCCESS; | |
6176 | } | |
9eff36b3 | 6177 | |
5c2fc921 QY |
6178 | DEFUN_HIDDEN (no_ospf_cost, |
6179 | no_ospf_cost_cmd, | |
6180 | "no ospf cost [(1-65535)] [A.B.C.D]", | |
6181 | NO_STR | |
6182 | "OSPF interface commands\n" | |
6183 | "Interface cost\n" | |
6184 | "Cost\n" | |
6185 | "Address of interface\n") | |
827341b7 | 6186 | { |
5c2fc921 | 6187 | return no_ip_ospf_cost (self, vty, argc, argv); |
827341b7 DO |
6188 | } |
6189 | ||
4dadc291 | 6190 | static void |
718e3744 | 6191 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6192 | { | |
6193 | struct route_node *rn; | |
6194 | struct ospf_neighbor *nbr; | |
6195 | ||
6196 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6197 | if ((nbr = rn->info)) | |
6198 | { | |
6199 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6200 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6201 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6202 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6203 | } | |
6204 | } | |
6205 | ||
f9ad937f | 6206 | static int |
6207 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6208 | const char *nbr_str, | |
6209 | const char *fast_hello_str) | |
718e3744 | 6210 | { |
cdc2d765 | 6211 | VTY_DECLVAR_CONTEXT(interface, ifp); |
718e3744 | 6212 | u_int32_t seconds; |
f9ad937f | 6213 | u_char hellomult; |
718e3744 | 6214 | struct in_addr addr; |
6215 | int ret; | |
6216 | struct ospf_if_params *params; | |
6217 | struct ospf_interface *oi; | |
6218 | struct route_node *rn; | |
6219 | ||
6220 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6221 | |
6222 | if (nbr_str) | |
718e3744 | 6223 | { |
f9ad937f | 6224 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6225 | if (!ret) |
6226 | { | |
6227 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6228 | VTY_NEWLINE); | |
6229 | return CMD_WARNING; | |
6230 | } | |
6231 | ||
6232 | params = ospf_get_if_params (ifp, addr); | |
6233 | ospf_if_update_params (ifp, addr); | |
6234 | } | |
6235 | ||
f9ad937f | 6236 | if (interval_str) |
6237 | { | |
6238 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, | |
6239 | 1, 65535); | |
6240 | ||
6241 | /* reset fast_hello too, just to be sure */ | |
6242 | UNSET_IF_PARAM (params, fast_hello); | |
6243 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6244 | } | |
6245 | else if (fast_hello_str) | |
6246 | { | |
6247 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, | |
6248 | 1, 10); | |
6249 | /* 1s dead-interval with sub-second hellos desired */ | |
6250 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6251 | SET_IF_PARAM (params, fast_hello); | |
6252 | params->fast_hello = hellomult; | |
6253 | } | |
6254 | else | |
6255 | { | |
6256 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
6257 | VTY_NEWLINE); | |
6258 | return CMD_WARNING; | |
6259 | } | |
6260 | ||
718e3744 | 6261 | SET_IF_PARAM (params, v_wait); |
6262 | params->v_wait = seconds; | |
6263 | ||
6264 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6265 | if (nbr_str) |
718e3744 | 6266 | { |
cac3b5c4 PJ |
6267 | struct ospf *ospf; |
6268 | if ((ospf = ospf_lookup())) | |
68980084 | 6269 | { |
6270 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6271 | if (oi) | |
6272 | ospf_nbr_timer_update (oi); | |
6273 | } | |
718e3744 | 6274 | } |
6275 | else | |
6276 | { | |
6277 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6278 | if ((oi = rn->info)) | |
6279 | ospf_nbr_timer_update (oi); | |
6280 | } | |
6281 | ||
6282 | return CMD_SUCCESS; | |
6283 | } | |
6284 | ||
f9ad937f | 6285 | DEFUN (ip_ospf_dead_interval, |
0d829fa7 | 6286 | ip_ospf_dead_interval_cmd, |
7a7be519 | 6287 | "ip ospf dead-interval (1-65535) [A.B.C.D]", |
f9ad937f | 6288 | "IP Information\n" |
6289 | "OSPF interface commands\n" | |
99a522c7 | 6290 | "Interval time after which a neighbor is declared down\n" |
f9ad937f | 6291 | "Seconds\n" |
6292 | "Address of interface\n") | |
6293 | { | |
0d829fa7 QY |
6294 | int idx = 0; |
6295 | char *interval = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL; | |
6296 | char *ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
6297 | return ospf_vty_dead_interval_set (vty, interval, ifaddr, NULL); | |
f9ad937f | 6298 | } |
6299 | ||
718e3744 | 6300 | |
7a7be519 | 6301 | DEFUN_HIDDEN (ospf_dead_interval, |
747e489c | 6302 | ospf_dead_interval_cmd, |
0d829fa7 | 6303 | "ospf dead-interval (1-65535) [A.B.C.D]", |
747e489c | 6304 | "OSPF interface commands\n" |
99a522c7 | 6305 | "Interval time after which a neighbor is declared down\n" |
0d829fa7 QY |
6306 | "Seconds\n" |
6307 | "Address of interface\n") | |
7a7be519 | 6308 | { |
0d829fa7 | 6309 | return ip_ospf_dead_interval (self, vty, argc, argv); |
7a7be519 | 6310 | } |
718e3744 | 6311 | |
f9ad937f | 6312 | DEFUN (ip_ospf_dead_interval_minimal, |
6313 | ip_ospf_dead_interval_minimal_addr_cmd, | |
7a7be519 | 6314 | "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]", |
f9ad937f | 6315 | "IP Information\n" |
6316 | "OSPF interface commands\n" | |
99a522c7 | 6317 | "Interval time after which a neighbor is declared down\n" |
f9ad937f | 6318 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
6319 | "Hello multiplier factor\n" | |
6320 | "Number of Hellos to send each second\n" | |
6321 | "Address of interface\n") | |
6322 | { | |
8d769265 DW |
6323 | int idx_number = 5; |
6324 | int idx_ipv4 = 6; | |
7a7be519 | 6325 | if (argc == 7) |
8d769265 | 6326 | return ospf_vty_dead_interval_set (vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); |
f9ad937f | 6327 | else |
8d769265 | 6328 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[idx_number]->arg); |
f9ad937f | 6329 | } |
6330 | ||
718e3744 | 6331 | DEFUN (no_ip_ospf_dead_interval, |
0d829fa7 | 6332 | no_ip_ospf_dead_interval_cmd, |
e83a9414 | 6333 | "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", |
718e3744 | 6334 | NO_STR |
6335 | "IP Information\n" | |
6336 | "OSPF interface commands\n" | |
99a522c7 | 6337 | "Interval time after which a neighbor is declared down\n" |
f9dfba8d | 6338 | "Seconds\n" |
718e3744 | 6339 | "Address of interface") |
6340 | { | |
cdc2d765 | 6341 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7a7be519 | 6342 | int idx_ipv4 = argc - 1; |
c604467a | 6343 | struct in_addr addr = { .s_addr = 0L}; |
718e3744 | 6344 | int ret; |
6345 | struct ospf_if_params *params; | |
6346 | struct ospf_interface *oi; | |
6347 | struct route_node *rn; | |
020709f9 | 6348 | |
718e3744 | 6349 | params = IF_DEF_PARAMS (ifp); |
6350 | ||
7a7be519 | 6351 | if (argv[idx_ipv4]->type == IPV4_TKN) |
718e3744 | 6352 | { |
8d769265 | 6353 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 6354 | if (!ret) |
6355 | { | |
6356 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6357 | VTY_NEWLINE); | |
6358 | return CMD_WARNING; | |
6359 | } | |
6360 | ||
6361 | params = ospf_lookup_if_params (ifp, addr); | |
6362 | if (params == NULL) | |
6363 | return CMD_SUCCESS; | |
6364 | } | |
6365 | ||
6366 | UNSET_IF_PARAM (params, v_wait); | |
6367 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 6368 | |
6369 | UNSET_IF_PARAM (params, fast_hello); | |
6370 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6371 | ||
718e3744 | 6372 | if (params != IF_DEF_PARAMS (ifp)) |
6373 | { | |
6374 | ospf_free_if_params (ifp, addr); | |
6375 | ospf_if_update_params (ifp, addr); | |
6376 | } | |
6377 | ||
6378 | /* Update timer values in neighbor structure. */ | |
6379 | if (argc == 1) | |
6380 | { | |
cac3b5c4 PJ |
6381 | struct ospf *ospf; |
6382 | ||
6383 | if ((ospf = ospf_lookup())) | |
68980084 | 6384 | { |
6385 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6386 | if (oi) | |
6387 | ospf_nbr_timer_update (oi); | |
6388 | } | |
718e3744 | 6389 | } |
6390 | else | |
6391 | { | |
6392 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6393 | if ((oi = rn->info)) | |
6394 | ospf_nbr_timer_update (oi); | |
6395 | } | |
6396 | ||
6397 | return CMD_SUCCESS; | |
6398 | } | |
6399 | ||
0d829fa7 QY |
6400 | DEFUN_HIDDEN (no_ospf_dead_interval, |
6401 | no_ospf_dead_interval_cmd, | |
6402 | "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", | |
6403 | NO_STR | |
6404 | "OSPF interface commands\n" | |
99a522c7 | 6405 | "Interval time after which a neighbor is declared down\n" |
0d829fa7 QY |
6406 | "Seconds\n" |
6407 | "Address of interface") | |
6408 | { | |
6409 | return no_ip_ospf_dead_interval (self, vty, argc, argv); | |
6410 | } | |
6411 | ||
718e3744 | 6412 | DEFUN (ip_ospf_hello_interval, |
0d829fa7 | 6413 | ip_ospf_hello_interval_cmd, |
7a7be519 | 6414 | "ip ospf hello-interval (1-65535) [A.B.C.D]", |
718e3744 | 6415 | "IP Information\n" |
6416 | "OSPF interface commands\n" | |
6417 | "Time between HELLO packets\n" | |
6418 | "Seconds\n" | |
0d829fa7 | 6419 | "Address of interface\n") |
718e3744 | 6420 | { |
cdc2d765 | 6421 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6422 | int idx = 0; |
718e3744 | 6423 | struct in_addr addr; |
718e3744 | 6424 | struct ospf_if_params *params; |
718e3744 | 6425 | params = IF_DEF_PARAMS (ifp); |
0d829fa7 | 6426 | u_int32_t seconds = 0; |
718e3744 | 6427 | |
0d829fa7 QY |
6428 | argv_find (argv, argc, "(1-65535)", &idx); |
6429 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6430 | |
0d829fa7 | 6431 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6432 | { |
0d829fa7 | 6433 | if(!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6434 | { |
6435 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6436 | VTY_NEWLINE); | |
6437 | return CMD_WARNING; | |
6438 | } | |
6439 | ||
6440 | params = ospf_get_if_params (ifp, addr); | |
6441 | ospf_if_update_params (ifp, addr); | |
6442 | } | |
6443 | ||
f9ad937f | 6444 | SET_IF_PARAM (params, v_hello); |
718e3744 | 6445 | params->v_hello = seconds; |
6446 | ||
6447 | return CMD_SUCCESS; | |
6448 | } | |
6449 | ||
7a7be519 | 6450 | DEFUN_HIDDEN (ospf_hello_interval, |
747e489c | 6451 | ospf_hello_interval_cmd, |
0d829fa7 | 6452 | "ospf hello-interval (1-65535) [A.B.C.D]", |
747e489c DW |
6453 | "OSPF interface commands\n" |
6454 | "Time between HELLO packets\n" | |
0d829fa7 QY |
6455 | "Seconds\n" |
6456 | "Address of interface\n") | |
7a7be519 | 6457 | { |
0d829fa7 | 6458 | return ip_ospf_hello_interval (self, vty, argc, argv); |
7a7be519 | 6459 | } |
718e3744 | 6460 | |
6461 | DEFUN (no_ip_ospf_hello_interval, | |
0d829fa7 QY |
6462 | no_ip_ospf_hello_interval_cmd, |
6463 | "no ip ospf hello-interval [(1-65535) [A.B.C.D]]", | |
718e3744 | 6464 | NO_STR |
6465 | "IP Information\n" | |
6466 | "OSPF interface commands\n" | |
0d829fa7 | 6467 | "Time between HELLO packets\n" // ignored |
f9dfba8d | 6468 | "Seconds\n" |
0d829fa7 | 6469 | "Address of interface\n") |
718e3744 | 6470 | { |
cdc2d765 | 6471 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6472 | int idx = 0; |
718e3744 | 6473 | struct in_addr addr; |
718e3744 | 6474 | struct ospf_if_params *params; |
df581cd3 | 6475 | |
718e3744 | 6476 | params = IF_DEF_PARAMS (ifp); |
6477 | ||
0d829fa7 | 6478 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6479 | { |
0d829fa7 | 6480 | if(!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6481 | { |
6482 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6483 | VTY_NEWLINE); | |
6484 | return CMD_WARNING; | |
6485 | } | |
6486 | ||
6487 | params = ospf_lookup_if_params (ifp, addr); | |
6488 | if (params == NULL) | |
6489 | return CMD_SUCCESS; | |
6490 | } | |
6491 | ||
6492 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 6493 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 6494 | |
6495 | if (params != IF_DEF_PARAMS (ifp)) | |
6496 | { | |
6497 | ospf_free_if_params (ifp, addr); | |
6498 | ospf_if_update_params (ifp, addr); | |
6499 | } | |
6500 | ||
6501 | return CMD_SUCCESS; | |
6502 | } | |
6503 | ||
0d829fa7 QY |
6504 | DEFUN_HIDDEN (no_ospf_hello_interval, |
6505 | no_ospf_hello_interval_cmd, | |
6506 | "no ospf hello-interval [(1-65535) [A.B.C.D]]", | |
6507 | NO_STR | |
6508 | "OSPF interface commands\n" | |
6509 | "Time between HELLO packets\n" // ignored | |
6510 | "Seconds\n" | |
6511 | "Address of interface\n") | |
6512 | { | |
030204c7 | 6513 | return no_ip_ospf_hello_interval (self, vty, argc, argv); |
0d829fa7 | 6514 | } |
718e3744 | 6515 | |
6516 | DEFUN (ip_ospf_network, | |
6517 | ip_ospf_network_cmd, | |
6147e2c6 | 6518 | "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
718e3744 | 6519 | "IP Information\n" |
6520 | "OSPF interface commands\n" | |
6521 | "Network type\n" | |
6522 | "Specify OSPF broadcast multi-access network\n" | |
6523 | "Specify OSPF NBMA network\n" | |
6524 | "Specify OSPF point-to-multipoint network\n" | |
6525 | "Specify OSPF point-to-point network\n") | |
6526 | { | |
cdc2d765 | 6527 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6528 | int idx = 0; |
718e3744 | 6529 | int old_type = IF_DEF_PARAMS (ifp)->type; |
6530 | struct route_node *rn; | |
4b4bda9b CF |
6531 | |
6532 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
6533 | { | |
6534 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); | |
6535 | return CMD_WARNING; | |
6536 | } | |
6537 | ||
0d829fa7 | 6538 | if (argv_find (argv, argc, "broadcast", &idx)) |
718e3744 | 6539 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
0d829fa7 | 6540 | else if (argv_find (argv, argc, "non-broadcast", &idx)) |
718e3744 | 6541 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
0d829fa7 | 6542 | else if (argv_find (argv, argc, "point-to-multipoint", &idx)) |
718e3744 | 6543 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
0d829fa7 | 6544 | else if (argv_find (argv, argc, "point-to-point", &idx)) |
718e3744 | 6545 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
6546 | ||
6547 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6548 | return CMD_SUCCESS; | |
6549 | ||
6550 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
6551 | ||
6552 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6553 | { | |
6554 | struct ospf_interface *oi = rn->info; | |
6555 | ||
6556 | if (!oi) | |
6557 | continue; | |
6558 | ||
6559 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6560 | ||
6561 | if (oi->state > ISM_Down) | |
6562 | { | |
7a7be519 | 6563 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
6564 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6565 | } | |
6566 | } | |
6567 | ||
6568 | return CMD_SUCCESS; | |
6569 | } | |
6570 | ||
6571 | DEFUN_HIDDEN (ospf_network, | |
6572 | ospf_network_cmd, | |
e83a9414 | 6573 | "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
7a7be519 | 6574 | "OSPF interface commands\n" |
6575 | "Network type\n" | |
6576 | "Specify OSPF broadcast multi-access network\n" | |
6577 | "Specify OSPF NBMA network\n" | |
6578 | "Specify OSPF point-to-multipoint network\n" | |
6579 | "Specify OSPF point-to-point network\n") | |
6580 | { | |
0d829fa7 | 6581 | return ip_ospf_network (self, vty, argc, argv); |
7a7be519 | 6582 | } |
6583 | ||
6584 | DEFUN (no_ip_ospf_network, | |
6585 | no_ip_ospf_network_cmd, | |
6586 | "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
6587 | NO_STR | |
6588 | "IP Information\n" | |
6589 | "OSPF interface commands\n" | |
6590 | "Network type\n" | |
6591 | "Specify OSPF broadcast multi-access network\n" | |
6592 | "Specify OSPF NBMA network\n" | |
6593 | "Specify OSPF point-to-multipoint network\n" | |
6594 | "Specify OSPF point-to-point network\n") | |
22b27e95 | 6595 | { |
cdc2d765 | 6596 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7a7be519 | 6597 | int old_type = IF_DEF_PARAMS (ifp)->type; |
6598 | struct route_node *rn; | |
6599 | ||
6600 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); | |
6601 | ||
6602 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6603 | return CMD_SUCCESS; | |
6604 | ||
6605 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6606 | { | |
6607 | struct ospf_interface *oi = rn->info; | |
6608 | ||
6609 | if (!oi) | |
6610 | continue; | |
6611 | ||
6612 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6613 | ||
6614 | if (oi->state > ISM_Down) | |
6615 | { | |
6616 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
6617 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6618 | } | |
6619 | } | |
6620 | ||
6621 | return CMD_SUCCESS; | |
6622 | } | |
6623 | ||
0d829fa7 QY |
6624 | DEFUN_HIDDEN (no_ospf_network, |
6625 | no_ospf_network_cmd, | |
6626 | "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
6627 | NO_STR | |
6628 | "OSPF interface commands\n" | |
6629 | "Network type\n" | |
6630 | "Specify OSPF broadcast multi-access network\n" | |
6631 | "Specify OSPF NBMA network\n" | |
6632 | "Specify OSPF point-to-multipoint network\n" | |
6633 | "Specify OSPF point-to-point network\n") | |
6634 | { | |
6635 | return no_ip_ospf_network (self, vty, argc, argv); | |
6636 | } | |
6637 | ||
7a7be519 | 6638 | DEFUN (ip_ospf_priority, |
537eae3f | 6639 | ip_ospf_priority_cmd, |
7a7be519 | 6640 | "ip ospf priority (0-255) [A.B.C.D]", |
6641 | "IP Information\n" | |
6642 | "OSPF interface commands\n" | |
6643 | "Router priority\n" | |
6644 | "Priority\n" | |
6645 | "Address of interface") | |
6646 | { | |
cdc2d765 | 6647 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6648 | int idx = 0; |
7a7be519 | 6649 | long priority; |
6650 | struct route_node *rn; | |
6651 | struct in_addr addr; | |
7a7be519 | 6652 | struct ospf_if_params *params; |
7a7be519 | 6653 | params = IF_DEF_PARAMS (ifp); |
6654 | ||
0d829fa7 QY |
6655 | argv_find (argv, argc, "(0-255)", &idx); |
6656 | priority = strtol (argv[idx]->arg, NULL, 10); | |
7a7be519 | 6657 | |
0d829fa7 | 6658 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 6659 | { |
0d829fa7 | 6660 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 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_get_if_params (ifp, addr); | |
6668 | ospf_if_update_params (ifp, addr); | |
6669 | } | |
6670 | ||
6671 | SET_IF_PARAM (params, priority); | |
6672 | params->priority = priority; | |
6673 | ||
6674 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6675 | { | |
6676 | struct ospf_interface *oi = rn->info; | |
6677 | ||
6678 | if (!oi) | |
6679 | continue; | |
6680 | ||
6681 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
6682 | { | |
6683 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6684 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
718e3744 | 6685 | } |
6686 | } | |
6687 | ||
6688 | return CMD_SUCCESS; | |
6689 | } | |
6690 | ||
7a7be519 | 6691 | DEFUN_HIDDEN (ospf_priority, |
6692 | ospf_priority_cmd, | |
0d829fa7 | 6693 | "ospf priority (0-255) [A.B.C.D]", |
7a7be519 | 6694 | "OSPF interface commands\n" |
6695 | "Router priority\n" | |
3a2d747c QY |
6696 | "Priority\n" |
6697 | "Address of interface") | |
718e3744 | 6698 | { |
0d829fa7 | 6699 | return ip_ospf_priority (self, vty, argc, argv); |
718e3744 | 6700 | } |
6701 | ||
718e3744 | 6702 | DEFUN (no_ip_ospf_priority, |
537eae3f | 6703 | no_ip_ospf_priority_cmd, |
7a7be519 | 6704 | "no ip ospf priority [(0-255) [A.B.C.D]]", |
718e3744 | 6705 | NO_STR |
6706 | "IP Information\n" | |
6707 | "OSPF interface commands\n" | |
0d829fa7 | 6708 | "Router priority\n" // ignored |
813d4307 | 6709 | "Priority\n" |
718e3744 | 6710 | "Address of interface") |
6711 | { | |
cdc2d765 | 6712 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6713 | int idx = 0; |
718e3744 | 6714 | struct route_node *rn; |
6715 | struct in_addr addr; | |
718e3744 | 6716 | struct ospf_if_params *params; |
6717 | ||
718e3744 | 6718 | params = IF_DEF_PARAMS (ifp); |
6719 | ||
0d829fa7 | 6720 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6721 | { |
0d829fa7 | 6722 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6723 | { |
6724 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6725 | VTY_NEWLINE); | |
6726 | return CMD_WARNING; | |
6727 | } | |
6728 | ||
6729 | params = ospf_lookup_if_params (ifp, addr); | |
6730 | if (params == NULL) | |
6731 | return CMD_SUCCESS; | |
6732 | } | |
6733 | ||
6734 | UNSET_IF_PARAM (params, priority); | |
6735 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
6736 | ||
6737 | if (params != IF_DEF_PARAMS (ifp)) | |
6738 | { | |
6739 | ospf_free_if_params (ifp, addr); | |
6740 | ospf_if_update_params (ifp, addr); | |
6741 | } | |
6742 | ||
6743 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6744 | { | |
6745 | struct ospf_interface *oi = rn->info; | |
6746 | ||
6747 | if (!oi) | |
6748 | continue; | |
6749 | ||
718e3744 | 6750 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
6751 | { | |
6752 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6753 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
6754 | } | |
6755 | } | |
6756 | ||
6757 | return CMD_SUCCESS; | |
6758 | } | |
6759 | ||
0d829fa7 | 6760 | DEFUN_HIDDEN (no_ospf_priority, |
537eae3f | 6761 | no_ospf_priority_cmd, |
0d829fa7 QY |
6762 | "no ospf priority [(0-255) [A.B.C.D]]", |
6763 | NO_STR | |
6764 | "OSPF interface commands\n" | |
6765 | "Router priority\n" | |
6766 | "Priority\n" | |
6767 | "Address of interface") | |
6768 | { | |
6769 | return no_ip_ospf_priority (self, vty, argc, argv); | |
6770 | } | |
a1afa410 | 6771 | |
718e3744 | 6772 | DEFUN (ip_ospf_retransmit_interval, |
6773 | ip_ospf_retransmit_interval_addr_cmd, | |
7a7be519 | 6774 | "ip ospf retransmit-interval (3-65535) [A.B.C.D]", |
718e3744 | 6775 | "IP Information\n" |
6776 | "OSPF interface commands\n" | |
6777 | "Time between retransmitting lost link state advertisements\n" | |
6778 | "Seconds\n" | |
6779 | "Address of interface") | |
6780 | { | |
cdc2d765 | 6781 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6782 | int idx = 0; |
718e3744 | 6783 | u_int32_t seconds; |
6784 | struct in_addr addr; | |
718e3744 | 6785 | struct ospf_if_params *params; |
718e3744 | 6786 | params = IF_DEF_PARAMS (ifp); |
718e3744 | 6787 | |
0d829fa7 QY |
6788 | argv_find (argv, argc, "(3-65535)", &idx); |
6789 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6790 | |
0d829fa7 | 6791 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6792 | { |
0d829fa7 | 6793 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6794 | { |
6795 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6796 | VTY_NEWLINE); | |
6797 | return CMD_WARNING; | |
6798 | } | |
6799 | ||
6800 | params = ospf_get_if_params (ifp, addr); | |
6801 | ospf_if_update_params (ifp, addr); | |
6802 | } | |
6803 | ||
6804 | SET_IF_PARAM (params, retransmit_interval); | |
6805 | params->retransmit_interval = seconds; | |
6806 | ||
6807 | return CMD_SUCCESS; | |
6808 | } | |
6809 | ||
7a7be519 | 6810 | DEFUN_HIDDEN (ospf_retransmit_interval, |
747e489c | 6811 | ospf_retransmit_interval_cmd, |
0d829fa7 | 6812 | "ospf retransmit-interval (3-65535) [A.B.C.D]", |
747e489c DW |
6813 | "OSPF interface commands\n" |
6814 | "Time between retransmitting lost link state advertisements\n" | |
3a2d747c QY |
6815 | "Seconds\n" |
6816 | "Address of interface") | |
7a7be519 | 6817 | { |
0d829fa7 | 6818 | return ip_ospf_retransmit_interval (self, vty, argc, argv); |
7a7be519 | 6819 | } |
718e3744 | 6820 | |
6821 | DEFUN (no_ip_ospf_retransmit_interval, | |
6822 | no_ip_ospf_retransmit_interval_addr_cmd, | |
0d829fa7 | 6823 | "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]", |
718e3744 | 6824 | NO_STR |
6825 | "IP Information\n" | |
6826 | "OSPF interface commands\n" | |
3a2d747c QY |
6827 | "Time between retransmitting lost link state advertisements\n" |
6828 | "Seconds\n" | |
0d829fa7 | 6829 | "Address of interface\n") |
718e3744 | 6830 | { |
cdc2d765 | 6831 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6832 | int idx = 0; |
718e3744 | 6833 | struct in_addr addr; |
718e3744 | 6834 | struct ospf_if_params *params; |
47b91972 | 6835 | |
718e3744 | 6836 | params = IF_DEF_PARAMS (ifp); |
6837 | ||
47b91972 | 6838 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6839 | { |
0d829fa7 | 6840 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6841 | { |
6842 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6843 | VTY_NEWLINE); | |
6844 | return CMD_WARNING; | |
6845 | } | |
6846 | ||
6847 | params = ospf_lookup_if_params (ifp, addr); | |
6848 | if (params == NULL) | |
6849 | return CMD_SUCCESS; | |
6850 | } | |
6851 | ||
6852 | UNSET_IF_PARAM (params, retransmit_interval); | |
6853 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
6854 | ||
6855 | if (params != IF_DEF_PARAMS (ifp)) | |
6856 | { | |
6857 | ospf_free_if_params (ifp, addr); | |
6858 | ospf_if_update_params (ifp, addr); | |
6859 | } | |
6860 | ||
6861 | return CMD_SUCCESS; | |
6862 | } | |
6863 | ||
0d829fa7 QY |
6864 | DEFUN_HIDDEN (no_ospf_retransmit_interval, |
6865 | no_ospf_retransmit_interval_cmd, | |
6866 | "no ospf retransmit-interval [(3-65535)] [A.B.C.D]", | |
6867 | NO_STR | |
6868 | "OSPF interface commands\n" | |
3a2d747c QY |
6869 | "Time between retransmitting lost link state advertisements\n" |
6870 | "Seconds\n" | |
6871 | "Address of interface\n") | |
0d829fa7 QY |
6872 | { |
6873 | return no_ip_ospf_retransmit_interval (self, vty, argc, argv); | |
6874 | } | |
813d4307 | 6875 | |
718e3744 | 6876 | DEFUN (ip_ospf_transmit_delay, |
6877 | ip_ospf_transmit_delay_addr_cmd, | |
7a7be519 | 6878 | "ip ospf transmit-delay (1-65535) [A.B.C.D]", |
718e3744 | 6879 | "IP Information\n" |
6880 | "OSPF interface commands\n" | |
6881 | "Link state transmit delay\n" | |
6882 | "Seconds\n" | |
6883 | "Address of interface") | |
6884 | { | |
cdc2d765 | 6885 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6886 | int idx = 0; |
718e3744 | 6887 | u_int32_t seconds; |
6888 | struct in_addr addr; | |
718e3744 | 6889 | struct ospf_if_params *params; |
47b91972 | 6890 | |
718e3744 | 6891 | params = IF_DEF_PARAMS (ifp); |
0d829fa7 QY |
6892 | argv_find (argv, argc, "(1-65535)", &idx); |
6893 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6894 | |
0d829fa7 | 6895 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6896 | { |
0d829fa7 | 6897 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6898 | { |
6899 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6900 | VTY_NEWLINE); | |
6901 | return CMD_WARNING; | |
6902 | } | |
6903 | ||
6904 | params = ospf_get_if_params (ifp, addr); | |
6905 | ospf_if_update_params (ifp, addr); | |
6906 | } | |
6907 | ||
47b91972 | 6908 | SET_IF_PARAM (params, transmit_delay); |
718e3744 | 6909 | params->transmit_delay = seconds; |
6910 | ||
6911 | return CMD_SUCCESS; | |
6912 | } | |
6913 | ||
7a7be519 | 6914 | DEFUN_HIDDEN (ospf_transmit_delay, |
747e489c | 6915 | ospf_transmit_delay_cmd, |
0d829fa7 | 6916 | "ospf transmit-delay (1-65535) [A.B.C.D]", |
747e489c DW |
6917 | "OSPF interface commands\n" |
6918 | "Link state transmit delay\n" | |
3a2d747c QY |
6919 | "Seconds\n" |
6920 | "Address of interface") | |
7a7be519 | 6921 | { |
0d829fa7 | 6922 | return ip_ospf_transmit_delay (self, vty, argc, argv); |
7a7be519 | 6923 | } |
718e3744 | 6924 | |
6925 | DEFUN (no_ip_ospf_transmit_delay, | |
6926 | no_ip_ospf_transmit_delay_addr_cmd, | |
0d829fa7 | 6927 | "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]", |
718e3744 | 6928 | NO_STR |
6929 | "IP Information\n" | |
6930 | "OSPF interface commands\n" | |
6931 | "Link state transmit delay\n" | |
6932 | "Address of interface") | |
6933 | { | |
cdc2d765 | 6934 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6935 | int idx = 0; |
718e3744 | 6936 | struct in_addr addr; |
718e3744 | 6937 | struct ospf_if_params *params; |
6938 | ||
718e3744 | 6939 | params = IF_DEF_PARAMS (ifp); |
6940 | ||
0d829fa7 | 6941 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6942 | { |
0d829fa7 | 6943 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6944 | { |
6945 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
6946 | VTY_NEWLINE); | |
6947 | return CMD_WARNING; | |
6948 | } | |
6949 | ||
6950 | params = ospf_lookup_if_params (ifp, addr); | |
6951 | if (params == NULL) | |
6952 | return CMD_SUCCESS; | |
6953 | } | |
6954 | ||
6955 | UNSET_IF_PARAM (params, transmit_delay); | |
6956 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
6957 | ||
6958 | if (params != IF_DEF_PARAMS (ifp)) | |
6959 | { | |
6960 | ospf_free_if_params (ifp, addr); | |
6961 | ospf_if_update_params (ifp, addr); | |
6962 | } | |
6963 | ||
6964 | return CMD_SUCCESS; | |
6965 | } | |
6966 | ||
813d4307 | 6967 | |
0d829fa7 QY |
6968 | DEFUN_HIDDEN (no_ospf_transmit_delay, |
6969 | no_ospf_transmit_delay_cmd, | |
6970 | "no ospf transmit-delay", | |
6971 | NO_STR | |
6972 | "OSPF interface commands\n" | |
6973 | "Link state transmit delay\n") | |
813d4307 | 6974 | { |
0d829fa7 | 6975 | return no_ip_ospf_transmit_delay (self, vty, argc, argv); |
813d4307 DW |
6976 | } |
6977 | ||
e723861d DS |
6978 | DEFUN (ip_ospf_area, |
6979 | ip_ospf_area_cmd, | |
22b27e95 | 6980 | "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>", |
e723861d DS |
6981 | "IP Information\n" |
6982 | "OSPF interface commands\n" | |
7a7be519 | 6983 | "Instance ID\n" |
e723861d DS |
6984 | "Enable OSPF on this interface\n" |
6985 | "OSPF area ID in IP address format\n" | |
6986 | "OSPF area ID as a decimal value\n") | |
6987 | { | |
cdc2d765 | 6988 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6989 | int idx = 0; |
e723861d DS |
6990 | int format, ret; |
6991 | struct in_addr area_id; | |
6992 | struct ospf *ospf; | |
6993 | struct ospf_if_params *params; | |
6994 | struct route_node *rn; | |
7c8ff89e | 6995 | u_short instance = 0; |
e723861d | 6996 | |
0d829fa7 QY |
6997 | if (argv_find (argv, argc, "(1-65535)", &idx)) |
6998 | instance = strtol (argv[idx]->arg, NULL, 10); | |
6999 | char *areaid = argv[argc - 1]->arg; | |
7c8ff89e DS |
7000 | |
7001 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
7002 | if (ospf == NULL) |
7003 | { | |
7c8ff89e DS |
7004 | params = IF_DEF_PARAMS (ifp); |
7005 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7006 | { | |
7007 | ospf_interface_unset (ifp); | |
7008 | ospf = ospf_lookup(); | |
7009 | ospf->if_ospf_cli_count--; | |
7010 | } | |
e723861d DS |
7011 | return CMD_SUCCESS; |
7012 | } | |
7013 | ||
86573dcb | 7014 | ret = str2area_id (areaid, &area_id, &format); |
e723861d DS |
7015 | if (ret < 0) |
7016 | { | |
7017 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
7018 | VTY_NEWLINE); | |
7019 | return CMD_WARNING; | |
7020 | } | |
7021 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
7022 | { | |
7023 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); | |
7024 | return CMD_WARNING; | |
7025 | } | |
7026 | ||
7027 | params = IF_DEF_PARAMS (ifp); | |
7028 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7029 | { | |
73b9f703 VK |
7030 | vty_out (vty, |
7031 | "Must remove previous area config before changing ospf area %s", | |
7032 | VTY_NEWLINE); | |
e723861d DS |
7033 | return CMD_WARNING; |
7034 | } | |
7035 | ||
7036 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) | |
7037 | { | |
7038 | if (rn->info != NULL) | |
7039 | { | |
7040 | vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE); | |
7041 | return CMD_WARNING; | |
7042 | } | |
7043 | } | |
7044 | ||
7045 | /* enable ospf on this interface with area_id */ | |
7046 | ospf_interface_set (ifp, area_id); | |
7047 | ospf->if_ospf_cli_count++; | |
7048 | ||
7049 | return CMD_SUCCESS; | |
7050 | } | |
7051 | ||
7052 | DEFUN (no_ip_ospf_area, | |
7053 | no_ip_ospf_area_cmd, | |
0d829fa7 | 7054 | "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]", |
e723861d DS |
7055 | NO_STR |
7056 | "IP Information\n" | |
7057 | "OSPF interface commands\n" | |
3a2d747c | 7058 | "Instance ID\n" |
7a7be519 | 7059 | "Disable OSPF on this interface\n" |
7060 | "OSPF area ID in IP address format\n" | |
7061 | "OSPF area ID as a decimal value\n") | |
e723861d | 7062 | { |
cdc2d765 | 7063 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 7064 | int idx = 0; |
e723861d DS |
7065 | struct ospf *ospf; |
7066 | struct ospf_if_params *params; | |
7c8ff89e | 7067 | u_short instance = 0; |
e723861d | 7068 | |
0d829fa7 QY |
7069 | if (argv_find (argv, argc, "(1-65535)", &idx)) |
7070 | instance = strtol (argv[idx]->arg, NULL, 10); | |
813d4307 DW |
7071 | |
7072 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
7073 | return CMD_SUCCESS; | |
7074 | ||
7075 | params = IF_DEF_PARAMS (ifp); | |
7076 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7077 | { | |
0d829fa7 | 7078 | vty_out (vty, "Can't find specified interface area configuration.%s", VTY_NEWLINE); |
813d4307 DW |
7079 | return CMD_WARNING; |
7080 | } | |
7081 | ||
7082 | ospf_interface_unset (ifp); | |
7083 | ospf->if_ospf_cli_count--; | |
7084 | return CMD_SUCCESS; | |
7085 | } | |
7086 | ||
6f2a6703 CF |
7087 | DEFUN (ospf_redistribute_source, |
7088 | ospf_redistribute_source_cmd, | |
40d1cbfb | 7089 | "redistribute " FRR_REDIST_STR_OSPFD " [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
d1c65c21 | 7090 | REDIST_STR |
ab0181ee | 7091 | FRR_REDIST_HELP_STR_OSPFD |
718e3744 | 7092 | "Metric for redistributed routes\n" |
7093 | "OSPF default metric\n" | |
7094 | "OSPF exterior metric type for redistributed routes\n" | |
7095 | "Set OSPF External Type 1 metrics\n" | |
7096 | "Set OSPF External Type 2 metrics\n" | |
7097 | "Route map reference\n" | |
7098 | "Pointer to route-map entries\n") | |
7099 | { | |
cdc2d765 | 7100 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7101 | int idx_protocol = 1; |
718e3744 | 7102 | int source; |
7103 | int type = -1; | |
7104 | int metric = -1; | |
7c8ff89e | 7105 | struct ospf_redist *red; |
6d681bd8 | 7106 | int idx = 0; |
6f2a6703 | 7107 | |
7c8ff89e DS |
7108 | if (!ospf) |
7109 | return CMD_SUCCESS; | |
7110 | ||
718e3744 | 7111 | /* Get distribute source. */ |
6d681bd8 QY |
7112 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
7113 | if (source < 0) | |
718e3744 | 7114 | return CMD_WARNING; |
7115 | ||
6d681bd8 QY |
7116 | red = ospf_redist_add(ospf, source, 0); |
7117 | ||
718e3744 | 7118 | /* Get metric value. */ |
6d681bd8 QY |
7119 | if (argv_find (argv, argc, "(0-16777214)", &idx)) { |
7120 | if (!str2metric (argv[idx]->arg, &metric)) | |
718e3744 | 7121 | return CMD_WARNING; |
6d681bd8 | 7122 | } |
718e3744 | 7123 | /* Get metric type. */ |
6d681bd8 QY |
7124 | else if (argv_find (argv, argc, "(1-2)", &idx)) { |
7125 | if (!str2metric_type (argv[idx]->arg, &type)) | |
718e3744 | 7126 | return CMD_WARNING; |
6d681bd8 QY |
7127 | } |
7128 | /* Get route-map */ | |
7129 | else if (argv_find (argv, argc, "WORD", &idx)) { | |
7130 | ospf_routemap_set (red, argv[idx]->arg); | |
7131 | } | |
718e3744 | 7132 | else |
7c8ff89e | 7133 | ospf_routemap_unset (red); |
718e3744 | 7134 | |
7c8ff89e | 7135 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 7136 | } |
7137 | ||
718e3744 | 7138 | DEFUN (no_ospf_redistribute_source, |
7139 | no_ospf_redistribute_source_cmd, | |
40d1cbfb | 7140 | "no redistribute " FRR_REDIST_STR_OSPFD " [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7141 | NO_STR |
d1c65c21 | 7142 | REDIST_STR |
ab0181ee | 7143 | FRR_REDIST_HELP_STR_OSPFD |
813d4307 DW |
7144 | "Metric for redistributed routes\n" |
7145 | "OSPF default metric\n" | |
7146 | "OSPF exterior metric type for redistributed routes\n" | |
7147 | "Set OSPF External Type 1 metrics\n" | |
7148 | "Set OSPF External Type 2 metrics\n" | |
7149 | "Route map reference\n" | |
7150 | "Pointer to route-map entries\n") | |
718e3744 | 7151 | { |
cdc2d765 | 7152 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7153 | int idx_protocol = 2; |
718e3744 | 7154 | int source; |
7c8ff89e | 7155 | struct ospf_redist *red; |
718e3744 | 7156 | |
6d681bd8 QY |
7157 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
7158 | if (source < 0) | |
718e3744 | 7159 | return CMD_WARNING; |
7160 | ||
7c8ff89e DS |
7161 | red = ospf_redist_lookup(ospf, source, 0); |
7162 | if (!red) | |
7163 | return CMD_SUCCESS; | |
7164 | ||
7165 | ospf_routemap_unset (red); | |
7166 | return ospf_redistribute_unset (ospf, source, 0); | |
7167 | } | |
7168 | ||
7169 | DEFUN (ospf_redistribute_instance_source, | |
7170 | ospf_redistribute_instance_source_cmd, | |
1a5ce38b | 7171 | "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
7c8ff89e DS |
7172 | REDIST_STR |
7173 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7174 | "Non-main Kernel Routing Table\n" |
7175 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
7176 | "Metric for redistributed routes\n" |
7177 | "OSPF default metric\n" | |
7178 | "OSPF exterior metric type for redistributed routes\n" | |
7179 | "Set OSPF External Type 1 metrics\n" | |
7180 | "Set OSPF External Type 2 metrics\n" | |
7181 | "Route map reference\n" | |
7182 | "Pointer to route-map entries\n") | |
7183 | { | |
cdc2d765 | 7184 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7185 | int idx_ospf_table = 1; |
7186 | int idx_number = 2; | |
f4d78586 | 7187 | int idx = 3; |
7c8ff89e DS |
7188 | int source; |
7189 | int type = -1; | |
7190 | int metric = -1; | |
7191 | u_short instance; | |
7192 | struct ospf_redist *red; | |
7193 | ||
d8f70b86 DS |
7194 | if (!ospf) |
7195 | return CMD_SUCCESS; | |
7196 | ||
6d681bd8 | 7197 | source = proto_redistnum (AFI_IP, argv[idx_ospf_table]->text); |
2d627ff5 | 7198 | |
8d769265 | 7199 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7c8ff89e DS |
7200 | |
7201 | if (!ospf) | |
7202 | return CMD_SUCCESS; | |
7203 | ||
2d627ff5 | 7204 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7205 | { |
7206 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
7207 | VTY_NEWLINE); | |
7208 | return CMD_WARNING; | |
7209 | } | |
7210 | ||
2d627ff5 | 7211 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7212 | { |
7213 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
7214 | VTY_NEWLINE); | |
7215 | return CMD_WARNING; | |
7216 | } | |
7217 | ||
7c8ff89e | 7218 | /* Get metric value. */ |
f4d78586 DS |
7219 | if (argv_find (argv, argc, "metric", &idx)) |
7220 | if (!str2metric (argv[idx+1]->arg, &metric)) | |
7c8ff89e DS |
7221 | return CMD_WARNING; |
7222 | ||
f4d78586 | 7223 | idx = 3; |
7c8ff89e | 7224 | /* Get metric type. */ |
f4d78586 DS |
7225 | if (argv_find (argv, argc, "metric-type", &idx)) |
7226 | if (!str2metric_type (argv[idx+1]->arg, &type)) | |
7c8ff89e DS |
7227 | return CMD_WARNING; |
7228 | ||
7229 | red = ospf_redist_add(ospf, source, instance); | |
7a7be519 | 7230 | |
f4d78586 DS |
7231 | idx = 3; |
7232 | if (argv_find (argv, argc, "route-map", &idx)) | |
7233 | ospf_routemap_set (red, argv[idx+1]->arg); | |
7c8ff89e DS |
7234 | else |
7235 | ospf_routemap_unset (red); | |
7236 | ||
7237 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
7238 | } | |
7239 | ||
7240 | DEFUN (no_ospf_redistribute_instance_source, | |
7241 | no_ospf_redistribute_instance_source_cmd, | |
1a5ce38b | 7242 | "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
7c8ff89e DS |
7243 | NO_STR |
7244 | REDIST_STR | |
7245 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7246 | "Non-main Kernel Routing Table\n" |
7247 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
7248 | "Metric for redistributed routes\n" |
7249 | "OSPF default metric\n" | |
7250 | "OSPF exterior metric type for redistributed routes\n" | |
7251 | "Set OSPF External Type 1 metrics\n" | |
7252 | "Set OSPF External Type 2 metrics\n" | |
7253 | "Route map reference\n" | |
7254 | "Pointer to route-map entries\n") | |
7255 | { | |
cdc2d765 | 7256 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7257 | int idx_ospf_table = 2; |
7258 | int idx_number = 3; | |
7c8ff89e DS |
7259 | u_int instance; |
7260 | struct ospf_redist *red; | |
7261 | int source; | |
7262 | ||
8d769265 | 7263 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
2d627ff5 DS |
7264 | source = ZEBRA_ROUTE_OSPF; |
7265 | else | |
7266 | source = ZEBRA_ROUTE_TABLE; | |
7267 | ||
8d769265 | 7268 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7c8ff89e | 7269 | |
2d627ff5 | 7270 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7271 | { |
7272 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
7273 | VTY_NEWLINE); | |
7274 | return CMD_WARNING; | |
7275 | } | |
7276 | ||
2d627ff5 | 7277 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7278 | { |
7279 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
7280 | VTY_NEWLINE); | |
7281 | return CMD_WARNING; | |
7282 | } | |
7283 | ||
7c8ff89e DS |
7284 | red = ospf_redist_lookup(ospf, source, instance); |
7285 | if (!red) | |
7286 | return CMD_SUCCESS; | |
7287 | ||
7288 | ospf_routemap_unset (red); | |
7289 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 7290 | } |
7291 | ||
7292 | DEFUN (ospf_distribute_list_out, | |
7293 | ospf_distribute_list_out_cmd, | |
40d1cbfb | 7294 | "distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
718e3744 | 7295 | "Filter networks in routing updates\n" |
6f2a6703 CF |
7296 | "Access-list name\n" |
7297 | OUT_STR | |
ab0181ee | 7298 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 7299 | { |
cdc2d765 | 7300 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7301 | int idx_word = 1; |
6f2a6703 | 7302 | int source; |
718e3744 | 7303 | |
6d681bd8 QY |
7304 | char *proto = argv[argc - 1]->text; |
7305 | ||
6f2a6703 | 7306 | /* Get distribute source. */ |
6d681bd8 QY |
7307 | source = proto_redistnum(AFI_IP, proto); |
7308 | if (source < 0) | |
6f2a6703 | 7309 | return CMD_WARNING; |
718e3744 | 7310 | |
8d769265 | 7311 | return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); |
718e3744 | 7312 | } |
7313 | ||
6f2a6703 CF |
7314 | DEFUN (no_ospf_distribute_list_out, |
7315 | no_ospf_distribute_list_out_cmd, | |
40d1cbfb | 7316 | "no distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
6f2a6703 CF |
7317 | NO_STR |
7318 | "Filter networks in routing updates\n" | |
7319 | "Access-list name\n" | |
7320 | OUT_STR | |
ab0181ee | 7321 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 7322 | { |
cdc2d765 | 7323 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7324 | int idx_word = 2; |
6f2a6703 | 7325 | int source; |
020709f9 | 7326 | |
6d681bd8 QY |
7327 | char *proto = argv[argc - 1]->text; |
7328 | source = proto_redistnum(AFI_IP, proto); | |
7329 | if (source < 0) | |
6f2a6703 | 7330 | return CMD_WARNING; |
718e3744 | 7331 | |
8d769265 | 7332 | return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); |
718e3744 | 7333 | } |
7334 | ||
6f2a6703 CF |
7335 | /* Default information originate. */ |
7336 | DEFUN (ospf_default_information_originate, | |
7337 | ospf_default_information_originate_cmd, | |
e83a9414 | 7338 | "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7339 | "Control distribution of default information\n" |
7340 | "Distribute a default route\n" | |
7341 | "Always advertise default route\n" | |
6f2a6703 CF |
7342 | "OSPF default metric\n" |
7343 | "OSPF metric\n" | |
718e3744 | 7344 | "OSPF metric type for default routes\n" |
7345 | "Set OSPF External Type 1 metrics\n" | |
7346 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 7347 | "Route map reference\n" |
7348 | "Pointer to route-map entries\n") | |
7349 | { | |
cdc2d765 | 7350 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
6f2a6703 | 7351 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 7352 | int type = -1; |
7353 | int metric = -1; | |
7c8ff89e | 7354 | struct ospf_redist *red; |
6d681bd8 | 7355 | int idx = 0; |
7c8ff89e | 7356 | |
6d681bd8 | 7357 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
6f2a6703 CF |
7358 | |
7359 | /* Check whether "always" was specified */ | |
6d681bd8 | 7360 | if (argv_find (argv, argc, "always", &idx)) |
6f2a6703 | 7361 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
6d681bd8 QY |
7362 | /* Get metric value */ |
7363 | else if (argv_find (argv, argc, "(0-16777214)", &idx)) { | |
7364 | if (!str2metric (argv[idx]->arg, &metric)) | |
718e3744 | 7365 | return CMD_WARNING; |
6d681bd8 | 7366 | } |
718e3744 | 7367 | /* Get metric type. */ |
6d681bd8 QY |
7368 | else if (argv_find (argv, argc, "(1-2)", &idx)) { |
7369 | if (!str2metric_type (argv[idx]->arg, &type)) | |
718e3744 | 7370 | return CMD_WARNING; |
6d681bd8 QY |
7371 | } |
7372 | /* Get route-map */ | |
7373 | else if (argv_find (argv, argc, "WORD", &idx)) | |
7374 | ospf_routemap_set (red, argv[idx]->arg); | |
718e3744 | 7375 | else |
7c8ff89e | 7376 | ospf_routemap_unset (red); |
718e3744 | 7377 | |
6f2a6703 CF |
7378 | return ospf_redistribute_default_set (ospf, default_originate, |
7379 | type, metric); | |
718e3744 | 7380 | } |
7381 | ||
7382 | DEFUN (no_ospf_default_information_originate, | |
7383 | no_ospf_default_information_originate_cmd, | |
12dcf78e | 7384 | "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7385 | NO_STR |
7386 | "Control distribution of default information\n" | |
813d4307 DW |
7387 | "Distribute a default route\n" |
7388 | "Always advertise default route\n" | |
7389 | "OSPF default metric\n" | |
7390 | "OSPF metric\n" | |
7391 | "OSPF metric type for default routes\n" | |
7392 | "Set OSPF External Type 1 metrics\n" | |
7393 | "Set OSPF External Type 2 metrics\n" | |
7394 | "Route map reference\n" | |
7395 | "Pointer to route-map entries\n") | |
718e3744 | 7396 | { |
cdc2d765 | 7397 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 7398 | struct prefix_ipv4 p; |
7c8ff89e DS |
7399 | struct ospf_external *ext; |
7400 | struct ospf_redist *red; | |
7c8ff89e | 7401 | |
718e3744 | 7402 | p.family = AF_INET; |
7403 | p.prefix.s_addr = 0; | |
7404 | p.prefixlen = 0; | |
7405 | ||
5339cfdb | 7406 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 7407 | |
7c8ff89e DS |
7408 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
7409 | EXTERNAL_INFO (ext)) { | |
7410 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
7411 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 7412 | } |
7413 | ||
7c8ff89e DS |
7414 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
7415 | if (!red) | |
7416 | return CMD_SUCCESS; | |
7417 | ||
7418 | ospf_routemap_unset (red); | |
020709f9 | 7419 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 7420 | } |
7421 | ||
7422 | DEFUN (ospf_default_metric, | |
7423 | ospf_default_metric_cmd, | |
6147e2c6 | 7424 | "default-metric (0-16777214)", |
718e3744 | 7425 | "Set metric of redistributed routes\n" |
7426 | "Default metric\n") | |
7427 | { | |
cdc2d765 | 7428 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7429 | int idx_number = 1; |
718e3744 | 7430 | int metric = -1; |
7431 | ||
8d769265 | 7432 | if (!str2metric (argv[idx_number]->arg, &metric)) |
718e3744 | 7433 | return CMD_WARNING; |
7434 | ||
68980084 | 7435 | ospf->default_metric = metric; |
718e3744 | 7436 | |
7437 | return CMD_SUCCESS; | |
7438 | } | |
7439 | ||
7440 | DEFUN (no_ospf_default_metric, | |
7441 | no_ospf_default_metric_cmd, | |
7a7be519 | 7442 | "no default-metric [(0-16777214)]", |
718e3744 | 7443 | NO_STR |
7a7be519 | 7444 | "Set metric of redistributed routes\n" |
7445 | "Default metric\n") | |
718e3744 | 7446 | { |
cdc2d765 | 7447 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
68980084 | 7448 | |
7449 | ospf->default_metric = -1; | |
7450 | ||
718e3744 | 7451 | return CMD_SUCCESS; |
7452 | } | |
7453 | ||
718e3744 | 7454 | |
7455 | DEFUN (ospf_distance, | |
7456 | ospf_distance_cmd, | |
6147e2c6 | 7457 | "distance (1-255)", |
eaa1ae0d | 7458 | "Administrative distance\n" |
718e3744 | 7459 | "OSPF Administrative distance\n") |
7460 | { | |
cdc2d765 | 7461 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7462 | int idx_number = 1; |
68980084 | 7463 | |
8d769265 | 7464 | ospf->distance_all = atoi (argv[idx_number]->arg); |
68980084 | 7465 | |
718e3744 | 7466 | return CMD_SUCCESS; |
7467 | } | |
7468 | ||
7469 | DEFUN (no_ospf_distance, | |
7470 | no_ospf_distance_cmd, | |
6147e2c6 | 7471 | "no distance (1-255)", |
718e3744 | 7472 | NO_STR |
eaa1ae0d | 7473 | "Administrative distance\n" |
718e3744 | 7474 | "OSPF Administrative distance\n") |
7475 | { | |
cdc2d765 | 7476 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
68980084 | 7477 | |
7478 | ospf->distance_all = 0; | |
7479 | ||
718e3744 | 7480 | return CMD_SUCCESS; |
7481 | } | |
7482 | ||
7483 | DEFUN (no_ospf_distance_ospf, | |
7484 | no_ospf_distance_ospf_cmd, | |
eaa1ae0d | 7485 | "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]", |
718e3744 | 7486 | NO_STR |
eaa1ae0d QY |
7487 | "Administrative distance\n" |
7488 | "OSPF administrative distance\n" | |
718e3744 | 7489 | "Intra-area routes\n" |
813d4307 | 7490 | "Distance for intra-area routes\n" |
718e3744 | 7491 | "Inter-area routes\n" |
813d4307 DW |
7492 | "Distance for inter-area routes\n" |
7493 | "External routes\n" | |
7494 | "Distance for external routes\n") | |
718e3744 | 7495 | { |
cdc2d765 | 7496 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
eaa1ae0d | 7497 | int idx = 0; |
718e3744 | 7498 | |
7c8ff89e DS |
7499 | if (!ospf) |
7500 | return CMD_SUCCESS; | |
7501 | ||
eaa1ae0d QY |
7502 | if (argv_find (argv, argc, "intra-area", &idx) || argc == 3) |
7503 | idx = ospf->distance_intra = 0; | |
7504 | if (argv_find (argv, argc, "inter-area", &idx) || argc == 3) | |
7505 | idx = ospf->distance_inter = 0; | |
7506 | if (argv_find (argv, argc, "external", &idx) || argc == 3) | |
6f2a6703 | 7507 | ospf->distance_external = 0; |
718e3744 | 7508 | |
718e3744 | 7509 | return CMD_SUCCESS; |
7510 | } | |
7511 | ||
6f2a6703 CF |
7512 | DEFUN (ospf_distance_ospf, |
7513 | ospf_distance_ospf_cmd, | |
eaa1ae0d QY |
7514 | "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}", |
7515 | "Administrative distance\n" | |
7516 | "OSPF administrative distance\n" | |
718e3744 | 7517 | "Intra-area routes\n" |
7518 | "Distance for intra-area routes\n" | |
718e3744 | 7519 | "Inter-area routes\n" |
7520 | "Distance for inter-area routes\n" | |
7521 | "External routes\n" | |
718e3744 | 7522 | "Distance for external routes\n") |
7523 | { | |
cdc2d765 | 7524 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
eaa1ae0d | 7525 | int idx = 0; |
68980084 | 7526 | |
eaa1ae0d QY |
7527 | if (argv_find (argv, argc, "intra-area", &idx)) |
7528 | ospf->distance_intra = atoi(argv[idx + 1]->arg); | |
7529 | idx = 0; | |
7530 | if (argv_find (argv, argc, "inter-area", &idx)) | |
7531 | ospf->distance_inter = atoi(argv[idx + 1]->arg); | |
7532 | idx = 0; | |
7533 | if (argv_find (argv, argc, "external", &idx)) | |
7534 | ospf->distance_external = atoi(argv[idx + 1]->arg); | |
68980084 | 7535 | |
718e3744 | 7536 | return CMD_SUCCESS; |
7537 | } | |
7538 | ||
d7d73ffc | 7539 | #if 0 |
718e3744 | 7540 | DEFUN (ospf_distance_source, |
7541 | ospf_distance_source_cmd, | |
6147e2c6 | 7542 | "distance (1-255) A.B.C.D/M", |
718e3744 | 7543 | "Administrative distance\n" |
7544 | "Distance value\n" | |
7545 | "IP source prefix\n") | |
7546 | { | |
cdc2d765 | 7547 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7548 | int idx_number = 1; |
7549 | int idx_ipv4_prefixlen = 2; | |
020709f9 | 7550 | |
7c8ff89e DS |
7551 | if (!ospf) |
7552 | return CMD_SUCCESS; | |
7553 | ||
8d769265 | 7554 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
68980084 | 7555 | |
718e3744 | 7556 | return CMD_SUCCESS; |
7557 | } | |
7558 | ||
7559 | DEFUN (no_ospf_distance_source, | |
7560 | no_ospf_distance_source_cmd, | |
6147e2c6 | 7561 | "no distance (1-255) A.B.C.D/M", |
718e3744 | 7562 | NO_STR |
7563 | "Administrative distance\n" | |
7564 | "Distance value\n" | |
7565 | "IP source prefix\n") | |
7566 | { | |
cdc2d765 | 7567 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7568 | int idx_number = 2; |
7569 | int idx_ipv4_prefixlen = 3; | |
020709f9 | 7570 | |
7c8ff89e DS |
7571 | if (!ospf) |
7572 | return CMD_SUCCESS; | |
7573 | ||
8d769265 | 7574 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
020709f9 | 7575 | |
718e3744 | 7576 | return CMD_SUCCESS; |
7577 | } | |
7578 | ||
7579 | DEFUN (ospf_distance_source_access_list, | |
7580 | ospf_distance_source_access_list_cmd, | |
6147e2c6 | 7581 | "distance (1-255) A.B.C.D/M WORD", |
718e3744 | 7582 | "Administrative distance\n" |
7583 | "Distance value\n" | |
7584 | "IP source prefix\n" | |
7585 | "Access list name\n") | |
7586 | { | |
cdc2d765 | 7587 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7588 | int idx_number = 1; |
7589 | int idx_ipv4_prefixlen = 2; | |
7590 | int idx_word = 3; | |
020709f9 | 7591 | |
7c8ff89e DS |
7592 | if (!ospf) |
7593 | return CMD_SUCCESS; | |
7594 | ||
8d769265 | 7595 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 7596 | |
718e3744 | 7597 | return CMD_SUCCESS; |
7598 | } | |
7599 | ||
7600 | DEFUN (no_ospf_distance_source_access_list, | |
7601 | no_ospf_distance_source_access_list_cmd, | |
6147e2c6 | 7602 | "no distance (1-255) A.B.C.D/M WORD", |
718e3744 | 7603 | NO_STR |
7604 | "Administrative distance\n" | |
7605 | "Distance value\n" | |
7606 | "IP source prefix\n" | |
7607 | "Access list name\n") | |
7608 | { | |
cdc2d765 | 7609 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7610 | int idx_number = 2; |
7611 | int idx_ipv4_prefixlen = 3; | |
7612 | int idx_word = 4; | |
020709f9 | 7613 | |
7c8ff89e DS |
7614 | if (!ospf) |
7615 | return CMD_SUCCESS; | |
7616 | ||
8d769265 | 7617 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 7618 | |
718e3744 | 7619 | return CMD_SUCCESS; |
7620 | } | |
d7d73ffc | 7621 | #endif |
718e3744 | 7622 | |
ba682537 | 7623 | DEFUN (ip_ospf_mtu_ignore, |
7624 | ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 7625 | "ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 7626 | "IP Information\n" |
7627 | "OSPF interface commands\n" | |
99a522c7 | 7628 | "Disable MTU mismatch detection on this interface\n" |
ba682537 | 7629 | "Address of interface") |
7630 | { | |
cdc2d765 | 7631 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 7632 | int idx_ipv4 = 3; |
ba682537 | 7633 | struct in_addr addr; |
7634 | int ret; | |
7635 | ||
7636 | struct ospf_if_params *params; | |
7637 | params = IF_DEF_PARAMS (ifp); | |
7638 | ||
7a7be519 | 7639 | if (argc == 4) |
ba682537 | 7640 | { |
8d769265 | 7641 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
ba682537 | 7642 | if (!ret) |
7643 | { | |
7644 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7645 | VTY_NEWLINE); | |
7646 | return CMD_WARNING; | |
7647 | } | |
7648 | params = ospf_get_if_params (ifp, addr); | |
7649 | ospf_if_update_params (ifp, addr); | |
7650 | } | |
7651 | params->mtu_ignore = 1; | |
7652 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7653 | SET_IF_PARAM (params, mtu_ignore); | |
7654 | else | |
7655 | { | |
7656 | UNSET_IF_PARAM (params, mtu_ignore); | |
7657 | if (params != IF_DEF_PARAMS (ifp)) | |
7658 | { | |
7659 | ospf_free_if_params (ifp, addr); | |
7660 | ospf_if_update_params (ifp, addr); | |
7661 | } | |
7662 | } | |
7663 | return CMD_SUCCESS; | |
7664 | } | |
7665 | ||
ba682537 | 7666 | DEFUN (no_ip_ospf_mtu_ignore, |
7667 | no_ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 7668 | "no ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 7669 | "IP Information\n" |
7670 | "OSPF interface commands\n" | |
99a522c7 | 7671 | "Disable MTU mismatch detection on this interface\n" |
ba682537 | 7672 | "Address of interface") |
7673 | { | |
cdc2d765 | 7674 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 7675 | int idx_ipv4 = 4; |
ba682537 | 7676 | struct in_addr addr; |
7677 | int ret; | |
7678 | ||
7679 | struct ospf_if_params *params; | |
7680 | params = IF_DEF_PARAMS (ifp); | |
7681 | ||
7a7be519 | 7682 | if (argc == 5) |
ba682537 | 7683 | { |
8d769265 | 7684 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
ba682537 | 7685 | if (!ret) |
7686 | { | |
7687 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
7688 | VTY_NEWLINE); | |
7689 | return CMD_WARNING; | |
7690 | } | |
7691 | params = ospf_get_if_params (ifp, addr); | |
7692 | ospf_if_update_params (ifp, addr); | |
7693 | } | |
7694 | params->mtu_ignore = 0; | |
7695 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7696 | SET_IF_PARAM (params, mtu_ignore); | |
7697 | else | |
7698 | { | |
7699 | UNSET_IF_PARAM (params, mtu_ignore); | |
7700 | if (params != IF_DEF_PARAMS (ifp)) | |
7701 | { | |
7702 | ospf_free_if_params (ifp, addr); | |
7703 | ospf_if_update_params (ifp, addr); | |
7704 | } | |
7705 | } | |
7706 | return CMD_SUCCESS; | |
7707 | } | |
7708 | ||
6b0655a2 | 7709 | |
88d6cf37 | 7710 | DEFUN (ospf_max_metric_router_lsa_admin, |
7711 | ospf_max_metric_router_lsa_admin_cmd, | |
7712 | "max-metric router-lsa administrative", | |
7713 | "OSPF maximum / infinite-distance metric\n" | |
7714 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7715 | "Administratively applied, for an indefinite period\n") | |
7716 | { | |
cdc2d765 | 7717 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
88d6cf37 | 7718 | struct listnode *ln; |
7719 | struct ospf_area *area; | |
7c8ff89e | 7720 | |
88d6cf37 | 7721 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7722 | { | |
7723 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7724 | ||
7725 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 7726 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7727 | } |
4ba4fc85 AB |
7728 | |
7729 | /* Allows for areas configured later to get the property */ | |
7730 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
7731 | ||
88d6cf37 | 7732 | return CMD_SUCCESS; |
7733 | } | |
7734 | ||
7735 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
7736 | no_ospf_max_metric_router_lsa_admin_cmd, | |
7737 | "no max-metric router-lsa administrative", | |
7738 | NO_STR | |
7739 | "OSPF maximum / infinite-distance metric\n" | |
7740 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7741 | "Administratively applied, for an indefinite period\n") | |
7742 | { | |
cdc2d765 | 7743 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
88d6cf37 | 7744 | struct listnode *ln; |
7745 | struct ospf_area *area; | |
7c8ff89e | 7746 | |
88d6cf37 | 7747 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7748 | { | |
7749 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7750 | ||
7751 | /* Don't trample on the start-up stub timer */ | |
7752 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
7753 | && !area->t_stub_router) | |
7754 | { | |
7755 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 7756 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7757 | } |
7758 | } | |
4ba4fc85 | 7759 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 7760 | return CMD_SUCCESS; |
7761 | } | |
7762 | ||
7763 | DEFUN (ospf_max_metric_router_lsa_startup, | |
7764 | ospf_max_metric_router_lsa_startup_cmd, | |
6147e2c6 | 7765 | "max-metric router-lsa on-startup (5-86400)", |
88d6cf37 | 7766 | "OSPF maximum / infinite-distance metric\n" |
7767 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7768 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
7769 | "Time (seconds) to advertise self as stub-router\n") | |
7770 | { | |
cdc2d765 | 7771 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7772 | int idx_number = 3; |
88d6cf37 | 7773 | unsigned int seconds; |
7c8ff89e | 7774 | |
88d6cf37 | 7775 | if (argc != 1) |
7776 | { | |
7777 | vty_out (vty, "%% Must supply stub-router period"); | |
7778 | return CMD_WARNING; | |
7779 | } | |
7780 | ||
8d769265 | 7781 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[idx_number]->arg); |
88d6cf37 | 7782 | |
7783 | ospf->stub_router_startup_time = seconds; | |
7784 | ||
7785 | return CMD_SUCCESS; | |
7786 | } | |
7787 | ||
7788 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
7789 | no_ospf_max_metric_router_lsa_startup_cmd, | |
7a7be519 | 7790 | "no max-metric router-lsa on-startup [(5-86400)]", |
88d6cf37 | 7791 | NO_STR |
7792 | "OSPF maximum / infinite-distance metric\n" | |
7793 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
7794 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
7795 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 7796 | { |
cdc2d765 | 7797 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
88d6cf37 | 7798 | struct listnode *ln; |
7799 | struct ospf_area *area; | |
7c8ff89e | 7800 | |
88d6cf37 | 7801 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
7802 | ||
7803 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
7804 | { | |
7805 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
7806 | OSPF_TIMER_OFF (area->t_stub_router); | |
7807 | ||
7808 | /* Don't trample on admin stub routed */ | |
7809 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
7810 | { | |
7811 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 7812 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7813 | } |
7814 | } | |
7815 | return CMD_SUCCESS; | |
7816 | } | |
7817 | ||
a1afa410 | 7818 | |
88d6cf37 | 7819 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
7820 | ospf_max_metric_router_lsa_shutdown_cmd, | |
6147e2c6 | 7821 | "max-metric router-lsa on-shutdown (5-100)", |
88d6cf37 | 7822 | "OSPF maximum / infinite-distance metric\n" |
7823 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7824 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
7825 | "Time (seconds) to wait till full shutdown\n") | |
7826 | { | |
cdc2d765 | 7827 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7828 | int idx_number = 3; |
88d6cf37 | 7829 | unsigned int seconds; |
7c8ff89e | 7830 | |
88d6cf37 | 7831 | if (argc != 1) |
7832 | { | |
7833 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
7834 | return CMD_WARNING; | |
7835 | } | |
7836 | ||
8d769265 | 7837 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[idx_number]->arg); |
88d6cf37 | 7838 | |
7839 | ospf->stub_router_shutdown_time = seconds; | |
7840 | ||
7841 | return CMD_SUCCESS; | |
7842 | } | |
7843 | ||
7844 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
7845 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
7a7be519 | 7846 | "no max-metric router-lsa on-shutdown [(5-100)]", |
88d6cf37 | 7847 | NO_STR |
7848 | "OSPF maximum / infinite-distance metric\n" | |
7849 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
7850 | "Advertise stub-router prior to full shutdown of OSPF\n" |
7851 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 7852 | { |
cdc2d765 | 7853 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7c8ff89e | 7854 | |
88d6cf37 | 7855 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
7856 | ||
7857 | return CMD_SUCCESS; | |
7858 | } | |
7859 | ||
a636c635 DW |
7860 | static void |
7861 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
88d6cf37 | 7862 | { |
7863 | struct listnode *ln; | |
7864 | struct ospf_area *area; | |
7865 | ||
7866 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
7867 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
7868 | ospf->stub_router_startup_time, VTY_NEWLINE); | |
7869 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
7870 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
7871 | ospf->stub_router_shutdown_time, VTY_NEWLINE); | |
7872 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
7873 | { | |
7874 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
7875 | { | |
7876 | vty_out (vty, " max-metric router-lsa administrative%s", | |
7877 | VTY_NEWLINE); | |
7878 | break; | |
7879 | } | |
7880 | } | |
7881 | return; | |
7882 | } | |
6b0655a2 | 7883 | |
4dadc291 | 7884 | static void |
718e3744 | 7885 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
7886 | { | |
7887 | struct route_node *rn; | |
7888 | struct ospf_route *or; | |
1eb8ef25 | 7889 | struct listnode *pnode, *pnnode; |
718e3744 | 7890 | struct ospf_path *path; |
7891 | ||
7892 | vty_out (vty, "============ OSPF network routing table ============%s", | |
7893 | VTY_NEWLINE); | |
7894 | ||
7895 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
7896 | if ((or = rn->info) != NULL) | |
7897 | { | |
7898 | char buf1[19]; | |
7899 | snprintf (buf1, 19, "%s/%d", | |
7900 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
7901 | ||
7902 | switch (or->path_type) | |
7903 | { | |
7904 | case OSPF_PATH_INTER_AREA: | |
7905 | if (or->type == OSPF_DESTINATION_NETWORK) | |
7906 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
7907 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
7908 | else if (or->type == OSPF_DESTINATION_DISCARD) | |
7909 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); | |
7910 | break; | |
7911 | case OSPF_PATH_INTRA_AREA: | |
7912 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
7913 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); | |
7914 | break; | |
7915 | default: | |
7916 | break; | |
7917 | } | |
7918 | ||
7919 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 7920 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 7921 | { |
7e2b7603 | 7922 | if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) |
96735eea | 7923 | { |
7924 | if (path->nexthop.s_addr == 0) | |
7925 | vty_out (vty, "%24s directly attached to %s%s", | |
baaea325 | 7926 | "", ifindex2ifname (path->ifindex, VRF_DEFAULT), VTY_NEWLINE); |
96735eea | 7927 | else |
7928 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f | 7929 | inet_ntoa (path->nexthop), |
baaea325 | 7930 | ifindex2ifname (path->ifindex, VRF_DEFAULT), VTY_NEWLINE); |
96735eea | 7931 | } |
7932 | } | |
718e3744 | 7933 | } |
7934 | vty_out (vty, "%s", VTY_NEWLINE); | |
7935 | } | |
7936 | ||
4dadc291 | 7937 | static void |
718e3744 | 7938 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
7939 | { | |
7940 | struct route_node *rn; | |
7941 | struct ospf_route *or; | |
1eb8ef25 | 7942 | struct listnode *pnode; |
7943 | struct listnode *node; | |
718e3744 | 7944 | struct ospf_path *path; |
7945 | ||
7946 | vty_out (vty, "============ OSPF router routing table =============%s", | |
7947 | VTY_NEWLINE); | |
7948 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) | |
7949 | if (rn->info) | |
7950 | { | |
7951 | int flag = 0; | |
7952 | ||
7953 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
7954 | ||
1eb8ef25 | 7955 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
7956 | { | |
7957 | if (flag++) | |
7958 | vty_out (vty, "%24s", ""); | |
7959 | ||
7960 | /* Show path. */ | |
7961 | vty_out (vty, "%s [%d] area: %s", | |
7962 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
7963 | or->cost, inet_ntoa (or->u.std.area_id)); | |
7964 | /* Show flags. */ | |
7965 | vty_out (vty, "%s%s%s", | |
7966 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
7967 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
7968 | VTY_NEWLINE); | |
7969 | ||
7970 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
7971 | { | |
7e2b7603 | 7972 | if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) |
54bedb55 | 7973 | { |
7974 | if (path->nexthop.s_addr == 0) | |
7975 | vty_out (vty, "%24s directly attached to %s%s", | |
baaea325 | 7976 | "", ifindex2ifname (path->ifindex, VRF_DEFAULT), |
a8ba847f | 7977 | VTY_NEWLINE); |
54bedb55 | 7978 | else |
7979 | vty_out (vty, "%24s via %s, %s%s", "", | |
7980 | inet_ntoa (path->nexthop), | |
baaea325 | 7981 | ifindex2ifname (path->ifindex, VRF_DEFAULT), |
a8ba847f | 7982 | VTY_NEWLINE); |
54bedb55 | 7983 | } |
1eb8ef25 | 7984 | } |
7985 | } | |
718e3744 | 7986 | } |
7987 | vty_out (vty, "%s", VTY_NEWLINE); | |
7988 | } | |
7989 | ||
4dadc291 | 7990 | static void |
718e3744 | 7991 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
7992 | { | |
7993 | struct route_node *rn; | |
7994 | struct ospf_route *er; | |
1eb8ef25 | 7995 | struct listnode *pnode, *pnnode; |
718e3744 | 7996 | struct ospf_path *path; |
7997 | ||
7998 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
7999 | VTY_NEWLINE); | |
8000 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
8001 | if ((er = rn->info) != NULL) | |
8002 | { | |
8003 | char buf1[19]; | |
8004 | snprintf (buf1, 19, "%s/%d", | |
8005 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8006 | ||
8007 | switch (er->path_type) | |
8008 | { | |
8009 | case OSPF_PATH_TYPE1_EXTERNAL: | |
dc9ffce8 | 8010 | vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1, |
718e3744 | 8011 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
8012 | break; | |
8013 | case OSPF_PATH_TYPE2_EXTERNAL: | |
dc9ffce8 | 8014 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost, |
718e3744 | 8015 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
8016 | break; | |
8017 | } | |
8018 | ||
1eb8ef25 | 8019 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 8020 | { |
7e2b7603 | 8021 | if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) |
718e3744 | 8022 | { |
8023 | if (path->nexthop.s_addr == 0) | |
96735eea | 8024 | vty_out (vty, "%24s directly attached to %s%s", |
baaea325 | 8025 | "", ifindex2ifname (path->ifindex, VRF_DEFAULT), VTY_NEWLINE); |
96735eea | 8026 | else |
8027 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f | 8028 | inet_ntoa (path->nexthop), |
baaea325 | 8029 | ifindex2ifname (path->ifindex, VRF_DEFAULT), |
96735eea | 8030 | VTY_NEWLINE); |
718e3744 | 8031 | } |
8032 | } | |
8033 | } | |
8034 | vty_out (vty, "%s", VTY_NEWLINE); | |
8035 | } | |
8036 | ||
7c8ff89e DS |
8037 | static int |
8038 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 8039 | { |
7c8ff89e DS |
8040 | if (ospf->instance) |
8041 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
8042 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 8043 | |
68980084 | 8044 | if (ospf->new_table == NULL) |
718e3744 | 8045 | { |
8046 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
8047 | return CMD_SUCCESS; | |
8048 | } | |
8049 | ||
8050 | /* Show Network routes. | |
020709f9 | 8051 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 8052 | |
8053 | /* Show Router routes. */ | |
68980084 | 8054 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8055 | |
7c8ff89e DS |
8056 | vty_out (vty, "%s", VTY_NEWLINE); |
8057 | ||
718e3744 | 8058 | return CMD_SUCCESS; |
8059 | } | |
718e3744 | 8060 | |
7c8ff89e DS |
8061 | DEFUN (show_ip_ospf_border_routers, |
8062 | show_ip_ospf_border_routers_cmd, | |
8063 | "show ip ospf border-routers", | |
718e3744 | 8064 | SHOW_STR |
8065 | IP_STR | |
8066 | "OSPF information\n" | |
7c8ff89e | 8067 | "Show all the ABR's and ASBR's\n") |
718e3744 | 8068 | { |
020709f9 | 8069 | struct ospf *ospf; |
68980084 | 8070 | |
0bad4851 | 8071 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8072 | return CMD_SUCCESS; |
8073 | ||
8074 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8075 | } | |
8076 | ||
8077 | DEFUN (show_ip_ospf_instance_border_routers, | |
8078 | show_ip_ospf_instance_border_routers_cmd, | |
6147e2c6 | 8079 | "show ip ospf (1-65535) border-routers", |
7c8ff89e DS |
8080 | SHOW_STR |
8081 | IP_STR | |
8082 | "OSPF information\n" | |
8083 | "Instance ID\n" | |
8084 | "Show all the ABR's and ASBR's\n") | |
8085 | { | |
8d769265 | 8086 | int idx_number = 3; |
7c8ff89e DS |
8087 | struct ospf *ospf; |
8088 | u_short instance = 0; | |
8089 | ||
8d769265 | 8090 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 8091 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8092 | return CMD_SUCCESS; |
8093 | ||
8094 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8095 | } | |
8096 | ||
8097 | static int | |
8098 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
8099 | { | |
8100 | if (ospf->instance) | |
8101 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance, | |
8102 | VTY_NEWLINE, VTY_NEWLINE); | |
718e3744 | 8103 | |
68980084 | 8104 | if (ospf->new_table == NULL) |
718e3744 | 8105 | { |
8106 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); | |
8107 | return CMD_SUCCESS; | |
8108 | } | |
8109 | ||
8110 | /* Show Network routes. */ | |
68980084 | 8111 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 8112 | |
8113 | /* Show Router routes. */ | |
68980084 | 8114 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8115 | |
8116 | /* Show AS External routes. */ | |
68980084 | 8117 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 8118 | |
7c8ff89e DS |
8119 | vty_out (vty, "%s", VTY_NEWLINE); |
8120 | ||
718e3744 | 8121 | return CMD_SUCCESS; |
8122 | } | |
8123 | ||
7c8ff89e DS |
8124 | DEFUN (show_ip_ospf_route, |
8125 | show_ip_ospf_route_cmd, | |
8126 | "show ip ospf route", | |
8127 | SHOW_STR | |
8128 | IP_STR | |
8129 | "OSPF information\n" | |
8130 | "OSPF routing table\n") | |
8131 | { | |
8132 | struct ospf *ospf; | |
8133 | ||
0bad4851 | 8134 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8135 | return CMD_SUCCESS; |
8136 | ||
8137 | return show_ip_ospf_route_common(vty, ospf); | |
8138 | } | |
8139 | ||
8140 | DEFUN (show_ip_ospf_instance_route, | |
8141 | show_ip_ospf_instance_route_cmd, | |
6147e2c6 | 8142 | "show ip ospf (1-65535) route", |
7c8ff89e DS |
8143 | SHOW_STR |
8144 | IP_STR | |
8145 | "OSPF information\n" | |
8146 | "Instance ID\n" | |
8147 | "OSPF routing table\n") | |
8148 | { | |
8d769265 | 8149 | int idx_number = 3; |
7c8ff89e DS |
8150 | struct ospf *ospf; |
8151 | u_short instance = 0; | |
8152 | ||
8d769265 | 8153 | VTY_GET_INTEGER ("Instance", instance, argv[idx_number]->arg); |
0bad4851 | 8154 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8155 | return CMD_SUCCESS; |
8156 | ||
8157 | return show_ip_ospf_route_common(vty, ospf); | |
8158 | } | |
6b0655a2 | 8159 | |
eb1ce605 | 8160 | const char *ospf_abr_type_str[] = |
718e3744 | 8161 | { |
8162 | "unknown", | |
8163 | "standard", | |
8164 | "ibm", | |
8165 | "cisco", | |
8166 | "shortcut" | |
8167 | }; | |
8168 | ||
eb1ce605 | 8169 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 8170 | { |
8171 | "default", | |
8172 | "enable", | |
8173 | "disable" | |
8174 | }; | |
8175 | ||
eb1ce605 | 8176 | const char *ospf_int_type_str[] = |
718e3744 | 8177 | { |
8178 | "unknown", /* should never be used. */ | |
8179 | "point-to-point", | |
8180 | "broadcast", | |
8181 | "non-broadcast", | |
8182 | "point-to-multipoint", | |
8183 | "virtual-link", /* should never be used. */ | |
8184 | "loopback" | |
8185 | }; | |
8186 | ||
8187 | /* Configuration write function for ospfd. */ | |
4dadc291 | 8188 | static int |
718e3744 | 8189 | config_write_interface (struct vty *vty) |
8190 | { | |
52dc7ee6 | 8191 | struct listnode *n1, *n2; |
718e3744 | 8192 | struct interface *ifp; |
8193 | struct crypt_key *ck; | |
8194 | int write = 0; | |
8195 | struct route_node *rn = NULL; | |
8196 | struct ospf_if_params *params; | |
7c8ff89e | 8197 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 8198 | |
b2d7c082 | 8199 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp)) |
718e3744 | 8200 | { |
718e3744 | 8201 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
8202 | continue; | |
8203 | ||
84361d61 DS |
8204 | if (ifp->ifindex == IFINDEX_DELETED) |
8205 | continue; | |
8206 | ||
718e3744 | 8207 | vty_out (vty, "!%s", VTY_NEWLINE); |
8208 | vty_out (vty, "interface %s%s", ifp->name, | |
8209 | VTY_NEWLINE); | |
8210 | if (ifp->desc) | |
8211 | vty_out (vty, " description %s%s", ifp->desc, | |
8212 | VTY_NEWLINE); | |
8213 | ||
8214 | write++; | |
8215 | ||
8216 | params = IF_DEF_PARAMS (ifp); | |
8217 | ||
8218 | do { | |
8219 | /* Interface Network print. */ | |
8220 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 8221 | params->type != OSPF_IFTYPE_LOOPBACK) |
8222 | { | |
bc18d616 | 8223 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 8224 | { |
8225 | vty_out (vty, " ip ospf network %s", | |
8226 | ospf_int_type_str[params->type]); | |
8227 | if (params != IF_DEF_PARAMS (ifp)) | |
8228 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8229 | vty_out (vty, "%s", VTY_NEWLINE); | |
8230 | } | |
718e3744 | 8231 | } |
8232 | ||
8233 | /* OSPF interface authentication print */ | |
8234 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
8235 | params->auth_type != OSPF_AUTH_NOTSET) | |
8236 | { | |
eb1ce605 | 8237 | const char *auth_str; |
718e3744 | 8238 | |
8239 | /* Translation tables are not that much help here due to syntax | |
8240 | of the simple option */ | |
8241 | switch (params->auth_type) | |
8242 | { | |
8243 | ||
8244 | case OSPF_AUTH_NULL: | |
8245 | auth_str = " null"; | |
8246 | break; | |
8247 | ||
8248 | case OSPF_AUTH_SIMPLE: | |
8249 | auth_str = ""; | |
8250 | break; | |
8251 | ||
8252 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
8253 | auth_str = " message-digest"; | |
8254 | break; | |
8255 | ||
8256 | default: | |
8257 | auth_str = ""; | |
8258 | break; | |
8259 | } | |
8260 | ||
8261 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
8262 | if (params != IF_DEF_PARAMS (ifp)) | |
8263 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8264 | vty_out (vty, "%s", VTY_NEWLINE); | |
8265 | } | |
8266 | ||
8267 | /* Simple Authentication Password print. */ | |
8268 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
8269 | params->auth_simple[0] != '\0') | |
8270 | { | |
8271 | vty_out (vty, " ip ospf authentication-key %s", | |
8272 | params->auth_simple); | |
8273 | if (params != IF_DEF_PARAMS (ifp)) | |
8274 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8275 | vty_out (vty, "%s", VTY_NEWLINE); | |
8276 | } | |
8277 | ||
8278 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 8279 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 8280 | { |
718e3744 | 8281 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 8282 | ck->key_id, ck->auth_key); |
718e3744 | 8283 | if (params != IF_DEF_PARAMS (ifp)) |
8284 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8285 | vty_out (vty, "%s", VTY_NEWLINE); | |
8286 | } | |
8287 | ||
8288 | /* Interface Output Cost print. */ | |
8289 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
8290 | { | |
8291 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
8292 | if (params != IF_DEF_PARAMS (ifp)) | |
8293 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8294 | vty_out (vty, "%s", VTY_NEWLINE); | |
8295 | } | |
8296 | ||
8297 | /* Hello Interval print. */ | |
8298 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
8299 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
8300 | { | |
8301 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
8302 | if (params != IF_DEF_PARAMS (ifp)) | |
8303 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8304 | vty_out (vty, "%s", VTY_NEWLINE); | |
8305 | } | |
8306 | ||
8307 | ||
8308 | /* Router Dead Interval print. */ | |
8309 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
8310 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
8311 | { | |
f9ad937f | 8312 | vty_out (vty, " ip ospf dead-interval "); |
8313 | ||
8314 | /* fast hello ? */ | |
8315 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
8316 | vty_out (vty, "minimal hello-multiplier %d", | |
8317 | params->fast_hello); | |
8318 | else | |
8319 | vty_out (vty, "%u", params->v_wait); | |
8320 | ||
718e3744 | 8321 | if (params != IF_DEF_PARAMS (ifp)) |
8322 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8323 | vty_out (vty, "%s", VTY_NEWLINE); | |
8324 | } | |
8325 | ||
8326 | /* Router Priority print. */ | |
8327 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
8328 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
8329 | { | |
8330 | vty_out (vty, " ip ospf priority %u", params->priority); | |
8331 | if (params != IF_DEF_PARAMS (ifp)) | |
8332 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8333 | vty_out (vty, "%s", VTY_NEWLINE); | |
8334 | } | |
8335 | ||
8336 | /* Retransmit Interval print. */ | |
8337 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
8338 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
8339 | { | |
8340 | vty_out (vty, " ip ospf retransmit-interval %u", | |
8341 | params->retransmit_interval); | |
8342 | if (params != IF_DEF_PARAMS (ifp)) | |
8343 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8344 | vty_out (vty, "%s", VTY_NEWLINE); | |
8345 | } | |
8346 | ||
8347 | /* Transmit Delay print. */ | |
8348 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
8349 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8350 | { | |
8351 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
8352 | if (params != IF_DEF_PARAMS (ifp)) | |
8353 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8354 | vty_out (vty, "%s", VTY_NEWLINE); | |
8355 | } | |
8356 | ||
953cde65 JT |
8357 | /* Area print. */ |
8358 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
8359 | { | |
8360 | if (ospf->instance) | |
8361 | vty_out (vty, " ip ospf %d area %s%s", ospf->instance, | |
8362 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
8363 | else | |
8364 | vty_out (vty, " ip ospf area %s%s", | |
8365 | inet_ntoa (params->if_area), VTY_NEWLINE); | |
8366 | ||
8367 | } | |
8368 | ||
d5a5c8f0 | 8369 | /* bfd print. */ |
7f342629 | 8370 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 8371 | |
ba682537 | 8372 | /* MTU ignore print. */ |
8373 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
8374 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8375 | { | |
8376 | if (params->mtu_ignore == 0) | |
8377 | vty_out (vty, " no ip ospf mtu-ignore"); | |
8378 | else | |
8379 | vty_out (vty, " ip ospf mtu-ignore"); | |
8380 | if (params != IF_DEF_PARAMS (ifp)) | |
8381 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
8382 | vty_out (vty, "%s", VTY_NEWLINE); | |
8383 | } | |
8384 | ||
8385 | ||
718e3744 | 8386 | while (1) |
8387 | { | |
8388 | if (rn == NULL) | |
8389 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
8390 | else | |
8391 | rn = route_next (rn); | |
8392 | ||
8393 | if (rn == NULL) | |
8394 | break; | |
8395 | params = rn->info; | |
8396 | if (params != NULL) | |
8397 | break; | |
8398 | } | |
8399 | } while (rn); | |
8400 | ||
718e3744 | 8401 | ospf_opaque_config_write_if (vty, ifp); |
718e3744 | 8402 | } |
8403 | ||
8404 | return write; | |
8405 | } | |
8406 | ||
4dadc291 | 8407 | static int |
68980084 | 8408 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8409 | { |
8410 | struct route_node *rn; | |
8411 | u_char buf[INET_ADDRSTRLEN]; | |
8412 | ||
8413 | /* `network area' print. */ | |
68980084 | 8414 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 8415 | if (rn->info) |
8416 | { | |
8417 | struct ospf_network *n = rn->info; | |
8418 | ||
8419 | memset (buf, 0, INET_ADDRSTRLEN); | |
8420 | ||
8421 | /* Create Area ID string by specified Area ID format. */ | |
86573dcb | 8422 | if (n->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) |
c9e52be3 | 8423 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 8424 | else |
c9e52be3 | 8425 | sprintf ((char *) buf, "%lu", |
718e3744 | 8426 | (unsigned long int) ntohl (n->area_id.s_addr)); |
8427 | ||
8428 | /* Network print. */ | |
8429 | vty_out (vty, " network %s/%d area %s%s", | |
8430 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
8431 | buf, VTY_NEWLINE); | |
8432 | } | |
8433 | ||
8434 | return 0; | |
8435 | } | |
8436 | ||
4dadc291 | 8437 | static int |
68980084 | 8438 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8439 | { |
52dc7ee6 | 8440 | struct listnode *node; |
1eb8ef25 | 8441 | struct ospf_area *area; |
718e3744 | 8442 | u_char buf[INET_ADDRSTRLEN]; |
8443 | ||
8444 | /* Area configuration print. */ | |
1eb8ef25 | 8445 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 8446 | { |
718e3744 | 8447 | struct route_node *rn1; |
8448 | ||
86573dcb QY |
8449 | area_id2str ((char *) buf, INET_ADDRSTRLEN, &area->area_id, |
8450 | area->area_id_fmt); | |
718e3744 | 8451 | |
8452 | if (area->auth_type != OSPF_AUTH_NULL) | |
8453 | { | |
8454 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
8455 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); | |
8456 | else | |
8457 | vty_out (vty, " area %s authentication message-digest%s", | |
8458 | buf, VTY_NEWLINE); | |
8459 | } | |
8460 | ||
8461 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
8462 | vty_out (vty, " area %s shortcut %s%s", buf, | |
8463 | ospf_shortcut_mode_str[area->shortcut_configured], | |
8464 | VTY_NEWLINE); | |
8465 | ||
8466 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 8467 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 8468 | ) |
8469 | { | |
b0a053be | 8470 | if (area->external_routing == OSPF_AREA_STUB) |
8471 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 8472 | else if (area->external_routing == OSPF_AREA_NSSA) |
8473 | { | |
8474 | vty_out (vty, " area %s nssa", buf); | |
8475 | switch (area->NSSATranslatorRole) | |
8476 | { | |
8477 | case OSPF_NSSA_ROLE_NEVER: | |
8478 | vty_out (vty, " translate-never"); | |
8479 | break; | |
8480 | case OSPF_NSSA_ROLE_ALWAYS: | |
8481 | vty_out (vty, " translate-always"); | |
8482 | break; | |
8483 | case OSPF_NSSA_ROLE_CANDIDATE: | |
8484 | default: | |
8485 | vty_out (vty, " translate-candidate"); | |
8486 | } | |
8487 | } | |
718e3744 | 8488 | |
8489 | if (area->no_summary) | |
8490 | vty_out (vty, " no-summary"); | |
8491 | ||
8492 | vty_out (vty, "%s", VTY_NEWLINE); | |
8493 | ||
8494 | if (area->default_cost != 1) | |
8495 | vty_out (vty, " area %s default-cost %d%s", buf, | |
8496 | area->default_cost, VTY_NEWLINE); | |
8497 | } | |
8498 | ||
8499 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
8500 | if (rn1->info) | |
8501 | { | |
8502 | struct ospf_area_range *range = rn1->info; | |
8503 | ||
8504 | vty_out (vty, " area %s range %s/%d", buf, | |
8505 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
8506 | ||
6c835671 | 8507 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 8508 | vty_out (vty, " cost %d", range->cost_config); |
8509 | ||
8510 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
8511 | vty_out (vty, " not-advertise"); | |
8512 | ||
8513 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
8514 | vty_out (vty, " substitute %s/%d", | |
8515 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
8516 | ||
8517 | vty_out (vty, "%s", VTY_NEWLINE); | |
8518 | } | |
8519 | ||
8520 | if (EXPORT_NAME (area)) | |
8521 | vty_out (vty, " area %s export-list %s%s", buf, | |
8522 | EXPORT_NAME (area), VTY_NEWLINE); | |
8523 | ||
8524 | if (IMPORT_NAME (area)) | |
8525 | vty_out (vty, " area %s import-list %s%s", buf, | |
8526 | IMPORT_NAME (area), VTY_NEWLINE); | |
8527 | ||
8528 | if (PREFIX_NAME_IN (area)) | |
8529 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
8530 | PREFIX_NAME_IN (area), VTY_NEWLINE); | |
8531 | ||
8532 | if (PREFIX_NAME_OUT (area)) | |
8533 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
8534 | PREFIX_NAME_OUT (area), VTY_NEWLINE); | |
8535 | } | |
8536 | ||
8537 | return 0; | |
8538 | } | |
8539 | ||
4dadc291 | 8540 | static int |
68980084 | 8541 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 8542 | { |
8543 | struct ospf_nbr_nbma *nbr_nbma; | |
8544 | struct route_node *rn; | |
8545 | ||
8546 | /* Static Neighbor configuration print. */ | |
68980084 | 8547 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 8548 | if ((nbr_nbma = rn->info)) |
8549 | { | |
8550 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
8551 | ||
8552 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
8553 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
8554 | ||
8555 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
8556 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
8557 | ||
8558 | vty_out (vty, "%s", VTY_NEWLINE); | |
8559 | } | |
8560 | ||
8561 | return 0; | |
8562 | } | |
8563 | ||
4dadc291 | 8564 | static int |
68980084 | 8565 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 8566 | { |
52dc7ee6 | 8567 | struct listnode *node; |
1eb8ef25 | 8568 | struct ospf_vl_data *vl_data; |
86573dcb | 8569 | char buf[INET_ADDRSTRLEN]; |
718e3744 | 8570 | |
8571 | /* Virtual-Link print */ | |
1eb8ef25 | 8572 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 8573 | { |
52dc7ee6 | 8574 | struct listnode *n2; |
718e3744 | 8575 | struct crypt_key *ck; |
718e3744 | 8576 | struct ospf_interface *oi; |
8577 | ||
8578 | if (vl_data != NULL) | |
8579 | { | |
8580 | memset (buf, 0, INET_ADDRSTRLEN); | |
86573dcb QY |
8581 | |
8582 | area_id2str (buf, sizeof(buf), &vl_data->vl_area_id, vl_data->vl_area_id_fmt); | |
718e3744 | 8583 | oi = vl_data->vl_oi; |
8584 | ||
8585 | /* timers */ | |
8586 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
8587 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
8588 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
8589 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8590 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
8591 | buf, | |
8592 | inet_ntoa (vl_data->vl_peer), | |
8593 | OSPF_IF_PARAM (oi, v_hello), | |
8594 | OSPF_IF_PARAM (oi, retransmit_interval), | |
8595 | OSPF_IF_PARAM (oi, transmit_delay), | |
8596 | OSPF_IF_PARAM (oi, v_wait), | |
8597 | VTY_NEWLINE); | |
8598 | else | |
8599 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
8600 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); | |
8601 | /* Auth key */ | |
8602 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
8603 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
8604 | buf, | |
8605 | inet_ntoa (vl_data->vl_peer), | |
8606 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
8607 | VTY_NEWLINE); | |
8608 | /* md5 keys */ | |
1eb8ef25 | 8609 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
8610 | n2, ck)) | |
8611 | vty_out (vty, " area %s virtual-link %s" | |
8612 | " message-digest-key %d md5 %s%s", | |
8613 | buf, | |
8614 | inet_ntoa (vl_data->vl_peer), | |
8615 | ck->key_id, ck->auth_key, VTY_NEWLINE); | |
718e3744 | 8616 | |
8617 | } | |
8618 | } | |
8619 | ||
8620 | return 0; | |
8621 | } | |
8622 | ||
6b0655a2 | 8623 | |
4dadc291 | 8624 | static int |
68980084 | 8625 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8626 | { |
8627 | int type; | |
8628 | ||
8629 | /* redistribute print. */ | |
8630 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
8631 | { |
8632 | struct list *red_list; | |
8633 | struct listnode *node; | |
8634 | struct ospf_redist *red; | |
718e3744 | 8635 | |
7c8ff89e DS |
8636 | red_list = ospf->redist[type]; |
8637 | if (!red_list) | |
8638 | continue; | |
8639 | ||
8640 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
8641 | { | |
8642 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
8643 | if (red->instance) | |
8644 | vty_out (vty, " %d", red->instance); | |
8645 | ||
8646 | if (red->dmetric.value >= 0) | |
8647 | vty_out (vty, " metric %d", red->dmetric.value); | |
8648 | ||
8649 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8650 | vty_out (vty, " metric-type 1"); | |
8651 | ||
8652 | if (ROUTEMAP_NAME (red)) | |
8653 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
8654 | ||
8655 | vty_out (vty, "%s", VTY_NEWLINE); | |
8656 | } | |
8657 | } | |
718e3744 | 8658 | |
8659 | return 0; | |
8660 | } | |
8661 | ||
4dadc291 | 8662 | static int |
68980084 | 8663 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 8664 | { |
68980084 | 8665 | if (ospf->default_metric != -1) |
8666 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
718e3744 | 8667 | VTY_NEWLINE); |
8668 | return 0; | |
8669 | } | |
8670 | ||
4dadc291 | 8671 | static int |
68980084 | 8672 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8673 | { |
8674 | int type; | |
7c8ff89e | 8675 | struct ospf_redist *red; |
718e3744 | 8676 | |
68980084 | 8677 | if (ospf) |
718e3744 | 8678 | { |
8679 | /* distribute-list print. */ | |
8680 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 8681 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 8682 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 8683 | DISTRIBUTE_NAME (ospf, type), |
f52d13cb | 8684 | zebra_route_string(type), VTY_NEWLINE); |
718e3744 | 8685 | |
8686 | /* default-information print. */ | |
68980084 | 8687 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 8688 | { |
c42c177d | 8689 | vty_out (vty, " default-information originate"); |
8690 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
8691 | vty_out (vty, " always"); | |
718e3744 | 8692 | |
7c8ff89e DS |
8693 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8694 | if (red) | |
8695 | { | |
8696 | if (red->dmetric.value >= 0) | |
8697 | vty_out (vty, " metric %d", | |
8698 | red->dmetric.value); | |
8699 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8700 | vty_out (vty, " metric-type 1"); | |
8701 | ||
8702 | if (ROUTEMAP_NAME (red)) | |
8703 | vty_out (vty, " route-map %s", | |
8704 | ROUTEMAP_NAME (red)); | |
8705 | } | |
718e3744 | 8706 | |
8707 | vty_out (vty, "%s", VTY_NEWLINE); | |
8708 | } | |
8709 | ||
8710 | } | |
8711 | ||
8712 | return 0; | |
8713 | } | |
8714 | ||
4dadc291 | 8715 | static int |
68980084 | 8716 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 8717 | { |
8718 | struct route_node *rn; | |
8719 | struct ospf_distance *odistance; | |
8720 | ||
68980084 | 8721 | if (ospf->distance_all) |
8722 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); | |
718e3744 | 8723 | |
68980084 | 8724 | if (ospf->distance_intra |
8725 | || ospf->distance_inter | |
8726 | || ospf->distance_external) | |
718e3744 | 8727 | { |
8728 | vty_out (vty, " distance ospf"); | |
8729 | ||
68980084 | 8730 | if (ospf->distance_intra) |
8731 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
8732 | if (ospf->distance_inter) | |
8733 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
8734 | if (ospf->distance_external) | |
8735 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 8736 | |
8737 | vty_out (vty, "%s", VTY_NEWLINE); | |
8738 | } | |
8739 | ||
68980084 | 8740 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 8741 | if ((odistance = rn->info) != NULL) |
8742 | { | |
8743 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
8744 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
8745 | odistance->access_list ? odistance->access_list : "", | |
8746 | VTY_NEWLINE); | |
8747 | } | |
8748 | return 0; | |
8749 | } | |
8750 | ||
8751 | /* OSPF configuration write function. */ | |
4dadc291 | 8752 | static int |
718e3744 | 8753 | ospf_config_write (struct vty *vty) |
8754 | { | |
020709f9 | 8755 | struct ospf *ospf; |
1eb8ef25 | 8756 | struct interface *ifp; |
8757 | struct ospf_interface *oi; | |
52dc7ee6 | 8758 | struct listnode *node; |
718e3744 | 8759 | int write = 0; |
8760 | ||
020709f9 | 8761 | ospf = ospf_lookup (); |
0bad4851 | 8762 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 8763 | { |
8764 | /* `router ospf' print. */ | |
7c8ff89e DS |
8765 | if (ospf->instance) |
8766 | vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE); | |
8767 | else | |
8768 | vty_out (vty, "router ospf%s", VTY_NEWLINE); | |
718e3744 | 8769 | |
8770 | write++; | |
8771 | ||
68980084 | 8772 | if (!ospf->networks) |
718e3744 | 8773 | return write; |
8774 | ||
8775 | /* Router ID print. */ | |
68980084 | 8776 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 8777 | vty_out (vty, " ospf router-id %s%s", |
68980084 | 8778 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
718e3744 | 8779 | |
8780 | /* ABR type print. */ | |
d57834f6 | 8781 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 8782 | vty_out (vty, " ospf abr-type %s%s", |
68980084 | 8783 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
718e3744 | 8784 | |
d7e60dd7 AS |
8785 | /* log-adjacency-changes flag print. */ |
8786 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
8787 | { | |
d7e60dd7 | 8788 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
692c7954 | 8789 | vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE); |
8efe88ea DL |
8790 | else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES) |
8791 | vty_out(vty, " log-adjacency-changes%s", VTY_NEWLINE); | |
d7e60dd7 | 8792 | } |
8efe88ea | 8793 | else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) |
692c7954 DW |
8794 | { |
8795 | vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE); | |
8796 | } | |
d7e60dd7 | 8797 | |
718e3744 | 8798 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 8799 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
718e3744 | 8800 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
8801 | ||
8802 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 8803 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 8804 | { |
8805 | vty_out (vty, "! Important: ensure reference bandwidth " | |
8806 | "is consistent across all routers%s", VTY_NEWLINE); | |
8807 | vty_out (vty, " auto-cost reference-bandwidth %d%s", | |
70bd3c43 | 8808 | ospf->ref_bandwidth, VTY_NEWLINE); |
f9ad937f | 8809 | } |
718e3744 | 8810 | |
8811 | /* SPF timers print. */ | |
68980084 | 8812 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 8813 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
8814 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
8815 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 8816 | ospf->spf_delay, ospf->spf_holdtime, |
ea4ffc90 | 8817 | ospf->spf_max_holdtime, VTY_NEWLINE); |
b6927875 DS |
8818 | |
8819 | /* LSA timers print. */ | |
ac7424f9 MR |
8820 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
8821 | vty_out (vty, " timers throttle lsa all %d%s", | |
8822 | ospf->min_ls_interval, VTY_NEWLINE); | |
8823 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
b6927875 | 8824 | vty_out (vty, " timers lsa min-arrival %d%s", |
ac7424f9 | 8825 | ospf->min_ls_arrival, VTY_NEWLINE); |
b6927875 | 8826 | |
2f8f370e | 8827 | /* Write multiplier print. */ |
e8f45e82 | 8828 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 8829 | vty_out (vty, " ospf write-multiplier %d%s", |
e8f45e82 | 8830 | ospf->write_oi_count, VTY_NEWLINE); |
2f8f370e | 8831 | |
88d6cf37 | 8832 | /* Max-metric router-lsa print */ |
8833 | config_write_stub_router (vty, ospf); | |
8834 | ||
718e3744 | 8835 | /* SPF refresh parameters print. */ |
68980084 | 8836 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 8837 | vty_out (vty, " refresh timer %d%s", |
68980084 | 8838 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
718e3744 | 8839 | |
8840 | /* Redistribute information print. */ | |
68980084 | 8841 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 8842 | |
8843 | /* passive-interface print. */ | |
7ffa8fa2 PJ |
8844 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
8845 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); | |
8846 | ||
1eb8ef25 | 8847 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
8848 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
8849 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
8850 | ospf->passive_interface_default) | |
8851 | { | |
8852 | vty_out (vty, " %spassive-interface %s%s", | |
8853 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
8854 | ifp->name, VTY_NEWLINE); | |
8855 | } | |
1eb8ef25 | 8856 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
8857 | { |
8858 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
8859 | continue; | |
8860 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
8861 | passive_interface)) | |
8862 | { | |
8863 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
8864 | continue; | |
8865 | } | |
8866 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
8867 | continue; | |
8868 | ||
8869 | vty_out (vty, " %spassive-interface %s %s%s", | |
8870 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 8871 | oi->ifp->name, |
8872 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); | |
7ffa8fa2 | 8873 | } |
718e3744 | 8874 | |
8875 | /* Network area print. */ | |
68980084 | 8876 | config_write_network_area (vty, ospf); |
718e3744 | 8877 | |
8878 | /* Area config print. */ | |
68980084 | 8879 | config_write_ospf_area (vty, ospf); |
718e3744 | 8880 | |
8881 | /* static neighbor print. */ | |
68980084 | 8882 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 8883 | |
8884 | /* Virtual-Link print. */ | |
68980084 | 8885 | config_write_virtual_link (vty, ospf); |
718e3744 | 8886 | |
8887 | /* Default metric configuration. */ | |
68980084 | 8888 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 8889 | |
8890 | /* Distribute-list and default-information print. */ | |
68980084 | 8891 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 8892 | |
8893 | /* Distance configuration. */ | |
68980084 | 8894 | config_write_ospf_distance (vty, ospf); |
718e3744 | 8895 | |
68980084 | 8896 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 8897 | } |
8898 | ||
8899 | return write; | |
8900 | } | |
8901 | ||
8902 | void | |
4dadc291 | 8903 | ospf_vty_show_init (void) |
718e3744 | 8904 | { |
8905 | /* "show ip ospf" commands. */ | |
8906 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
718e3744 | 8907 | |
7c8ff89e | 8908 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
7c8ff89e | 8909 | |
718e3744 | 8910 | /* "show ip ospf database" commands. */ |
718e3744 | 8911 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
7a7be519 | 8912 | install_element (VIEW_NODE, &show_ip_ospf_database_max_cmd); |
718e3744 | 8913 | |
7c8ff89e | 8914 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); |
7c8ff89e | 8915 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); |
7a7be519 | 8916 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_max_cmd); |
7c8ff89e | 8917 | |
718e3744 | 8918 | /* "show ip ospf interface" commands. */ |
8919 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
718e3744 | 8920 | |
7c8ff89e | 8921 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
7c8ff89e | 8922 | |
718e3744 | 8923 | /* "show ip ospf neighbor" commands. */ |
8924 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
8925 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
8926 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
8927 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
8928 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
8929 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
8930 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
718e3744 | 8931 | |
7c8ff89e DS |
8932 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
8933 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
8934 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
8935 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
8936 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
8937 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
8938 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
7c8ff89e | 8939 | |
718e3744 | 8940 | /* "show ip ospf route" commands. */ |
8941 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 8942 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
7c8ff89e DS |
8943 | |
8944 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
7c8ff89e | 8945 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); |
718e3744 | 8946 | } |
8947 | ||
6b0655a2 | 8948 | |
718e3744 | 8949 | /* ospfd's interface node. */ |
7fc626de | 8950 | static struct cmd_node interface_node = |
718e3744 | 8951 | { |
8952 | INTERFACE_NODE, | |
8953 | "%s(config-if)# ", | |
8954 | 1 | |
8955 | }; | |
8956 | ||
8957 | /* Initialization of OSPF interface. */ | |
4dadc291 | 8958 | static void |
8959 | ospf_vty_if_init (void) | |
718e3744 | 8960 | { |
8961 | /* Install interface node. */ | |
8962 | install_node (&interface_node, config_write_interface); | |
0b84f294 | 8963 | if_cmd_init (); |
718e3744 | 8964 | |
8965 | /* "ip ospf authentication" commands. */ | |
8966 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
718e3744 | 8967 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
b4a039bf | 8968 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
718e3744 | 8969 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
718e3744 | 8970 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
813d4307 | 8971 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); |
7a7be519 | 8972 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_addr_cmd); |
718e3744 | 8973 | |
8974 | /* "ip ospf message-digest-key" commands. */ | |
537eae3f QY |
8975 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
8976 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
718e3744 | 8977 | |
8978 | /* "ip ospf cost" commands. */ | |
5c2fc921 QY |
8979 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
8980 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); | |
718e3744 | 8981 | |
ba682537 | 8982 | /* "ip ospf mtu-ignore" commands. */ |
8983 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
ba682537 | 8984 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
ba682537 | 8985 | |
718e3744 | 8986 | /* "ip ospf dead-interval" commands. */ |
0d829fa7 | 8987 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
f9ad937f | 8988 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
0d829fa7 | 8989 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
f9ad937f | 8990 | |
718e3744 | 8991 | /* "ip ospf hello-interval" commands. */ |
0d829fa7 QY |
8992 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
8993 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
718e3744 | 8994 | |
8995 | /* "ip ospf network" commands. */ | |
8996 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
8997 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
8998 | ||
8999 | /* "ip ospf priority" commands. */ | |
537eae3f QY |
9000 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
9001 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); | |
718e3744 | 9002 | |
9003 | /* "ip ospf retransmit-interval" commands. */ | |
9004 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
718e3744 | 9005 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
718e3744 | 9006 | |
9007 | /* "ip ospf transmit-delay" commands. */ | |
9008 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
718e3744 | 9009 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
718e3744 | 9010 | |
953cde65 JT |
9011 | /* "ip ospf area" commands. */ |
9012 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
9013 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
953cde65 | 9014 | |
718e3744 | 9015 | /* These commands are compatibitliy for previous version. */ |
9016 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
718e3744 | 9017 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
537eae3f | 9018 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
718e3744 | 9019 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
537eae3f | 9020 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
718e3744 | 9021 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
537eae3f QY |
9022 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
9023 | install_element (INTERFACE_NODE, &ospf_cost_cmd); | |
9024 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); | |
718e3744 | 9025 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
537eae3f | 9026 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
718e3744 | 9027 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
537eae3f | 9028 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
718e3744 | 9029 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
537eae3f | 9030 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
718e3744 | 9031 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
537eae3f | 9032 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
718e3744 | 9033 | } |
9034 | ||
4dadc291 | 9035 | static void |
9036 | ospf_vty_zebra_init (void) | |
718e3744 | 9037 | { |
718e3744 | 9038 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 9039 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
9040 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
9041 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 9042 | |
9043 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
9044 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
9045 | ||
718e3744 | 9046 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 9047 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
9048 | ||
9049 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
9050 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
718e3744 | 9051 | |
9052 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
9053 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
9054 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 9055 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 9056 | #if 0 |
9057 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
9058 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
9059 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
9060 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
9061 | #endif /* 0 */ | |
9062 | } | |
9063 | ||
7fc626de | 9064 | static struct cmd_node ospf_node = |
718e3744 | 9065 | { |
9066 | OSPF_NODE, | |
9067 | "%s(config-router)# ", | |
9068 | 1 | |
9069 | }; | |
9070 | ||
09f35f8c DS |
9071 | static void |
9072 | ospf_interface_clear (struct interface *ifp) | |
9073 | { | |
9074 | if (!if_is_operative (ifp)) return; | |
9075 | ||
9076 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
4525281a | 9077 | zlog_debug("ISM[%s]: clear by reset", ifp->name); |
09f35f8c DS |
9078 | |
9079 | ospf_if_reset(ifp); | |
9080 | } | |
9081 | ||
9082 | DEFUN (clear_ip_ospf_interface, | |
9083 | clear_ip_ospf_interface_cmd, | |
9084 | "clear ip ospf interface [IFNAME]", | |
9085 | CLEAR_STR | |
9086 | IP_STR | |
9087 | "OSPF information\n" | |
9088 | "Interface information\n" | |
9089 | "Interface name\n") | |
9090 | { | |
8d769265 | 9091 | int idx_ifname = 4; |
09f35f8c DS |
9092 | struct interface *ifp; |
9093 | struct listnode *node; | |
9094 | ||
7a7be519 | 9095 | if (argc == 4) /* Clear all the ospfv2 interfaces. */ |
09f35f8c | 9096 | { |
b2d7c082 | 9097 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
09f35f8c DS |
9098 | ospf_interface_clear(ifp); |
9099 | } | |
9100 | else /* Interface name is specified. */ | |
9101 | { | |
1306c09a | 9102 | if ((ifp = if_lookup_by_name (argv[idx_ifname]->text, VRF_DEFAULT)) == NULL) |
09f35f8c DS |
9103 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
9104 | else | |
9105 | ospf_interface_clear(ifp); | |
9106 | } | |
9107 | ||
9108 | return CMD_SUCCESS; | |
9109 | } | |
9110 | ||
9111 | void | |
9112 | ospf_vty_clear_init (void) | |
9113 | { | |
9114 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
9115 | } | |
9116 | ||
6b0655a2 | 9117 | |
718e3744 | 9118 | /* Install OSPF related vty commands. */ |
9119 | void | |
4dadc291 | 9120 | ospf_vty_init (void) |
718e3744 | 9121 | { |
9122 | /* Install ospf top node. */ | |
9123 | install_node (&ospf_node, ospf_config_write); | |
9124 | ||
9125 | /* "router ospf" commands. */ | |
9126 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
9127 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
9128 | ||
7c8ff89e | 9129 | |
718e3744 | 9130 | install_default (OSPF_NODE); |
9131 | ||
9132 | /* "ospf router-id" commands. */ | |
9133 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
747e489c | 9134 | install_element (OSPF_NODE, &ospf_router_id_old_cmd); |
718e3744 | 9135 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
718e3744 | 9136 | |
9137 | /* "passive-interface" commands. */ | |
a2c62831 | 9138 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
a2c62831 | 9139 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
718e3744 | 9140 | |
9141 | /* "ospf abr-type" commands. */ | |
9142 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
9143 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
9144 | ||
d7e60dd7 AS |
9145 | /* "ospf log-adjacency-changes" commands. */ |
9146 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
9147 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
9148 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
9149 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
9150 | ||
718e3744 | 9151 | /* "ospf rfc1583-compatible" commands. */ |
718e3744 | 9152 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
9153 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
7a7be519 | 9154 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
9155 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
718e3744 | 9156 | |
9157 | /* "network area" commands. */ | |
a2c62831 | 9158 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
9159 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 9160 | |
9161 | /* "area authentication" commands. */ | |
a2c62831 | 9162 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
9163 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
9164 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 9165 | |
9166 | /* "area range" commands. */ | |
a2c62831 | 9167 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
7a7be519 | 9168 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
a2c62831 | 9169 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
9170 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
a2c62831 | 9171 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
9172 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 9173 | |
9174 | /* "area virtual-link" commands. */ | |
a2c62831 | 9175 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
7a7be519 | 9176 | install_element (OSPF_NODE, &ospf_area_vlink_intervals_cmd); |
a2c62831 | 9177 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
7a7be519 | 9178 | install_element (OSPF_NODE, &no_ospf_area_vlink_intervals_cmd); |
718e3744 | 9179 | |
718e3744 | 9180 | |
718e3744 | 9181 | |
718e3744 | 9182 | |
718e3744 | 9183 | |
718e3744 | 9184 | |
718e3744 | 9185 | |
718e3744 | 9186 | |
718e3744 | 9187 | |
718e3744 | 9188 | |
9189 | /* "area stub" commands. */ | |
a2c62831 | 9190 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
9191 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
9192 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
9193 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 9194 | |
718e3744 | 9195 | /* "area nssa" commands. */ |
a2c62831 | 9196 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
9197 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
9198 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
9199 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
9200 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
718e3744 | 9201 | |
a2c62831 | 9202 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
9203 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 9204 | |
a2c62831 | 9205 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
9206 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 9207 | |
a2c62831 | 9208 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
9209 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 9210 | |
a2c62831 | 9211 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
9212 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 9213 | |
a2c62831 | 9214 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
9215 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 9216 | |
9217 | /* SPF timer commands */ | |
d24f6e2a | 9218 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
9219 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
9220 | ||
b6927875 | 9221 | /* LSA timers commands */ |
ac7424f9 MR |
9222 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
9223 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
9224 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); | |
9225 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
b6927875 DS |
9226 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
9227 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
b6927875 | 9228 | |
88d6cf37 | 9229 | /* refresh timer commands */ |
a2c62831 | 9230 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
9231 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
718e3744 | 9232 | |
88d6cf37 | 9233 | /* max-metric commands */ |
9234 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
9235 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
9236 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
9237 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
9238 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
9239 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
9240 | ||
9241 | /* reference bandwidth commands */ | |
a2c62831 | 9242 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
9243 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
718e3744 | 9244 | |
9245 | /* "neighbor" commands. */ | |
a2c62831 | 9246 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
a2c62831 | 9247 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
a2c62831 | 9248 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
7a7be519 | 9249 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_cmd); |
718e3744 | 9250 | |
2f8f370e DS |
9251 | /* write multiplier commands */ |
9252 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
7a7be519 | 9253 | install_element (OSPF_NODE, &write_multiplier_cmd); |
2f8f370e | 9254 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); |
7a7be519 | 9255 | install_element (OSPF_NODE, &no_write_multiplier_cmd); |
2f8f370e | 9256 | |
718e3744 | 9257 | /* Init interface related vty commands. */ |
9258 | ospf_vty_if_init (); | |
9259 | ||
9260 | /* Init zebra related vty commands. */ | |
9261 | ospf_vty_zebra_init (); | |
9262 | } |