]>
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 | |
d62a17ae | 56 | static const char *ospf_network_type_str[] = { |
57 | "Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT", | |
58 | "VIRTUALLINK", "LOOPBACK"}; | |
718e3744 | 59 | |
718e3744 | 60 | /* Utility functions. */ |
d62a17ae | 61 | int str2area_id(const char *str, struct in_addr *area_id, int *area_id_fmt) |
718e3744 | 62 | { |
d62a17ae | 63 | char *ep; |
718e3744 | 64 | |
d62a17ae | 65 | area_id->s_addr = htonl(strtoul(str, &ep, 10)); |
66 | if (*ep && !inet_aton(str, area_id)) | |
67 | return -1; | |
718e3744 | 68 | |
d62a17ae | 69 | *area_id_fmt = |
70 | *ep ? OSPF_AREA_ID_FMT_DOTTEDQUAD : OSPF_AREA_ID_FMT_DECIMAL; | |
718e3744 | 71 | |
d62a17ae | 72 | return 0; |
718e3744 | 73 | } |
74 | ||
d62a17ae | 75 | void area_id2str(char *buf, int length, struct in_addr *area_id, |
76 | int area_id_fmt) | |
86573dcb | 77 | { |
d62a17ae | 78 | memset(buf, 0, length); |
86573dcb | 79 | |
d62a17ae | 80 | if (area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) |
81 | strncpy(buf, inet_ntoa(*area_id), length); | |
82 | else | |
83 | sprintf(buf, "%lu", (unsigned long)ntohl(area_id->s_addr)); | |
86573dcb | 84 | } |
6b0655a2 | 85 | |
d62a17ae | 86 | static int str2metric(const char *str, int *metric) |
718e3744 | 87 | { |
d62a17ae | 88 | /* Sanity check. */ |
89 | if (str == NULL) | |
90 | return 0; | |
718e3744 | 91 | |
d62a17ae | 92 | *metric = strtol(str, NULL, 10); |
93 | if (*metric < 0 && *metric > 16777214) { | |
94 | /* vty_out (vty, "OSPF metric value is invalid\n"); */ | |
95 | return 0; | |
96 | } | |
718e3744 | 97 | |
d62a17ae | 98 | return 1; |
718e3744 | 99 | } |
100 | ||
d62a17ae | 101 | static int str2metric_type(const char *str, int *metric_type) |
718e3744 | 102 | { |
d62a17ae | 103 | /* Sanity check. */ |
104 | if (str == NULL) | |
105 | return 0; | |
718e3744 | 106 | |
d62a17ae | 107 | if (strncmp(str, "1", 1) == 0) |
108 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
109 | else if (strncmp(str, "2", 1) == 0) | |
110 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
111 | else | |
112 | return 0; | |
718e3744 | 113 | |
d62a17ae | 114 | return 1; |
718e3744 | 115 | } |
116 | ||
d62a17ae | 117 | int ospf_oi_count(struct interface *ifp) |
718e3744 | 118 | { |
d62a17ae | 119 | struct route_node *rn; |
120 | int i = 0; | |
718e3744 | 121 | |
d62a17ae | 122 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) |
123 | if (rn->info) | |
124 | i++; | |
718e3744 | 125 | |
d62a17ae | 126 | return i; |
718e3744 | 127 | } |
128 | ||
996c9314 LB |
129 | #define OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \ |
130 | if (argv_find(argv, argc, "vrf", &idx_vrf)) { \ | |
131 | vrf_name = argv[idx_vrf + 1]->arg; \ | |
132 | all_vrf = strmatch(vrf_name, "all"); \ | |
43b8d1d8 CS |
133 | } |
134 | ||
135 | static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty, | |
136 | struct cmd_token *argv[], | |
996c9314 | 137 | const int argc, uint32_t enable, |
43b8d1d8 | 138 | u_short *instance) |
718e3744 | 139 | { |
b5a8894d | 140 | struct ospf *ospf = NULL; |
34d6798f | 141 | int idx_vrf = 0, idx_inst = 0; |
b5a8894d CS |
142 | const char *vrf_name = NULL; |
143 | ||
34d6798f CS |
144 | *instance = 0; |
145 | if (argv_find(argv, argc, "(1-65535)", &idx_inst)) | |
146 | *instance = strtoul(argv[idx_inst]->arg, NULL, 10); | |
147 | ||
b5a8894d | 148 | if (argv_find(argv, argc, "vrf", &idx_vrf)) { |
b5a8894d | 149 | vrf_name = argv[idx_vrf + 1]->arg; |
43b8d1d8 | 150 | if (enable) { |
43b8d1d8 CS |
151 | /* Allocate VRF aware instance */ |
152 | ospf = ospf_get(*instance, vrf_name); | |
153 | } else { | |
43b8d1d8 CS |
154 | ospf = ospf_lookup_by_inst_name(*instance, vrf_name); |
155 | } | |
b5a8894d | 156 | } else { |
43b8d1d8 | 157 | if (enable) { |
34d6798f | 158 | ospf = ospf_get(*instance, NULL); |
43b8d1d8 | 159 | } else { |
43b8d1d8 | 160 | ospf = ospf_lookup_instance(*instance); |
b5a8894d | 161 | } |
d62a17ae | 162 | } |
34d6798f | 163 | |
43b8d1d8 CS |
164 | return ospf; |
165 | } | |
166 | ||
52d0c099 | 167 | static void ospf_show_vrf_name(struct ospf *ospf, struct vty *vty, |
b1c3ae8c | 168 | json_object *json, u_char use_vrf) |
52d0c099 | 169 | { |
b1c3ae8c CS |
170 | if (use_vrf) { |
171 | if (json) { | |
172 | if (ospf->vrf_id == VRF_DEFAULT) | |
173 | json_object_string_add(json, "vrfName", | |
174 | "default"); | |
175 | else | |
176 | json_object_string_add(json, "vrfName", | |
177 | ospf->name); | |
178 | json_object_int_add(json, "vrfId", ospf->vrf_id); | |
179 | } else { | |
180 | if (ospf->vrf_id == VRF_DEFAULT) | |
181 | vty_out(vty, "VRF Name: %s\n", "default"); | |
182 | else if (ospf->name) | |
183 | vty_out(vty, "VRF Name: %s\n", ospf->name); | |
184 | } | |
52d0c099 | 185 | } |
52d0c099 CS |
186 | } |
187 | ||
43b8d1d8 | 188 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 189 | #include "ospfd/ospf_vty_clippy.c" |
43b8d1d8 CS |
190 | #endif |
191 | ||
192 | DEFUN_NOSH (router_ospf, | |
193 | router_ospf_cmd, | |
194 | "router ospf [{(1-65535)|vrf NAME}]", | |
195 | "Enable a routing process\n" | |
196 | "Start OSPF configuration\n" | |
197 | "Instance ID\n" | |
198 | VRF_CMD_HELP_STR) | |
199 | { | |
200 | struct ospf *ospf = NULL; | |
201 | int ret = CMD_SUCCESS; | |
202 | u_short instance = 0; | |
aed7cc62 CS |
203 | struct vrf *vrf = NULL; |
204 | struct route_node *rn; | |
205 | struct interface *ifp; | |
43b8d1d8 CS |
206 | |
207 | ospf = ospf_cmd_lookup_ospf(vty, argv, argc, 1, &instance); | |
208 | if (!ospf) | |
209 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 210 | |
d62a17ae | 211 | /* The following logic to set the vty qobj index is in place to be able |
212 | to ignore the commands which dont belong to this instance. */ | |
64ac44f6 | 213 | if (ospf->instance != instance) { |
d62a17ae | 214 | VTY_PUSH_CONTEXT_NULL(OSPF_NODE); |
64ac44f6 CS |
215 | ret = CMD_NOT_MY_INSTANCE; |
216 | } else { | |
b5a8894d CS |
217 | if (ospf->vrf_id != VRF_UNKNOWN) |
218 | ospf->oi_running = 1; | |
d62a17ae | 219 | if (IS_DEBUG_OSPF_EVENT) |
996c9314 LB |
220 | zlog_debug( |
221 | "Config command 'router ospf %d' received, vrf %s id %u oi_running %u", | |
222 | instance, ospf->name ? ospf->name : "NIL", | |
223 | ospf->vrf_id, ospf->oi_running); | |
d62a17ae | 224 | VTY_PUSH_CONTEXT(OSPF_NODE, ospf); |
aed7cc62 CS |
225 | |
226 | /* Activate 'ip ospf area x' configured interfaces for given | |
227 | * vrf. Activate area on vrf x aware interfaces. | |
228 | * vrf_enable callback calls router_id_update which | |
229 | * internally will call ospf_if_update to trigger | |
230 | * network_run_state | |
231 | */ | |
232 | vrf = vrf_lookup_by_id(ospf->vrf_id); | |
233 | ||
234 | FOR_ALL_INTERFACES (vrf, ifp) { | |
235 | struct ospf_if_params *params; | |
236 | ||
237 | params = IF_DEF_PARAMS(ifp); | |
238 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) { | |
239 | for (rn = route_top(ospf->networks); rn; | |
240 | rn = route_next(rn)) { | |
241 | if (rn->info != NULL) { | |
242 | vty_out(vty, | |
996c9314 LB |
243 | "Interface %s has area config but please remove all network commands first.\n", |
244 | ifp->name); | |
aed7cc62 CS |
245 | return ret; |
246 | } | |
247 | } | |
248 | ospf_interface_area_set(ospf, ifp); | |
249 | ospf->if_ospf_cli_count++; | |
250 | } | |
251 | } | |
252 | ||
d62a17ae | 253 | ospf_router_id_update(ospf); |
254 | } | |
255 | ||
64ac44f6 | 256 | return ret; |
718e3744 | 257 | } |
258 | ||
259 | DEFUN (no_router_ospf, | |
260 | no_router_ospf_cmd, | |
43b8d1d8 | 261 | "no router ospf [{(1-65535)|vrf NAME}]", |
718e3744 | 262 | NO_STR |
263 | "Enable a routing process\n" | |
7a7be519 | 264 | "Start OSPF configuration\n" |
b5a8894d CS |
265 | "Instance ID\n" |
266 | VRF_CMD_HELP_STR) | |
718e3744 | 267 | { |
d62a17ae | 268 | struct ospf *ospf; |
269 | u_short instance = 0; | |
b5a8894d | 270 | |
43b8d1d8 CS |
271 | ospf = ospf_cmd_lookup_ospf(vty, argv, argc, 0, &instance); |
272 | if (ospf == NULL) { | |
273 | if (instance) | |
b5a8894d | 274 | return CMD_NOT_MY_INSTANCE; |
43b8d1d8 CS |
275 | else |
276 | return CMD_WARNING; | |
b5a8894d | 277 | } |
d62a17ae | 278 | ospf_finish(ospf); |
718e3744 | 279 | |
d62a17ae | 280 | return CMD_SUCCESS; |
718e3744 | 281 | } |
282 | ||
7c8ff89e | 283 | |
43b8d1d8 | 284 | DEFPY (ospf_router_id, |
718e3744 | 285 | ospf_router_id_cmd, |
286 | "ospf router-id A.B.C.D", | |
287 | "OSPF specific commands\n" | |
288 | "router-id for the OSPF process\n" | |
289 | "OSPF router-id in IP address format\n") | |
290 | { | |
a3d826f0 | 291 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
43b8d1d8 | 292 | |
d62a17ae | 293 | struct listnode *node; |
294 | struct ospf_area *area; | |
d62a17ae | 295 | |
296 | ospf->router_id_static = router_id; | |
297 | ||
298 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) | |
299 | if (area->full_nbrs) { | |
300 | vty_out(vty, | |
301 | "For this router-id change to take effect," | |
302 | " save config and restart ospfd\n"); | |
303 | return CMD_SUCCESS; | |
304 | } | |
305 | ||
306 | ospf_router_id_update(ospf); | |
307 | ||
308 | return CMD_SUCCESS; | |
718e3744 | 309 | } |
310 | ||
7a7be519 | 311 | DEFUN_HIDDEN (ospf_router_id_old, |
747e489c DW |
312 | ospf_router_id_old_cmd, |
313 | "router-id A.B.C.D", | |
314 | "router-id for the OSPF process\n" | |
315 | "OSPF router-id in IP address format\n") | |
7a7be519 | 316 | { |
a3d826f0 | 317 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 318 | int idx_ipv4 = 1; |
319 | struct listnode *node; | |
320 | struct ospf_area *area; | |
321 | struct in_addr router_id; | |
322 | int ret; | |
323 | ||
324 | ret = inet_aton(argv[idx_ipv4]->arg, &router_id); | |
325 | if (!ret) { | |
326 | vty_out(vty, "Please specify Router ID by A.B.C.D\n"); | |
327 | return CMD_WARNING_CONFIG_FAILED; | |
328 | } | |
7a7be519 | 329 | |
d62a17ae | 330 | ospf->router_id_static = router_id; |
331 | ||
332 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) | |
333 | if (area->full_nbrs) { | |
334 | vty_out(vty, | |
335 | "For this router-id change to take effect," | |
336 | " save config and restart ospfd\n"); | |
337 | return CMD_SUCCESS; | |
338 | } | |
339 | ||
340 | ospf_router_id_update(ospf); | |
341 | ||
342 | return CMD_SUCCESS; | |
7a7be519 | 343 | } |
747e489c | 344 | |
43b8d1d8 | 345 | DEFPY (no_ospf_router_id, |
718e3744 | 346 | no_ospf_router_id_cmd, |
7a7be519 | 347 | "no ospf router-id [A.B.C.D]", |
718e3744 | 348 | NO_STR |
349 | "OSPF specific commands\n" | |
7a7be519 | 350 | "router-id for the OSPF process\n" |
351 | "OSPF router-id in IP address format\n") | |
718e3744 | 352 | { |
a3d826f0 | 353 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 354 | struct listnode *node; |
355 | struct ospf_area *area; | |
68980084 | 356 | |
43b8d1d8 CS |
357 | if (router_id_str) { |
358 | if (!IPV4_ADDR_SAME(&ospf->router_id_static, &router_id)) { | |
359 | vty_out(vty, "%% OSPF router-id doesn't match\n"); | |
360 | return CMD_WARNING_CONFIG_FAILED; | |
361 | } | |
362 | } | |
363 | ||
d62a17ae | 364 | ospf->router_id_static.s_addr = 0; |
718e3744 | 365 | |
d62a17ae | 366 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) |
367 | if (area->full_nbrs) { | |
368 | vty_out(vty, | |
369 | "For this router-id change to take effect," | |
370 | " save config and restart ospfd\n"); | |
371 | return CMD_SUCCESS; | |
372 | } | |
2c19a6ec | 373 | |
d62a17ae | 374 | ospf_router_id_update(ospf); |
718e3744 | 375 | |
d62a17ae | 376 | return CMD_SUCCESS; |
718e3744 | 377 | } |
378 | ||
718e3744 | 379 | |
d62a17ae | 380 | static void ospf_passive_interface_default(struct ospf *ospf, u_char newval) |
381 | { | |
f4e14fdb | 382 | struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); |
d62a17ae | 383 | struct listnode *ln; |
384 | struct interface *ifp; | |
385 | struct ospf_interface *oi; | |
386 | ||
387 | ospf->passive_interface_default = newval; | |
388 | ||
451fda4f | 389 | FOR_ALL_INTERFACES (vrf, ifp) { |
9d303b37 DL |
390 | if (ifp && OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), |
391 | passive_interface)) | |
d62a17ae | 392 | UNSET_IF_PARAM(IF_DEF_PARAMS(ifp), passive_interface); |
393 | } | |
394 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, ln, oi)) { | |
395 | if (OSPF_IF_PARAM_CONFIGURED(oi->params, passive_interface)) | |
396 | UNSET_IF_PARAM(oi->params, passive_interface); | |
397 | /* update multicast memberships */ | |
398 | ospf_if_set_multicast(oi); | |
399 | } | |
400 | } | |
401 | ||
402 | static void ospf_passive_interface_update_addr(struct ospf *ospf, | |
403 | struct interface *ifp, | |
404 | struct ospf_if_params *params, | |
405 | u_char value, | |
406 | struct in_addr addr) | |
407 | { | |
408 | u_char dflt; | |
409 | ||
410 | params->passive_interface = value; | |
411 | if (params != IF_DEF_PARAMS(ifp)) { | |
412 | if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), | |
413 | passive_interface)) | |
414 | dflt = IF_DEF_PARAMS(ifp)->passive_interface; | |
415 | else | |
416 | dflt = ospf->passive_interface_default; | |
417 | ||
418 | if (value != dflt) | |
419 | SET_IF_PARAM(params, passive_interface); | |
420 | else | |
421 | UNSET_IF_PARAM(params, passive_interface); | |
422 | ||
423 | ospf_free_if_params(ifp, addr); | |
424 | ospf_if_update_params(ifp, addr); | |
425 | } | |
426 | } | |
427 | ||
428 | static void ospf_passive_interface_update(struct ospf *ospf, | |
429 | struct interface *ifp, | |
430 | struct ospf_if_params *params, | |
431 | u_char value) | |
432 | { | |
433 | params->passive_interface = value; | |
434 | if (params == IF_DEF_PARAMS(ifp)) { | |
435 | if (value != ospf->passive_interface_default) | |
436 | SET_IF_PARAM(params, passive_interface); | |
437 | else | |
438 | UNSET_IF_PARAM(params, passive_interface); | |
439 | } | |
7ffa8fa2 PJ |
440 | } |
441 | ||
a2c62831 | 442 | DEFUN (ospf_passive_interface, |
443 | ospf_passive_interface_addr_cmd, | |
7a7be519 | 444 | "passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 445 | "Suppress routing updates on an interface\n" |
7a7be519 | 446 | "Interface's name\n" |
3a2d747c | 447 | "IPv4 address\n" |
7a7be519 | 448 | "Suppress routing updates on interfaces by default\n") |
718e3744 | 449 | { |
a3d826f0 | 450 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 451 | int idx_ipv4 = 2; |
e99734f1 | 452 | struct interface *ifp = NULL; |
d62a17ae | 453 | struct in_addr addr = {.s_addr = INADDR_ANY}; |
454 | int ret; | |
455 | struct ospf_if_params *params; | |
456 | struct route_node *rn; | |
457 | ||
458 | if (strmatch(argv[1]->text, "default")) { | |
459 | ospf_passive_interface_default(ospf, OSPF_IF_PASSIVE); | |
460 | return CMD_SUCCESS; | |
461 | } | |
e99734f1 CS |
462 | if (ospf->vrf_id != VRF_UNKNOWN) |
463 | ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0); | |
d62a17ae | 464 | |
b5a8894d | 465 | if (ifp == NULL) { |
996c9314 | 466 | vty_out(vty, "interface %s not found.\n", (char *)argv[1]->arg); |
e99734f1 | 467 | return CMD_WARNING_CONFIG_FAILED; |
b5a8894d | 468 | } |
d62a17ae | 469 | |
470 | params = IF_DEF_PARAMS(ifp); | |
471 | ||
472 | if (argc == 3) { | |
473 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
474 | if (!ret) { | |
475 | vty_out(vty, | |
476 | "Please specify interface address by A.B.C.D\n"); | |
477 | return CMD_WARNING_CONFIG_FAILED; | |
478 | } | |
479 | ||
480 | params = ospf_get_if_params(ifp, addr); | |
481 | ospf_if_update_params(ifp, addr); | |
482 | ospf_passive_interface_update_addr(ospf, ifp, params, | |
483 | OSPF_IF_PASSIVE, addr); | |
484 | } | |
485 | ||
486 | ospf_passive_interface_update(ospf, ifp, params, OSPF_IF_PASSIVE); | |
487 | ||
488 | /* XXX We should call ospf_if_set_multicast on exactly those | |
489 | * interfaces for which the passive property changed. It is too much | |
490 | * work to determine this set, so we do this for every interface. | |
491 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
492 | * record of joined groups to avoid systems calls if the desired | |
493 | * memberships match the current memership. | |
494 | */ | |
495 | ||
496 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
497 | struct ospf_interface *oi = rn->info; | |
498 | ||
9d303b37 DL |
499 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) |
500 | == OSPF_IF_PASSIVE)) | |
d62a17ae | 501 | ospf_if_set_multicast(oi); |
502 | } | |
503 | /* | |
504 | * XXX It is not clear what state transitions the interface needs to | |
505 | * undergo when going from active to passive. Fixing this will | |
506 | * require precise identification of interfaces having such a | |
507 | * transition. | |
508 | */ | |
509 | ||
510 | return CMD_SUCCESS; | |
718e3744 | 511 | } |
512 | ||
a2c62831 | 513 | DEFUN (no_ospf_passive_interface, |
514 | no_ospf_passive_interface_addr_cmd, | |
7a7be519 | 515 | "no passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 516 | NO_STR |
517 | "Allow routing updates on an interface\n" | |
7a7be519 | 518 | "Interface's name\n" |
3a2d747c | 519 | "IPv4 address\n" |
7a7be519 | 520 | "Allow routing updates on interfaces by default\n") |
718e3744 | 521 | { |
a3d826f0 | 522 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 523 | int idx_ipv4 = 3; |
e99734f1 | 524 | struct interface *ifp = NULL; |
d62a17ae | 525 | struct in_addr addr = {.s_addr = INADDR_ANY}; |
526 | struct ospf_if_params *params; | |
527 | int ret; | |
528 | struct route_node *rn; | |
529 | ||
530 | if (strmatch(argv[2]->text, "default")) { | |
531 | ospf_passive_interface_default(ospf, OSPF_IF_ACTIVE); | |
532 | return CMD_SUCCESS; | |
43540886 AS |
533 | } |
534 | ||
e99734f1 | 535 | if (ospf->vrf_id != VRF_UNKNOWN) |
9a0dfa3a | 536 | ifp = if_get_by_name(argv[2]->arg, ospf->vrf_id, 0); |
e99734f1 | 537 | |
b5a8894d | 538 | if (ifp == NULL) { |
996c9314 | 539 | vty_out(vty, "interface %s not found.\n", (char *)argv[2]->arg); |
e99734f1 | 540 | return CMD_WARNING_CONFIG_FAILED; |
b5a8894d | 541 | } |
ba6454ec | 542 | |
d62a17ae | 543 | params = IF_DEF_PARAMS(ifp); |
544 | ||
545 | if (argc == 4) { | |
546 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
547 | if (!ret) { | |
548 | vty_out(vty, | |
549 | "Please specify interface address by A.B.C.D\n"); | |
550 | return CMD_WARNING_CONFIG_FAILED; | |
551 | } | |
552 | ||
553 | params = ospf_lookup_if_params(ifp, addr); | |
554 | if (params == NULL) | |
555 | return CMD_SUCCESS; | |
556 | ospf_passive_interface_update_addr(ospf, ifp, params, | |
557 | OSPF_IF_ACTIVE, addr); | |
558 | } | |
559 | ospf_passive_interface_update(ospf, ifp, params, OSPF_IF_ACTIVE); | |
560 | ||
561 | /* XXX We should call ospf_if_set_multicast on exactly those | |
562 | * interfaces for which the passive property changed. It is too much | |
563 | * work to determine this set, so we do this for every interface. | |
564 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
565 | * record of joined groups to avoid systems calls if the desired | |
566 | * memberships match the current memership. | |
567 | */ | |
568 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
569 | struct ospf_interface *oi = rn->info; | |
570 | ||
571 | if (oi | |
572 | && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
573 | ospf_if_set_multicast(oi); | |
574 | } | |
575 | ||
576 | return CMD_SUCCESS; | |
718e3744 | 577 | } |
578 | ||
718e3744 | 579 | |
a2c62831 | 580 | DEFUN (ospf_network_area, |
581 | ospf_network_area_cmd, | |
6147e2c6 | 582 | "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 583 | "Enable routing on an IP network\n" |
584 | "OSPF network prefix\n" | |
585 | "Set the OSPF area ID\n" | |
586 | "OSPF area ID in IP address format\n" | |
587 | "OSPF area ID as a decimal value\n") | |
588 | { | |
a3d826f0 | 589 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 590 | int idx_ipv4_prefixlen = 1; |
591 | int idx_ipv4_number = 3; | |
592 | struct prefix_ipv4 p; | |
593 | struct in_addr area_id; | |
594 | int ret, format; | |
595 | ||
596 | if (ospf->instance) { | |
597 | vty_out(vty, | |
598 | "The network command is not supported in multi-instance ospf\n"); | |
599 | return CMD_WARNING_CONFIG_FAILED; | |
600 | } | |
718e3744 | 601 | |
d62a17ae | 602 | if (ospf->if_ospf_cli_count > 0) { |
603 | vty_out(vty, | |
604 | "Please remove all ip ospf area x.x.x.x commands first.\n"); | |
aed7cc62 | 605 | if (IS_DEBUG_OSPF_EVENT) |
996c9314 LB |
606 | zlog_debug( |
607 | "%s ospf vrf %s num of %u ip osp area x config", | |
608 | __PRETTY_FUNCTION__, | |
609 | ospf->name ? ospf->name : "NIL", | |
610 | ospf->if_ospf_cli_count); | |
d62a17ae | 611 | return CMD_WARNING_CONFIG_FAILED; |
612 | } | |
613 | ||
614 | /* Get network prefix and Area ID. */ | |
615 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
616 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); | |
617 | ||
618 | ret = ospf_network_set(ospf, &p, area_id, format); | |
619 | if (ret == 0) { | |
620 | vty_out(vty, "There is already same network statement.\n"); | |
2b0a905a | 621 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 622 | } |
623 | ||
624 | return CMD_SUCCESS; | |
718e3744 | 625 | } |
626 | ||
a2c62831 | 627 | DEFUN (no_ospf_network_area, |
628 | no_ospf_network_area_cmd, | |
6147e2c6 | 629 | "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 630 | NO_STR |
631 | "Enable routing on an IP network\n" | |
632 | "OSPF network prefix\n" | |
633 | "Set the OSPF area ID\n" | |
634 | "OSPF area ID in IP address format\n" | |
635 | "OSPF area ID as a decimal value\n") | |
636 | { | |
a3d826f0 | 637 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 638 | int idx_ipv4_prefixlen = 2; |
639 | int idx_ipv4_number = 4; | |
640 | struct prefix_ipv4 p; | |
641 | struct in_addr area_id; | |
642 | int ret, format; | |
643 | ||
644 | if (ospf->instance) { | |
645 | vty_out(vty, | |
646 | "The network command is not supported in multi-instance ospf\n"); | |
647 | return CMD_WARNING_CONFIG_FAILED; | |
648 | } | |
718e3744 | 649 | |
d62a17ae | 650 | /* Get network prefix and Area ID. */ |
651 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
652 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); | |
653 | ||
654 | ret = ospf_network_unset(ospf, &p, area_id); | |
655 | if (ret == 0) { | |
656 | vty_out(vty, | |
657 | "Can't find specified network area configuration.\n"); | |
658 | return CMD_WARNING_CONFIG_FAILED; | |
659 | } | |
660 | ||
661 | return CMD_SUCCESS; | |
718e3744 | 662 | } |
663 | ||
a2c62831 | 664 | DEFUN (ospf_area_range, |
665 | ospf_area_range_cmd, | |
7a7be519 | 666 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]", |
718e3744 | 667 | "OSPF area parameters\n" |
668 | "OSPF area ID in IP address format\n" | |
669 | "OSPF area ID as a decimal value\n" | |
670 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 671 | "Area range prefix\n" |
672 | "Advertise this range (default)\n" | |
673 | "User specified metric for this range\n" | |
674 | "Advertised metric for this range\n") | |
718e3744 | 675 | { |
a3d826f0 | 676 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 677 | int idx_ipv4_number = 1; |
678 | int idx_ipv4_prefixlen = 3; | |
679 | int idx_cost = 6; | |
680 | struct prefix_ipv4 p; | |
681 | struct in_addr area_id; | |
682 | int format; | |
683 | u_int32_t cost; | |
684 | ||
685 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); | |
686 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
687 | ||
688 | ospf_area_range_set(ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
689 | if (argc > 5) { | |
690 | cost = strtoul(argv[idx_cost]->arg, NULL, 10); | |
691 | ospf_area_range_cost_set(ospf, area_id, &p, cost); | |
692 | } | |
718e3744 | 693 | |
d62a17ae | 694 | return CMD_SUCCESS; |
718e3744 | 695 | } |
696 | ||
7a7be519 | 697 | DEFUN (ospf_area_range_cost, |
698 | ospf_area_range_cost_cmd, | |
699 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)", | |
700 | "OSPF area parameters\n" | |
701 | "OSPF area ID in IP address format\n" | |
702 | "OSPF area ID as a decimal value\n" | |
703 | "Summarize routes matching address/mask (border routers only)\n" | |
704 | "Area range prefix\n" | |
705 | "User specified metric for this range\n" | |
706 | "Advertised metric for this range\n") | |
707 | { | |
a3d826f0 | 708 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 709 | int idx_ipv4_number = 1; |
710 | int idx_ipv4_prefixlen = 3; | |
711 | int idx_cost = 5; | |
712 | struct prefix_ipv4 p; | |
713 | struct in_addr area_id; | |
714 | int format; | |
715 | u_int32_t cost; | |
7a7be519 | 716 | |
d62a17ae | 717 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
718 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
7a7be519 | 719 | |
d62a17ae | 720 | ospf_area_range_set(ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
721 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
722 | format); | |
718e3744 | 723 | |
d62a17ae | 724 | cost = strtoul(argv[idx_cost]->arg, NULL, 10); |
725 | ospf_area_range_cost_set(ospf, area_id, &p, cost); | |
718e3744 | 726 | |
d62a17ae | 727 | return CMD_SUCCESS; |
7a7be519 | 728 | } |
718e3744 | 729 | |
a2c62831 | 730 | DEFUN (ospf_area_range_not_advertise, |
731 | ospf_area_range_not_advertise_cmd, | |
6147e2c6 | 732 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise", |
718e3744 | 733 | "OSPF area parameters\n" |
734 | "OSPF area ID in IP address format\n" | |
735 | "OSPF area ID as a decimal value\n" | |
736 | "Summarize routes matching address/mask (border routers only)\n" | |
737 | "Area range prefix\n" | |
738 | "DoNotAdvertise this range\n") | |
739 | { | |
a3d826f0 | 740 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 741 | int idx_ipv4_number = 1; |
742 | int idx_ipv4_prefixlen = 3; | |
743 | struct prefix_ipv4 p; | |
744 | struct in_addr area_id; | |
745 | int format; | |
718e3744 | 746 | |
d62a17ae | 747 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
748 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
718e3744 | 749 | |
d62a17ae | 750 | ospf_area_range_set(ospf, area_id, &p, 0); |
751 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
752 | format); | |
718e3744 | 753 | |
d62a17ae | 754 | return CMD_SUCCESS; |
718e3744 | 755 | } |
756 | ||
a2c62831 | 757 | DEFUN (no_ospf_area_range, |
758 | no_ospf_area_range_cmd, | |
3a2d747c | 759 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]", |
718e3744 | 760 | NO_STR |
761 | "OSPF area parameters\n" | |
762 | "OSPF area ID in IP address format\n" | |
763 | "OSPF area ID as a decimal value\n" | |
764 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 765 | "Area range prefix\n" |
3a2d747c QY |
766 | "User specified metric for this range\n" |
767 | "Advertised metric for this range\n" | |
7a7be519 | 768 | "Advertise this range (default)\n" |
3a2d747c QY |
769 | "User specified metric for this range\n" |
770 | "Advertised metric for this range\n" | |
7a7be519 | 771 | "DoNotAdvertise this range\n") |
718e3744 | 772 | { |
a3d826f0 | 773 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 774 | int idx_ipv4_number = 2; |
775 | int idx_ipv4_prefixlen = 4; | |
776 | struct prefix_ipv4 p; | |
777 | struct in_addr area_id; | |
778 | int format; | |
718e3744 | 779 | |
d62a17ae | 780 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
781 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
718e3744 | 782 | |
d62a17ae | 783 | ospf_area_range_unset(ospf, area_id, &p); |
718e3744 | 784 | |
d62a17ae | 785 | return CMD_SUCCESS; |
718e3744 | 786 | } |
787 | ||
a2c62831 | 788 | DEFUN (ospf_area_range_substitute, |
789 | ospf_area_range_substitute_cmd, | |
6147e2c6 | 790 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 791 | "OSPF area parameters\n" |
792 | "OSPF area ID in IP address format\n" | |
793 | "OSPF area ID as a decimal value\n" | |
794 | "Summarize routes matching address/mask (border routers only)\n" | |
795 | "Area range prefix\n" | |
796 | "Announce area range as another prefix\n" | |
797 | "Network prefix to be announced instead of range\n") | |
798 | { | |
a3d826f0 | 799 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 800 | int idx_ipv4_number = 1; |
801 | int idx_ipv4_prefixlen = 3; | |
802 | int idx_ipv4_prefixlen_2 = 5; | |
803 | struct prefix_ipv4 p, s; | |
804 | struct in_addr area_id; | |
805 | int format; | |
718e3744 | 806 | |
d62a17ae | 807 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
808 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
809 | str2prefix_ipv4(argv[idx_ipv4_prefixlen_2]->arg, &s); | |
718e3744 | 810 | |
d62a17ae | 811 | ospf_area_range_substitute_set(ospf, area_id, &p, &s); |
812 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
813 | format); | |
718e3744 | 814 | |
d62a17ae | 815 | return CMD_SUCCESS; |
718e3744 | 816 | } |
817 | ||
a2c62831 | 818 | DEFUN (no_ospf_area_range_substitute, |
819 | no_ospf_area_range_substitute_cmd, | |
6147e2c6 | 820 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 821 | NO_STR |
822 | "OSPF area parameters\n" | |
823 | "OSPF area ID in IP address format\n" | |
824 | "OSPF area ID as a decimal value\n" | |
825 | "Summarize routes matching address/mask (border routers only)\n" | |
826 | "Area range prefix\n" | |
827 | "Announce area range as another prefix\n" | |
828 | "Network prefix to be announced instead of range\n") | |
829 | { | |
a3d826f0 | 830 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 831 | int idx_ipv4_number = 2; |
832 | int idx_ipv4_prefixlen = 4; | |
833 | int idx_ipv4_prefixlen_2 = 6; | |
834 | struct prefix_ipv4 p, s; | |
835 | struct in_addr area_id; | |
836 | int format; | |
718e3744 | 837 | |
d62a17ae | 838 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
839 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); | |
840 | str2prefix_ipv4(argv[idx_ipv4_prefixlen_2]->arg, &s); | |
718e3744 | 841 | |
d62a17ae | 842 | ospf_area_range_substitute_unset(ospf, area_id, &p); |
718e3744 | 843 | |
d62a17ae | 844 | return CMD_SUCCESS; |
718e3744 | 845 | } |
846 | ||
6b0655a2 | 847 | |
718e3744 | 848 | /* Command Handler Logic in VLink stuff is delicate!! |
849 | ||
850 | ALTER AT YOUR OWN RISK!!!! | |
851 | ||
852 | Various dummy values are used to represent 'NoChange' state for | |
853 | VLink configuration NOT being changed by a VLink command, and | |
854 | special syntax is used within the command strings so that the | |
855 | typed in command verbs can be seen in the configuration command | |
856 | bacckend handler. This is to drastically reduce the verbeage | |
857 | required to coe up with a reasonably compatible Cisco VLink command | |
858 | ||
d62a17ae | 859 | - Matthew Grant <grantma@anathoth.gen.nz> |
718e3744 | 860 | Wed, 21 Feb 2001 15:13:52 +1300 |
861 | */ | |
862 | ||
d62a17ae | 863 | /* Configuration data for virtual links |
864 | */ | |
718e3744 | 865 | struct ospf_vl_config_data { |
d62a17ae | 866 | struct vty *vty; /* vty stuff */ |
867 | struct in_addr area_id; /* area ID from command line */ | |
868 | int area_id_fmt; /* command line area ID format */ | |
869 | struct in_addr vl_peer; /* command line vl_peer */ | |
870 | int auth_type; /* Authehntication type, if given */ | |
871 | char *auth_key; /* simple password if present */ | |
872 | int crypto_key_id; /* Cryptographic key ID */ | |
873 | char *md5_key; /* MD5 authentication key */ | |
874 | int hello_interval; /* Obvious what these are... */ | |
875 | int retransmit_interval; | |
876 | int transmit_delay; | |
877 | int dead_interval; | |
718e3744 | 878 | }; |
879 | ||
d62a17ae | 880 | static void ospf_vl_config_data_init(struct ospf_vl_config_data *vl_config, |
881 | struct vty *vty) | |
718e3744 | 882 | { |
d62a17ae | 883 | memset(vl_config, 0, sizeof(struct ospf_vl_config_data)); |
884 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
885 | vl_config->vty = vty; | |
718e3744 | 886 | } |
887 | ||
4dadc291 | 888 | static struct ospf_vl_data * |
d62a17ae | 889 | ospf_find_vl_data(struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
890 | { | |
891 | struct ospf_area *area; | |
892 | struct ospf_vl_data *vl_data; | |
893 | struct vty *vty; | |
894 | struct in_addr area_id; | |
895 | ||
896 | vty = vl_config->vty; | |
897 | area_id = vl_config->area_id; | |
898 | ||
899 | if (area_id.s_addr == OSPF_AREA_BACKBONE) { | |
900 | vty_out(vty, | |
901 | "Configuring VLs over the backbone is not allowed\n"); | |
902 | return NULL; | |
903 | } | |
904 | area = ospf_area_get(ospf, area_id); | |
905 | ospf_area_display_format_set(ospf, area, vl_config->area_id_fmt); | |
906 | ||
907 | if (area->external_routing != OSPF_AREA_DEFAULT) { | |
908 | if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) | |
909 | vty_out(vty, "Area %s is %s\n", inet_ntoa(area_id), | |
910 | area->external_routing == OSPF_AREA_NSSA | |
911 | ? "nssa" | |
912 | : "stub"); | |
913 | else | |
914 | vty_out(vty, "Area %ld is %s\n", | |
915 | (u_long)ntohl(area_id.s_addr), | |
916 | area->external_routing == OSPF_AREA_NSSA | |
917 | ? "nssa" | |
918 | : "stub"); | |
919 | return NULL; | |
920 | } | |
921 | ||
922 | if ((vl_data = ospf_vl_lookup(ospf, area, vl_config->vl_peer)) | |
923 | == NULL) { | |
924 | vl_data = ospf_vl_data_new(area, vl_config->vl_peer); | |
925 | if (vl_data->vl_oi == NULL) { | |
926 | vl_data->vl_oi = ospf_vl_new(ospf, vl_data); | |
927 | ospf_vl_add(ospf, vl_data); | |
928 | ospf_spf_calculate_schedule(ospf, | |
929 | SPF_FLAG_CONFIG_CHANGE); | |
930 | } | |
718e3744 | 931 | } |
d62a17ae | 932 | return vl_data; |
718e3744 | 933 | } |
934 | ||
935 | ||
d62a17ae | 936 | static int ospf_vl_set_security(struct ospf_vl_data *vl_data, |
937 | struct ospf_vl_config_data *vl_config) | |
938 | { | |
939 | struct crypt_key *ck; | |
940 | struct vty *vty; | |
941 | struct interface *ifp = vl_data->vl_oi->ifp; | |
942 | ||
943 | vty = vl_config->vty; | |
944 | ||
945 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) { | |
946 | SET_IF_PARAM(IF_DEF_PARAMS(ifp), auth_type); | |
947 | IF_DEF_PARAMS(ifp)->auth_type = vl_config->auth_type; | |
718e3744 | 948 | } |
718e3744 | 949 | |
d62a17ae | 950 | if (vl_config->auth_key) { |
951 | memset(IF_DEF_PARAMS(ifp)->auth_simple, 0, | |
952 | OSPF_AUTH_SIMPLE_SIZE + 1); | |
953 | strncpy((char *)IF_DEF_PARAMS(ifp)->auth_simple, | |
954 | vl_config->auth_key, OSPF_AUTH_SIMPLE_SIZE); | |
955 | } else if (vl_config->md5_key) { | |
956 | if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp)->auth_crypt, | |
957 | vl_config->crypto_key_id) | |
958 | != NULL) { | |
959 | vty_out(vty, "OSPF: Key %d already exists\n", | |
960 | vl_config->crypto_key_id); | |
851fcbae | 961 | return CMD_WARNING; |
d62a17ae | 962 | } |
963 | ck = ospf_crypt_key_new(); | |
964 | ck->key_id = vl_config->crypto_key_id; | |
965 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE + 1); | |
966 | strncpy((char *)ck->auth_key, vl_config->md5_key, | |
967 | OSPF_AUTH_MD5_SIZE); | |
968 | ||
969 | ospf_crypt_key_add(IF_DEF_PARAMS(ifp)->auth_crypt, ck); | |
970 | } else if (vl_config->crypto_key_id != 0) { | |
971 | /* Delete a key */ | |
972 | ||
973 | if (ospf_crypt_key_lookup(IF_DEF_PARAMS(ifp)->auth_crypt, | |
974 | vl_config->crypto_key_id) | |
975 | == NULL) { | |
976 | vty_out(vty, "OSPF: Key %d does not exist\n", | |
977 | vl_config->crypto_key_id); | |
978 | return CMD_WARNING_CONFIG_FAILED; | |
979 | } | |
980 | ||
981 | ospf_crypt_key_delete(IF_DEF_PARAMS(ifp)->auth_crypt, | |
982 | vl_config->crypto_key_id); | |
983 | } | |
984 | ||
985 | return CMD_SUCCESS; | |
718e3744 | 986 | } |
987 | ||
d62a17ae | 988 | static int ospf_vl_set_timers(struct ospf_vl_data *vl_data, |
989 | struct ospf_vl_config_data *vl_config) | |
990 | { | |
991 | struct interface *ifp = vl_data->vl_oi->ifp; | |
992 | /* Virtual Link data initialised to defaults, so only set | |
993 | if a value given */ | |
994 | if (vl_config->hello_interval) { | |
995 | SET_IF_PARAM(IF_DEF_PARAMS(ifp), v_hello); | |
996 | IF_DEF_PARAMS(ifp)->v_hello = vl_config->hello_interval; | |
997 | } | |
998 | ||
999 | if (vl_config->dead_interval) { | |
1000 | SET_IF_PARAM(IF_DEF_PARAMS(ifp), v_wait); | |
1001 | IF_DEF_PARAMS(ifp)->v_wait = vl_config->dead_interval; | |
1002 | } | |
1003 | ||
1004 | if (vl_config->retransmit_interval) { | |
1005 | SET_IF_PARAM(IF_DEF_PARAMS(ifp), retransmit_interval); | |
1006 | IF_DEF_PARAMS(ifp)->retransmit_interval = | |
1007 | vl_config->retransmit_interval; | |
1008 | } | |
1009 | ||
1010 | if (vl_config->transmit_delay) { | |
1011 | SET_IF_PARAM(IF_DEF_PARAMS(ifp), transmit_delay); | |
1012 | IF_DEF_PARAMS(ifp)->transmit_delay = vl_config->transmit_delay; | |
1013 | } | |
1014 | ||
1015 | return CMD_SUCCESS; | |
718e3744 | 1016 | } |
1017 | ||
1018 | ||
718e3744 | 1019 | /* The business end of all of the above */ |
d62a17ae | 1020 | static int ospf_vl_set(struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
1021 | { | |
1022 | struct ospf_vl_data *vl_data; | |
1023 | int ret; | |
718e3744 | 1024 | |
d62a17ae | 1025 | vl_data = ospf_find_vl_data(ospf, vl_config); |
1026 | if (!vl_data) | |
1027 | return CMD_WARNING_CONFIG_FAILED; | |
1028 | ||
1029 | /* Process this one first as it can have a fatal result, which can | |
1030 | only logically occur if the virtual link exists already | |
1031 | Thus a command error does not result in a change to the | |
1032 | running configuration such as unexpectedly altered timer | |
1033 | values etc.*/ | |
1034 | ret = ospf_vl_set_security(vl_data, vl_config); | |
1035 | if (ret != CMD_SUCCESS) | |
1036 | return ret; | |
1037 | ||
1038 | /* Set any time based parameters, these area already range checked */ | |
1039 | ||
1040 | ret = ospf_vl_set_timers(vl_data, vl_config); | |
1041 | if (ret != CMD_SUCCESS) | |
1042 | return ret; | |
718e3744 | 1043 | |
d62a17ae | 1044 | return CMD_SUCCESS; |
718e3744 | 1045 | } |
1046 | ||
1047 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
1048 | */ | |
d62a17ae | 1049 | #define VLINK_HELPSTR_IPADDR \ |
1050 | "OSPF area parameters\n" \ | |
1051 | "OSPF area ID in IP address format\n" \ | |
1052 | "OSPF area ID as a decimal value\n" \ | |
1053 | "Configure a virtual link\n" \ | |
1054 | "Router ID of the remote ABR\n" | |
1055 | ||
1056 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1057 | "Enable authentication on this virtual link\n" \ | |
1058 | "dummy string \n" | |
1059 | ||
1060 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
1061 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
1062 | "Use null authentication\n" \ | |
1063 | "Use message-digest authentication\n" | |
1064 | ||
1065 | #define VLINK_HELPSTR_TIME_PARAM \ | |
1066 | "Time between HELLO packets\n" \ | |
1067 | "Seconds\n" \ | |
1068 | "Time between retransmitting lost link state advertisements\n" \ | |
1069 | "Seconds\n" \ | |
1070 | "Link state transmit delay\n" \ | |
1071 | "Seconds\n" \ | |
1072 | "Interval time after which a neighbor is declared down\n" \ | |
1073 | "Seconds\n" | |
1074 | ||
1075 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1076 | "Authentication password (key)\n" \ | |
baf9eaad | 1077 | "The OSPF password (key)\n" |
d62a17ae | 1078 | |
1079 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1080 | "Message digest authentication password (key)\n" \ | |
d62a17ae | 1081 | "Key ID\n" \ |
1082 | "Use MD5 algorithm\n" \ | |
baf9eaad | 1083 | "The OSPF password (key)\n" |
718e3744 | 1084 | |
a2c62831 | 1085 | DEFUN (ospf_area_vlink, |
1086 | ospf_area_vlink_cmd, | |
3d1c6dc2 | 1087 | "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 | 1088 | VLINK_HELPSTR_IPADDR |
3d1c6dc2 | 1089 | "Enable authentication on this virtual link\n" |
7a7be519 | 1090 | "Use message-digest authentication\n" |
3d1c6dc2 | 1091 | "Use null authentication\n" |
baf9eaad CS |
1092 | VLINK_HELPSTR_AUTH_MD5 |
1093 | VLINK_HELPSTR_AUTH_SIMPLE) | |
718e3744 | 1094 | { |
a3d826f0 | 1095 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1096 | int idx_ipv4_number = 1; |
1097 | int idx_ipv4 = 3; | |
1098 | struct ospf_vl_config_data vl_config; | |
1099 | char auth_key[OSPF_AUTH_SIMPLE_SIZE + 1]; | |
1100 | char md5_key[OSPF_AUTH_MD5_SIZE + 1]; | |
d62a17ae | 1101 | int ret; |
55d1da24 | 1102 | int idx = 0; |
d62a17ae | 1103 | |
1104 | ospf_vl_config_data_init(&vl_config, vty); | |
1105 | ||
1106 | /* Read off first 2 parameters and check them */ | |
1107 | ret = str2area_id(argv[idx_ipv4_number]->arg, &vl_config.area_id, | |
1108 | &vl_config.area_id_fmt); | |
1109 | if (ret < 0) { | |
1110 | vty_out(vty, "OSPF area ID is invalid\n"); | |
1111 | return CMD_WARNING_CONFIG_FAILED; | |
1112 | } | |
718e3744 | 1113 | |
d62a17ae | 1114 | ret = inet_aton(argv[idx_ipv4]->arg, &vl_config.vl_peer); |
1115 | if (!ret) { | |
1116 | vty_out(vty, "Please specify valid Router ID as a.b.c.d\n"); | |
1117 | return CMD_WARNING_CONFIG_FAILED; | |
7a7be519 | 1118 | } |
7a7be519 | 1119 | |
d62a17ae | 1120 | if (argc <= 4) { |
1121 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
7a7be519 | 1122 | |
d62a17ae | 1123 | return ospf_vl_set(ospf, &vl_config); |
1124 | } | |
1125 | ||
3d1c6dc2 CS |
1126 | if (argv_find(argv, argc, "authentication", &idx)) { |
1127 | /* authentication - this option can only occur | |
1128 | at start of command line */ | |
1129 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1130 | } | |
1131 | ||
3d1c6dc2 | 1132 | if (argv_find(argv, argc, "message-digest", &idx)) { |
baf9eaad | 1133 | /* authentication message-digest */ |
3d1c6dc2 CS |
1134 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
1135 | } else if (argv_find(argv, argc, "null", &idx)) { | |
1136 | /* "authentication null" */ | |
1137 | vl_config.auth_type = OSPF_AUTH_NULL; | |
d62a17ae | 1138 | } |
7a7be519 | 1139 | |
3d1c6dc2 | 1140 | if (argv_find(argv, argc, "message-digest-key", &idx)) { |
3d1c6dc2 | 1141 | vl_config.md5_key = NULL; |
cbb9b53d | 1142 | vl_config.crypto_key_id = strtol(argv[idx + 1]->arg, NULL, 10); |
3d1c6dc2 CS |
1143 | if (vl_config.crypto_key_id < 0) |
1144 | return CMD_WARNING_CONFIG_FAILED; | |
1145 | ||
3d1c6dc2 | 1146 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE + 1); |
cbb9b53d | 1147 | strncpy(md5_key, argv[idx + 3]->arg, OSPF_AUTH_MD5_SIZE); |
3d1c6dc2 CS |
1148 | vl_config.md5_key = md5_key; |
1149 | } | |
1150 | ||
3d1c6dc2 | 1151 | if (argv_find(argv, argc, "authentication-key", &idx)) { |
3d1c6dc2 | 1152 | memset(auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
cbb9b53d | 1153 | strncpy(auth_key, argv[idx + 1]->arg, OSPF_AUTH_SIMPLE_SIZE); |
3d1c6dc2 CS |
1154 | vl_config.auth_key = auth_key; |
1155 | } | |
7a7be519 | 1156 | |
d62a17ae | 1157 | /* Action configuration */ |
1158 | ||
1159 | return ospf_vl_set(ospf, &vl_config); | |
7a7be519 | 1160 | } |
1161 | ||
a2c62831 | 1162 | DEFUN (no_ospf_area_vlink, |
1163 | no_ospf_area_vlink_cmd, | |
3d1c6dc2 | 1164 | "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 | 1165 | NO_STR |
7a7be519 | 1166 | VLINK_HELPSTR_IPADDR |
1167 | "Enable authentication on this virtual link\n" \ | |
3d1c6dc2 | 1168 | "Use message-digest authentication\n" \ |
7a7be519 | 1169 | "Use null authentication\n" \ |
baf9eaad CS |
1170 | VLINK_HELPSTR_AUTH_MD5 |
1171 | VLINK_HELPSTR_AUTH_SIMPLE) | |
718e3744 | 1172 | { |
a3d826f0 | 1173 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1174 | int idx_ipv4_number = 2; |
1175 | int idx_ipv4 = 4; | |
1176 | struct ospf_area *area; | |
1177 | struct ospf_vl_config_data vl_config; | |
1178 | struct ospf_vl_data *vl_data = NULL; | |
1179 | char auth_key[OSPF_AUTH_SIMPLE_SIZE + 1]; | |
3d1c6dc2 | 1180 | int idx = 0; |
d62a17ae | 1181 | int ret, format; |
1182 | ||
1183 | ospf_vl_config_data_init(&vl_config, vty); | |
1184 | ||
1185 | ret = str2area_id(argv[idx_ipv4_number]->arg, &vl_config.area_id, | |
1186 | &format); | |
1187 | if (ret < 0) { | |
1188 | vty_out(vty, "OSPF area ID is invalid\n"); | |
1189 | return CMD_WARNING_CONFIG_FAILED; | |
1190 | } | |
1191 | ||
1192 | area = ospf_area_lookup_by_area_id(ospf, vl_config.area_id); | |
1193 | if (!area) { | |
1194 | vty_out(vty, "Area does not exist\n"); | |
1195 | return CMD_WARNING_CONFIG_FAILED; | |
1196 | } | |
1197 | ||
1198 | ret = inet_aton(argv[idx_ipv4]->arg, &vl_config.vl_peer); | |
1199 | if (!ret) { | |
1200 | vty_out(vty, "Please specify valid Router ID as a.b.c.d\n"); | |
1201 | return CMD_WARNING_CONFIG_FAILED; | |
1202 | } | |
718e3744 | 1203 | |
d62a17ae | 1204 | if (argc <= 5) { |
1205 | /* Basic VLink no command */ | |
1206 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1207 | if ((vl_data = ospf_vl_lookup(ospf, area, vl_config.vl_peer))) | |
1208 | ospf_vl_delete(ospf, vl_data); | |
1209 | ||
1210 | ospf_area_check_free(ospf, vl_config.area_id); | |
1211 | ||
1212 | return CMD_SUCCESS; | |
1213 | } | |
1214 | ||
1215 | /* If we are down here, we are reseting parameters */ | |
d62a17ae | 1216 | /* Deal with other parameters */ |
3d1c6dc2 CS |
1217 | |
1218 | if (argv_find(argv, argc, "authentication", &idx)) { | |
1219 | /* authentication - this option can only occur | |
1220 | at start of command line */ | |
1221 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1222 | } | |
1223 | ||
3d1c6dc2 | 1224 | if (argv_find(argv, argc, "message-digest-key", &idx)) { |
3d1c6dc2 | 1225 | vl_config.md5_key = NULL; |
cbb9b53d | 1226 | vl_config.crypto_key_id = strtol(argv[idx + 1]->arg, NULL, 10); |
3d1c6dc2 CS |
1227 | if (vl_config.crypto_key_id < 0) |
1228 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 1229 | } |
1230 | ||
3d1c6dc2 | 1231 | if (argv_find(argv, argc, "authentication-key", &idx)) { |
cbb9b53d | 1232 | /* Reset authentication-key to 0 */ |
3d1c6dc2 CS |
1233 | memset(auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
1234 | vl_config.auth_key = auth_key; | |
1235 | } | |
d62a17ae | 1236 | |
1237 | /* Action configuration */ | |
1238 | ||
1239 | return ospf_vl_set(ospf, &vl_config); | |
7a7be519 | 1240 | } |
1241 | ||
b1c02cec QY |
1242 | DEFUN (ospf_area_vlink_intervals, |
1243 | ospf_area_vlink_intervals_cmd, | |
1244 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", | |
1245 | VLINK_HELPSTR_IPADDR | |
1246 | VLINK_HELPSTR_TIME_PARAM) | |
1247 | { | |
a3d826f0 | 1248 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1249 | struct ospf_vl_config_data vl_config; |
1250 | int ret = 0; | |
1251 | ||
1252 | ospf_vl_config_data_init(&vl_config, vty); | |
1253 | ||
1254 | char *area_id = argv[1]->arg; | |
1255 | char *router_id = argv[3]->arg; | |
1256 | ||
1257 | ret = str2area_id(area_id, &vl_config.area_id, &vl_config.area_id_fmt); | |
1258 | if (ret < 0) { | |
1259 | vty_out(vty, "OSPF area ID is invalid\n"); | |
1260 | return CMD_WARNING_CONFIG_FAILED; | |
1261 | } | |
1262 | ||
1263 | ret = inet_aton(router_id, &vl_config.vl_peer); | |
1264 | if (!ret) { | |
1265 | vty_out(vty, "Please specify valid Router ID as a.b.c.d\n"); | |
1266 | return CMD_WARNING_CONFIG_FAILED; | |
1267 | } | |
1268 | ||
1269 | for (int idx = 4; idx < argc; idx++) { | |
1270 | if (strmatch(argv[idx]->text, "hello-interval")) | |
1271 | vl_config.hello_interval = | |
1272 | strtol(argv[++idx]->arg, NULL, 10); | |
1273 | else if (strmatch(argv[idx]->text, "retransmit-interval")) | |
1274 | vl_config.retransmit_interval = | |
1275 | strtol(argv[++idx]->arg, NULL, 10); | |
1276 | else if (strmatch(argv[idx]->text, "transmit-delay")) | |
1277 | vl_config.transmit_delay = | |
1278 | strtol(argv[++idx]->arg, NULL, 10); | |
1279 | else if (strmatch(argv[idx]->text, "dead-interval")) | |
1280 | vl_config.dead_interval = | |
1281 | strtol(argv[++idx]->arg, NULL, 10); | |
1282 | } | |
1283 | ||
1284 | /* Action configuration */ | |
1285 | return ospf_vl_set(ospf, &vl_config); | |
b1c02cec QY |
1286 | } |
1287 | ||
7a7be519 | 1288 | DEFUN (no_ospf_area_vlink_intervals, |
1289 | no_ospf_area_vlink_intervals_cmd, | |
a663a38e | 1290 | "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", |
3a2d747c | 1291 | NO_STR |
7a7be519 | 1292 | VLINK_HELPSTR_IPADDR |
7a7be519 | 1293 | VLINK_HELPSTR_TIME_PARAM) |
1294 | { | |
a3d826f0 | 1295 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1296 | struct ospf_vl_config_data vl_config; |
1297 | int ret = 0; | |
1298 | ||
1299 | ospf_vl_config_data_init(&vl_config, vty); | |
1300 | ||
1301 | char *area_id = argv[2]->arg; | |
1302 | char *router_id = argv[4]->arg; | |
1303 | ||
1304 | ret = str2area_id(area_id, &vl_config.area_id, &vl_config.area_id_fmt); | |
1305 | if (ret < 0) { | |
1306 | vty_out(vty, "OSPF area ID is invalid\n"); | |
1307 | return CMD_WARNING_CONFIG_FAILED; | |
1308 | } | |
1309 | ||
1310 | ret = inet_aton(router_id, &vl_config.vl_peer); | |
1311 | if (!ret) { | |
1312 | vty_out(vty, "Please specify valid Router ID as a.b.c.d\n"); | |
1313 | return CMD_WARNING_CONFIG_FAILED; | |
1314 | } | |
1315 | ||
1316 | for (int idx = 5; idx < argc; idx++) { | |
1317 | if (strmatch(argv[idx]->text, "hello-interval")) | |
1318 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; | |
1319 | else if (strmatch(argv[idx]->text, "retransmit-interval")) | |
1320 | vl_config.retransmit_interval = | |
1321 | OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
1322 | else if (strmatch(argv[idx]->text, "transmit-delay")) | |
1323 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
1324 | else if (strmatch(argv[idx]->text, "dead-interval")) | |
1325 | vl_config.dead_interval = | |
1326 | OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
1327 | } | |
1328 | ||
1329 | /* Action configuration */ | |
1330 | return ospf_vl_set(ospf, &vl_config); | |
718e3744 | 1331 | } |
1332 | ||
a2c62831 | 1333 | DEFUN (ospf_area_shortcut, |
1334 | ospf_area_shortcut_cmd, | |
6147e2c6 | 1335 | "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>", |
718e3744 | 1336 | "OSPF area parameters\n" |
1337 | "OSPF area ID in IP address format\n" | |
1338 | "OSPF area ID as a decimal value\n" | |
1339 | "Configure the area's shortcutting mode\n" | |
1340 | "Set default shortcutting behavior\n" | |
1341 | "Enable shortcutting through the area\n" | |
1342 | "Disable shortcutting through the area\n") | |
1343 | { | |
a3d826f0 | 1344 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1345 | int idx_ipv4_number = 1; |
1346 | int idx_enable_disable = 3; | |
1347 | struct ospf_area *area; | |
1348 | struct in_addr area_id; | |
1349 | int mode; | |
1350 | int format; | |
1351 | ||
1352 | VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id, format, | |
1353 | argv[idx_ipv4_number]->arg); | |
1354 | ||
1355 | area = ospf_area_get(ospf, area_id); | |
1356 | ospf_area_display_format_set(ospf, area, format); | |
1357 | ||
1358 | if (strncmp(argv[idx_enable_disable]->arg, "de", 2) == 0) | |
1359 | mode = OSPF_SHORTCUT_DEFAULT; | |
1360 | else if (strncmp(argv[idx_enable_disable]->arg, "di", 2) == 0) | |
1361 | mode = OSPF_SHORTCUT_DISABLE; | |
1362 | else if (strncmp(argv[idx_enable_disable]->arg, "e", 1) == 0) | |
1363 | mode = OSPF_SHORTCUT_ENABLE; | |
1364 | else | |
1365 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 1366 | |
d62a17ae | 1367 | ospf_area_shortcut_set(ospf, area, mode); |
718e3744 | 1368 | |
d62a17ae | 1369 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
1370 | vty_out(vty, | |
1371 | "Shortcut area setting will take effect " | |
1372 | "only when the router is configured as Shortcut ABR\n"); | |
718e3744 | 1373 | |
d62a17ae | 1374 | return CMD_SUCCESS; |
718e3744 | 1375 | } |
1376 | ||
a2c62831 | 1377 | DEFUN (no_ospf_area_shortcut, |
1378 | no_ospf_area_shortcut_cmd, | |
6147e2c6 | 1379 | "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>", |
718e3744 | 1380 | NO_STR |
1381 | "OSPF area parameters\n" | |
1382 | "OSPF area ID in IP address format\n" | |
1383 | "OSPF area ID as a decimal value\n" | |
1384 | "Deconfigure the area's shortcutting mode\n" | |
1385 | "Deconfigure enabled shortcutting through the area\n" | |
1386 | "Deconfigure disabled shortcutting through the area\n") | |
1387 | { | |
a3d826f0 | 1388 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1389 | int idx_ipv4_number = 2; |
1390 | struct ospf_area *area; | |
1391 | struct in_addr area_id; | |
1392 | int format; | |
718e3744 | 1393 | |
d62a17ae | 1394 | VTY_GET_OSPF_AREA_ID_NO_BB("shortcut", area_id, format, |
1395 | argv[idx_ipv4_number]->arg); | |
718e3744 | 1396 | |
d62a17ae | 1397 | area = ospf_area_lookup_by_area_id(ospf, area_id); |
1398 | if (!area) | |
1399 | return CMD_SUCCESS; | |
718e3744 | 1400 | |
d62a17ae | 1401 | ospf_area_shortcut_unset(ospf, area); |
718e3744 | 1402 | |
d62a17ae | 1403 | return CMD_SUCCESS; |
718e3744 | 1404 | } |
1405 | ||
6b0655a2 | 1406 | |
a2c62831 | 1407 | DEFUN (ospf_area_stub, |
1408 | ospf_area_stub_cmd, | |
6147e2c6 | 1409 | "area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1410 | "OSPF area parameters\n" |
1411 | "OSPF area ID in IP address format\n" | |
1412 | "OSPF area ID as a decimal value\n" | |
1413 | "Configure OSPF area as stub\n") | |
1414 | { | |
a3d826f0 | 1415 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1416 | int idx_ipv4_number = 1; |
1417 | struct in_addr area_id; | |
1418 | int ret, format; | |
1419 | ||
1420 | VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id, format, | |
1421 | argv[idx_ipv4_number]->arg); | |
1422 | ||
1423 | ret = ospf_area_stub_set(ospf, area_id); | |
1424 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
1425 | format); | |
1426 | if (ret == 0) { | |
1427 | vty_out(vty, | |
1428 | "First deconfigure all virtual link through this area\n"); | |
1429 | return CMD_WARNING_CONFIG_FAILED; | |
1430 | } | |
718e3744 | 1431 | |
d62a17ae | 1432 | ospf_area_no_summary_unset(ospf, area_id); |
718e3744 | 1433 | |
d62a17ae | 1434 | return CMD_SUCCESS; |
718e3744 | 1435 | } |
1436 | ||
a2c62831 | 1437 | DEFUN (ospf_area_stub_no_summary, |
1438 | ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1439 | "area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1440 | "OSPF stub parameters\n" |
1441 | "OSPF area ID in IP address format\n" | |
1442 | "OSPF area ID as a decimal value\n" | |
1443 | "Configure OSPF area as stub\n" | |
1444 | "Do not inject inter-area routes into stub\n") | |
1445 | { | |
a3d826f0 | 1446 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1447 | int idx_ipv4_number = 1; |
1448 | struct in_addr area_id; | |
1449 | int ret, format; | |
1450 | ||
1451 | VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id, format, | |
1452 | argv[idx_ipv4_number]->arg); | |
1453 | ||
1454 | ret = ospf_area_stub_set(ospf, area_id); | |
1455 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
1456 | format); | |
1457 | if (ret == 0) { | |
1458 | vty_out(vty, | |
1459 | "%% Area cannot be stub as it contains a virtual link\n"); | |
1460 | return CMD_WARNING_CONFIG_FAILED; | |
1461 | } | |
718e3744 | 1462 | |
d62a17ae | 1463 | ospf_area_no_summary_set(ospf, area_id); |
718e3744 | 1464 | |
d62a17ae | 1465 | return CMD_SUCCESS; |
718e3744 | 1466 | } |
1467 | ||
a2c62831 | 1468 | DEFUN (no_ospf_area_stub, |
1469 | no_ospf_area_stub_cmd, | |
6147e2c6 | 1470 | "no area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1471 | NO_STR |
1472 | "OSPF area parameters\n" | |
1473 | "OSPF area ID in IP address format\n" | |
1474 | "OSPF area ID as a decimal value\n" | |
1475 | "Configure OSPF area as stub\n") | |
1476 | { | |
a3d826f0 | 1477 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1478 | int idx_ipv4_number = 2; |
1479 | struct in_addr area_id; | |
1480 | int format; | |
718e3744 | 1481 | |
d62a17ae | 1482 | VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id, format, |
1483 | argv[idx_ipv4_number]->arg); | |
718e3744 | 1484 | |
d62a17ae | 1485 | ospf_area_stub_unset(ospf, area_id); |
1486 | ospf_area_no_summary_unset(ospf, area_id); | |
718e3744 | 1487 | |
d62a17ae | 1488 | return CMD_SUCCESS; |
718e3744 | 1489 | } |
1490 | ||
a2c62831 | 1491 | DEFUN (no_ospf_area_stub_no_summary, |
1492 | no_ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1493 | "no area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1494 | NO_STR |
1495 | "OSPF area parameters\n" | |
1496 | "OSPF area ID in IP address format\n" | |
1497 | "OSPF area ID as a decimal value\n" | |
1498 | "Configure OSPF area as stub\n" | |
1499 | "Do not inject inter-area routes into area\n") | |
1500 | { | |
a3d826f0 | 1501 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1502 | int idx_ipv4_number = 2; |
1503 | struct in_addr area_id; | |
1504 | int format; | |
718e3744 | 1505 | |
d62a17ae | 1506 | VTY_GET_OSPF_AREA_ID_NO_BB("stub", area_id, format, |
1507 | argv[idx_ipv4_number]->arg); | |
1508 | ospf_area_no_summary_unset(ospf, area_id); | |
718e3744 | 1509 | |
d62a17ae | 1510 | return CMD_SUCCESS; |
718e3744 | 1511 | } |
1512 | ||
d62a17ae | 1513 | static int ospf_area_nssa_cmd_handler(struct vty *vty, int argc, |
7ef56a73 CS |
1514 | struct cmd_token **argv, int cfg_nosum, |
1515 | int nosum) | |
718e3744 | 1516 | { |
a3d826f0 | 1517 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1518 | struct in_addr area_id; |
1519 | int ret, format; | |
1520 | ||
1521 | VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id, format, argv[1]->arg); | |
1522 | ||
1523 | ret = ospf_area_nssa_set(ospf, area_id); | |
1524 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
1525 | format); | |
1526 | if (ret == 0) { | |
1527 | vty_out(vty, | |
1528 | "%% Area cannot be nssa as it contains a virtual link\n"); | |
1529 | return CMD_WARNING_CONFIG_FAILED; | |
1530 | } | |
1531 | ||
1532 | if (argc > 3) { | |
1533 | if (strncmp(argv[3]->text, "translate-c", 11) == 0) | |
1534 | ospf_area_nssa_translator_role_set( | |
1535 | ospf, area_id, OSPF_NSSA_ROLE_CANDIDATE); | |
1536 | else if (strncmp(argv[3]->text, "translate-n", 11) == 0) | |
1537 | ospf_area_nssa_translator_role_set( | |
1538 | ospf, area_id, OSPF_NSSA_ROLE_NEVER); | |
1539 | else if (strncmp(argv[3]->text, "translate-a", 11) == 0) | |
1540 | ospf_area_nssa_translator_role_set( | |
1541 | ospf, area_id, OSPF_NSSA_ROLE_ALWAYS); | |
1542 | } else { | |
1543 | ospf_area_nssa_translator_role_set(ospf, area_id, | |
1544 | OSPF_NSSA_ROLE_CANDIDATE); | |
1545 | } | |
1546 | ||
7ef56a73 CS |
1547 | if (cfg_nosum) { |
1548 | if (nosum) | |
1549 | ospf_area_no_summary_set(ospf, area_id); | |
1550 | else | |
1551 | ospf_area_no_summary_unset(ospf, area_id); | |
1552 | } | |
d62a17ae | 1553 | |
1554 | ospf_schedule_abr_task(ospf); | |
1555 | ||
1556 | return CMD_SUCCESS; | |
718e3744 | 1557 | } |
1558 | ||
718e3744 | 1559 | |
b0a053be | 1560 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1561 | ospf_area_nssa_translate_cmd, |
6147e2c6 | 1562 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>", |
718e3744 | 1563 | "OSPF area parameters\n" |
1564 | "OSPF area ID in IP address format\n" | |
1565 | "OSPF area ID as a decimal value\n" | |
1566 | "Configure OSPF area as nssa\n" | |
1567 | "Configure NSSA-ABR for translate election (default)\n" | |
1568 | "Configure NSSA-ABR to never translate\n" | |
1569 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1570 | { |
7ef56a73 | 1571 | return ospf_area_nssa_cmd_handler(vty, argc, argv, 0, 0); |
b0a053be | 1572 | } |
1573 | ||
1574 | DEFUN (ospf_area_nssa, | |
1575 | ospf_area_nssa_cmd, | |
6147e2c6 | 1576 | "area <A.B.C.D|(0-4294967295)> nssa", |
b0a053be | 1577 | "OSPF area parameters\n" |
1578 | "OSPF area ID in IP address format\n" | |
1579 | "OSPF area ID as a decimal value\n" | |
1580 | "Configure OSPF area as nssa\n") | |
1581 | { | |
2643b2bc | 1582 | return ospf_area_nssa_cmd_handler(vty, argc, argv, 0, 0); |
b0a053be | 1583 | } |
718e3744 | 1584 | |
a2c62831 | 1585 | DEFUN (ospf_area_nssa_no_summary, |
1586 | ospf_area_nssa_no_summary_cmd, | |
6147e2c6 | 1587 | "area <A.B.C.D|(0-4294967295)> nssa no-summary", |
718e3744 | 1588 | "OSPF area parameters\n" |
1589 | "OSPF area ID in IP address format\n" | |
1590 | "OSPF area ID as a decimal value\n" | |
1591 | "Configure OSPF area as nssa\n" | |
1592 | "Do not inject inter-area routes into nssa\n") | |
1593 | { | |
7ef56a73 CS |
1594 | int idx_ipv4_number = 1; |
1595 | struct in_addr area_id; | |
1596 | int format; | |
1597 | ||
1598 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); | |
1599 | VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id, format, | |
1600 | argv[idx_ipv4_number]->arg); | |
1601 | ||
1602 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
1603 | format); | |
1604 | ospf_area_nssa_no_summary_set(ospf, area_id); | |
1605 | ||
1606 | ospf_schedule_abr_task(ospf); | |
1607 | ||
1608 | return CMD_SUCCESS; | |
1609 | } | |
1610 | ||
1611 | DEFUN (no_ospf_area_nssa_no_summary, | |
1612 | no_ospf_area_nssa_no_summary_cmd, | |
1613 | "no area <A.B.C.D|(0-4294967295)> nssa no-summary", | |
1614 | NO_STR | |
1615 | "OSPF area parameters\n" | |
1616 | "OSPF area ID in IP address format\n" | |
1617 | "OSPF area ID as a decimal value\n" | |
1618 | "Configure OSPF area as nssa\n" | |
1619 | "Do not inject inter-area routes into nssa\n") | |
1620 | { | |
1621 | int idx_ipv4_number = 2; | |
1622 | struct in_addr area_id; | |
1623 | int format; | |
1624 | ||
1625 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); | |
1626 | ||
1627 | VTY_GET_OSPF_AREA_ID_NO_BB("nssa", area_id, format, | |
1628 | argv[idx_ipv4_number]->arg); | |
1629 | ||
1630 | ospf_area_display_format_set(ospf, ospf_area_get(ospf, area_id), | |
1631 | format); | |
1632 | ospf_area_no_summary_unset(ospf, area_id); | |
1633 | ||
1634 | ospf_schedule_abr_task(ospf); | |
1635 | ||
1636 | return CMD_SUCCESS; | |
718e3744 | 1637 | } |
1638 | ||
a2c62831 | 1639 | DEFUN (no_ospf_area_nssa, |
1640 | no_ospf_area_nssa_cmd, | |
7ef56a73 | 1641 | "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always>]", |
718e3744 | 1642 | NO_STR |
1643 | "OSPF area parameters\n" | |
1644 | "OSPF area ID in IP address format\n" | |
1645 | "OSPF area ID as a decimal value\n" | |
7a7be519 | 1646 | "Configure OSPF area as nssa\n" |
1647 | "Configure NSSA-ABR for translate election (default)\n" | |
1648 | "Configure NSSA-ABR to never translate\n" | |
7ef56a73 | 1649 | "Configure NSSA-ABR to always translate\n") |
22b27e95 | 1650 | { |
a3d826f0 | 1651 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1652 | int idx_ipv4_number = 2; |
1653 | struct in_addr area_id; | |
1654 | int format; | |
718e3744 | 1655 | |
d62a17ae | 1656 | VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id, format, |
1657 | argv[idx_ipv4_number]->arg); | |
718e3744 | 1658 | |
7ef56a73 | 1659 | ospf_area_nssa_unset(ospf, area_id, argc); |
718e3744 | 1660 | |
d62a17ae | 1661 | ospf_schedule_abr_task(ospf); |
b0a053be | 1662 | |
d62a17ae | 1663 | return CMD_SUCCESS; |
718e3744 | 1664 | } |
1665 | ||
718e3744 | 1666 | |
a2c62831 | 1667 | DEFUN (ospf_area_default_cost, |
1668 | ospf_area_default_cost_cmd, | |
6147e2c6 | 1669 | "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1670 | "OSPF area parameters\n" |
1671 | "OSPF area ID in IP address format\n" | |
1672 | "OSPF area ID as a decimal value\n" | |
1673 | "Set the summary-default cost of a NSSA or stub area\n" | |
1674 | "Stub's advertised default summary cost\n") | |
1675 | { | |
a3d826f0 | 1676 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1677 | int idx_ipv4_number = 1; |
1678 | int idx_number = 3; | |
1679 | struct ospf_area *area; | |
1680 | struct in_addr area_id; | |
1681 | u_int32_t cost; | |
1682 | int format; | |
1683 | struct prefix_ipv4 p; | |
1684 | ||
1685 | VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id, format, | |
1686 | argv[idx_ipv4_number]->arg); | |
1687 | cost = strtoul(argv[idx_number]->arg, NULL, 10); | |
1688 | ||
1689 | area = ospf_area_get(ospf, area_id); | |
1690 | ospf_area_display_format_set(ospf, area, format); | |
1691 | ||
1692 | if (area->external_routing == OSPF_AREA_DEFAULT) { | |
1693 | vty_out(vty, "The area is neither stub, nor NSSA\n"); | |
1694 | return CMD_WARNING_CONFIG_FAILED; | |
1695 | } | |
ba682537 | 1696 | |
d62a17ae | 1697 | area->default_cost = cost; |
1698 | ||
1699 | p.family = AF_INET; | |
1700 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1701 | p.prefixlen = 0; | |
1702 | if (IS_DEBUG_OSPF_EVENT) | |
1703 | zlog_debug( | |
1704 | "ospf_abr_announce_stub_defaults(): " | |
1705 | "announcing 0.0.0.0/0 to area %s", | |
1706 | inet_ntoa(area->area_id)); | |
1707 | ospf_abr_announce_network_to_area(&p, area->default_cost, area); | |
1708 | ||
1709 | return CMD_SUCCESS; | |
718e3744 | 1710 | } |
1711 | ||
a2c62831 | 1712 | DEFUN (no_ospf_area_default_cost, |
1713 | no_ospf_area_default_cost_cmd, | |
6147e2c6 | 1714 | "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1715 | NO_STR |
1716 | "OSPF area parameters\n" | |
1717 | "OSPF area ID in IP address format\n" | |
1718 | "OSPF area ID as a decimal value\n" | |
1719 | "Set the summary-default cost of a NSSA or stub area\n" | |
1720 | "Stub's advertised default summary cost\n") | |
1721 | { | |
a3d826f0 | 1722 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1723 | int idx_ipv4_number = 2; |
1724 | struct ospf_area *area; | |
1725 | struct in_addr area_id; | |
1726 | int format; | |
1727 | struct prefix_ipv4 p; | |
718e3744 | 1728 | |
d62a17ae | 1729 | VTY_GET_OSPF_AREA_ID_NO_BB("default-cost", area_id, format, |
1730 | argv[idx_ipv4_number]->arg); | |
718e3744 | 1731 | |
d62a17ae | 1732 | area = ospf_area_lookup_by_area_id(ospf, area_id); |
1733 | if (area == NULL) | |
1734 | return CMD_SUCCESS; | |
718e3744 | 1735 | |
d62a17ae | 1736 | if (area->external_routing == OSPF_AREA_DEFAULT) { |
1737 | vty_out(vty, "The area is neither stub, nor NSSA\n"); | |
1738 | return CMD_WARNING_CONFIG_FAILED; | |
1739 | } | |
718e3744 | 1740 | |
d62a17ae | 1741 | area->default_cost = 1; |
718e3744 | 1742 | |
d62a17ae | 1743 | p.family = AF_INET; |
1744 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1745 | p.prefixlen = 0; | |
1746 | if (IS_DEBUG_OSPF_EVENT) | |
1747 | zlog_debug( | |
1748 | "ospf_abr_announce_stub_defaults(): " | |
1749 | "announcing 0.0.0.0/0 to area %s", | |
1750 | inet_ntoa(area->area_id)); | |
1751 | ospf_abr_announce_network_to_area(&p, area->default_cost, area); | |
ba682537 | 1752 | |
1753 | ||
d62a17ae | 1754 | ospf_area_check_free(ospf, area_id); |
718e3744 | 1755 | |
d62a17ae | 1756 | return CMD_SUCCESS; |
718e3744 | 1757 | } |
1758 | ||
a2c62831 | 1759 | DEFUN (ospf_area_export_list, |
1760 | ospf_area_export_list_cmd, | |
6147e2c6 | 1761 | "area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1762 | "OSPF area parameters\n" |
1763 | "OSPF area ID in IP address format\n" | |
1764 | "OSPF area ID as a decimal value\n" | |
1765 | "Set the filter for networks announced to other areas\n" | |
1766 | "Name of the access-list\n") | |
1767 | { | |
a3d826f0 | 1768 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1769 | int idx_ipv4_number = 1; |
1770 | struct ospf_area *area; | |
1771 | struct in_addr area_id; | |
1772 | int format; | |
718e3744 | 1773 | |
d62a17ae | 1774 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1775 | |
d62a17ae | 1776 | area = ospf_area_get(ospf, area_id); |
1777 | ospf_area_display_format_set(ospf, area, format); | |
1778 | ospf_area_export_list_set(ospf, area, argv[3]->arg); | |
718e3744 | 1779 | |
d62a17ae | 1780 | return CMD_SUCCESS; |
718e3744 | 1781 | } |
1782 | ||
a2c62831 | 1783 | DEFUN (no_ospf_area_export_list, |
1784 | no_ospf_area_export_list_cmd, | |
6147e2c6 | 1785 | "no area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1786 | NO_STR |
1787 | "OSPF area parameters\n" | |
1788 | "OSPF area ID in IP address format\n" | |
1789 | "OSPF area ID as a decimal value\n" | |
1790 | "Unset the filter for networks announced to other areas\n" | |
1791 | "Name of the access-list\n") | |
1792 | { | |
a3d826f0 | 1793 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1794 | int idx_ipv4_number = 2; |
1795 | struct ospf_area *area; | |
1796 | struct in_addr area_id; | |
1797 | int format; | |
718e3744 | 1798 | |
d62a17ae | 1799 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1800 | |
d62a17ae | 1801 | area = ospf_area_lookup_by_area_id(ospf, area_id); |
1802 | if (area == NULL) | |
1803 | return CMD_SUCCESS; | |
718e3744 | 1804 | |
d62a17ae | 1805 | ospf_area_export_list_unset(ospf, area); |
718e3744 | 1806 | |
d62a17ae | 1807 | return CMD_SUCCESS; |
718e3744 | 1808 | } |
1809 | ||
1810 | ||
a2c62831 | 1811 | DEFUN (ospf_area_import_list, |
1812 | ospf_area_import_list_cmd, | |
6147e2c6 | 1813 | "area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1814 | "OSPF area parameters\n" |
1815 | "OSPF area ID in IP address format\n" | |
1816 | "OSPF area ID as a decimal value\n" | |
1817 | "Set the filter for networks from other areas announced to the specified one\n" | |
1818 | "Name of the access-list\n") | |
1819 | { | |
a3d826f0 | 1820 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1821 | int idx_ipv4_number = 1; |
1822 | struct ospf_area *area; | |
1823 | struct in_addr area_id; | |
1824 | int format; | |
718e3744 | 1825 | |
d62a17ae | 1826 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1827 | |
d62a17ae | 1828 | area = ospf_area_get(ospf, area_id); |
1829 | ospf_area_display_format_set(ospf, area, format); | |
1830 | ospf_area_import_list_set(ospf, area, argv[3]->arg); | |
718e3744 | 1831 | |
d62a17ae | 1832 | return CMD_SUCCESS; |
718e3744 | 1833 | } |
1834 | ||
a2c62831 | 1835 | DEFUN (no_ospf_area_import_list, |
1836 | no_ospf_area_import_list_cmd, | |
6147e2c6 | 1837 | "no area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1838 | NO_STR |
1839 | "OSPF area parameters\n" | |
1840 | "OSPF area ID in IP address format\n" | |
1841 | "OSPF area ID as a decimal value\n" | |
1842 | "Unset the filter for networks announced to other areas\n" | |
1843 | "Name of the access-list\n") | |
1844 | { | |
a3d826f0 | 1845 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1846 | int idx_ipv4_number = 2; |
1847 | struct ospf_area *area; | |
1848 | struct in_addr area_id; | |
1849 | int format; | |
718e3744 | 1850 | |
d62a17ae | 1851 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1852 | |
d62a17ae | 1853 | area = ospf_area_lookup_by_area_id(ospf, area_id); |
1854 | if (area == NULL) | |
1855 | return CMD_SUCCESS; | |
718e3744 | 1856 | |
d62a17ae | 1857 | ospf_area_import_list_unset(ospf, area); |
718e3744 | 1858 | |
d62a17ae | 1859 | return CMD_SUCCESS; |
718e3744 | 1860 | } |
1861 | ||
a2c62831 | 1862 | DEFUN (ospf_area_filter_list, |
1863 | ospf_area_filter_list_cmd, | |
6147e2c6 | 1864 | "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1865 | "OSPF area parameters\n" |
1866 | "OSPF area ID in IP address format\n" | |
1867 | "OSPF area ID as a decimal value\n" | |
1868 | "Filter networks between OSPF areas\n" | |
1869 | "Filter prefixes between OSPF areas\n" | |
1870 | "Name of an IP prefix-list\n" | |
1871 | "Filter networks sent to this area\n" | |
1872 | "Filter networks sent from this area\n") | |
1873 | { | |
a3d826f0 | 1874 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1875 | int idx_ipv4_number = 1; |
1876 | int idx_word = 4; | |
1877 | int idx_in_out = 5; | |
1878 | struct ospf_area *area; | |
1879 | struct in_addr area_id; | |
1880 | struct prefix_list *plist; | |
1881 | int format; | |
1882 | ||
1883 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); | |
1884 | ||
1885 | area = ospf_area_get(ospf, area_id); | |
1886 | ospf_area_display_format_set(ospf, area, format); | |
1887 | plist = prefix_list_lookup(AFI_IP, argv[idx_word]->arg); | |
1888 | if (strncmp(argv[idx_in_out]->arg, "in", 2) == 0) { | |
1889 | PREFIX_LIST_IN(area) = plist; | |
1890 | if (PREFIX_NAME_IN(area)) | |
1891 | free(PREFIX_NAME_IN(area)); | |
1892 | ||
1893 | PREFIX_NAME_IN(area) = strdup(argv[idx_word]->arg); | |
1894 | ospf_schedule_abr_task(ospf); | |
1895 | } else { | |
1896 | PREFIX_LIST_OUT(area) = plist; | |
1897 | if (PREFIX_NAME_OUT(area)) | |
1898 | free(PREFIX_NAME_OUT(area)); | |
1899 | ||
1900 | PREFIX_NAME_OUT(area) = strdup(argv[idx_word]->arg); | |
1901 | ospf_schedule_abr_task(ospf); | |
1902 | } | |
718e3744 | 1903 | |
d62a17ae | 1904 | return CMD_SUCCESS; |
718e3744 | 1905 | } |
1906 | ||
a2c62831 | 1907 | DEFUN (no_ospf_area_filter_list, |
1908 | no_ospf_area_filter_list_cmd, | |
6147e2c6 | 1909 | "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1910 | NO_STR |
1911 | "OSPF area parameters\n" | |
1912 | "OSPF area ID in IP address format\n" | |
1913 | "OSPF area ID as a decimal value\n" | |
1914 | "Filter networks between OSPF areas\n" | |
1915 | "Filter prefixes between OSPF areas\n" | |
1916 | "Name of an IP prefix-list\n" | |
1917 | "Filter networks sent to this area\n" | |
1918 | "Filter networks sent from this area\n") | |
1919 | { | |
a3d826f0 | 1920 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 1921 | int idx_ipv4_number = 2; |
1922 | int idx_word = 5; | |
1923 | int idx_in_out = 6; | |
1924 | struct ospf_area *area; | |
1925 | struct in_addr area_id; | |
1926 | int format; | |
718e3744 | 1927 | |
d62a17ae | 1928 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1929 | |
d62a17ae | 1930 | if ((area = ospf_area_lookup_by_area_id(ospf, area_id)) == NULL) |
1931 | return CMD_SUCCESS; | |
718e3744 | 1932 | |
d62a17ae | 1933 | if (strncmp(argv[idx_in_out]->arg, "in", 2) == 0) { |
1934 | if (PREFIX_NAME_IN(area)) | |
1935 | if (strcmp(PREFIX_NAME_IN(area), argv[idx_word]->arg) | |
1936 | != 0) | |
1937 | return CMD_SUCCESS; | |
718e3744 | 1938 | |
d62a17ae | 1939 | PREFIX_LIST_IN(area) = NULL; |
1940 | if (PREFIX_NAME_IN(area)) | |
1941 | free(PREFIX_NAME_IN(area)); | |
718e3744 | 1942 | |
d62a17ae | 1943 | PREFIX_NAME_IN(area) = NULL; |
718e3744 | 1944 | |
d62a17ae | 1945 | ospf_schedule_abr_task(ospf); |
1946 | } else { | |
1947 | if (PREFIX_NAME_OUT(area)) | |
1948 | if (strcmp(PREFIX_NAME_OUT(area), argv[idx_word]->arg) | |
1949 | != 0) | |
1950 | return CMD_SUCCESS; | |
718e3744 | 1951 | |
d62a17ae | 1952 | PREFIX_LIST_OUT(area) = NULL; |
1953 | if (PREFIX_NAME_OUT(area)) | |
1954 | free(PREFIX_NAME_OUT(area)); | |
718e3744 | 1955 | |
d62a17ae | 1956 | PREFIX_NAME_OUT(area) = NULL; |
718e3744 | 1957 | |
d62a17ae | 1958 | ospf_schedule_abr_task(ospf); |
1959 | } | |
1960 | ||
1961 | return CMD_SUCCESS; | |
718e3744 | 1962 | } |
1963 | ||
6b0655a2 | 1964 | |
a2c62831 | 1965 | DEFUN (ospf_area_authentication_message_digest, |
1966 | ospf_area_authentication_message_digest_cmd, | |
32573073 QY |
1967 | "[no] area <A.B.C.D|(0-4294967295)> authentication message-digest", |
1968 | NO_STR | |
718e3744 | 1969 | "OSPF area parameters\n" |
2b00515a CF |
1970 | "OSPF area ID in IP address format\n" |
1971 | "OSPF area ID as a decimal value\n" | |
718e3744 | 1972 | "Enable authentication\n" |
1973 | "Use message-digest authentication\n") | |
1974 | { | |
a3d826f0 | 1975 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
ca19319b | 1976 | int idx = 0; |
d62a17ae | 1977 | struct ospf_area *area; |
1978 | struct in_addr area_id; | |
1979 | int format; | |
718e3744 | 1980 | |
ca19319b | 1981 | argv_find(argv, argc, "area", &idx); |
1982 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx + 1]->arg); | |
718e3744 | 1983 | |
d62a17ae | 1984 | area = ospf_area_get(ospf, area_id); |
1985 | ospf_area_display_format_set(ospf, area, format); | |
996c9314 LB |
1986 | area->auth_type = strmatch(argv[0]->text, "no") |
1987 | ? OSPF_AUTH_NULL | |
1988 | : OSPF_AUTH_CRYPTOGRAPHIC; | |
718e3744 | 1989 | |
d62a17ae | 1990 | return CMD_SUCCESS; |
718e3744 | 1991 | } |
1992 | ||
a2c62831 | 1993 | DEFUN (ospf_area_authentication, |
1994 | ospf_area_authentication_cmd, | |
6147e2c6 | 1995 | "area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 1996 | "OSPF area parameters\n" |
1997 | "OSPF area ID in IP address format\n" | |
1998 | "OSPF area ID as a decimal value\n" | |
1999 | "Enable authentication\n") | |
2000 | { | |
a3d826f0 | 2001 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2002 | int idx_ipv4_number = 1; |
2003 | struct ospf_area *area; | |
2004 | struct in_addr area_id; | |
2005 | int format; | |
718e3744 | 2006 | |
d62a17ae | 2007 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 2008 | |
d62a17ae | 2009 | area = ospf_area_get(ospf, area_id); |
2010 | ospf_area_display_format_set(ospf, area, format); | |
2011 | area->auth_type = OSPF_AUTH_SIMPLE; | |
718e3744 | 2012 | |
d62a17ae | 2013 | return CMD_SUCCESS; |
718e3744 | 2014 | } |
2015 | ||
a2c62831 | 2016 | DEFUN (no_ospf_area_authentication, |
2017 | no_ospf_area_authentication_cmd, | |
6147e2c6 | 2018 | "no area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 2019 | NO_STR |
2020 | "OSPF area parameters\n" | |
2021 | "OSPF area ID in IP address format\n" | |
2022 | "OSPF area ID as a decimal value\n" | |
2023 | "Enable authentication\n") | |
2024 | { | |
a3d826f0 | 2025 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2026 | int idx_ipv4_number = 2; |
2027 | struct ospf_area *area; | |
2028 | struct in_addr area_id; | |
2029 | int format; | |
718e3744 | 2030 | |
d62a17ae | 2031 | VTY_GET_OSPF_AREA_ID(area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 2032 | |
d62a17ae | 2033 | area = ospf_area_lookup_by_area_id(ospf, area_id); |
2034 | if (area == NULL) | |
2035 | return CMD_SUCCESS; | |
718e3744 | 2036 | |
d62a17ae | 2037 | area->auth_type = OSPF_AUTH_NULL; |
718e3744 | 2038 | |
d62a17ae | 2039 | ospf_area_check_free(ospf, area_id); |
2040 | ||
2041 | return CMD_SUCCESS; | |
718e3744 | 2042 | } |
2043 | ||
6b0655a2 | 2044 | |
718e3744 | 2045 | DEFUN (ospf_abr_type, |
2046 | ospf_abr_type_cmd, | |
6147e2c6 | 2047 | "ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2048 | "OSPF specific commands\n" |
2049 | "Set OSPF ABR type\n" | |
2050 | "Alternative ABR, cisco implementation\n" | |
2051 | "Alternative ABR, IBM implementation\n" | |
2052 | "Shortcut ABR\n" | |
2053 | "Standard behavior (RFC2328)\n") | |
2054 | { | |
a3d826f0 | 2055 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2056 | int idx_vendor = 2; |
2057 | u_char abr_type = OSPF_ABR_UNKNOWN; | |
2058 | ||
2059 | if (strncmp(argv[idx_vendor]->arg, "c", 1) == 0) | |
2060 | abr_type = OSPF_ABR_CISCO; | |
2061 | else if (strncmp(argv[idx_vendor]->arg, "i", 1) == 0) | |
2062 | abr_type = OSPF_ABR_IBM; | |
2063 | else if (strncmp(argv[idx_vendor]->arg, "sh", 2) == 0) | |
2064 | abr_type = OSPF_ABR_SHORTCUT; | |
2065 | else if (strncmp(argv[idx_vendor]->arg, "st", 2) == 0) | |
2066 | abr_type = OSPF_ABR_STAND; | |
2067 | else | |
2068 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2069 | |
d62a17ae | 2070 | /* If ABR type value is changed, schedule ABR task. */ |
2071 | if (ospf->abr_type != abr_type) { | |
2072 | ospf->abr_type = abr_type; | |
2073 | ospf_schedule_abr_task(ospf); | |
2074 | } | |
2075 | ||
2076 | return CMD_SUCCESS; | |
718e3744 | 2077 | } |
2078 | ||
2079 | DEFUN (no_ospf_abr_type, | |
2080 | no_ospf_abr_type_cmd, | |
6147e2c6 | 2081 | "no ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2082 | NO_STR |
2083 | "OSPF specific commands\n" | |
2084 | "Set OSPF ABR type\n" | |
2085 | "Alternative ABR, cisco implementation\n" | |
2086 | "Alternative ABR, IBM implementation\n" | |
3a2d747c QY |
2087 | "Shortcut ABR\n" |
2088 | "Standard ABR\n") | |
718e3744 | 2089 | { |
a3d826f0 | 2090 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2091 | int idx_vendor = 3; |
2092 | u_char abr_type = OSPF_ABR_UNKNOWN; | |
2093 | ||
2094 | if (strncmp(argv[idx_vendor]->arg, "c", 1) == 0) | |
2095 | abr_type = OSPF_ABR_CISCO; | |
2096 | else if (strncmp(argv[idx_vendor]->arg, "i", 1) == 0) | |
2097 | abr_type = OSPF_ABR_IBM; | |
2098 | else if (strncmp(argv[idx_vendor]->arg, "sh", 2) == 0) | |
2099 | abr_type = OSPF_ABR_SHORTCUT; | |
2100 | else if (strncmp(argv[idx_vendor]->arg, "st", 2) == 0) | |
2101 | abr_type = OSPF_ABR_STAND; | |
2102 | else | |
2103 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2104 | |
d62a17ae | 2105 | /* If ABR type value is changed, schedule ABR task. */ |
2106 | if (ospf->abr_type == abr_type) { | |
2107 | ospf->abr_type = OSPF_ABR_DEFAULT; | |
2108 | ospf_schedule_abr_task(ospf); | |
2109 | } | |
2110 | ||
2111 | return CMD_SUCCESS; | |
718e3744 | 2112 | } |
2113 | ||
d7e60dd7 AS |
2114 | DEFUN (ospf_log_adjacency_changes, |
2115 | ospf_log_adjacency_changes_cmd, | |
2116 | "log-adjacency-changes", | |
2117 | "Log changes in adjacency state\n") | |
2118 | { | |
a3d826f0 | 2119 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d7e60dd7 | 2120 | |
d62a17ae | 2121 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2122 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2123 | return CMD_SUCCESS; | |
d7e60dd7 AS |
2124 | } |
2125 | ||
2126 | DEFUN (ospf_log_adjacency_changes_detail, | |
2127 | ospf_log_adjacency_changes_detail_cmd, | |
2128 | "log-adjacency-changes detail", | |
2129 | "Log changes in adjacency state\n" | |
2130 | "Log all state changes\n") | |
2131 | { | |
a3d826f0 | 2132 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d7e60dd7 | 2133 | |
d62a17ae | 2134 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
2135 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2136 | return CMD_SUCCESS; | |
d7e60dd7 AS |
2137 | } |
2138 | ||
2139 | DEFUN (no_ospf_log_adjacency_changes, | |
2140 | no_ospf_log_adjacency_changes_cmd, | |
2141 | "no log-adjacency-changes", | |
2142 | NO_STR | |
2143 | "Log changes in adjacency state\n") | |
2144 | { | |
a3d826f0 | 2145 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d7e60dd7 | 2146 | |
d62a17ae | 2147 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2148 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2149 | return CMD_SUCCESS; | |
d7e60dd7 AS |
2150 | } |
2151 | ||
2152 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2153 | no_ospf_log_adjacency_changes_detail_cmd, | |
2154 | "no log-adjacency-changes detail", | |
2155 | NO_STR | |
2156 | "Log changes in adjacency state\n" | |
2157 | "Log all state changes\n") | |
2158 | { | |
a3d826f0 | 2159 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d7e60dd7 | 2160 | |
d62a17ae | 2161 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
2162 | return CMD_SUCCESS; | |
d7e60dd7 AS |
2163 | } |
2164 | ||
718e3744 | 2165 | DEFUN (ospf_compatible_rfc1583, |
2166 | ospf_compatible_rfc1583_cmd, | |
2167 | "compatible rfc1583", | |
2168 | "OSPF compatibility list\n" | |
2169 | "compatible with RFC 1583\n") | |
2170 | { | |
a3d826f0 | 2171 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
718e3744 | 2172 | |
d62a17ae | 2173 | if (!CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) { |
2174 | SET_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE); | |
2175 | ospf_spf_calculate_schedule(ospf, SPF_FLAG_CONFIG_CHANGE); | |
2176 | } | |
2177 | return CMD_SUCCESS; | |
718e3744 | 2178 | } |
2179 | ||
2180 | DEFUN (no_ospf_compatible_rfc1583, | |
2181 | no_ospf_compatible_rfc1583_cmd, | |
2182 | "no compatible rfc1583", | |
2183 | NO_STR | |
2184 | "OSPF compatibility list\n" | |
2185 | "compatible with RFC 1583\n") | |
2186 | { | |
a3d826f0 | 2187 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
718e3744 | 2188 | |
d62a17ae | 2189 | if (CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) { |
2190 | UNSET_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE); | |
2191 | ospf_spf_calculate_schedule(ospf, SPF_FLAG_CONFIG_CHANGE); | |
2192 | } | |
2193 | return CMD_SUCCESS; | |
718e3744 | 2194 | } |
2195 | ||
d62a17ae | 2196 | ALIAS(ospf_compatible_rfc1583, ospf_rfc1583_flag_cmd, |
2197 | "ospf rfc1583compatibility", | |
2198 | "OSPF specific commands\n" | |
2199 | "Enable the RFC1583Compatibility flag\n") | |
718e3744 | 2200 | |
d62a17ae | 2201 | ALIAS(no_ospf_compatible_rfc1583, no_ospf_rfc1583_flag_cmd, |
9d303b37 | 2202 | "no ospf rfc1583compatibility", NO_STR |
d62a17ae | 2203 | "OSPF specific commands\n" |
2204 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2205 | |
d62a17ae | 2206 | static int ospf_timers_spf_set(struct vty *vty, unsigned int delay, |
2207 | unsigned int hold, unsigned int max) | |
d24f6e2a | 2208 | { |
a3d826f0 | 2209 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
7c8ff89e | 2210 | |
d62a17ae | 2211 | ospf->spf_delay = delay; |
2212 | ospf->spf_holdtime = hold; | |
2213 | ospf->spf_max_holdtime = max; | |
2214 | ||
2215 | return CMD_SUCCESS; | |
d24f6e2a | 2216 | } |
718e3744 | 2217 | |
ac7424f9 MR |
2218 | DEFUN (ospf_timers_min_ls_interval, |
2219 | ospf_timers_min_ls_interval_cmd, | |
6147e2c6 | 2220 | "timers throttle lsa all (0-5000)", |
ac7424f9 MR |
2221 | "Adjust routing timers\n" |
2222 | "Throttling adaptive timer\n" | |
2223 | "LSA delay between transmissions\n" | |
813d4307 | 2224 | "All LSA types\n" |
ac7424f9 MR |
2225 | "Delay (msec) between sending LSAs\n") |
2226 | { | |
a3d826f0 | 2227 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2228 | int idx_number = 4; |
2229 | unsigned int interval; | |
ac7424f9 | 2230 | |
d62a17ae | 2231 | if (argc < 5) { |
2232 | vty_out(vty, "Insufficient arguments\n"); | |
2233 | return CMD_WARNING_CONFIG_FAILED; | |
2234 | } | |
ac7424f9 | 2235 | |
d62a17ae | 2236 | interval = strtoul(argv[idx_number]->arg, NULL, 10); |
ac7424f9 | 2237 | |
d62a17ae | 2238 | ospf->min_ls_interval = interval; |
ac7424f9 | 2239 | |
d62a17ae | 2240 | return CMD_SUCCESS; |
ac7424f9 MR |
2241 | } |
2242 | ||
2243 | DEFUN (no_ospf_timers_min_ls_interval, | |
2244 | no_ospf_timers_min_ls_interval_cmd, | |
7a7be519 | 2245 | "no timers throttle lsa all [(0-5000)]", |
ac7424f9 MR |
2246 | NO_STR |
2247 | "Adjust routing timers\n" | |
2248 | "Throttling adaptive timer\n" | |
813d4307 | 2249 | "LSA delay between transmissions\n" |
7a7be519 | 2250 | "All LSA types\n" |
2251 | "Delay (msec) between sending LSAs\n") | |
ac7424f9 | 2252 | { |
a3d826f0 | 2253 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2254 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; |
ac7424f9 | 2255 | |
d62a17ae | 2256 | return CMD_SUCCESS; |
ac7424f9 MR |
2257 | } |
2258 | ||
d24f6e2a | 2259 | DEFUN (ospf_timers_throttle_spf, |
2260 | ospf_timers_throttle_spf_cmd, | |
6147e2c6 | 2261 | "timers throttle spf (0-600000) (0-600000) (0-600000)", |
d24f6e2a | 2262 | "Adjust routing timers\n" |
2263 | "Throttling adaptive timer\n" | |
2264 | "OSPF SPF timers\n" | |
2265 | "Delay (msec) from first change received till SPF calculation\n" | |
2266 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2267 | "Maximum hold time (msec)\n") | |
2268 | { | |
d62a17ae | 2269 | int idx_number = 3; |
2270 | int idx_number_2 = 4; | |
2271 | int idx_number_3 = 5; | |
2272 | unsigned int delay, hold, max; | |
2273 | ||
2274 | if (argc < 6) { | |
2275 | vty_out(vty, "Insufficient arguments\n"); | |
2276 | return CMD_WARNING_CONFIG_FAILED; | |
2277 | } | |
2278 | ||
2279 | delay = strtoul(argv[idx_number]->arg, NULL, 10); | |
2280 | hold = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
2281 | max = strtoul(argv[idx_number_3]->arg, NULL, 10); | |
2282 | ||
2283 | return ospf_timers_spf_set(vty, delay, hold, max); | |
d24f6e2a | 2284 | } |
2285 | ||
d24f6e2a | 2286 | DEFUN (no_ospf_timers_throttle_spf, |
2287 | no_ospf_timers_throttle_spf_cmd, | |
7a7be519 | 2288 | "no timers throttle spf [(0-600000)(0-600000)(0-600000)]", |
718e3744 | 2289 | NO_STR |
2290 | "Adjust routing timers\n" | |
d24f6e2a | 2291 | "Throttling adaptive timer\n" |
7a7be519 | 2292 | "OSPF SPF timers\n" |
2293 | "Delay (msec) from first change received till SPF calculation\n" | |
2294 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2295 | "Maximum hold time (msec)\n") | |
22b27e95 | 2296 | { |
d62a17ae | 2297 | return ospf_timers_spf_set(vty, OSPF_SPF_DELAY_DEFAULT, |
2298 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2299 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2300 | } |
2301 | ||
b4a039bf | 2302 | |
0e88de35 QY |
2303 | DEFUN (ospf_timers_lsa_min_arrival, |
2304 | ospf_timers_lsa_min_arrival_cmd, | |
6147e2c6 | 2305 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
2306 | "Adjust routing timers\n" |
2307 | "OSPF LSA timers\n" | |
2308 | "Minimum delay in receiving new version of a LSA\n" | |
2309 | "Delay in milliseconds\n") | |
2310 | { | |
a3d826f0 | 2311 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
0e88de35 | 2312 | ospf->min_ls_arrival = strtoul(argv[argc - 1]->arg, NULL, 10); |
d62a17ae | 2313 | return CMD_SUCCESS; |
b6927875 DS |
2314 | } |
2315 | ||
0e88de35 QY |
2316 | DEFUN (no_ospf_timers_lsa_min_arrival, |
2317 | no_ospf_timers_lsa_min_arrival_cmd, | |
7a7be519 | 2318 | "no timers lsa min-arrival [(0-600000)]", |
b6927875 DS |
2319 | NO_STR |
2320 | "Adjust routing timers\n" | |
2321 | "OSPF LSA timers\n" | |
7a7be519 | 2322 | "Minimum delay in receiving new version of a LSA\n" |
2323 | "Delay in milliseconds\n") | |
b6927875 | 2324 | { |
a3d826f0 | 2325 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2326 | unsigned int minarrival; |
b6927875 | 2327 | |
d62a17ae | 2328 | if (argc > 4) { |
0e88de35 | 2329 | minarrival = strtoul(argv[argc - 1]->arg, NULL, 10); |
b6927875 | 2330 | |
d62a17ae | 2331 | if (ospf->min_ls_arrival != minarrival |
2332 | || minarrival == OSPF_MIN_LS_ARRIVAL) | |
2333 | return CMD_SUCCESS; | |
2334 | } | |
b6927875 | 2335 | |
d62a17ae | 2336 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 | 2337 | |
d62a17ae | 2338 | return CMD_SUCCESS; |
b6927875 DS |
2339 | } |
2340 | ||
5d1a2ee8 QY |
2341 | #if CONFDATE > 20180708 |
2342 | CPP_NOTICE("ospf: `timers lsa arrival (0-1000)` deprecated 2017/07/08") | |
2343 | #endif | |
996c9314 LB |
2344 | ALIAS_HIDDEN(ospf_timers_lsa_min_arrival, ospf_timers_lsa_arrival_cmd, |
2345 | "timers lsa arrival (0-1000)", | |
2346 | "adjust routing timers\n" | |
2347 | "throttling link state advertisement delays\n" | |
2348 | "ospf minimum arrival interval delay\n" | |
2349 | "delay (msec) between accepted lsas\n"); | |
0e88de35 | 2350 | |
5d1a2ee8 QY |
2351 | #if CONFDATE > 20180708 |
2352 | CPP_NOTICE("ospf: `no timers lsa arrival (0-1000)` deprecated 2017/07/08") | |
2353 | #endif | |
996c9314 LB |
2354 | ALIAS_HIDDEN(no_ospf_timers_lsa_min_arrival, no_ospf_timers_lsa_arrival_cmd, |
2355 | "no timers lsa arrival (0-1000)", NO_STR | |
2356 | "adjust routing timers\n" | |
2357 | "throttling link state advertisement delays\n" | |
2358 | "ospf minimum arrival interval delay\n" | |
2359 | "delay (msec) between accepted lsas\n"); | |
0e88de35 QY |
2360 | |
2361 | ||
a2c62831 | 2362 | DEFUN (ospf_neighbor, |
2363 | ospf_neighbor_cmd, | |
7a7be519 | 2364 | "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]", |
718e3744 | 2365 | NEIGHBOR_STR |
7a7be519 | 2366 | "Neighbor IP address\n" |
2367 | "Neighbor Priority\n" | |
2368 | "Priority\n" | |
2369 | "Dead Neighbor Polling interval\n" | |
2370 | "Seconds\n") | |
718e3744 | 2371 | { |
a3d826f0 | 2372 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2373 | int idx_ipv4 = 1; |
2374 | int idx_pri = 3; | |
2375 | int idx_poll = 5; | |
2376 | struct in_addr nbr_addr; | |
2377 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; | |
2378 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2379 | |
cc9b06ad DS |
2380 | if (!inet_aton(argv[idx_ipv4]->arg, &nbr_addr)) { |
2381 | vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n"); | |
2382 | return CMD_WARNING_CONFIG_FAILED; | |
2383 | } | |
718e3744 | 2384 | |
d62a17ae | 2385 | if (argc > 2) |
2386 | priority = strtoul(argv[idx_pri]->arg, NULL, 10); | |
7a7be519 | 2387 | |
d62a17ae | 2388 | if (argc > 4) |
2389 | interval = strtoul(argv[idx_poll]->arg, NULL, 10); | |
718e3744 | 2390 | |
d62a17ae | 2391 | ospf_nbr_nbma_set(ospf, nbr_addr); |
7a7be519 | 2392 | |
d62a17ae | 2393 | if (argc > 2) |
2394 | ospf_nbr_nbma_priority_set(ospf, nbr_addr, priority); | |
7a7be519 | 2395 | |
d62a17ae | 2396 | if (argc > 4) |
2397 | ospf_nbr_nbma_poll_interval_set(ospf, nbr_addr, interval); | |
718e3744 | 2398 | |
d62a17ae | 2399 | return CMD_SUCCESS; |
718e3744 | 2400 | } |
2401 | ||
a2c62831 | 2402 | DEFUN (ospf_neighbor_poll_interval, |
2403 | ospf_neighbor_poll_interval_cmd, | |
7a7be519 | 2404 | "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", |
718e3744 | 2405 | NEIGHBOR_STR |
2406 | "Neighbor IP address\n" | |
2407 | "Dead Neighbor Polling interval\n" | |
7a7be519 | 2408 | "Seconds\n" |
2409 | "OSPF priority of non-broadcast neighbor\n" | |
2410 | "Priority\n") | |
22b27e95 | 2411 | { |
a3d826f0 | 2412 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2413 | int idx_ipv4 = 1; |
2414 | int idx_poll = 3; | |
2415 | int idx_pri = 5; | |
2416 | struct in_addr nbr_addr; | |
2417 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; | |
2418 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2419 | |
cc9b06ad DS |
2420 | if (!inet_aton(argv[idx_ipv4]->arg, &nbr_addr)) { |
2421 | vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n"); | |
2422 | return CMD_WARNING_CONFIG_FAILED; | |
2423 | } | |
718e3744 | 2424 | |
d62a17ae | 2425 | interval = strtoul(argv[idx_poll]->arg, NULL, 10); |
718e3744 | 2426 | |
d62a17ae | 2427 | if (argc > 4) |
2428 | priority = strtoul(argv[idx_pri]->arg, NULL, 10); | |
718e3744 | 2429 | |
d62a17ae | 2430 | ospf_nbr_nbma_set(ospf, nbr_addr); |
2431 | ospf_nbr_nbma_poll_interval_set(ospf, nbr_addr, interval); | |
7a7be519 | 2432 | |
d62a17ae | 2433 | if (argc > 4) |
2434 | ospf_nbr_nbma_priority_set(ospf, nbr_addr, priority); | |
718e3744 | 2435 | |
d62a17ae | 2436 | return CMD_SUCCESS; |
718e3744 | 2437 | } |
2438 | ||
a2c62831 | 2439 | DEFUN (no_ospf_neighbor, |
2440 | no_ospf_neighbor_cmd, | |
7a7be519 | 2441 | "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]", |
718e3744 | 2442 | NO_STR |
2443 | NEIGHBOR_STR | |
7a7be519 | 2444 | "Neighbor IP address\n" |
2445 | "Neighbor Priority\n" | |
2446 | "Priority\n" | |
2447 | "Dead Neighbor Polling interval\n" | |
2448 | "Seconds\n") | |
718e3744 | 2449 | { |
a3d826f0 | 2450 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2451 | int idx_ipv4 = 2; |
2452 | struct in_addr nbr_addr; | |
718e3744 | 2453 | |
cc9b06ad DS |
2454 | if (!inet_aton(argv[idx_ipv4]->arg, &nbr_addr)) { |
2455 | vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n"); | |
2456 | return CMD_WARNING_CONFIG_FAILED; | |
2457 | } | |
718e3744 | 2458 | |
d62a17ae | 2459 | (void)ospf_nbr_nbma_unset(ospf, nbr_addr); |
718e3744 | 2460 | |
d62a17ae | 2461 | return CMD_SUCCESS; |
718e3744 | 2462 | } |
2463 | ||
7a7be519 | 2464 | DEFUN (no_ospf_neighbor_poll, |
2465 | no_ospf_neighbor_poll_cmd, | |
2466 | "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", | |
2467 | NO_STR | |
2468 | NEIGHBOR_STR | |
2469 | "Neighbor IP address\n" | |
2470 | "Dead Neighbor Polling interval\n" | |
2471 | "Seconds\n" | |
2472 | "Neighbor Priority\n" | |
2473 | "Priority\n") | |
2474 | { | |
a3d826f0 | 2475 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2476 | int idx_ipv4 = 2; |
2477 | struct in_addr nbr_addr; | |
7a7be519 | 2478 | |
cc9b06ad DS |
2479 | if (!inet_aton(argv[idx_ipv4]->arg, &nbr_addr)) { |
2480 | vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n"); | |
2481 | return CMD_WARNING_CONFIG_FAILED; | |
2482 | } | |
718e3744 | 2483 | |
d62a17ae | 2484 | (void)ospf_nbr_nbma_unset(ospf, nbr_addr); |
813d4307 | 2485 | |
d62a17ae | 2486 | return CMD_SUCCESS; |
7a7be519 | 2487 | } |
718e3744 | 2488 | |
bf2bfafd DW |
2489 | DEFUN (ospf_refresh_timer, |
2490 | ospf_refresh_timer_cmd, | |
6147e2c6 | 2491 | "refresh timer (10-1800)", |
718e3744 | 2492 | "Adjust refresh parameters\n" |
2493 | "Set refresh timer\n" | |
2494 | "Timer value in seconds\n") | |
2495 | { | |
a3d826f0 | 2496 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2497 | int idx_number = 2; |
2498 | unsigned int interval; | |
7c8ff89e | 2499 | |
d62a17ae | 2500 | interval = strtoul(argv[idx_number]->arg, NULL, 10); |
2501 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) | |
2502 | * OSPF_LSA_REFRESHER_GRANULARITY; | |
718e3744 | 2503 | |
d62a17ae | 2504 | ospf_timers_refresh_set(ospf, interval); |
718e3744 | 2505 | |
d62a17ae | 2506 | return CMD_SUCCESS; |
718e3744 | 2507 | } |
2508 | ||
bf2bfafd DW |
2509 | DEFUN (no_ospf_refresh_timer, |
2510 | no_ospf_refresh_timer_val_cmd, | |
7a7be519 | 2511 | "no refresh timer [(10-1800)]", |
3a2d747c | 2512 | NO_STR |
718e3744 | 2513 | "Adjust refresh parameters\n" |
2514 | "Unset refresh timer\n" | |
2515 | "Timer value in seconds\n") | |
2516 | { | |
a3d826f0 | 2517 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2518 | int idx_number = 3; |
2519 | unsigned int interval; | |
718e3744 | 2520 | |
d62a17ae | 2521 | if (argc == 1) { |
2522 | interval = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 2523 | |
d62a17ae | 2524 | if (ospf->lsa_refresh_interval != interval |
2525 | || interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2526 | return CMD_SUCCESS; | |
2527 | } | |
2528 | ||
2529 | ospf_timers_refresh_unset(ospf); | |
2530 | ||
2531 | return CMD_SUCCESS; | |
718e3744 | 2532 | } |
2533 | ||
718e3744 | 2534 | |
a2c62831 | 2535 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2536 | ospf_auto_cost_reference_bandwidth_cmd, | |
6147e2c6 | 2537 | "auto-cost reference-bandwidth (1-4294967)", |
718e3744 | 2538 | "Calculate OSPF interface cost according to bandwidth\n" |
2539 | "Use reference bandwidth method to assign OSPF cost\n" | |
2540 | "The reference bandwidth in terms of Mbits per second\n") | |
2541 | { | |
a3d826f0 | 2542 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
f4e14fdb | 2543 | struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); |
d62a17ae | 2544 | int idx_number = 2; |
2545 | u_int32_t refbw; | |
d62a17ae | 2546 | struct interface *ifp; |
2547 | ||
2548 | refbw = strtol(argv[idx_number]->arg, NULL, 10); | |
2549 | if (refbw < 1 || refbw > 4294967) { | |
2550 | vty_out(vty, "reference-bandwidth value is invalid\n"); | |
2551 | return CMD_WARNING_CONFIG_FAILED; | |
2552 | } | |
2553 | ||
2554 | /* If reference bandwidth is changed. */ | |
2555 | if ((refbw) == ospf->ref_bandwidth) | |
2556 | return CMD_SUCCESS; | |
2557 | ||
2558 | ospf->ref_bandwidth = refbw; | |
451fda4f | 2559 | FOR_ALL_INTERFACES (vrf, ifp) |
d62a17ae | 2560 | ospf_if_recalculate_output_cost(ifp); |
2561 | ||
2562 | return CMD_SUCCESS; | |
718e3744 | 2563 | } |
2564 | ||
a2c62831 | 2565 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2566 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
7a7be519 | 2567 | "no auto-cost reference-bandwidth [(1-4294967)]", |
718e3744 | 2568 | NO_STR |
2569 | "Calculate OSPF interface cost according to bandwidth\n" | |
7a7be519 | 2570 | "Use reference bandwidth method to assign OSPF cost\n" |
2571 | "The reference bandwidth in terms of Mbits per second\n") | |
718e3744 | 2572 | { |
a3d826f0 | 2573 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
f4e14fdb | 2574 | struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); |
d62a17ae | 2575 | struct interface *ifp; |
718e3744 | 2576 | |
d62a17ae | 2577 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
2578 | return CMD_SUCCESS; | |
2579 | ||
2580 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; | |
2581 | vty_out(vty, "%% OSPF: Reference bandwidth is changed.\n"); | |
2582 | vty_out(vty, | |
2583 | " Please ensure reference bandwidth is consistent across all routers\n"); | |
2584 | ||
451fda4f | 2585 | FOR_ALL_INTERFACES (vrf, ifp) |
d62a17ae | 2586 | ospf_if_recalculate_output_cost(ifp); |
2587 | ||
2588 | return CMD_SUCCESS; | |
718e3744 | 2589 | } |
2590 | ||
2f8f370e DS |
2591 | DEFUN (ospf_write_multiplier, |
2592 | ospf_write_multiplier_cmd, | |
6147e2c6 | 2593 | "ospf write-multiplier (1-100)", |
e8f45e82 DS |
2594 | "OSPF specific commands\n" |
2595 | "Write multiplier\n" | |
2596 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2597 | { |
a3d826f0 | 2598 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 2599 | int idx_number; |
2600 | u_int32_t write_oi_count; | |
2601 | ||
2602 | if (argc == 3) | |
2603 | idx_number = 2; | |
2604 | else | |
2605 | idx_number = 1; | |
2606 | ||
2607 | write_oi_count = strtol(argv[idx_number]->arg, NULL, 10); | |
2608 | if (write_oi_count < 1 || write_oi_count > 100) { | |
2609 | vty_out(vty, "write-multiplier value is invalid\n"); | |
2610 | return CMD_WARNING_CONFIG_FAILED; | |
2611 | } | |
2612 | ||
2613 | ospf->write_oi_count = write_oi_count; | |
2614 | return CMD_SUCCESS; | |
2f8f370e DS |
2615 | } |
2616 | ||
d62a17ae | 2617 | ALIAS(ospf_write_multiplier, write_multiplier_cmd, "write-multiplier (1-100)", |
2618 | "Write multiplier\n" | |
2619 | "Maximum number of interface serviced per write\n") | |
e8f45e82 | 2620 | |
2f8f370e DS |
2621 | DEFUN (no_ospf_write_multiplier, |
2622 | no_ospf_write_multiplier_cmd, | |
6147e2c6 | 2623 | "no ospf write-multiplier (1-100)", |
2f8f370e | 2624 | NO_STR |
e8f45e82 | 2625 | "OSPF specific commands\n" |
813d4307 DW |
2626 | "Write multiplier\n" |
2627 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2628 | { |
a3d826f0 | 2629 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
2f8f370e | 2630 | |
d62a17ae | 2631 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2632 | return CMD_SUCCESS; | |
2f8f370e DS |
2633 | } |
2634 | ||
d62a17ae | 2635 | ALIAS(no_ospf_write_multiplier, no_write_multiplier_cmd, |
9d303b37 | 2636 | "no write-multiplier (1-100)", NO_STR |
d62a17ae | 2637 | "Write multiplier\n" |
2638 | "Maximum number of interface serviced per write\n") | |
2639 | ||
2640 | const char *ospf_abr_type_descr_str[] = {"Unknown", "Standard (RFC2328)", | |
2641 | "Alternative IBM", "Alternative Cisco", | |
2642 | "Alternative Shortcut"}; | |
2643 | ||
2644 | const char *ospf_shortcut_mode_descr_str[] = {"Default", "Enabled", "Disabled"}; | |
2645 | ||
2646 | static void show_ip_ospf_area(struct vty *vty, struct ospf_area *area, | |
2647 | json_object *json_areas, u_char use_json) | |
2648 | { | |
2649 | json_object *json_area = NULL; | |
2650 | ||
2651 | if (use_json) | |
2652 | json_area = json_object_new_object(); | |
2653 | ||
2654 | /* Show Area ID. */ | |
2655 | if (!use_json) | |
2656 | vty_out(vty, " Area ID: %s", inet_ntoa(area->area_id)); | |
2657 | ||
2658 | /* Show Area type/mode. */ | |
2659 | if (OSPF_IS_AREA_BACKBONE(area)) { | |
2660 | if (use_json) | |
2661 | json_object_boolean_true_add(json_area, "backbone"); | |
2662 | else | |
2663 | vty_out(vty, " (Backbone)\n"); | |
2664 | } else { | |
2665 | if (use_json) { | |
2666 | if (area->external_routing == OSPF_AREA_STUB) { | |
2667 | if (area->no_summary) | |
2668 | json_object_boolean_true_add( | |
2669 | json_area, "stubNoSummary"); | |
2670 | if (area->shortcut_configured) | |
2671 | json_object_boolean_true_add( | |
2672 | json_area, "stubShortcut"); | |
2673 | } else if (area->external_routing == OSPF_AREA_NSSA) { | |
2674 | if (area->no_summary) | |
2675 | json_object_boolean_true_add( | |
2676 | json_area, "nssaNoSummary"); | |
2677 | if (area->shortcut_configured) | |
2678 | json_object_boolean_true_add( | |
2679 | json_area, "nssaShortcut"); | |
2680 | } | |
813d4307 | 2681 | |
d62a17ae | 2682 | json_object_string_add( |
2683 | json_area, "shortcuttingMode", | |
2684 | ospf_shortcut_mode_descr_str | |
2685 | [area->shortcut_configured]); | |
2686 | if (area->shortcut_capability) | |
2687 | json_object_boolean_true_add(json_area, | |
2688 | "sBitConcensus"); | |
2689 | } else { | |
2690 | if (area->external_routing == OSPF_AREA_STUB) | |
2691 | vty_out(vty, " (Stub%s%s)", | |
2692 | area->no_summary ? ", no summary" : "", | |
2693 | area->shortcut_configured ? "; " : ""); | |
2694 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2695 | vty_out(vty, " (NSSA%s%s)", | |
2696 | area->no_summary ? ", no summary" : "", | |
2697 | area->shortcut_configured ? "; " : ""); | |
2698 | ||
2699 | vty_out(vty, "\n"); | |
2700 | vty_out(vty, " Shortcutting mode: %s", | |
2701 | ospf_shortcut_mode_descr_str | |
2702 | [area->shortcut_configured]); | |
2703 | vty_out(vty, ", S-bit consensus: %s\n", | |
2704 | area->shortcut_capability ? "ok" : "no"); | |
2705 | } | |
2706 | } | |
718e3744 | 2707 | |
d62a17ae | 2708 | /* Show number of interfaces */ |
2709 | if (use_json) { | |
2710 | json_object_int_add(json_area, "areaIfTotalCounter", | |
2711 | listcount(area->oiflist)); | |
2712 | json_object_int_add(json_area, "areaIfActiveCounter", | |
2713 | area->act_ints); | |
2714 | } else | |
2715 | vty_out(vty, | |
2716 | " Number of interfaces in this area: Total: %d, " | |
2717 | "Active: %d\n", | |
2718 | listcount(area->oiflist), area->act_ints); | |
2719 | ||
2720 | if (area->external_routing == OSPF_AREA_NSSA) { | |
2721 | if (use_json) { | |
2722 | json_object_boolean_true_add(json_area, "nssa"); | |
2723 | if (!IS_OSPF_ABR(area->ospf)) | |
2724 | json_object_boolean_false_add(json_area, "abr"); | |
2725 | else if (area->NSSATranslatorState) { | |
2726 | json_object_boolean_true_add(json_area, "abr"); | |
2727 | if (area->NSSATranslatorRole | |
2728 | == OSPF_NSSA_ROLE_CANDIDATE) | |
2729 | json_object_boolean_true_add( | |
2730 | json_area, | |
2731 | "nssaTranslatorElected"); | |
2732 | else if (area->NSSATranslatorRole | |
2733 | == OSPF_NSSA_ROLE_ALWAYS) | |
2734 | json_object_boolean_true_add( | |
2735 | json_area, | |
2736 | "nssaTranslatorAlways"); | |
2737 | } else { | |
2738 | json_object_boolean_true_add(json_area, "abr"); | |
2739 | if (area->NSSATranslatorRole | |
2740 | == OSPF_NSSA_ROLE_CANDIDATE) | |
2741 | json_object_boolean_false_add( | |
2742 | json_area, | |
2743 | "nssaTranslatorElected"); | |
2744 | else | |
2745 | json_object_boolean_true_add( | |
2746 | json_area, | |
2747 | "nssaTranslatorNever"); | |
2748 | } | |
2749 | } else { | |
2750 | vty_out(vty, | |
2751 | " It is an NSSA configuration. \n Elected NSSA/ABR performs type-7/type-5 LSA translation. \n"); | |
2752 | if (!IS_OSPF_ABR(area->ospf)) | |
2753 | vty_out(vty, | |
2754 | " It is not ABR, therefore not Translator. \n"); | |
2755 | else if (area->NSSATranslatorState) { | |
2756 | vty_out(vty, " We are an ABR and "); | |
2757 | if (area->NSSATranslatorRole | |
2758 | == OSPF_NSSA_ROLE_CANDIDATE) | |
2759 | vty_out(vty, | |
2760 | "the NSSA Elected Translator. \n"); | |
2761 | else if (area->NSSATranslatorRole | |
2762 | == OSPF_NSSA_ROLE_ALWAYS) | |
2763 | vty_out(vty, | |
2764 | "always an NSSA Translator. \n"); | |
2765 | } else { | |
2766 | vty_out(vty, " We are an ABR, but "); | |
2767 | if (area->NSSATranslatorRole | |
2768 | == OSPF_NSSA_ROLE_CANDIDATE) | |
2769 | vty_out(vty, | |
2770 | "not the NSSA Elected Translator. \n"); | |
2771 | else | |
2772 | vty_out(vty, | |
2773 | "never an NSSA Translator. \n"); | |
2774 | } | |
2775 | } | |
2776 | } | |
2777 | ||
2778 | /* Stub-router state for this area */ | |
2779 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) { | |
2780 | char timebuf[OSPF_TIME_DUMP_SIZE]; | |
2781 | ||
2782 | if (use_json) { | |
2783 | json_object_boolean_true_add( | |
2784 | json_area, "originStubMaxDistRouterLsa"); | |
2785 | if (CHECK_FLAG(area->stub_router_state, | |
2786 | OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2787 | json_object_boolean_true_add( | |
2788 | json_area, "indefiniteActiveAdmin"); | |
2789 | if (area->t_stub_router) { | |
2790 | long time_store; | |
2791 | time_store = | |
2792 | monotime_until( | |
2793 | &area->t_stub_router->u.sands, | |
2794 | NULL) | |
2795 | / 1000LL; | |
2796 | json_object_int_add( | |
2797 | json_area, | |
2798 | "activeStartupRemainderMsecs", | |
2799 | time_store); | |
2800 | } | |
2801 | } else { | |
2802 | vty_out(vty, | |
2803 | " Originating stub / maximum-distance Router-LSA\n"); | |
2804 | if (CHECK_FLAG(area->stub_router_state, | |
2805 | OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2806 | vty_out(vty, | |
2807 | " Administratively activated (indefinitely)\n"); | |
2808 | if (area->t_stub_router) | |
2809 | vty_out(vty, | |
2810 | " Active from startup, %s remaining\n", | |
2811 | ospf_timer_dump(area->t_stub_router, | |
2812 | timebuf, | |
2813 | sizeof(timebuf))); | |
2814 | } | |
2815 | } | |
2816 | ||
2817 | if (use_json) { | |
2818 | /* Show number of fully adjacent neighbors. */ | |
2819 | json_object_int_add(json_area, "nbrFullAdjacentCounter", | |
2820 | area->full_nbrs); | |
2821 | ||
2822 | /* Show authentication type. */ | |
2823 | if (area->auth_type == OSPF_AUTH_NULL) | |
2824 | json_object_string_add(json_area, "authentication", | |
2825 | "authenticationNone"); | |
2826 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
2827 | json_object_string_add(json_area, "authentication", | |
2828 | "authenticationSimplePassword"); | |
2829 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
2830 | json_object_string_add(json_area, "authentication", | |
2831 | "authenticationMessageDigest"); | |
2832 | ||
2833 | if (!OSPF_IS_AREA_BACKBONE(area)) | |
2834 | json_object_int_add(json_area, | |
2835 | "virtualAdjacenciesPassingCounter", | |
2836 | area->full_vls); | |
2837 | ||
2838 | /* Show SPF calculation times. */ | |
2839 | json_object_int_add(json_area, "spfExecutedCounter", | |
2840 | area->spf_calculation); | |
2841 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); | |
2842 | json_object_int_add( | |
2843 | json_area, "lsaRouterNumber", | |
2844 | ospf_lsdb_count(area->lsdb, OSPF_ROUTER_LSA)); | |
2845 | json_object_int_add( | |
2846 | json_area, "lsaRouterChecksum", | |
2847 | ospf_lsdb_checksum(area->lsdb, OSPF_ROUTER_LSA)); | |
2848 | json_object_int_add( | |
2849 | json_area, "lsaNetworkNumber", | |
2850 | ospf_lsdb_count(area->lsdb, OSPF_NETWORK_LSA)); | |
2851 | json_object_int_add( | |
2852 | json_area, "lsaNetworkChecksum", | |
2853 | ospf_lsdb_checksum(area->lsdb, OSPF_NETWORK_LSA)); | |
2854 | json_object_int_add( | |
2855 | json_area, "lsaSummaryNumber", | |
2856 | ospf_lsdb_count(area->lsdb, OSPF_SUMMARY_LSA)); | |
2857 | json_object_int_add( | |
2858 | json_area, "lsaSummaryChecksum", | |
2859 | ospf_lsdb_checksum(area->lsdb, OSPF_SUMMARY_LSA)); | |
2860 | json_object_int_add( | |
2861 | json_area, "lsaAsbrNumber", | |
2862 | ospf_lsdb_count(area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2863 | json_object_int_add( | |
2864 | json_area, "lsaAsbrChecksum", | |
2865 | ospf_lsdb_checksum(area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2866 | json_object_int_add( | |
2867 | json_area, "lsaNssaNumber", | |
2868 | ospf_lsdb_count(area->lsdb, OSPF_AS_NSSA_LSA)); | |
2869 | json_object_int_add( | |
2870 | json_area, "lsaNssaChecksum", | |
2871 | ospf_lsdb_checksum(area->lsdb, OSPF_AS_NSSA_LSA)); | |
2872 | } else { | |
2873 | /* Show number of fully adjacent neighbors. */ | |
2874 | vty_out(vty, | |
2875 | " Number of fully adjacent neighbors in this area:" | |
2876 | " %d\n", | |
2877 | area->full_nbrs); | |
2878 | ||
2879 | /* Show authentication type. */ | |
2880 | vty_out(vty, " Area has "); | |
2881 | if (area->auth_type == OSPF_AUTH_NULL) | |
2882 | vty_out(vty, "no authentication\n"); | |
2883 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
2884 | vty_out(vty, "simple password authentication\n"); | |
2885 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
2886 | vty_out(vty, "message digest authentication\n"); | |
2887 | ||
2888 | if (!OSPF_IS_AREA_BACKBONE(area)) | |
2889 | vty_out(vty, | |
2890 | " Number of full virtual adjacencies going through" | |
2891 | " this area: %d\n", | |
2892 | area->full_vls); | |
2893 | ||
2894 | /* Show SPF calculation times. */ | |
2895 | vty_out(vty, " SPF algorithm executed %d times\n", | |
2896 | area->spf_calculation); | |
2897 | ||
2898 | /* Show number of LSA. */ | |
2899 | vty_out(vty, " Number of LSA %ld\n", area->lsdb->total); | |
2900 | vty_out(vty, | |
2901 | " Number of router LSA %ld. Checksum Sum 0x%08x\n", | |
2902 | ospf_lsdb_count(area->lsdb, OSPF_ROUTER_LSA), | |
2903 | ospf_lsdb_checksum(area->lsdb, OSPF_ROUTER_LSA)); | |
2904 | vty_out(vty, | |
2905 | " Number of network LSA %ld. Checksum Sum 0x%08x\n", | |
2906 | ospf_lsdb_count(area->lsdb, OSPF_NETWORK_LSA), | |
2907 | ospf_lsdb_checksum(area->lsdb, OSPF_NETWORK_LSA)); | |
2908 | vty_out(vty, | |
2909 | " Number of summary LSA %ld. Checksum Sum 0x%08x\n", | |
2910 | ospf_lsdb_count(area->lsdb, OSPF_SUMMARY_LSA), | |
2911 | ospf_lsdb_checksum(area->lsdb, OSPF_SUMMARY_LSA)); | |
2912 | vty_out(vty, | |
2913 | " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x\n", | |
2914 | ospf_lsdb_count(area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
2915 | ospf_lsdb_checksum(area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2916 | vty_out(vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x\n", | |
2917 | ospf_lsdb_count(area->lsdb, OSPF_AS_NSSA_LSA), | |
2918 | ospf_lsdb_checksum(area->lsdb, OSPF_AS_NSSA_LSA)); | |
2919 | } | |
2920 | ||
2921 | if (use_json) { | |
2922 | json_object_int_add( | |
2923 | json_area, "lsaOpaqueLinkNumber", | |
2924 | ospf_lsdb_count(area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2925 | json_object_int_add( | |
2926 | json_area, "lsaOpaqueLinkChecksum", | |
2927 | ospf_lsdb_checksum(area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2928 | json_object_int_add( | |
2929 | json_area, "lsaOpaqueAreaNumber", | |
2930 | ospf_lsdb_count(area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2931 | json_object_int_add( | |
2932 | json_area, "lsaOpaqueAreaChecksum", | |
2933 | ospf_lsdb_checksum(area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2934 | } else { | |
2935 | vty_out(vty, | |
2936 | " Number of opaque link LSA %ld. Checksum Sum 0x%08x\n", | |
2937 | ospf_lsdb_count(area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
2938 | ospf_lsdb_checksum(area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2939 | vty_out(vty, | |
2940 | " Number of opaque area LSA %ld. Checksum Sum 0x%08x\n", | |
2941 | ospf_lsdb_count(area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
2942 | ospf_lsdb_checksum(area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2943 | } | |
718e3744 | 2944 | |
d62a17ae | 2945 | if (use_json) |
2946 | json_object_object_add(json_areas, inet_ntoa(area->area_id), | |
2947 | json_area); | |
2948 | else | |
2949 | vty_out(vty, "\n"); | |
718e3744 | 2950 | } |
2951 | ||
d62a17ae | 2952 | static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf, |
b1c3ae8c | 2953 | json_object *json, u_char use_vrf) |
d62a17ae | 2954 | { |
2955 | struct listnode *node, *nnode; | |
2956 | struct ospf_area *area; | |
2957 | struct timeval result; | |
2958 | char timebuf[OSPF_TIME_DUMP_SIZE]; | |
b1c3ae8c | 2959 | json_object *json_vrf = NULL; |
d62a17ae | 2960 | json_object *json_areas = NULL; |
718e3744 | 2961 | |
b1c3ae8c CS |
2962 | if (json) { |
2963 | if (use_vrf) | |
2964 | json_vrf = json_object_new_object(); | |
2965 | else | |
2966 | json_vrf = json; | |
d62a17ae | 2967 | json_areas = json_object_new_object(); |
2968 | } | |
2969 | ||
2970 | if (ospf->instance) { | |
b1c3ae8c | 2971 | if (json) { |
d62a17ae | 2972 | json_object_int_add(json, "ospfInstance", |
2973 | ospf->instance); | |
2974 | } else { | |
2975 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
2976 | } | |
2977 | } | |
2978 | ||
b1c3ae8c | 2979 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
87bd50e8 | 2980 | |
d62a17ae | 2981 | /* Show Router ID. */ |
b1c3ae8c CS |
2982 | if (json) { |
2983 | json_object_string_add(json_vrf, "routerId", | |
d62a17ae | 2984 | inet_ntoa(ospf->router_id)); |
2985 | } else { | |
2986 | vty_out(vty, " OSPF Routing Process, Router ID: %s\n", | |
2987 | inet_ntoa(ospf->router_id)); | |
2988 | } | |
2989 | ||
2990 | /* Graceful shutdown */ | |
2991 | if (ospf->t_deferred_shutdown) { | |
b1c3ae8c | 2992 | if (json) { |
d62a17ae | 2993 | long time_store; |
2994 | time_store = | |
2995 | monotime_until( | |
2996 | &ospf->t_deferred_shutdown->u.sands, | |
2997 | NULL) | |
2998 | / 1000LL; | |
b1c3ae8c | 2999 | json_object_int_add(json_vrf, "deferredShutdownMsecs", |
d62a17ae | 3000 | time_store); |
3001 | } else { | |
3002 | vty_out(vty, | |
3003 | " Deferred shutdown in progress, %s remaining\n", | |
3004 | ospf_timer_dump(ospf->t_deferred_shutdown, | |
3005 | timebuf, sizeof(timebuf))); | |
3006 | } | |
3007 | } | |
3008 | ||
3009 | /* Show capability. */ | |
b1c3ae8c CS |
3010 | if (json) { |
3011 | json_object_boolean_true_add(json_vrf, "tosRoutesOnly"); | |
3012 | json_object_boolean_true_add(json_vrf, "rfc2328Conform"); | |
d62a17ae | 3013 | if (CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) { |
b1c3ae8c | 3014 | json_object_boolean_true_add(json_vrf, |
d62a17ae | 3015 | "rfc1583Compatibility"); |
3016 | } | |
3017 | } else { | |
3018 | vty_out(vty, " Supports only single TOS (TOS0) routes\n"); | |
3019 | vty_out(vty, " This implementation conforms to RFC2328\n"); | |
3020 | vty_out(vty, " RFC1583Compatibility flag is %s\n", | |
3021 | CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE) | |
3022 | ? "enabled" | |
3023 | : "disabled"); | |
3024 | } | |
3025 | ||
b1c3ae8c | 3026 | if (json) { |
d62a17ae | 3027 | if (CHECK_FLAG(ospf->config, OSPF_OPAQUE_CAPABLE)) { |
b1c3ae8c | 3028 | json_object_boolean_true_add(json_vrf, "opaqueCapable"); |
d62a17ae | 3029 | } |
3030 | } else { | |
3031 | vty_out(vty, " OpaqueCapability flag is %s\n", | |
3032 | CHECK_FLAG(ospf->config, OSPF_OPAQUE_CAPABLE) | |
3033 | ? "enabled" | |
3034 | : "disabled"); | |
3035 | } | |
3036 | ||
3037 | /* Show stub-router configuration */ | |
3038 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3039 | || ospf->stub_router_shutdown_time | |
3040 | != OSPF_STUB_ROUTER_UNCONFIGURED) { | |
b1c3ae8c CS |
3041 | if (json) { |
3042 | json_object_boolean_true_add(json_vrf, | |
3043 | "stubAdvertisement"); | |
d62a17ae | 3044 | if (ospf->stub_router_startup_time |
3045 | != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3046 | json_object_int_add( | |
b1c3ae8c | 3047 | json_vrf, "postStartEnabledMsecs", |
d62a17ae | 3048 | ospf->stub_router_startup_time / 1000); |
3049 | if (ospf->stub_router_shutdown_time | |
3050 | != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3051 | json_object_int_add( | |
b1c3ae8c | 3052 | json_vrf, "preShutdownEnabledMsecs", |
d62a17ae | 3053 | ospf->stub_router_shutdown_time / 1000); |
3054 | } else { | |
3055 | vty_out(vty, | |
3056 | " Stub router advertisement is configured\n"); | |
3057 | if (ospf->stub_router_startup_time | |
3058 | != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3059 | vty_out(vty, | |
3060 | " Enabled for %us after start-up\n", | |
3061 | ospf->stub_router_startup_time); | |
3062 | if (ospf->stub_router_shutdown_time | |
3063 | != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3064 | vty_out(vty, | |
3065 | " Enabled for %us prior to full shutdown\n", | |
3066 | ospf->stub_router_shutdown_time); | |
3067 | } | |
3068 | } | |
3069 | ||
3070 | /* Show SPF timers. */ | |
b1c3ae8c CS |
3071 | if (json) { |
3072 | json_object_int_add(json_vrf, "spfScheduleDelayMsecs", | |
d62a17ae | 3073 | ospf->spf_delay); |
b1c3ae8c | 3074 | json_object_int_add(json_vrf, "holdtimeMinMsecs", |
d62a17ae | 3075 | ospf->spf_holdtime); |
b1c3ae8c | 3076 | json_object_int_add(json_vrf, "holdtimeMaxMsecs", |
d62a17ae | 3077 | ospf->spf_max_holdtime); |
b1c3ae8c | 3078 | json_object_int_add(json_vrf, "holdtimeMultplier", |
d62a17ae | 3079 | ospf->spf_hold_multiplier); |
3080 | } else { | |
3081 | vty_out(vty, | |
3082 | " Initial SPF scheduling delay %d millisec(s)\n" | |
3083 | " Minimum hold time between consecutive SPFs %d millisec(s)\n" | |
3084 | " Maximum hold time between consecutive SPFs %d millisec(s)\n" | |
3085 | " Hold time multiplier is currently %d\n", | |
3086 | ospf->spf_delay, ospf->spf_holdtime, | |
3087 | ospf->spf_max_holdtime, ospf->spf_hold_multiplier); | |
3088 | } | |
3089 | ||
b1c3ae8c | 3090 | if (json) { |
d62a17ae | 3091 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) { |
3092 | long time_store = 0; | |
3093 | ||
3094 | time_store = | |
3095 | monotime_since(&ospf->ts_spf, NULL) / 1000LL; | |
b1c3ae8c | 3096 | json_object_int_add(json_vrf, "spfLastExecutedMsecs", |
d62a17ae | 3097 | time_store); |
3098 | ||
3099 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) | |
3100 | + (ospf->ts_spf_duration.tv_usec / 1000); | |
b1c3ae8c | 3101 | json_object_int_add(json_vrf, "spfLastDurationMsecs", |
d62a17ae | 3102 | time_store); |
3103 | } else | |
b1c3ae8c | 3104 | json_object_boolean_true_add(json_vrf, "spfHasNotRun"); |
d62a17ae | 3105 | } else { |
3106 | vty_out(vty, " SPF algorithm "); | |
3107 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) { | |
3108 | monotime_since(&ospf->ts_spf, &result); | |
3109 | vty_out(vty, "last executed %s ago\n", | |
3110 | ospf_timeval_dump(&result, timebuf, | |
3111 | sizeof(timebuf))); | |
3112 | vty_out(vty, " Last SPF duration %s\n", | |
3113 | ospf_timeval_dump(&ospf->ts_spf_duration, | |
3114 | timebuf, sizeof(timebuf))); | |
3115 | } else | |
3116 | vty_out(vty, "has not been run\n"); | |
3117 | } | |
3118 | ||
b1c3ae8c | 3119 | if (json) { |
d62a17ae | 3120 | if (ospf->t_spf_calc) { |
3121 | long time_store; | |
3122 | time_store = | |
3123 | monotime_until(&ospf->t_spf_calc->u.sands, NULL) | |
3124 | / 1000LL; | |
b1c3ae8c | 3125 | json_object_int_add(json_vrf, "spfTimerDueInMsecs", |
d62a17ae | 3126 | time_store); |
3127 | } | |
3128 | ||
b1c3ae8c | 3129 | json_object_int_add(json_vrf, "lsaMinIntervalMsecs", |
d62a17ae | 3130 | ospf->min_ls_interval); |
b1c3ae8c | 3131 | json_object_int_add(json_vrf, "lsaMinArrivalMsecs", |
d62a17ae | 3132 | ospf->min_ls_arrival); |
3133 | /* Show write multiplier values */ | |
b1c3ae8c | 3134 | json_object_int_add(json_vrf, "writeMultiplier", |
d62a17ae | 3135 | ospf->write_oi_count); |
3136 | /* Show refresh parameters. */ | |
b1c3ae8c | 3137 | json_object_int_add(json_vrf, "refreshTimerMsecs", |
d62a17ae | 3138 | ospf->lsa_refresh_interval * 1000); |
3139 | } else { | |
3140 | vty_out(vty, " SPF timer %s%s\n", | |
3141 | (ospf->t_spf_calc ? "due in " : "is "), | |
3142 | ospf_timer_dump(ospf->t_spf_calc, timebuf, | |
3143 | sizeof(timebuf))); | |
3144 | ||
3145 | vty_out(vty, " LSA minimum interval %d msecs\n", | |
3146 | ospf->min_ls_interval); | |
3147 | vty_out(vty, " LSA minimum arrival %d msecs\n", | |
3148 | ospf->min_ls_arrival); | |
3149 | ||
3150 | /* Show write multiplier values */ | |
3151 | vty_out(vty, " Write Multiplier set to %d \n", | |
3152 | ospf->write_oi_count); | |
3153 | ||
3154 | /* Show refresh parameters. */ | |
3155 | vty_out(vty, " Refresh timer %d secs\n", | |
3156 | ospf->lsa_refresh_interval); | |
3157 | } | |
3158 | ||
3159 | /* Show ABR/ASBR flags. */ | |
3160 | if (CHECK_FLAG(ospf->flags, OSPF_FLAG_ABR)) { | |
b1c3ae8c | 3161 | if (json) |
d62a17ae | 3162 | json_object_string_add( |
b1c3ae8c | 3163 | json_vrf, "abrType", |
d62a17ae | 3164 | ospf_abr_type_descr_str[ospf->abr_type]); |
3165 | else | |
3166 | vty_out(vty, | |
3167 | " This router is an ABR, ABR type is: %s\n", | |
3168 | ospf_abr_type_descr_str[ospf->abr_type]); | |
3169 | } | |
3170 | if (CHECK_FLAG(ospf->flags, OSPF_FLAG_ASBR)) { | |
b1c3ae8c | 3171 | if (json) |
d62a17ae | 3172 | json_object_string_add( |
b1c3ae8c | 3173 | json_vrf, "asbrRouter", |
d62a17ae | 3174 | "injectingExternalRoutingInformation"); |
3175 | else | |
3176 | vty_out(vty, | |
3177 | " This router is an ASBR " | |
3178 | "(injecting external routing information)\n"); | |
3179 | } | |
3180 | ||
3181 | /* Show Number of AS-external-LSAs. */ | |
b1c3ae8c | 3182 | if (json) { |
d62a17ae | 3183 | json_object_int_add( |
b1c3ae8c | 3184 | json_vrf, "lsaExternalCounter", |
d62a17ae | 3185 | ospf_lsdb_count(ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3186 | json_object_int_add( | |
b1c3ae8c | 3187 | json_vrf, "lsaExternalChecksum", |
d62a17ae | 3188 | ospf_lsdb_checksum(ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3189 | } else { | |
3190 | vty_out(vty, | |
3191 | " Number of external LSA %ld. Checksum Sum 0x%08x\n", | |
3192 | ospf_lsdb_count(ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
3193 | ospf_lsdb_checksum(ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3194 | } | |
3195 | ||
b1c3ae8c | 3196 | if (json) { |
d62a17ae | 3197 | json_object_int_add( |
b1c3ae8c | 3198 | json_vrf, "lsaAsopaqueCounter", |
d62a17ae | 3199 | ospf_lsdb_count(ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3200 | json_object_int_add( | |
b1c3ae8c | 3201 | json_vrf, "lsaAsOpaqueChecksum", |
d62a17ae | 3202 | ospf_lsdb_checksum(ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3203 | } else { | |
3204 | vty_out(vty, | |
3205 | " Number of opaque AS LSA %ld. Checksum Sum 0x%08x\n", | |
3206 | ospf_lsdb_count(ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
3207 | ospf_lsdb_checksum(ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3208 | } | |
3209 | ||
3210 | /* Show number of areas attached. */ | |
b1c3ae8c CS |
3211 | if (json) |
3212 | json_object_int_add(json_vrf, "attachedAreaCounter", | |
d62a17ae | 3213 | listcount(ospf->areas)); |
3214 | else | |
3215 | vty_out(vty, " Number of areas attached to this router: %d\n", | |
3216 | listcount(ospf->areas)); | |
3217 | ||
3218 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) { | |
3219 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) { | |
b1c3ae8c | 3220 | if (json) |
d62a17ae | 3221 | json_object_boolean_true_add( |
b1c3ae8c | 3222 | json_vrf, "adjacencyChangesLoggedAll"); |
d62a17ae | 3223 | else |
3224 | vty_out(vty, | |
3225 | " All adjacency changes are logged\n"); | |
3226 | } else { | |
b1c3ae8c | 3227 | if (json) |
d62a17ae | 3228 | json_object_boolean_true_add( |
b1c3ae8c | 3229 | json_vrf, "adjacencyChangesLogged"); |
d62a17ae | 3230 | else |
3231 | vty_out(vty, " Adjacency changes are logged\n"); | |
3232 | } | |
3233 | } | |
3234 | /* Show each area status. */ | |
3235 | for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) | |
b1c3ae8c CS |
3236 | show_ip_ospf_area(vty, area, json_areas, json ? 1 : 0); |
3237 | ||
3238 | if (json) { | |
3239 | if (use_vrf) { | |
3240 | json_object_object_add(json_vrf, "areas", json_areas); | |
3241 | if (ospf->vrf_id == VRF_DEFAULT) | |
3242 | json_object_object_add(json, "default", | |
3243 | json_vrf); | |
3244 | else | |
3245 | json_object_object_add(json, ospf->name, | |
3246 | json_vrf); | |
3247 | } else { | |
3248 | json_object_object_add(json, "areas", json_areas); | |
3249 | } | |
d62a17ae | 3250 | } else |
3251 | vty_out(vty, "\n"); | |
3252 | ||
3253 | return CMD_SUCCESS; | |
718e3744 | 3254 | } |
3255 | ||
7c8ff89e DS |
3256 | DEFUN (show_ip_ospf, |
3257 | show_ip_ospf_cmd, | |
b5a8894d | 3258 | "show ip ospf [vrf <NAME|all>] [json]", |
7c8ff89e DS |
3259 | SHOW_STR |
3260 | IP_STR | |
ca08c43d | 3261 | "OSPF information\n" |
b5a8894d CS |
3262 | VRF_CMD_HELP_STR |
3263 | "All VRFs\n" | |
9973d184 | 3264 | JSON_STR) |
7c8ff89e | 3265 | { |
d62a17ae | 3266 | struct ospf *ospf; |
3267 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
3268 | struct listnode *node = NULL; |
3269 | char *vrf_name = NULL; | |
3270 | bool all_vrf = FALSE; | |
3271 | int ret = CMD_SUCCESS; | |
3272 | int inst = 0; | |
3273 | int idx_vrf = 0; | |
b1c3ae8c CS |
3274 | json_object *json = NULL; |
3275 | u_char use_vrf = 0; | |
7c8ff89e | 3276 | |
b5a8894d | 3277 | if (listcount(om->ospf) == 0) |
d62a17ae | 3278 | return CMD_SUCCESS; |
7c8ff89e | 3279 | |
43b8d1d8 | 3280 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
b5a8894d | 3281 | |
b1c3ae8c CS |
3282 | if (uj) |
3283 | json = json_object_new_object(); | |
3284 | ||
996c9314 | 3285 | /* vrf input is provided could be all or specific vrf*/ |
b5a8894d | 3286 | if (vrf_name) { |
b1c3ae8c | 3287 | use_vrf = 1; |
b5a8894d CS |
3288 | if (all_vrf) { |
3289 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
3290 | if (!ospf->oi_running) | |
3291 | continue; | |
b1c3ae8c CS |
3292 | ret = show_ip_ospf_common(vty, ospf, json, |
3293 | use_vrf); | |
3294 | } | |
3295 | if (uj) { | |
3296 | vty_out(vty, "%s\n", | |
996c9314 LB |
3297 | json_object_to_json_string_ext( |
3298 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c | 3299 | json_object_free(json); |
b5a8894d CS |
3300 | } |
3301 | return ret; | |
3302 | } | |
3303 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
b1c3ae8c CS |
3304 | if ((ospf == NULL) || !ospf->oi_running) { |
3305 | if (uj) | |
3306 | json_object_free(json); | |
b5a8894d | 3307 | return CMD_SUCCESS; |
b1c3ae8c | 3308 | } |
b5a8894d CS |
3309 | } else { |
3310 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
3311 | /* Display default ospf (instance 0) info */ | |
b1c3ae8c CS |
3312 | if (ospf == NULL || !ospf->oi_running) { |
3313 | if (uj) | |
3314 | json_object_free(json); | |
b5a8894d | 3315 | return CMD_SUCCESS; |
b1c3ae8c | 3316 | } |
b5a8894d CS |
3317 | } |
3318 | ||
996c9314 | 3319 | if (ospf) { |
b1c3ae8c CS |
3320 | show_ip_ospf_common(vty, ospf, json, use_vrf); |
3321 | if (uj) | |
996c9314 LB |
3322 | vty_out(vty, "%s\n", |
3323 | json_object_to_json_string_ext( | |
3324 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
3325 | } |
3326 | ||
3327 | if (uj) | |
3328 | json_object_free(json); | |
b5a8894d CS |
3329 | |
3330 | return ret; | |
7c8ff89e DS |
3331 | } |
3332 | ||
3333 | DEFUN (show_ip_ospf_instance, | |
3334 | show_ip_ospf_instance_cmd, | |
6147e2c6 | 3335 | "show ip ospf (1-65535) [json]", |
7c8ff89e DS |
3336 | SHOW_STR |
3337 | IP_STR | |
3338 | "OSPF information\n" | |
ca08c43d | 3339 | "Instance ID\n" |
9973d184 | 3340 | JSON_STR) |
7c8ff89e | 3341 | { |
d62a17ae | 3342 | int idx_number = 3; |
3343 | struct ospf *ospf; | |
3344 | u_short instance = 0; | |
3345 | u_char uj = use_json(argc, argv); | |
b1c3ae8c CS |
3346 | int ret = CMD_SUCCESS; |
3347 | json_object *json = NULL; | |
d62a17ae | 3348 | |
3349 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
ac28e4ec CS |
3350 | ospf = ospf_lookup_instance(instance); |
3351 | if (ospf == NULL) | |
3352 | return CMD_NOT_MY_INSTANCE; | |
3353 | ||
3354 | if (!ospf->oi_running) | |
d62a17ae | 3355 | return CMD_SUCCESS; |
3356 | ||
b1c3ae8c CS |
3357 | if (uj) |
3358 | json = json_object_new_object(); | |
3359 | ||
3360 | ret = show_ip_ospf_common(vty, ospf, json, 0); | |
3361 | ||
3362 | if (uj) { | |
996c9314 LB |
3363 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
3364 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
3365 | json_object_free(json); |
3366 | } | |
3367 | ||
3368 | return ret; | |
d62a17ae | 3369 | } |
3370 | ||
3371 | static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf, | |
3372 | struct interface *ifp, | |
3373 | json_object *json_interface_sub, | |
3374 | u_char use_json) | |
3375 | { | |
3376 | int is_up; | |
3377 | struct ospf_neighbor *nbr; | |
3378 | struct route_node *rn; | |
3379 | uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed; | |
3380 | ||
3381 | /* Is interface up? */ | |
3382 | if (use_json) { | |
3383 | is_up = if_is_operative(ifp); | |
3384 | if (is_up) | |
3385 | json_object_boolean_true_add(json_interface_sub, | |
3386 | "ifUp"); | |
3387 | else | |
3388 | json_object_boolean_false_add(json_interface_sub, | |
3389 | "ifDown"); | |
3390 | ||
3391 | json_object_int_add(json_interface_sub, "ifIndex", | |
3392 | ifp->ifindex); | |
3393 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
3394 | json_object_int_add(json_interface_sub, "bandwidthMbit", | |
3395 | bandwidth); | |
3396 | json_object_string_add(json_interface_sub, "ifFlags", | |
3397 | if_flag_dump(ifp->flags)); | |
3398 | } else { | |
3399 | vty_out(vty, "%s is %s\n", ifp->name, | |
3400 | ((is_up = if_is_operative(ifp)) ? "up" : "down")); | |
3401 | vty_out(vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s\n", | |
3402 | ifp->ifindex, ifp->mtu, bandwidth, | |
3403 | if_flag_dump(ifp->flags)); | |
3404 | } | |
7c8ff89e | 3405 | |
d62a17ae | 3406 | /* Is interface OSPF enabled? */ |
3407 | if (use_json) { | |
3408 | if (ospf_oi_count(ifp) == 0) { | |
3409 | json_object_boolean_false_add(json_interface_sub, | |
3410 | "ospfEnabled"); | |
3411 | return; | |
3412 | } else if (!is_up) { | |
3413 | json_object_boolean_false_add(json_interface_sub, | |
3414 | "ospfRunning"); | |
3415 | return; | |
3416 | } else | |
3417 | json_object_boolean_true_add(json_interface_sub, | |
3418 | "ospfEnabled"); | |
3419 | } else { | |
3420 | if (ospf_oi_count(ifp) == 0) { | |
3421 | vty_out(vty, " OSPF not enabled on this interface\n"); | |
3422 | return; | |
3423 | } else if (!is_up) { | |
3424 | vty_out(vty, | |
3425 | " OSPF is enabled, but not running on this interface\n"); | |
3426 | return; | |
3427 | } | |
3428 | } | |
3429 | ||
3430 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
3431 | struct ospf_interface *oi = rn->info; | |
3432 | ||
3433 | if (oi == NULL) | |
3434 | continue; | |
3435 | ||
3436 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) { | |
3437 | if (use_json) | |
3438 | json_object_boolean_true_add(json_interface_sub, | |
3439 | "ifUnnumbered"); | |
3440 | else | |
3441 | vty_out(vty, " This interface is UNNUMBERED,"); | |
3442 | } else { | |
3443 | /* Show OSPF interface information. */ | |
3444 | if (use_json) { | |
3445 | json_object_string_add( | |
3446 | json_interface_sub, "ipAddress", | |
3447 | inet_ntoa(oi->address->u.prefix4)); | |
3448 | json_object_int_add(json_interface_sub, | |
3449 | "ipAddressPrefixlen", | |
3450 | oi->address->prefixlen); | |
3451 | } else | |
3452 | vty_out(vty, " Internet Address %s/%d,", | |
3453 | inet_ntoa(oi->address->u.prefix4), | |
3454 | oi->address->prefixlen); | |
3455 | ||
3456 | if (oi->connected->destination | |
3457 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) { | |
3458 | struct in_addr *dest; | |
3459 | const char *dstr; | |
3460 | ||
3461 | if (CONNECTED_PEER(oi->connected) | |
3462 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3463 | dstr = "Peer"; | |
3464 | else | |
3465 | dstr = "Broadcast"; | |
3466 | ||
3467 | /* For Vlinks, showing the peer address is | |
9d303b37 DL |
3468 | * probably more |
3469 | * * * * * informative than the local | |
3470 | * interface that is being used | |
3471 | * * * * */ | |
d62a17ae | 3472 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3473 | dest = &oi->vl_data->peer_addr; | |
3474 | else | |
3475 | dest = &oi->connected->destination->u | |
3476 | .prefix4; | |
3477 | ||
3478 | if (use_json) { | |
3479 | json_object_string_add( | |
3480 | json_interface_sub, | |
3481 | "ospfIfType", dstr); | |
3482 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3483 | json_object_string_add( | |
3484 | json_interface_sub, | |
3485 | "vlinkPeer", | |
3486 | inet_ntoa(*dest)); | |
3487 | else | |
3488 | json_object_string_add( | |
3489 | json_interface_sub, | |
3490 | "localIfUsed", | |
3491 | inet_ntoa(*dest)); | |
3492 | } else | |
3493 | vty_out(vty, " %s %s,", dstr, | |
3494 | inet_ntoa(*dest)); | |
3495 | } | |
3496 | } | |
3497 | if (use_json) { | |
3498 | json_object_string_add(json_interface_sub, "area", | |
3499 | ospf_area_desc_string(oi->area)); | |
3500 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3501 | json_object_boolean_true_add( | |
3502 | json_interface_sub, | |
3503 | "mtuMismatchDetect"); | |
3504 | json_object_string_add(json_interface_sub, "routerId", | |
3505 | inet_ntoa(ospf->router_id)); | |
3506 | json_object_string_add(json_interface_sub, | |
3507 | "networkType", | |
3508 | ospf_network_type_str[oi->type]); | |
3509 | json_object_int_add(json_interface_sub, "cost", | |
3510 | oi->output_cost); | |
3511 | json_object_int_add( | |
3512 | json_interface_sub, "transmitDelayMsecs", | |
3513 | 1000 / OSPF_IF_PARAM(oi, transmit_delay)); | |
3514 | json_object_string_add(json_interface_sub, "state", | |
3515 | lookup_msg(ospf_ism_state_msg, | |
3516 | oi->state, NULL)); | |
3517 | json_object_int_add(json_interface_sub, "priority", | |
3518 | PRIORITY(oi)); | |
3519 | } else { | |
3520 | vty_out(vty, " Area %s\n", | |
3521 | ospf_area_desc_string(oi->area)); | |
3522 | ||
3523 | vty_out(vty, " MTU mismatch detection: %s\n", | |
3524 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" | |
3525 | : "enabled"); | |
3526 | ||
3527 | vty_out(vty, | |
3528 | " Router ID %s, Network Type %s, Cost: %d\n", | |
3529 | inet_ntoa(ospf->router_id), | |
3530 | ospf_network_type_str[oi->type], | |
3531 | oi->output_cost); | |
3532 | ||
3533 | vty_out(vty, | |
3534 | " Transmit Delay is %d sec, State %s, Priority %d\n", | |
3535 | OSPF_IF_PARAM(oi, transmit_delay), | |
3536 | lookup_msg(ospf_ism_state_msg, oi->state, NULL), | |
3537 | PRIORITY(oi)); | |
3538 | } | |
3539 | ||
3540 | /* Show DR information. */ | |
3541 | if (DR(oi).s_addr == 0) { | |
3542 | if (!use_json) | |
3543 | vty_out(vty, | |
3544 | " No backup designated router on this network\n"); | |
3545 | } else { | |
3546 | nbr = ospf_nbr_lookup_by_addr(oi->nbrs, &BDR(oi)); | |
3547 | if (nbr == NULL) { | |
3548 | if (!use_json) | |
3549 | vty_out(vty, | |
3550 | " No backup designated router on this network\n"); | |
3551 | } else { | |
3552 | if (use_json) { | |
3553 | json_object_string_add( | |
3554 | json_interface_sub, "bdrId", | |
3555 | inet_ntoa(nbr->router_id)); | |
3556 | json_object_string_add( | |
3557 | json_interface_sub, | |
3558 | "bdrAddress", | |
3559 | inet_ntoa(nbr->address.u | |
3560 | .prefix4)); | |
3561 | } else { | |
3562 | vty_out(vty, | |
3563 | " Backup Designated Router (ID) %s,", | |
3564 | inet_ntoa(nbr->router_id)); | |
3565 | vty_out(vty, " Interface Address %s\n", | |
3566 | inet_ntoa(nbr->address.u | |
3567 | .prefix4)); | |
3568 | } | |
3569 | } | |
3570 | } | |
3571 | ||
3572 | /* Next network-LSA sequence number we'll use, if we're elected | |
3573 | * DR */ | |
3574 | if (oi->params | |
3575 | && ntohl(oi->params->network_lsa_seqnum) | |
3576 | != OSPF_INITIAL_SEQUENCE_NUMBER) { | |
3577 | if (use_json) | |
3578 | json_object_int_add( | |
3579 | json_interface_sub, | |
3580 | "networkLsaSequence", | |
3581 | ntohl(oi->params->network_lsa_seqnum)); | |
3582 | else | |
3583 | vty_out(vty, | |
3584 | " Saved Network-LSA sequence number 0x%x\n", | |
3585 | ntohl(oi->params->network_lsa_seqnum)); | |
3586 | } | |
3587 | ||
3588 | if (use_json) { | |
3589 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3590 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) { | |
3591 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3592 | json_object_boolean_true_add( | |
3593 | json_interface_sub, | |
3594 | "mcastMemberOspfAllRouters"); | |
3595 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3596 | json_object_boolean_true_add( | |
3597 | json_interface_sub, | |
3598 | "mcastMemberOspfDesignatedRouters"); | |
3599 | } | |
3600 | } else { | |
3601 | vty_out(vty, " Multicast group memberships:"); | |
3602 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3603 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) { | |
3604 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3605 | vty_out(vty, " OSPFAllRouters"); | |
3606 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3607 | vty_out(vty, " OSPFDesignatedRouters"); | |
3608 | } else | |
3609 | vty_out(vty, " <None>"); | |
3610 | vty_out(vty, "\n"); | |
3611 | } | |
3612 | ||
3613 | if (use_json) { | |
3614 | if (OSPF_IF_PARAM(oi, fast_hello) == 0) | |
3615 | json_object_int_add( | |
3616 | json_interface_sub, "timerMsecs", | |
3617 | 1000 / OSPF_IF_PARAM(oi, v_hello)); | |
3618 | else | |
3619 | json_object_int_add( | |
3620 | json_interface_sub, "timerMsecs", | |
3621 | 1000 / OSPF_IF_PARAM(oi, fast_hello)); | |
3622 | json_object_int_add(json_interface_sub, | |
3623 | "timerDeadMsecs", | |
3624 | 1000 / OSPF_IF_PARAM(oi, v_wait)); | |
3625 | json_object_int_add(json_interface_sub, | |
3626 | "timerWaitMsecs", | |
3627 | 1000 / OSPF_IF_PARAM(oi, v_wait)); | |
3628 | json_object_int_add( | |
3629 | json_interface_sub, "timerRetransmit", | |
3630 | 1000 / OSPF_IF_PARAM(oi, retransmit_interval)); | |
3631 | } else { | |
3632 | vty_out(vty, " Timer intervals configured,"); | |
3633 | vty_out(vty, " Hello "); | |
3634 | if (OSPF_IF_PARAM(oi, fast_hello) == 0) | |
3635 | vty_out(vty, "%ds,", | |
3636 | OSPF_IF_PARAM(oi, v_hello)); | |
3637 | else | |
3638 | vty_out(vty, "%dms,", | |
3639 | 1000 / OSPF_IF_PARAM(oi, fast_hello)); | |
3640 | vty_out(vty, " Dead %ds, Wait %ds, Retransmit %d\n", | |
3641 | OSPF_IF_PARAM(oi, v_wait), | |
3642 | OSPF_IF_PARAM(oi, v_wait), | |
3643 | OSPF_IF_PARAM(oi, retransmit_interval)); | |
3644 | } | |
3645 | ||
3646 | if (OSPF_IF_PASSIVE_STATUS(oi) == OSPF_IF_ACTIVE) { | |
3647 | char timebuf[OSPF_TIME_DUMP_SIZE]; | |
3648 | if (use_json) { | |
3649 | long time_store = 0; | |
3650 | if (oi->t_hello) | |
3651 | time_store = | |
3652 | monotime_until( | |
3653 | &oi->t_hello->u.sands, | |
3654 | NULL) | |
3655 | / 1000LL; | |
3656 | json_object_int_add(json_interface_sub, | |
3657 | "timerHelloInMsecs", | |
3658 | time_store); | |
3659 | } else | |
3660 | vty_out(vty, " Hello due in %s\n", | |
3661 | ospf_timer_dump(oi->t_hello, timebuf, | |
3662 | sizeof(timebuf))); | |
3663 | } else /* passive-interface is set */ | |
3664 | { | |
3665 | if (use_json) | |
3666 | json_object_boolean_true_add( | |
3667 | json_interface_sub, | |
3668 | "timerPassiveIface"); | |
3669 | else | |
3670 | vty_out(vty, | |
3671 | " No Hellos (Passive interface)\n"); | |
3672 | } | |
7c8ff89e | 3673 | |
d62a17ae | 3674 | if (use_json) { |
3675 | json_object_int_add(json_interface_sub, "nbrCount", | |
3676 | ospf_nbr_count(oi, 0)); | |
3677 | json_object_int_add(json_interface_sub, | |
3678 | "nbrAdjacentCount", | |
3679 | ospf_nbr_count(oi, NSM_Full)); | |
3680 | } else | |
3681 | vty_out(vty, | |
3682 | " Neighbor Count is %d, Adjacent neighbor count is %d\n", | |
3683 | ospf_nbr_count(oi, 0), | |
3684 | ospf_nbr_count(oi, NSM_Full)); | |
3685 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); | |
3686 | } | |
718e3744 | 3687 | } |
3688 | ||
d62a17ae | 3689 | static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, |
b1c3ae8c CS |
3690 | char *intf_name, u_char use_vrf, |
3691 | json_object *json, u_char use_json) | |
d62a17ae | 3692 | { |
3693 | struct interface *ifp; | |
f4e14fdb | 3694 | struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); |
6282e124 | 3695 | json_object *json_vrf = NULL; |
7dab10ce | 3696 | json_object *json_interface_sub = NULL, *json_interface = NULL; |
7c8ff89e | 3697 | |
d62a17ae | 3698 | if (use_json) { |
b1c3ae8c CS |
3699 | if (use_vrf) |
3700 | json_vrf = json_object_new_object(); | |
3701 | else | |
3702 | json_vrf = json; | |
6282e124 | 3703 | json_interface = json_object_new_object(); |
d62a17ae | 3704 | } |
3705 | ||
3706 | if (ospf->instance) { | |
3707 | if (use_json) | |
3708 | json_object_int_add(json, "ospfInstance", | |
3709 | ospf->instance); | |
3710 | else | |
3711 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
3712 | } | |
3713 | ||
b1c3ae8c CS |
3714 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
3715 | ||
3716 | if (intf_name == NULL) { | |
d62a17ae | 3717 | /* Show All Interfaces.*/ |
451fda4f | 3718 | FOR_ALL_INTERFACES (vrf, ifp) { |
d62a17ae | 3719 | if (ospf_oi_count(ifp)) { |
7dab10ce | 3720 | if (use_json) { |
d62a17ae | 3721 | json_interface_sub = |
3722 | json_object_new_object(); | |
7dab10ce | 3723 | } |
d62a17ae | 3724 | show_ip_ospf_interface_sub(vty, ospf, ifp, |
3725 | json_interface_sub, | |
3726 | use_json); | |
3727 | ||
7dab10ce | 3728 | if (use_json) { |
d62a17ae | 3729 | json_object_object_add( |
7dab10ce | 3730 | json_interface, ifp->name, |
d62a17ae | 3731 | json_interface_sub); |
7dab10ce | 3732 | } |
d62a17ae | 3733 | } |
3734 | } | |
6282e124 CS |
3735 | if (use_json) |
3736 | json_object_object_add(json_vrf, "interfaces", | |
996c9314 | 3737 | json_interface); |
d62a17ae | 3738 | } else { |
3739 | /* Interface name is specified. */ | |
b1c3ae8c CS |
3740 | ifp = if_lookup_by_name(intf_name, ospf->vrf_id); |
3741 | if (ifp == NULL) { | |
d62a17ae | 3742 | if (use_json) |
b1c3ae8c | 3743 | json_object_boolean_true_add(json_vrf, |
d62a17ae | 3744 | "noSuchIface"); |
3745 | else | |
3746 | vty_out(vty, "No such interface name\n"); | |
3747 | } else { | |
7dab10ce | 3748 | if (use_json) { |
d62a17ae | 3749 | json_interface_sub = json_object_new_object(); |
7dab10ce | 3750 | json_interface = json_object_new_object(); |
7dab10ce | 3751 | } |
d62a17ae | 3752 | |
3753 | show_ip_ospf_interface_sub( | |
3754 | vty, ospf, ifp, json_interface_sub, use_json); | |
3755 | ||
7dab10ce | 3756 | if (use_json) { |
7dab10ce CS |
3757 | json_object_object_add(json_interface, |
3758 | ifp->name, | |
d62a17ae | 3759 | json_interface_sub); |
6282e124 CS |
3760 | json_object_object_add(json_vrf, "interfaces", |
3761 | json_interface); | |
7dab10ce | 3762 | } |
d62a17ae | 3763 | } |
3764 | } | |
3765 | ||
3766 | if (use_json) { | |
b1c3ae8c CS |
3767 | if (use_vrf) { |
3768 | if (ospf->vrf_id == VRF_DEFAULT) | |
3769 | json_object_object_add(json, "default", | |
3770 | json_vrf); | |
3771 | else | |
3772 | json_object_object_add(json, ospf->name, | |
3773 | json_vrf); | |
3774 | } | |
d62a17ae | 3775 | } else |
3776 | vty_out(vty, "\n"); | |
3777 | ||
3778 | return CMD_SUCCESS; | |
718e3744 | 3779 | } |
3780 | ||
c9339663 CS |
3781 | static void show_ip_ospf_interface_traffic_sub(struct vty *vty, |
3782 | struct ospf_interface *oi, | |
3783 | json_object *json_interface_sub, | |
3784 | u_char use_json) | |
3785 | { | |
3786 | if (use_json) { | |
996c9314 LB |
3787 | json_object_int_add(json_interface_sub, "ifIndex", |
3788 | oi->ifp->ifindex); | |
3789 | json_object_int_add(json_interface_sub, "helloIn", | |
3790 | oi->hello_in); | |
3791 | json_object_int_add(json_interface_sub, "helloOut", | |
3792 | oi->hello_out); | |
3793 | json_object_int_add(json_interface_sub, "dbDescIn", | |
3794 | oi->db_desc_in); | |
3795 | json_object_int_add(json_interface_sub, "dbDescOut", | |
3796 | oi->db_desc_out); | |
3797 | json_object_int_add(json_interface_sub, "lsReqIn", | |
3798 | oi->ls_req_in); | |
3799 | json_object_int_add(json_interface_sub, "lsReqOut", | |
3800 | oi->ls_req_out); | |
3801 | json_object_int_add(json_interface_sub, "lsUpdIn", | |
3802 | oi->ls_upd_in); | |
3803 | json_object_int_add(json_interface_sub, "lsUpdOut", | |
3804 | oi->ls_upd_out); | |
3805 | json_object_int_add(json_interface_sub, "lsAckIn", | |
3806 | oi->ls_ack_in); | |
3807 | json_object_int_add(json_interface_sub, "lsAckOut", | |
3808 | oi->ls_ack_out); | |
c9339663 CS |
3809 | } else { |
3810 | vty_out(vty, | |
3811 | "%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n", | |
996c9314 LB |
3812 | oi->ifp->name, oi->hello_in, oi->hello_out, |
3813 | oi->db_desc_in, oi->db_desc_out, oi->ls_req_in, | |
3814 | oi->ls_req_out, oi->ls_upd_in, oi->ls_upd_out, | |
c9339663 CS |
3815 | oi->ls_ack_in, oi->ls_ack_out); |
3816 | } | |
3817 | } | |
3818 | ||
3819 | /* OSPFv2 Packet Counters */ | |
996c9314 LB |
3820 | static int show_ip_ospf_interface_traffic_common( |
3821 | struct vty *vty, struct ospf *ospf, char *intf_name, json_object *json, | |
3822 | int display_once, u_char use_vrf, u_char use_json) | |
c9339663 CS |
3823 | { |
3824 | struct vrf *vrf = NULL; | |
3825 | struct interface *ifp = NULL; | |
b1c3ae8c | 3826 | json_object *json_vrf = NULL; |
c9339663 CS |
3827 | json_object *json_interface_sub = NULL; |
3828 | ||
3829 | if (!use_json && !display_once) { | |
3830 | vty_out(vty, "\n"); | |
996c9314 LB |
3831 | vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface", |
3832 | " HELLO", " DB-Desc", " LS-Req", " LS-Update", | |
3833 | " LS-Ack"); | |
c9339663 | 3834 | vty_out(vty, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "", |
996c9314 LB |
3835 | " Rx/Tx", " Rx/Tx", " Rx/Tx", " Rx/Tx", |
3836 | " Rx/Tx"); | |
c9339663 | 3837 | vty_out(vty, |
996c9314 | 3838 | "--------------------------------------------------------------------------------------------\n"); |
c9339663 | 3839 | } else if (use_json) { |
b1c3ae8c CS |
3840 | if (use_vrf) |
3841 | json_vrf = json_object_new_object(); | |
3842 | else | |
3843 | json_vrf = json; | |
c9339663 CS |
3844 | } |
3845 | ||
b1c3ae8c CS |
3846 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
3847 | ||
c9339663 CS |
3848 | if (intf_name == NULL) { |
3849 | vrf = vrf_lookup_by_id(ospf->vrf_id); | |
3850 | FOR_ALL_INTERFACES (vrf, ifp) { | |
3851 | struct route_node *rn; | |
3852 | struct ospf_interface *oi; | |
3853 | ||
3854 | if (ospf_oi_count(ifp) == 0) | |
3855 | continue; | |
3856 | ||
3857 | for (rn = route_top(IF_OIFS(ifp)); rn; | |
996c9314 | 3858 | rn = route_next(rn)) { |
c9339663 CS |
3859 | oi = rn->info; |
3860 | ||
3861 | if (oi == NULL) | |
3862 | continue; | |
3863 | ||
3864 | if (use_json) { | |
3865 | json_interface_sub = | |
3866 | json_object_new_object(); | |
3867 | } | |
3868 | ||
996c9314 LB |
3869 | show_ip_ospf_interface_traffic_sub( |
3870 | vty, oi, json_interface_sub, use_json); | |
c9339663 | 3871 | if (use_json) { |
996c9314 LB |
3872 | json_object_object_add( |
3873 | json_vrf, ifp->name, | |
3874 | json_interface_sub); | |
c9339663 CS |
3875 | } |
3876 | } | |
3877 | } | |
3878 | } else { | |
3879 | /* Interface name is specified. */ | |
3880 | ifp = if_lookup_by_name(intf_name, ospf->vrf_id); | |
3881 | if (ifp != NULL) { | |
3882 | struct route_node *rn; | |
3883 | struct ospf_interface *oi; | |
3884 | ||
3885 | if (ospf_oi_count(ifp) == 0) { | |
996c9314 LB |
3886 | vty_out(vty, |
3887 | " OSPF not enabled on this interface %s\n", | |
c9339663 CS |
3888 | ifp->name); |
3889 | return CMD_SUCCESS; | |
3890 | } | |
3891 | ||
3892 | for (rn = route_top(IF_OIFS(ifp)); rn; | |
3893 | rn = route_next(rn)) { | |
3894 | oi = rn->info; | |
3895 | ||
3896 | if (use_json) { | |
3897 | json_interface_sub = | |
3898 | json_object_new_object(); | |
3899 | } | |
3900 | ||
996c9314 LB |
3901 | show_ip_ospf_interface_traffic_sub( |
3902 | vty, oi, json_interface_sub, use_json); | |
c9339663 | 3903 | if (use_json) { |
996c9314 LB |
3904 | json_object_object_add( |
3905 | json_vrf, ifp->name, | |
3906 | json_interface_sub); | |
c9339663 CS |
3907 | } |
3908 | } | |
3909 | } | |
3910 | } | |
3911 | ||
3912 | if (use_json) { | |
b1c3ae8c CS |
3913 | if (use_vrf) { |
3914 | if (ospf->vrf_id == VRF_DEFAULT) | |
3915 | json_object_object_add(json, "default", | |
3916 | json_vrf); | |
3917 | else | |
3918 | json_object_object_add(json, ospf->name, | |
3919 | json_vrf); | |
3920 | } | |
3921 | } else | |
3922 | vty_out(vty, "\n"); | |
c9339663 CS |
3923 | |
3924 | return CMD_SUCCESS; | |
3925 | } | |
3926 | ||
7c8ff89e DS |
3927 | DEFUN (show_ip_ospf_interface, |
3928 | show_ip_ospf_interface_cmd, | |
43b8d1d8 | 3929 | "show ip ospf [vrf <NAME|all>] interface [INTERFACE] [json]", |
7c8ff89e DS |
3930 | SHOW_STR |
3931 | IP_STR | |
3932 | "OSPF information\n" | |
b5a8894d | 3933 | VRF_CMD_HELP_STR |
43b8d1d8 | 3934 | "All VRFs\n" |
7c8ff89e | 3935 | "Interface information\n" |
7ec4159b | 3936 | "Interface name\n" |
9973d184 | 3937 | JSON_STR) |
7c8ff89e | 3938 | { |
d62a17ae | 3939 | struct ospf *ospf; |
3940 | u_char uj = use_json(argc, argv); | |
b5a8894d | 3941 | struct listnode *node = NULL; |
b1c3ae8c | 3942 | char *vrf_name = NULL, *intf_name = NULL; |
b5a8894d CS |
3943 | bool all_vrf = FALSE; |
3944 | int ret = CMD_SUCCESS; | |
3945 | int inst = 0; | |
b1c3ae8c CS |
3946 | int idx_vrf = 0, idx_intf = 0; |
3947 | u_char use_vrf = 0; | |
3948 | json_object *json = NULL; | |
7c8ff89e | 3949 | |
43b8d1d8 CS |
3950 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
3951 | ||
b1c3ae8c CS |
3952 | if (argv_find(argv, argc, "INTERFACE", &idx_intf)) |
3953 | intf_name = argv[idx_intf]->arg; | |
3954 | ||
d62a17ae | 3955 | if (uj) |
b1c3ae8c | 3956 | json = json_object_new_object(); |
6be4da3d | 3957 | |
b5a8894d CS |
3958 | /* vrf input is provided could be all or specific vrf*/ |
3959 | if (vrf_name) { | |
b1c3ae8c | 3960 | use_vrf = 1; |
b5a8894d CS |
3961 | if (all_vrf) { |
3962 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
3963 | if (!ospf->oi_running) | |
3964 | continue; | |
996c9314 LB |
3965 | ret = show_ip_ospf_interface_common( |
3966 | vty, ospf, intf_name, use_vrf, json, | |
3967 | uj); | |
b5a8894d | 3968 | } |
b1c3ae8c CS |
3969 | |
3970 | if (uj) { | |
3971 | vty_out(vty, "%s\n", | |
996c9314 LB |
3972 | json_object_to_json_string_ext( |
3973 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
3974 | json_object_free(json); |
3975 | } | |
3976 | ||
b5a8894d CS |
3977 | return ret; |
3978 | } | |
3979 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
b1c3ae8c CS |
3980 | if (ospf == NULL || !ospf->oi_running) { |
3981 | if (uj) | |
3982 | json_object_free(json); | |
b5a8894d | 3983 | return CMD_SUCCESS; |
b1c3ae8c CS |
3984 | } |
3985 | ret = show_ip_ospf_interface_common(vty, ospf, intf_name, | |
3986 | use_vrf, json, uj); | |
b5a8894d CS |
3987 | |
3988 | } else { | |
3989 | /* Display default ospf (instance 0) info */ | |
3990 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
b1c3ae8c CS |
3991 | if (ospf == NULL || !ospf->oi_running) { |
3992 | if (uj) | |
3993 | json_object_free(json); | |
b5a8894d | 3994 | return CMD_SUCCESS; |
b1c3ae8c CS |
3995 | } |
3996 | ret = show_ip_ospf_interface_common(vty, ospf, intf_name, | |
3997 | use_vrf, json, uj); | |
3998 | } | |
3999 | ||
4000 | if (uj) { | |
996c9314 LB |
4001 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
4002 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c | 4003 | json_object_free(json); |
b5a8894d CS |
4004 | } |
4005 | ||
4006 | return ret; | |
7c8ff89e DS |
4007 | } |
4008 | ||
4009 | DEFUN (show_ip_ospf_instance_interface, | |
4010 | show_ip_ospf_instance_interface_cmd, | |
6147e2c6 | 4011 | "show ip ospf (1-65535) interface [INTERFACE] [json]", |
7c8ff89e DS |
4012 | SHOW_STR |
4013 | IP_STR | |
4014 | "OSPF information\n" | |
4015 | "Instance ID\n" | |
4016 | "Interface information\n" | |
7ec4159b | 4017 | "Interface name\n" |
9973d184 | 4018 | JSON_STR) |
7c8ff89e | 4019 | { |
d62a17ae | 4020 | int idx_number = 3; |
b1c3ae8c | 4021 | int idx_intf = 0; |
d62a17ae | 4022 | struct ospf *ospf; |
4023 | u_short instance = 0; | |
4024 | u_char uj = use_json(argc, argv); | |
b1c3ae8c CS |
4025 | char *intf_name = NULL; |
4026 | int ret = CMD_SUCCESS; | |
4027 | json_object *json = NULL; | |
d62a17ae | 4028 | |
4029 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
ac28e4ec CS |
4030 | ospf = ospf_lookup_instance(instance); |
4031 | if (ospf == NULL) | |
4032 | return CMD_NOT_MY_INSTANCE; | |
4033 | ||
4034 | if (!ospf->oi_running) | |
d62a17ae | 4035 | return CMD_SUCCESS; |
4036 | ||
4037 | if (uj) | |
b1c3ae8c CS |
4038 | json = json_object_new_object(); |
4039 | ||
4040 | if (argv_find(argv, argc, "INTERFACE", &idx_intf)) | |
4041 | intf_name = argv[idx_intf]->arg; | |
4042 | ||
4043 | ret = show_ip_ospf_interface_common(vty, ospf, intf_name, 0, json, uj); | |
4044 | ||
4045 | if (uj) { | |
996c9314 LB |
4046 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
4047 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
4048 | json_object_free(json); |
4049 | } | |
d62a17ae | 4050 | |
b1c3ae8c | 4051 | return ret; |
d62a17ae | 4052 | } |
4053 | ||
c9339663 CS |
4054 | DEFUN (show_ip_ospf_interface_traffic, |
4055 | show_ip_ospf_interface_traffic_cmd, | |
4056 | "show ip ospf [vrf <NAME|all>] interface traffic [INTERFACE] [json]", | |
4057 | SHOW_STR | |
4058 | IP_STR | |
4059 | "OSPF information\n" | |
4060 | VRF_CMD_HELP_STR | |
4061 | "All VRFs\n" | |
4062 | "Interface information\n" | |
4063 | "Protocol Packet counters\n" | |
4064 | "Interface name\n" | |
4065 | JSON_STR) | |
4066 | { | |
4067 | struct ospf *ospf = NULL; | |
4068 | struct listnode *node = NULL; | |
4069 | char *vrf_name = NULL, *intf_name = NULL; | |
4070 | bool all_vrf = FALSE; | |
4071 | int inst = 0; | |
4072 | int idx_vrf = 0, idx_intf = 0; | |
4073 | u_char uj = use_json(argc, argv); | |
b1c3ae8c | 4074 | json_object *json = NULL; |
c9339663 CS |
4075 | int ret = CMD_SUCCESS; |
4076 | int display_once = 0; | |
b1c3ae8c | 4077 | u_char use_vrf = 0; |
c9339663 CS |
4078 | |
4079 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
4080 | ||
4081 | if (argv_find(argv, argc, "INTERFACE", &idx_intf)) | |
4082 | intf_name = argv[idx_intf]->arg; | |
4083 | ||
b1c3ae8c CS |
4084 | if (uj) |
4085 | json = json_object_new_object(); | |
4086 | ||
c9339663 | 4087 | if (vrf_name) { |
b1c3ae8c | 4088 | use_vrf = 1; |
c9339663 CS |
4089 | if (all_vrf) { |
4090 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
4091 | if (!ospf->oi_running) | |
4092 | continue; | |
4093 | ||
996c9314 LB |
4094 | ret = show_ip_ospf_interface_traffic_common( |
4095 | vty, ospf, intf_name, json, | |
4096 | display_once, use_vrf, uj); | |
c9339663 CS |
4097 | display_once = 1; |
4098 | } | |
b1c3ae8c CS |
4099 | |
4100 | if (uj) { | |
4101 | vty_out(vty, "%s\n", | |
996c9314 LB |
4102 | json_object_to_json_string_ext( |
4103 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
4104 | json_object_free(json); |
4105 | } | |
4106 | ||
c9339663 CS |
4107 | return ret; |
4108 | } | |
4109 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
b1c3ae8c CS |
4110 | if (ospf == NULL || !ospf->oi_running) { |
4111 | if (uj) | |
4112 | json_object_free(json); | |
c9339663 | 4113 | return CMD_SUCCESS; |
b1c3ae8c CS |
4114 | } |
4115 | ||
996c9314 LB |
4116 | ret = show_ip_ospf_interface_traffic_common( |
4117 | vty, ospf, intf_name, json, display_once, use_vrf, uj); | |
c9339663 CS |
4118 | } else { |
4119 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
b1c3ae8c CS |
4120 | if (ospf == NULL || !ospf->oi_running) { |
4121 | if (uj) | |
4122 | json_object_free(json); | |
c9339663 | 4123 | return CMD_SUCCESS; |
b1c3ae8c CS |
4124 | } |
4125 | ||
996c9314 LB |
4126 | ret = show_ip_ospf_interface_traffic_common( |
4127 | vty, ospf, intf_name, json, display_once, use_vrf, uj); | |
b1c3ae8c CS |
4128 | } |
4129 | ||
4130 | if (uj) { | |
996c9314 LB |
4131 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
4132 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c | 4133 | json_object_free(json); |
c9339663 CS |
4134 | } |
4135 | ||
4136 | return ret; | |
4137 | } | |
4138 | ||
4139 | ||
d62a17ae | 4140 | static void show_ip_ospf_neighbour_header(struct vty *vty) |
4141 | { | |
4142 | vty_out(vty, "\n%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s\n", | |
4143 | "Neighbor ID", "Pri", "State", "Dead Time", "Address", | |
4144 | "Interface", "RXmtL", "RqstL", "DBsmL"); | |
4145 | } | |
4146 | ||
4147 | static void show_ip_ospf_neighbor_sub(struct vty *vty, | |
4148 | struct ospf_interface *oi, | |
4149 | json_object *json, u_char use_json) | |
4150 | { | |
4151 | struct route_node *rn; | |
cef262c3 | 4152 | struct ospf_neighbor *nbr, *prev_nbr = NULL; |
d62a17ae | 4153 | char msgbuf[16]; |
4154 | char timebuf[OSPF_TIME_DUMP_SIZE]; | |
cef262c3 | 4155 | json_object *json_neighbor = NULL, *json_neigh_array = NULL; |
d62a17ae | 4156 | |
4157 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) { | |
4158 | if ((nbr = rn->info)) { | |
4159 | /* Do not show myself. */ | |
cef262c3 CS |
4160 | if (nbr == oi->nbr_self) |
4161 | continue; | |
4162 | /* Down state is not shown. */ | |
4163 | if (nbr->state == NSM_Down) | |
4164 | continue; | |
4165 | if (use_json) { | |
4166 | char neigh_str[INET_ADDRSTRLEN]; | |
4167 | ||
996c9314 LB |
4168 | if (prev_nbr |
4169 | && !IPV4_ADDR_SAME(&prev_nbr->src, | |
4170 | &nbr->src)) { | |
cef262c3 CS |
4171 | /* Start new neigh list */ |
4172 | json_neigh_array = NULL; | |
4173 | } | |
4174 | ||
996c9314 LB |
4175 | if (nbr->state == NSM_Attempt |
4176 | && nbr->router_id.s_addr == 0) | |
6021c6c0 CS |
4177 | strlcpy(neigh_str, "neighbor", |
4178 | sizeof(neigh_str)); | |
cef262c3 | 4179 | else |
6021c6c0 | 4180 | strlcpy(neigh_str, |
cef262c3 | 4181 | inet_ntoa(nbr->router_id), |
6021c6c0 | 4182 | sizeof(neigh_str)); |
cef262c3 CS |
4183 | |
4184 | json_object_object_get_ex(json, neigh_str, | |
4185 | &json_neigh_array); | |
4186 | ||
4187 | if (!json_neigh_array) { | |
996c9314 LB |
4188 | json_neigh_array = |
4189 | json_object_new_array(); | |
4190 | json_object_object_add( | |
4191 | json, neigh_str, | |
4192 | json_neigh_array); | |
d62a17ae | 4193 | } |
cef262c3 | 4194 | |
996c9314 | 4195 | json_neighbor = json_object_new_object(); |
cef262c3 CS |
4196 | |
4197 | ospf_nbr_state_message(nbr, msgbuf, 16); | |
4198 | ||
4199 | long time_store; | |
4200 | ||
996c9314 LB |
4201 | time_store = |
4202 | monotime_until( | |
cef262c3 | 4203 | &nbr->t_inactivity->u.sands, |
996c9314 LB |
4204 | NULL) |
4205 | / 1000LL; | |
cef262c3 | 4206 | |
996c9314 | 4207 | json_object_int_add(json_neighbor, "priority", |
cef262c3 CS |
4208 | nbr->priority); |
4209 | json_object_string_add(json_neighbor, "state", | |
4210 | msgbuf); | |
4211 | json_object_int_add(json_neighbor, | |
4212 | "deadTimeMsecs", | |
4213 | time_store); | |
996c9314 | 4214 | json_object_string_add(json_neighbor, "address", |
cef262c3 CS |
4215 | inet_ntoa(nbr->src)); |
4216 | json_object_string_add(json_neighbor, | |
4217 | "ifaceName", | |
4218 | IF_NAME(oi)); | |
996c9314 LB |
4219 | json_object_int_add( |
4220 | json_neighbor, "retransmitCounter", | |
4221 | ospf_ls_retransmit_count(nbr)); | |
cef262c3 | 4222 | json_object_int_add(json_neighbor, |
996c9314 LB |
4223 | "requestCounter", |
4224 | ospf_ls_request_count(nbr)); | |
cef262c3 | 4225 | json_object_int_add(json_neighbor, |
996c9314 LB |
4226 | "dbSummaryCounter", |
4227 | ospf_db_summary_count(nbr)); | |
cef262c3 CS |
4228 | |
4229 | json_object_array_add(json_neigh_array, | |
4230 | json_neighbor); | |
4231 | } else { | |
4232 | ospf_nbr_state_message(nbr, msgbuf, 16); | |
4233 | ||
996c9314 LB |
4234 | if (nbr->state == NSM_Attempt |
4235 | && nbr->router_id.s_addr == 0) | |
4236 | vty_out(vty, "%-15s %3d %-15s ", "-", | |
4237 | nbr->priority, msgbuf); | |
cef262c3 | 4238 | else |
996c9314 | 4239 | vty_out(vty, "%-15s %3d %-15s ", |
cef262c3 | 4240 | inet_ntoa(nbr->router_id), |
996c9314 | 4241 | nbr->priority, msgbuf); |
cef262c3 CS |
4242 | |
4243 | vty_out(vty, "%9s ", | |
4244 | ospf_timer_dump(nbr->t_inactivity, | |
4245 | timebuf, | |
4246 | sizeof(timebuf))); | |
4247 | vty_out(vty, "%-15s ", inet_ntoa(nbr->src)); | |
996c9314 | 4248 | vty_out(vty, "%-20s %5ld %5ld %5d\n", |
cef262c3 CS |
4249 | IF_NAME(oi), |
4250 | ospf_ls_retransmit_count(nbr), | |
4251 | ospf_ls_request_count(nbr), | |
4252 | ospf_db_summary_count(nbr)); | |
d62a17ae | 4253 | } |
cef262c3 | 4254 | prev_nbr = nbr; |
d62a17ae | 4255 | } |
4256 | } | |
4257 | } | |
4258 | ||
4259 | static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf, | |
b1c3ae8c CS |
4260 | json_object *json, u_char use_json, |
4261 | u_char use_vrf) | |
d62a17ae | 4262 | { |
4263 | struct ospf_interface *oi; | |
4264 | struct listnode *node; | |
6282e124 | 4265 | json_object *json_vrf = NULL; |
2bc7673f | 4266 | json_object *json_nbr_sub = NULL; |
7c8ff89e | 4267 | |
b1c3ae8c CS |
4268 | if (use_json) { |
4269 | if (use_vrf) | |
4270 | json_vrf = json_object_new_object(); | |
4271 | else | |
4272 | json_vrf = json; | |
6282e124 | 4273 | json_nbr_sub = json_object_new_object(); |
b1c3ae8c | 4274 | } |
d62a17ae | 4275 | |
4276 | if (ospf->instance) { | |
4277 | if (use_json) | |
4278 | json_object_int_add(json, "ospfInstance", | |
4279 | ospf->instance); | |
4280 | else | |
4281 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
4282 | } | |
7c8ff89e | 4283 | |
b1c3ae8c CS |
4284 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
4285 | if (!use_json) | |
4286 | show_ip_ospf_neighbour_header(vty); | |
87bd50e8 | 4287 | |
2bc7673f CS |
4288 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { |
4289 | if (ospf_interface_neighbor_count(oi) == 0) | |
4290 | continue; | |
2bc7673f CS |
4291 | show_ip_ospf_neighbor_sub(vty, oi, json_nbr_sub, use_json); |
4292 | } | |
718e3744 | 4293 | |
d62a17ae | 4294 | if (use_json) { |
996c9314 | 4295 | json_object_object_add(json_vrf, "neighbors", json_nbr_sub); |
b1c3ae8c CS |
4296 | if (use_vrf) { |
4297 | if (ospf->vrf_id == VRF_DEFAULT) | |
4298 | json_object_object_add(json, "default", | |
4299 | json_vrf); | |
4300 | else | |
4301 | json_object_object_add(json, ospf->name, | |
4302 | json_vrf); | |
4303 | } | |
d62a17ae | 4304 | } else |
4305 | vty_out(vty, "\n"); | |
7c8ff89e | 4306 | |
d62a17ae | 4307 | return CMD_SUCCESS; |
718e3744 | 4308 | } |
4309 | ||
7c8ff89e DS |
4310 | DEFUN (show_ip_ospf_neighbor, |
4311 | show_ip_ospf_neighbor_cmd, | |
b5a8894d | 4312 | "show ip ospf [vrf <NAME|all>] neighbor [json]", |
718e3744 | 4313 | SHOW_STR |
4314 | IP_STR | |
4315 | "OSPF information\n" | |
b5a8894d CS |
4316 | VRF_CMD_HELP_STR |
4317 | "All VRFs\n" | |
91756b38 | 4318 | "Neighbor list\n" |
9973d184 | 4319 | JSON_STR) |
718e3744 | 4320 | { |
d62a17ae | 4321 | struct ospf *ospf; |
4322 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
4323 | struct listnode *node = NULL; |
4324 | char *vrf_name = NULL; | |
4325 | bool all_vrf = FALSE; | |
4326 | int ret = CMD_SUCCESS; | |
4327 | int inst = 0; | |
4328 | int idx_vrf = 0; | |
b1c3ae8c CS |
4329 | u_char use_vrf = 0; |
4330 | json_object *json = NULL; | |
718e3744 | 4331 | |
43b8d1d8 | 4332 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
7c8ff89e | 4333 | |
b1c3ae8c CS |
4334 | if (uj) |
4335 | json = json_object_new_object(); | |
b5a8894d CS |
4336 | |
4337 | /* vrf input is provided could be all or specific vrf*/ | |
4338 | if (vrf_name) { | |
b1c3ae8c | 4339 | use_vrf = 1; |
b5a8894d CS |
4340 | if (all_vrf) { |
4341 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
4342 | if (!ospf->oi_running) | |
4343 | continue; | |
996c9314 LB |
4344 | ret = show_ip_ospf_neighbor_common( |
4345 | vty, ospf, json, uj, use_vrf); | |
b1c3ae8c CS |
4346 | } |
4347 | ||
4348 | if (uj) { | |
4349 | vty_out(vty, "%s\n", | |
996c9314 LB |
4350 | json_object_to_json_string_ext( |
4351 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c | 4352 | json_object_free(json); |
b5a8894d | 4353 | } |
b1c3ae8c | 4354 | |
b5a8894d CS |
4355 | return ret; |
4356 | } | |
b1c3ae8c | 4357 | |
b5a8894d | 4358 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); |
b1c3ae8c CS |
4359 | if (ospf == NULL || !ospf->oi_running) { |
4360 | if (uj) | |
4361 | json_object_free(json); | |
b5a8894d | 4362 | return CMD_SUCCESS; |
b1c3ae8c | 4363 | } |
b5a8894d CS |
4364 | } else { |
4365 | /* Display default ospf (instance 0) info */ | |
4366 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
b1c3ae8c CS |
4367 | if (ospf == NULL || !ospf->oi_running) { |
4368 | if (uj) | |
4369 | json_object_free(json); | |
b5a8894d | 4370 | return CMD_SUCCESS; |
b1c3ae8c | 4371 | } |
b5a8894d CS |
4372 | } |
4373 | ||
b1c3ae8c CS |
4374 | if (ospf) { |
4375 | ret = show_ip_ospf_neighbor_common(vty, ospf, json, uj, | |
4376 | use_vrf); | |
4377 | ||
4378 | if (uj) { | |
4379 | vty_out(vty, "%s\n", | |
996c9314 LB |
4380 | json_object_to_json_string_ext( |
4381 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
4382 | } |
4383 | } | |
4384 | ||
4385 | if (uj) | |
4386 | json_object_free(json); | |
b5a8894d CS |
4387 | |
4388 | return ret; | |
7c8ff89e DS |
4389 | } |
4390 | ||
4391 | ||
4392 | DEFUN (show_ip_ospf_instance_neighbor, | |
4393 | show_ip_ospf_instance_neighbor_cmd, | |
6147e2c6 | 4394 | "show ip ospf (1-65535) neighbor [json]", |
7c8ff89e DS |
4395 | SHOW_STR |
4396 | IP_STR | |
4397 | "OSPF information\n" | |
4398 | "Instance ID\n" | |
91756b38 | 4399 | "Neighbor list\n" |
9973d184 | 4400 | JSON_STR) |
7c8ff89e | 4401 | { |
d62a17ae | 4402 | int idx_number = 3; |
4403 | struct ospf *ospf; | |
4404 | u_short instance = 0; | |
4405 | u_char uj = use_json(argc, argv); | |
b1c3ae8c CS |
4406 | json_object *json = NULL; |
4407 | int ret = CMD_SUCCESS; | |
7c8ff89e | 4408 | |
d62a17ae | 4409 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
4410 | ospf = ospf_lookup_instance(instance); |
4411 | if (ospf == NULL) | |
4412 | return CMD_NOT_MY_INSTANCE; | |
4413 | ||
4414 | if (!ospf->oi_running) | |
d62a17ae | 4415 | return CMD_SUCCESS; |
7c8ff89e | 4416 | |
b1c3ae8c CS |
4417 | if (uj) |
4418 | json = json_object_new_object(); | |
b5a8894d | 4419 | |
b1c3ae8c CS |
4420 | ret = show_ip_ospf_neighbor_common(vty, ospf, json, uj, 0); |
4421 | ||
4422 | if (uj) { | |
996c9314 LB |
4423 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
4424 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
4425 | json_object_free(json); |
4426 | } | |
4427 | ||
4428 | return ret; | |
7c8ff89e DS |
4429 | } |
4430 | ||
d62a17ae | 4431 | static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf, |
996c9314 | 4432 | json_object *json, u_char use_json, |
b1c3ae8c | 4433 | u_char use_vrf) |
d62a17ae | 4434 | { |
4435 | struct listnode *node; | |
4436 | struct ospf_interface *oi; | |
b1c3ae8c | 4437 | json_object *json_vrf = NULL; |
d62a17ae | 4438 | json_object *json_neighbor_sub = NULL; |
7c8ff89e | 4439 | |
d62a17ae | 4440 | if (use_json) { |
b1c3ae8c CS |
4441 | if (use_vrf) |
4442 | json_vrf = json_object_new_object(); | |
4443 | else | |
4444 | json_vrf = json; | |
d62a17ae | 4445 | json_neighbor_sub = json_object_new_object(); |
b5a8894d | 4446 | } |
d62a17ae | 4447 | |
b1c3ae8c CS |
4448 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
4449 | if (!use_json) | |
4450 | show_ip_ospf_neighbour_header(vty); | |
4451 | ||
d62a17ae | 4452 | if (ospf->instance) { |
4453 | if (use_json) | |
b1c3ae8c | 4454 | json_object_int_add(json_vrf, "ospfInstance", |
d62a17ae | 4455 | ospf->instance); |
4456 | else | |
4457 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
4458 | } | |
4459 | ||
4460 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { | |
4461 | struct listnode *nbr_node; | |
4462 | struct ospf_nbr_nbma *nbr_nbma; | |
4463 | ||
b1c3ae8c | 4464 | show_ip_ospf_neighbor_sub(vty, oi, json_vrf, use_json); |
d62a17ae | 4465 | |
4466 | /* print Down neighbor status */ | |
4467 | for (ALL_LIST_ELEMENTS_RO(oi->nbr_nbma, nbr_node, nbr_nbma)) { | |
4468 | if (nbr_nbma->nbr == NULL | |
4469 | || nbr_nbma->nbr->state == NSM_Down) { | |
4470 | if (use_json) { | |
4471 | json_object_int_add(json_neighbor_sub, | |
4472 | "nbrNbmaPriority", | |
4473 | nbr_nbma->priority); | |
4474 | json_object_boolean_true_add( | |
4475 | json_neighbor_sub, | |
4476 | "nbrNbmaDown"); | |
4477 | json_object_string_add( | |
4478 | json_neighbor_sub, | |
4479 | "nbrNbmaIfaceName", | |
4480 | IF_NAME(oi)); | |
4481 | json_object_int_add( | |
4482 | json_neighbor_sub, | |
4483 | "nbrNbmaRetransmitCounter", 0); | |
4484 | json_object_int_add( | |
4485 | json_neighbor_sub, | |
4486 | "nbrNbmaRequestCounter", 0); | |
4487 | json_object_int_add( | |
4488 | json_neighbor_sub, | |
4489 | "nbrNbmaDbSummaryCounter", 0); | |
4490 | json_object_object_add( | |
b1c3ae8c CS |
4491 | json_vrf, |
4492 | inet_ntoa(nbr_nbma->addr), | |
d62a17ae | 4493 | json_neighbor_sub); |
4494 | } else { | |
4495 | vty_out(vty, "%-15s %3d %-15s %9s ", | |
4496 | "-", nbr_nbma->priority, "Down", | |
4497 | "-"); | |
4498 | vty_out(vty, | |
4499 | "%-15s %-20s %5d %5d %5d\n", | |
4500 | inet_ntoa(nbr_nbma->addr), | |
4501 | IF_NAME(oi), 0, 0, 0); | |
4502 | } | |
4503 | } | |
4504 | } | |
4505 | } | |
4506 | ||
4507 | if (use_json) { | |
b1c3ae8c CS |
4508 | if (use_vrf) { |
4509 | if (ospf->vrf_id == VRF_DEFAULT) | |
4510 | json_object_object_add(json, "default", | |
4511 | json_vrf); | |
4512 | else | |
4513 | json_object_object_add(json, ospf->name, | |
4514 | json_vrf); | |
4515 | } | |
d62a17ae | 4516 | } else |
4517 | vty_out(vty, "\n"); | |
4518 | ||
4519 | return CMD_SUCCESS; | |
718e3744 | 4520 | } |
4521 | ||
7c8ff89e DS |
4522 | DEFUN (show_ip_ospf_neighbor_all, |
4523 | show_ip_ospf_neighbor_all_cmd, | |
b5a8894d | 4524 | "show ip ospf [vrf <NAME|all>] neighbor all [json]", |
718e3744 | 4525 | SHOW_STR |
4526 | IP_STR | |
4527 | "OSPF information\n" | |
b5a8894d CS |
4528 | VRF_CMD_HELP_STR |
4529 | "All VRFs\n" | |
718e3744 | 4530 | "Neighbor list\n" |
91756b38 | 4531 | "include down status neighbor\n" |
9973d184 | 4532 | JSON_STR) |
7c8ff89e | 4533 | { |
d62a17ae | 4534 | struct ospf *ospf; |
4535 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
4536 | struct listnode *node = NULL; |
4537 | char *vrf_name = NULL; | |
4538 | bool all_vrf = FALSE; | |
4539 | int ret = CMD_SUCCESS; | |
4540 | int inst = 0; | |
4541 | int idx_vrf = 0; | |
b1c3ae8c CS |
4542 | u_char use_vrf = 0; |
4543 | json_object *json = NULL; | |
7c8ff89e | 4544 | |
43b8d1d8 | 4545 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
7c8ff89e | 4546 | |
b1c3ae8c CS |
4547 | if (uj) |
4548 | json = json_object_new_object(); | |
b5a8894d CS |
4549 | |
4550 | /* vrf input is provided could be all or specific vrf*/ | |
4551 | if (vrf_name) { | |
b1c3ae8c | 4552 | use_vrf = 1; |
b5a8894d CS |
4553 | if (all_vrf) { |
4554 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
4555 | if (!ospf->oi_running) | |
4556 | continue; | |
996c9314 LB |
4557 | ret = show_ip_ospf_neighbor_all_common( |
4558 | vty, ospf, json, uj, use_vrf); | |
b1c3ae8c CS |
4559 | } |
4560 | ||
4561 | if (uj) { | |
4562 | vty_out(vty, "%s\n", | |
996c9314 LB |
4563 | json_object_to_json_string_ext( |
4564 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c | 4565 | json_object_free(json); |
b5a8894d | 4566 | } |
b1c3ae8c | 4567 | |
b5a8894d CS |
4568 | return ret; |
4569 | } | |
b1c3ae8c | 4570 | |
b5a8894d | 4571 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); |
b1c3ae8c CS |
4572 | if (ospf == NULL || !ospf->oi_running) { |
4573 | if (uj) | |
4574 | json_object_free(json); | |
b5a8894d | 4575 | return CMD_SUCCESS; |
b1c3ae8c | 4576 | } |
b5a8894d CS |
4577 | } else { |
4578 | /* Display default ospf (instance 0) info */ | |
4579 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
b1c3ae8c CS |
4580 | if (ospf == NULL || !ospf->oi_running) { |
4581 | if (uj) | |
4582 | json_object_free(json); | |
b5a8894d | 4583 | return CMD_SUCCESS; |
b1c3ae8c | 4584 | } |
b5a8894d CS |
4585 | } |
4586 | ||
b1c3ae8c CS |
4587 | if (ospf) { |
4588 | ret = show_ip_ospf_neighbor_all_common(vty, ospf, json, uj, | |
4589 | use_vrf); | |
4590 | if (uj) { | |
4591 | vty_out(vty, "%s\n", | |
996c9314 LB |
4592 | json_object_to_json_string_ext( |
4593 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
4594 | } |
4595 | } | |
4596 | ||
4597 | if (uj) | |
4598 | json_object_free(json); | |
b5a8894d CS |
4599 | |
4600 | return ret; | |
7c8ff89e DS |
4601 | } |
4602 | ||
4603 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
4604 | show_ip_ospf_instance_neighbor_all_cmd, | |
6147e2c6 | 4605 | "show ip ospf (1-65535) neighbor all [json]", |
7c8ff89e DS |
4606 | SHOW_STR |
4607 | IP_STR | |
4608 | "OSPF information\n" | |
4609 | "Instance ID\n" | |
4610 | "Neighbor list\n" | |
91756b38 | 4611 | "include down status neighbor\n" |
9973d184 | 4612 | JSON_STR) |
718e3744 | 4613 | { |
d62a17ae | 4614 | int idx_number = 3; |
4615 | struct ospf *ospf; | |
4616 | u_short instance = 0; | |
4617 | u_char uj = use_json(argc, argv); | |
b1c3ae8c CS |
4618 | json_object *json = NULL; |
4619 | int ret = CMD_SUCCESS; | |
7c8ff89e | 4620 | |
d62a17ae | 4621 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
4622 | ospf = ospf_lookup_instance(instance); |
4623 | if (ospf == NULL) | |
4624 | return CMD_NOT_MY_INSTANCE; | |
4625 | ||
4626 | if (!ospf->oi_running) | |
d62a17ae | 4627 | return CMD_SUCCESS; |
b1c3ae8c CS |
4628 | if (uj) |
4629 | json = json_object_new_object(); | |
4630 | ||
4631 | ret = show_ip_ospf_neighbor_all_common(vty, ospf, json, uj, 0); | |
4632 | ||
4633 | if (uj) { | |
4634 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
4635 | json, JSON_C_TO_STRING_PRETTY)); | |
4636 | json_object_free(json); | |
4637 | } | |
7c8ff89e | 4638 | |
b1c3ae8c | 4639 | return ret; |
7c8ff89e DS |
4640 | } |
4641 | ||
d62a17ae | 4642 | static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf, |
4643 | int arg_base, | |
4644 | struct cmd_token **argv, | |
b1c3ae8c | 4645 | u_char use_json, u_char use_vrf) |
d62a17ae | 4646 | { |
4647 | struct interface *ifp; | |
4648 | struct route_node *rn; | |
4649 | json_object *json = NULL; | |
91756b38 | 4650 | |
d62a17ae | 4651 | if (use_json) |
4652 | json = json_object_new_object(); | |
d62a17ae | 4653 | |
4654 | if (ospf->instance) { | |
4655 | if (use_json) | |
4656 | json_object_int_add(json, "ospfInstance", | |
4657 | ospf->instance); | |
4658 | else | |
4659 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
4660 | } | |
4661 | ||
b1c3ae8c | 4662 | ospf_show_vrf_name(ospf, vty, json, use_vrf); |
87bd50e8 | 4663 | |
b5a8894d | 4664 | ifp = if_lookup_by_name_all_vrf(argv[arg_base]->arg); |
d62a17ae | 4665 | if (!ifp) { |
4666 | if (use_json) | |
4667 | json_object_boolean_true_add(json, "noSuchIface"); | |
4668 | else | |
4669 | vty_out(vty, "No such interface.\n"); | |
4670 | return CMD_WARNING; | |
4671 | } | |
4672 | ||
4673 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
4674 | struct ospf_interface *oi = rn->info; | |
4675 | ||
4676 | if (oi == NULL) | |
4677 | continue; | |
4678 | ||
4679 | show_ip_ospf_neighbor_sub(vty, oi, json, use_json); | |
4680 | } | |
4681 | ||
4682 | if (use_json) { | |
9d303b37 DL |
4683 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
4684 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 4685 | json_object_free(json); |
4686 | } else | |
4687 | vty_out(vty, "\n"); | |
4688 | ||
4689 | return CMD_SUCCESS; | |
718e3744 | 4690 | } |
4691 | ||
7c8ff89e DS |
4692 | DEFUN (show_ip_ospf_neighbor_int, |
4693 | show_ip_ospf_neighbor_int_cmd, | |
b162fa78 | 4694 | "show ip ospf neighbor IFNAME [json]", |
7c8ff89e DS |
4695 | SHOW_STR |
4696 | IP_STR | |
4697 | "OSPF information\n" | |
4698 | "Neighbor list\n" | |
91756b38 | 4699 | "Interface name\n" |
9973d184 | 4700 | JSON_STR) |
7c8ff89e | 4701 | { |
d62a17ae | 4702 | struct ospf *ospf; |
b4e84315 | 4703 | int idx_ifname = 4; |
d62a17ae | 4704 | u_char uj = use_json(argc, argv); |
b5a8894d CS |
4705 | struct listnode *node = NULL; |
4706 | int ret = CMD_SUCCESS; | |
4707 | struct interface *ifp = NULL; | |
7c8ff89e | 4708 | |
b5a8894d CS |
4709 | if (!uj) |
4710 | show_ip_ospf_neighbour_header(vty); | |
7c8ff89e | 4711 | |
b5a8894d CS |
4712 | ifp = if_lookup_by_name_all_vrf(argv[idx_ifname]->arg); |
4713 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
4714 | if (!ospf->oi_running) | |
4715 | continue; | |
4716 | if (!ifp || ifp->vrf_id != ospf->vrf_id) | |
4717 | continue; | |
996c9314 LB |
4718 | ret = show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname, |
4719 | argv, uj, 0); | |
b5a8894d CS |
4720 | } |
4721 | ||
4722 | return ret; | |
7c8ff89e DS |
4723 | } |
4724 | ||
4725 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
4726 | show_ip_ospf_instance_neighbor_int_cmd, | |
6147e2c6 | 4727 | "show ip ospf (1-65535) neighbor IFNAME [json]", |
7c8ff89e DS |
4728 | SHOW_STR |
4729 | IP_STR | |
4730 | "OSPF information\n" | |
4731 | "Instance ID\n" | |
4732 | "Neighbor list\n" | |
91756b38 | 4733 | "Interface name\n" |
9973d184 | 4734 | JSON_STR) |
7c8ff89e | 4735 | { |
d62a17ae | 4736 | int idx_number = 3; |
b4e84315 | 4737 | int idx_ifname = 5; |
d62a17ae | 4738 | struct ospf *ospf; |
4739 | u_short instance = 0; | |
4740 | u_char uj = use_json(argc, argv); | |
7c8ff89e | 4741 | |
b5a8894d CS |
4742 | if (!uj) |
4743 | show_ip_ospf_neighbour_header(vty); | |
4744 | ||
d62a17ae | 4745 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
4746 | ospf = ospf_lookup_instance(instance); |
4747 | if (ospf == NULL) | |
4748 | return CMD_NOT_MY_INSTANCE; | |
4749 | ||
4750 | if (!ospf->oi_running) | |
d62a17ae | 4751 | return CMD_SUCCESS; |
7c8ff89e | 4752 | |
b5a8894d CS |
4753 | if (!uj) |
4754 | show_ip_ospf_neighbour_header(vty); | |
4755 | ||
996c9314 LB |
4756 | return show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname, argv, uj, |
4757 | 0); | |
718e3744 | 4758 | } |
4759 | ||
d62a17ae | 4760 | static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, |
4761 | struct ospf_interface *oi, | |
4762 | struct ospf_nbr_nbma *nbr_nbma, | |
4763 | u_char use_json, json_object *json) | |
4764 | { | |
4765 | char timebuf[OSPF_TIME_DUMP_SIZE]; | |
4766 | json_object *json_sub = NULL; | |
718e3744 | 4767 | |
d62a17ae | 4768 | if (use_json) |
4769 | json_sub = json_object_new_object(); | |
4770 | else /* Show neighbor ID. */ | |
4771 | vty_out(vty, " Neighbor %s,", "-"); | |
4772 | ||
4773 | /* Show interface address. */ | |
4774 | if (use_json) | |
4775 | json_object_string_add(json_sub, "ifaceAddress", | |
4776 | inet_ntoa(nbr_nbma->addr)); | |
4777 | else | |
4778 | vty_out(vty, " interface address %s\n", | |
4779 | inet_ntoa(nbr_nbma->addr)); | |
4780 | ||
4781 | /* Show Area ID. */ | |
4782 | if (use_json) { | |
4783 | json_object_string_add(json_sub, "areaId", | |
4784 | ospf_area_desc_string(oi->area)); | |
4785 | json_object_string_add(json_sub, "iface", IF_NAME(oi)); | |
4786 | } else | |
4787 | vty_out(vty, " In the area %s via interface %s\n", | |
4788 | ospf_area_desc_string(oi->area), IF_NAME(oi)); | |
4789 | ||
4790 | /* Show neighbor priority and state. */ | |
4791 | if (use_json) { | |
4792 | json_object_int_add(json_sub, "nbrPriority", | |
4793 | nbr_nbma->priority); | |
4794 | json_object_string_add(json_sub, "nbrState", "down"); | |
4795 | } else | |
4796 | vty_out(vty, " Neighbor priority is %d, State is %s,", | |
4797 | nbr_nbma->priority, "Down"); | |
4798 | ||
4799 | /* Show state changes. */ | |
4800 | if (use_json) | |
4801 | json_object_int_add(json_sub, "stateChangeCounter", | |
4802 | nbr_nbma->state_change); | |
4803 | else | |
4804 | vty_out(vty, " %d state changes\n", nbr_nbma->state_change); | |
4805 | ||
4806 | /* Show PollInterval */ | |
4807 | if (use_json) | |
4808 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4809 | else | |
4810 | vty_out(vty, " Poll interval %d\n", nbr_nbma->v_poll); | |
4811 | ||
4812 | /* Show poll-interval timer. */ | |
4813 | if (use_json) { | |
4814 | long time_store; | |
4815 | time_store = monotime_until(&nbr_nbma->t_poll->u.sands, NULL) | |
4816 | / 1000LL; | |
4817 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", | |
4818 | time_store); | |
4819 | } else | |
4820 | vty_out(vty, " Poll timer due in %s\n", | |
4821 | ospf_timer_dump(nbr_nbma->t_poll, timebuf, | |
4822 | sizeof(timebuf))); | |
4823 | ||
4824 | /* Show poll-interval timer thread. */ | |
4825 | if (use_json) { | |
4826 | if (nbr_nbma->t_poll != NULL) | |
4827 | json_object_string_add(json_sub, | |
4828 | "pollIntervalTimerThread", "on"); | |
4829 | } else | |
4830 | vty_out(vty, " Thread Poll Timer %s\n", | |
4831 | nbr_nbma->t_poll != NULL ? "on" : "off"); | |
4832 | ||
4833 | if (use_json) | |
4834 | json_object_object_add(json, "noNbrId", json_sub); | |
4835 | } | |
4836 | ||
4837 | static void show_ip_ospf_neighbor_detail_sub(struct vty *vty, | |
4838 | struct ospf_interface *oi, | |
4839 | struct ospf_neighbor *nbr, | |
996c9314 | 4840 | json_object *json, u_char use_json) |
d62a17ae | 4841 | { |
4842 | char timebuf[OSPF_TIME_DUMP_SIZE]; | |
4843 | json_object *json_sub = NULL; | |
4844 | ||
4845 | if (use_json) | |
4846 | json_sub = json_object_new_object(); | |
4847 | else { | |
4848 | /* Show neighbor ID. */ | |
4849 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4850 | vty_out(vty, " Neighbor %s,", "-"); | |
4851 | else | |
4852 | vty_out(vty, " Neighbor %s,", | |
4853 | inet_ntoa(nbr->router_id)); | |
4854 | } | |
4855 | ||
4856 | /* Show interface address. */ | |
4857 | if (use_json) | |
4858 | json_object_string_add(json_sub, "ifaceAddress", | |
4859 | inet_ntoa(nbr->address.u.prefix4)); | |
4860 | else | |
4861 | vty_out(vty, " interface address %s\n", | |
4862 | inet_ntoa(nbr->address.u.prefix4)); | |
4863 | ||
4864 | /* Show Area ID. */ | |
4865 | if (use_json) { | |
4866 | json_object_string_add(json_sub, "areaId", | |
4867 | ospf_area_desc_string(oi->area)); | |
4868 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4869 | } else | |
4870 | vty_out(vty, " In the area %s via interface %s\n", | |
4871 | ospf_area_desc_string(oi->area), oi->ifp->name); | |
4872 | ||
4873 | /* Show neighbor priority and state. */ | |
4874 | if (use_json) { | |
4875 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
4876 | json_object_string_add( | |
4877 | json_sub, "nbrState", | |
4878 | lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); | |
4879 | } else | |
4880 | vty_out(vty, " Neighbor priority is %d, State is %s,", | |
4881 | nbr->priority, | |
4882 | lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); | |
4883 | ||
4884 | /* Show state changes. */ | |
4885 | if (use_json) | |
4886 | json_object_int_add(json_sub, "stateChangeCounter", | |
4887 | nbr->state_change); | |
4888 | else | |
4889 | vty_out(vty, " %d state changes\n", nbr->state_change); | |
4890 | ||
4891 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) { | |
4892 | struct timeval res; | |
4893 | long time_store; | |
4894 | ||
4895 | time_store = | |
4896 | monotime_since(&nbr->ts_last_progress, &res) / 1000LL; | |
4897 | if (use_json) { | |
4898 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", | |
4899 | time_store); | |
4900 | } else { | |
4901 | vty_out(vty, | |
4902 | " Most recent state change statistics:\n"); | |
4903 | vty_out(vty, " Progressive change %s ago\n", | |
4904 | ospf_timeval_dump(&res, timebuf, | |
4905 | sizeof(timebuf))); | |
4906 | } | |
4907 | } | |
4908 | ||
4909 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) { | |
4910 | struct timeval res; | |
4911 | long time_store; | |
4912 | ||
4913 | time_store = | |
4914 | monotime_since(&nbr->ts_last_regress, &res) / 1000LL; | |
4915 | if (use_json) { | |
4916 | json_object_int_add(json_sub, | |
4917 | "lastRegressiveChangeMsec", | |
4918 | time_store); | |
4919 | if (nbr->last_regress_str) | |
4920 | json_object_string_add( | |
4921 | json_sub, "lastRegressiveChangeReason", | |
4922 | nbr->last_regress_str); | |
4923 | } else { | |
4924 | vty_out(vty, | |
4925 | " Regressive change %s ago, due to %s\n", | |
4926 | ospf_timeval_dump(&res, timebuf, | |
4927 | sizeof(timebuf)), | |
4928 | (nbr->last_regress_str ? nbr->last_regress_str | |
4929 | : "??")); | |
4930 | } | |
4931 | } | |
4932 | ||
4933 | /* Show Designated Rotuer ID. */ | |
4934 | if (use_json) | |
4935 | json_object_string_add(json_sub, "routerDesignatedId", | |
4936 | inet_ntoa(nbr->d_router)); | |
4937 | else | |
4938 | vty_out(vty, " DR is %s,", inet_ntoa(nbr->d_router)); | |
4939 | ||
4940 | /* Show Backup Designated Rotuer ID. */ | |
4941 | if (use_json) | |
4942 | json_object_string_add(json_sub, "routerDesignatedBackupId", | |
4943 | inet_ntoa(nbr->bd_router)); | |
4944 | else | |
4945 | vty_out(vty, " BDR is %s\n", inet_ntoa(nbr->bd_router)); | |
4946 | ||
4947 | /* Show options. */ | |
4948 | if (use_json) { | |
4949 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4950 | json_object_string_add(json_sub, "optionsList", | |
4951 | ospf_options_dump(nbr->options)); | |
4952 | } else | |
4953 | vty_out(vty, " Options %d %s\n", nbr->options, | |
4954 | ospf_options_dump(nbr->options)); | |
4955 | ||
4956 | /* Show Router Dead interval timer. */ | |
4957 | if (use_json) { | |
4958 | if (nbr->t_inactivity) { | |
4959 | long time_store; | |
4960 | time_store = monotime_until(&nbr->t_inactivity->u.sands, | |
4961 | NULL) | |
4962 | / 1000LL; | |
4963 | json_object_int_add(json_sub, | |
4964 | "routerDeadIntervalTimerDueMsec", | |
4965 | time_store); | |
4966 | } else | |
4967 | json_object_int_add( | |
4968 | json_sub, "routerDeadIntervalTimerDueMsec", -1); | |
4969 | } else | |
4970 | vty_out(vty, " Dead timer due in %s\n", | |
4971 | ospf_timer_dump(nbr->t_inactivity, timebuf, | |
4972 | sizeof(timebuf))); | |
4973 | ||
4974 | /* Show Database Summary list. */ | |
4975 | if (use_json) | |
4976 | json_object_int_add(json_sub, "databaseSummaryListCounter", | |
4977 | ospf_db_summary_count(nbr)); | |
4978 | else | |
4979 | vty_out(vty, " Database Summary List %d\n", | |
4980 | ospf_db_summary_count(nbr)); | |
4981 | ||
4982 | /* Show Link State Request list. */ | |
4983 | if (use_json) | |
4984 | json_object_int_add(json_sub, "linkStateRequestListCounter", | |
4985 | ospf_ls_request_count(nbr)); | |
4986 | else | |
4987 | vty_out(vty, " Link State Request List %ld\n", | |
4988 | ospf_ls_request_count(nbr)); | |
4989 | ||
4990 | /* Show Link State Retransmission list. */ | |
4991 | if (use_json) | |
4992 | json_object_int_add(json_sub, | |
4993 | "linkStateRetransmissionListCounter", | |
4994 | ospf_ls_retransmit_count(nbr)); | |
4995 | else | |
4996 | vty_out(vty, " Link State Retransmission List %ld\n", | |
4997 | ospf_ls_retransmit_count(nbr)); | |
4998 | ||
4999 | /* Show inactivity timer thread. */ | |
5000 | if (use_json) { | |
5001 | if (nbr->t_inactivity != NULL) | |
5002 | json_object_string_add(json_sub, | |
5003 | "threadInactivityTimer", "on"); | |
5004 | } else | |
5005 | vty_out(vty, " Thread Inactivity Timer %s\n", | |
5006 | nbr->t_inactivity != NULL ? "on" : "off"); | |
5007 | ||
5008 | /* Show Database Description retransmission thread. */ | |
5009 | if (use_json) { | |
5010 | if (nbr->t_db_desc != NULL) | |
5011 | json_object_string_add( | |
5012 | json_sub, | |
5013 | "threadDatabaseDescriptionRetransmission", | |
5014 | "on"); | |
5015 | } else | |
5016 | vty_out(vty, | |
5017 | " Thread Database Description Retransmision %s\n", | |
5018 | nbr->t_db_desc != NULL ? "on" : "off"); | |
5019 | ||
5020 | /* Show Link State Request Retransmission thread. */ | |
5021 | if (use_json) { | |
5022 | if (nbr->t_ls_req != NULL) | |
5023 | json_object_string_add( | |
5024 | json_sub, | |
5025 | "threadLinkStateRequestRetransmission", "on"); | |
5026 | } else | |
5027 | vty_out(vty, | |
5028 | " Thread Link State Request Retransmission %s\n", | |
5029 | nbr->t_ls_req != NULL ? "on" : "off"); | |
5030 | ||
5031 | /* Show Link State Update Retransmission thread. */ | |
5032 | if (use_json) { | |
5033 | if (nbr->t_ls_upd != NULL) | |
5034 | json_object_string_add( | |
5035 | json_sub, "threadLinkStateUpdateRetransmission", | |
5036 | "on"); | |
5037 | } else | |
5038 | vty_out(vty, | |
5039 | " Thread Link State Update Retransmission %s\n\n", | |
5040 | nbr->t_ls_upd != NULL ? "on" : "off"); | |
5041 | ||
5042 | if (use_json) { | |
5043 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
5044 | json_object_object_add(json, "noNbrId", json_sub); | |
5045 | else | |
5046 | json_object_object_add(json, inet_ntoa(nbr->router_id), | |
5047 | json_sub); | |
5048 | } | |
5049 | ||
5050 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
5051 | } | |
5052 | ||
5053 | static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf, | |
5054 | int arg_base, | |
5055 | struct cmd_token **argv, | |
996c9314 | 5056 | u_char use_json, u_char use_vrf) |
d62a17ae | 5057 | { |
5058 | struct listnode *node; | |
5059 | struct ospf_neighbor *nbr; | |
5060 | struct ospf_interface *oi; | |
5061 | struct in_addr router_id; | |
5062 | int ret; | |
5063 | json_object *json = NULL; | |
5064 | ||
5065 | if (use_json) | |
5066 | json = json_object_new_object(); | |
5067 | ||
5068 | if (ospf->instance) { | |
5069 | if (use_json) | |
5070 | json_object_int_add(json, "ospfInstance", | |
5071 | ospf->instance); | |
5072 | else | |
5073 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
5074 | } | |
5075 | ||
b1c3ae8c | 5076 | ospf_show_vrf_name(ospf, vty, json, use_vrf); |
87bd50e8 | 5077 | |
d62a17ae | 5078 | ret = inet_aton(argv[arg_base]->arg, &router_id); |
5079 | if (!ret) { | |
5080 | if (!use_json) | |
5081 | vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n"); | |
16307668 RW |
5082 | else { |
5083 | vty_out(vty, "{}\n"); | |
5084 | json_object_free(json); | |
5085 | } | |
d62a17ae | 5086 | return CMD_WARNING; |
5087 | } | |
5088 | ||
5089 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { | |
5090 | if ((nbr = ospf_nbr_lookup_by_routerid(oi->nbrs, &router_id))) { | |
b1c3ae8c CS |
5091 | show_ip_ospf_neighbor_detail_sub(vty, oi, nbr, json, |
5092 | use_json); | |
d62a17ae | 5093 | } |
5094 | } | |
5095 | ||
5096 | if (use_json) { | |
9d303b37 DL |
5097 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
5098 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 5099 | json_object_free(json); |
5100 | } else | |
5101 | vty_out(vty, "\n"); | |
5102 | ||
5103 | return CMD_SUCCESS; | |
718e3744 | 5104 | } |
5105 | ||
7c8ff89e DS |
5106 | DEFUN (show_ip_ospf_neighbor_id, |
5107 | show_ip_ospf_neighbor_id_cmd, | |
b162fa78 | 5108 | "show ip ospf neighbor A.B.C.D [json]", |
718e3744 | 5109 | SHOW_STR |
5110 | IP_STR | |
5111 | "OSPF information\n" | |
5112 | "Neighbor list\n" | |
3ac237f8 | 5113 | "Neighbor ID\n" |
9973d184 | 5114 | JSON_STR) |
718e3744 | 5115 | { |
d62a17ae | 5116 | struct ospf *ospf; |
5117 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
5118 | struct listnode *node = NULL; |
5119 | int ret = CMD_SUCCESS; | |
7c8ff89e | 5120 | |
b5a8894d CS |
5121 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { |
5122 | if (!ospf->oi_running) | |
5123 | continue; | |
996c9314 LB |
5124 | ret = show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj, |
5125 | 0); | |
b5a8894d | 5126 | } |
7c8ff89e | 5127 | |
b5a8894d | 5128 | return ret; |
7c8ff89e DS |
5129 | } |
5130 | ||
5131 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
5132 | show_ip_ospf_instance_neighbor_id_cmd, | |
6147e2c6 | 5133 | "show ip ospf (1-65535) neighbor A.B.C.D [json]", |
7c8ff89e DS |
5134 | SHOW_STR |
5135 | IP_STR | |
5136 | "OSPF information\n" | |
5137 | "Instance ID\n" | |
5138 | "Neighbor list\n" | |
3ac237f8 | 5139 | "Neighbor ID\n" |
9973d184 | 5140 | JSON_STR) |
7c8ff89e | 5141 | { |
d62a17ae | 5142 | int idx_number = 3; |
b4e84315 | 5143 | int idx_router_id = 5; |
d62a17ae | 5144 | struct ospf *ospf; |
5145 | u_short instance = 0; | |
5146 | u_char uj = use_json(argc, argv); | |
7c8ff89e | 5147 | |
d62a17ae | 5148 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
5149 | ospf = ospf_lookup_instance(instance); |
5150 | if (ospf == NULL) | |
5151 | return CMD_NOT_MY_INSTANCE; | |
5152 | ||
5153 | if (!ospf->oi_running) | |
d62a17ae | 5154 | return CMD_SUCCESS; |
7c8ff89e | 5155 | |
b1c3ae8c CS |
5156 | return show_ip_ospf_neighbor_id_common(vty, ospf, idx_router_id, argv, |
5157 | uj, 0); | |
7c8ff89e DS |
5158 | } |
5159 | ||
d62a17ae | 5160 | static int show_ip_ospf_neighbor_detail_common(struct vty *vty, |
5161 | struct ospf *ospf, | |
b1c3ae8c | 5162 | json_object *json, |
996c9314 | 5163 | u_char use_json, u_char use_vrf) |
d62a17ae | 5164 | { |
5165 | struct ospf_interface *oi; | |
5166 | struct listnode *node; | |
b1c3ae8c | 5167 | json_object *json_vrf = NULL; |
d62a17ae | 5168 | |
b1c3ae8c CS |
5169 | if (use_json) { |
5170 | if (use_vrf) | |
5171 | json_vrf = json_object_new_object(); | |
5172 | else | |
5173 | json_vrf = json; | |
5174 | } | |
d62a17ae | 5175 | if (ospf->instance) { |
5176 | if (use_json) | |
b1c3ae8c | 5177 | json_object_int_add(json_vrf, "ospfInstance", |
d62a17ae | 5178 | ospf->instance); |
5179 | else | |
5180 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
5181 | } | |
5182 | ||
b1c3ae8c | 5183 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
87bd50e8 | 5184 | |
d62a17ae | 5185 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { |
5186 | struct route_node *rn; | |
5187 | struct ospf_neighbor *nbr; | |
5188 | ||
5189 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) { | |
5190 | if ((nbr = rn->info)) { | |
5191 | if (nbr != oi->nbr_self) { | |
5192 | if (nbr->state != NSM_Down) { | |
5193 | show_ip_ospf_neighbor_detail_sub( | |
b1c3ae8c CS |
5194 | vty, oi, nbr, json_vrf, |
5195 | use_json); | |
d62a17ae | 5196 | } |
5197 | } | |
5198 | } | |
5199 | } | |
5200 | } | |
5201 | ||
5202 | if (use_json) { | |
b1c3ae8c CS |
5203 | if (use_vrf) { |
5204 | if (ospf->vrf_id == VRF_DEFAULT) | |
5205 | json_object_object_add(json, "default", | |
5206 | json_vrf); | |
5207 | else | |
5208 | json_object_object_add(json, ospf->name, | |
5209 | json_vrf); | |
5210 | } | |
d62a17ae | 5211 | } else |
5212 | vty_out(vty, "\n"); | |
5213 | ||
5214 | return CMD_SUCCESS; | |
718e3744 | 5215 | } |
5216 | ||
7c8ff89e DS |
5217 | DEFUN (show_ip_ospf_neighbor_detail, |
5218 | show_ip_ospf_neighbor_detail_cmd, | |
b5a8894d | 5219 | "show ip ospf [vrf <NAME|all>] neighbor detail [json]", |
718e3744 | 5220 | SHOW_STR |
5221 | IP_STR | |
5222 | "OSPF information\n" | |
b5a8894d CS |
5223 | VRF_CMD_HELP_STR |
5224 | "All VRFs\n" | |
718e3744 | 5225 | "Neighbor list\n" |
3ac237f8 | 5226 | "detail of all neighbors\n" |
9973d184 | 5227 | JSON_STR) |
718e3744 | 5228 | { |
d62a17ae | 5229 | struct ospf *ospf; |
5230 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
5231 | struct listnode *node = NULL; |
5232 | char *vrf_name = NULL; | |
5233 | bool all_vrf = FALSE; | |
5234 | int ret = CMD_SUCCESS; | |
5235 | int inst = 0; | |
5236 | int idx_vrf = 0; | |
b1c3ae8c CS |
5237 | u_char use_vrf = 0; |
5238 | json_object *json = NULL; | |
7c8ff89e | 5239 | |
43b8d1d8 | 5240 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
7c8ff89e | 5241 | |
b1c3ae8c CS |
5242 | if (uj) |
5243 | json = json_object_new_object(); | |
5244 | ||
b5a8894d CS |
5245 | /* vrf input is provided could be all or specific vrf*/ |
5246 | if (vrf_name) { | |
b1c3ae8c | 5247 | use_vrf = 1; |
b5a8894d CS |
5248 | if (all_vrf) { |
5249 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
5250 | if (!ospf->oi_running) | |
5251 | continue; | |
996c9314 LB |
5252 | ret = show_ip_ospf_neighbor_detail_common( |
5253 | vty, ospf, json, uj, use_vrf); | |
b1c3ae8c CS |
5254 | } |
5255 | if (uj) { | |
5256 | vty_out(vty, "%s\n", | |
996c9314 LB |
5257 | json_object_to_json_string_ext( |
5258 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c | 5259 | json_object_free(json); |
b5a8894d | 5260 | } |
b1c3ae8c | 5261 | |
b5a8894d CS |
5262 | return ret; |
5263 | } | |
5264 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
b1c3ae8c CS |
5265 | if (ospf == NULL || !ospf->oi_running) { |
5266 | if (uj) | |
5267 | json_object_free(json); | |
b5a8894d | 5268 | return CMD_SUCCESS; |
b1c3ae8c | 5269 | } |
b5a8894d CS |
5270 | } else { |
5271 | /* Display default ospf (instance 0) info */ | |
5272 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
b1c3ae8c CS |
5273 | if (ospf == NULL || !ospf->oi_running) { |
5274 | if (uj) | |
5275 | json_object_free(json); | |
b5a8894d | 5276 | return CMD_SUCCESS; |
b1c3ae8c | 5277 | } |
b5a8894d CS |
5278 | } |
5279 | ||
b1c3ae8c CS |
5280 | if (ospf) { |
5281 | ret = show_ip_ospf_neighbor_detail_common(vty, ospf, json, uj, | |
5282 | use_vrf); | |
5283 | if (uj) { | |
5284 | vty_out(vty, "%s\n", | |
996c9314 LB |
5285 | json_object_to_json_string_ext( |
5286 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
5287 | } |
5288 | } | |
5289 | ||
5290 | if (uj) | |
5291 | json_object_free(json); | |
b5a8894d CS |
5292 | |
5293 | return ret; | |
7c8ff89e DS |
5294 | } |
5295 | ||
5296 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
5297 | show_ip_ospf_instance_neighbor_detail_cmd, | |
6147e2c6 | 5298 | "show ip ospf (1-65535) neighbor detail [json]", |
7c8ff89e DS |
5299 | SHOW_STR |
5300 | IP_STR | |
5301 | "OSPF information\n" | |
5302 | "Instance ID\n" | |
5303 | "Neighbor list\n" | |
3ac237f8 | 5304 | "detail of all neighbors\n" |
9973d184 | 5305 | JSON_STR) |
7c8ff89e | 5306 | { |
d62a17ae | 5307 | int idx_number = 3; |
5308 | struct ospf *ospf; | |
5309 | u_short instance = 0; | |
5310 | u_char uj = use_json(argc, argv); | |
b1c3ae8c CS |
5311 | json_object *json = NULL; |
5312 | int ret = CMD_SUCCESS; | |
7c8ff89e | 5313 | |
d62a17ae | 5314 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
5315 | ospf = ospf_lookup_instance(instance); |
5316 | if (ospf == NULL) | |
5317 | return CMD_NOT_MY_INSTANCE; | |
5318 | ||
5319 | if (!ospf->oi_running) | |
d62a17ae | 5320 | return CMD_SUCCESS; |
7c8ff89e | 5321 | |
b1c3ae8c CS |
5322 | if (uj) |
5323 | json = json_object_new_object(); | |
5324 | ||
5325 | ret = show_ip_ospf_neighbor_detail_common(vty, ospf, json, uj, 0); | |
5326 | ||
5327 | if (uj) { | |
5328 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
5329 | json, JSON_C_TO_STRING_PRETTY)); | |
5330 | json_object_free(json); | |
5331 | } | |
5332 | ||
5333 | return ret; | |
7c8ff89e DS |
5334 | } |
5335 | ||
d62a17ae | 5336 | static int show_ip_ospf_neighbor_detail_all_common(struct vty *vty, |
5337 | struct ospf *ospf, | |
b1c3ae8c CS |
5338 | json_object *json, |
5339 | u_char use_json, | |
5340 | u_char use_vrf) | |
d62a17ae | 5341 | { |
5342 | struct listnode *node; | |
5343 | struct ospf_interface *oi; | |
b1c3ae8c | 5344 | json_object *json_vrf = NULL; |
718e3744 | 5345 | |
b1c3ae8c CS |
5346 | if (use_json) { |
5347 | if (use_vrf) | |
5348 | json_vrf = json_object_new_object(); | |
5349 | else | |
5350 | json_vrf = json; | |
5351 | } | |
d62a17ae | 5352 | |
5353 | if (ospf->instance) { | |
5354 | if (use_json) | |
5355 | json_object_int_add(json, "ospfInstance", | |
5356 | ospf->instance); | |
5357 | else | |
5358 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
5359 | } | |
5360 | ||
b1c3ae8c | 5361 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); |
87bd50e8 | 5362 | |
d62a17ae | 5363 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { |
5364 | struct route_node *rn; | |
5365 | struct ospf_neighbor *nbr; | |
5366 | struct ospf_nbr_nbma *nbr_nbma; | |
5367 | ||
5368 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) | |
5369 | if ((nbr = rn->info)) | |
5370 | if (nbr != oi->nbr_self) | |
5371 | if (nbr->state != NSM_Down) | |
5372 | show_ip_ospf_neighbor_detail_sub( | |
5373 | vty, oi, rn->info, | |
b1c3ae8c | 5374 | json_vrf, use_json); |
d62a17ae | 5375 | |
5376 | if (oi->type == OSPF_IFTYPE_NBMA) { | |
5377 | struct listnode *nd; | |
5378 | ||
5379 | for (ALL_LIST_ELEMENTS_RO(oi->nbr_nbma, nd, nbr_nbma)) { | |
5380 | if (nbr_nbma->nbr == NULL | |
5381 | || nbr_nbma->nbr->state == NSM_Down) | |
5382 | show_ip_ospf_nbr_nbma_detail_sub( | |
5383 | vty, oi, nbr_nbma, use_json, | |
b1c3ae8c | 5384 | json_vrf); |
d62a17ae | 5385 | } |
5386 | } | |
5387 | } | |
5388 | ||
5389 | if (use_json) { | |
b1c3ae8c CS |
5390 | if (use_vrf) { |
5391 | if (ospf->vrf_id == VRF_DEFAULT) | |
5392 | json_object_object_add(json, "default", | |
5393 | json_vrf); | |
5394 | else | |
5395 | json_object_object_add(json, ospf->name, | |
5396 | json_vrf); | |
5397 | } | |
d62a17ae | 5398 | } else { |
5399 | vty_out(vty, "\n"); | |
5400 | } | |
5401 | ||
5402 | return CMD_SUCCESS; | |
718e3744 | 5403 | } |
5404 | ||
7c8ff89e DS |
5405 | DEFUN (show_ip_ospf_neighbor_detail_all, |
5406 | show_ip_ospf_neighbor_detail_all_cmd, | |
b5a8894d | 5407 | "show ip ospf [vrf <NAME|all>] neighbor detail all [json]", |
718e3744 | 5408 | SHOW_STR |
5409 | IP_STR | |
5410 | "OSPF information\n" | |
b5a8894d CS |
5411 | VRF_CMD_HELP_STR |
5412 | "All VRFs\n" | |
718e3744 | 5413 | "Neighbor list\n" |
7c8ff89e | 5414 | "detail of all neighbors\n" |
3ac237f8 | 5415 | "include down status neighbor\n" |
9973d184 | 5416 | JSON_STR) |
718e3744 | 5417 | { |
d62a17ae | 5418 | struct ospf *ospf; |
5419 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
5420 | struct listnode *node = NULL; |
5421 | char *vrf_name = NULL; | |
5422 | bool all_vrf = FALSE; | |
5423 | int ret = CMD_SUCCESS; | |
5424 | int inst = 0; | |
5425 | int idx_vrf = 0; | |
b1c3ae8c CS |
5426 | u_char use_vrf = 0; |
5427 | json_object *json = NULL; | |
7c8ff89e | 5428 | |
43b8d1d8 | 5429 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
7c8ff89e | 5430 | |
b1c3ae8c CS |
5431 | if (uj) |
5432 | json = json_object_new_object(); | |
5433 | ||
b5a8894d CS |
5434 | /* vrf input is provided could be all or specific vrf*/ |
5435 | if (vrf_name) { | |
b1c3ae8c | 5436 | use_vrf = 1; |
b5a8894d CS |
5437 | if (all_vrf) { |
5438 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
5439 | if (!ospf->oi_running) | |
5440 | continue; | |
996c9314 LB |
5441 | ret = show_ip_ospf_neighbor_detail_all_common( |
5442 | vty, ospf, json, uj, use_vrf); | |
b5a8894d | 5443 | } |
b1c3ae8c CS |
5444 | |
5445 | if (uj) { | |
5446 | vty_out(vty, "%s\n", | |
996c9314 LB |
5447 | json_object_to_json_string_ext( |
5448 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
5449 | json_object_free(json); |
5450 | } | |
5451 | ||
b5a8894d CS |
5452 | return ret; |
5453 | } | |
5454 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
b1c3ae8c CS |
5455 | if (ospf == NULL || !ospf->oi_running) { |
5456 | if (uj) | |
5457 | json_object_free(json); | |
b5a8894d | 5458 | return CMD_SUCCESS; |
b1c3ae8c | 5459 | } |
b5a8894d CS |
5460 | } else { |
5461 | /* Display default ospf (instance 0) info */ | |
5462 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
b1c3ae8c CS |
5463 | if (ospf == NULL || !ospf->oi_running) { |
5464 | if (uj) | |
5465 | json_object_free(json); | |
b5a8894d | 5466 | return CMD_SUCCESS; |
b1c3ae8c | 5467 | } |
b5a8894d CS |
5468 | } |
5469 | ||
b1c3ae8c CS |
5470 | if (ospf) { |
5471 | ret = show_ip_ospf_neighbor_detail_all_common(vty, ospf, json, | |
5472 | uj, use_vrf); | |
5473 | if (uj) { | |
5474 | vty_out(vty, "%s\n", | |
996c9314 LB |
5475 | json_object_to_json_string_ext( |
5476 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
5477 | } |
5478 | } | |
5479 | ||
5480 | if (uj) | |
5481 | json_object_free(json); | |
b5a8894d CS |
5482 | |
5483 | return ret; | |
7c8ff89e DS |
5484 | } |
5485 | ||
5486 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
5487 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
6147e2c6 | 5488 | "show ip ospf (1-65535) neighbor detail all [json]", |
7c8ff89e DS |
5489 | SHOW_STR |
5490 | IP_STR | |
5491 | "OSPF information\n" | |
5492 | "Instance ID\n" | |
5493 | "Neighbor list\n" | |
5494 | "detail of all neighbors\n" | |
3ac237f8 | 5495 | "include down status neighbor\n" |
9973d184 | 5496 | JSON_STR) |
7c8ff89e | 5497 | { |
d62a17ae | 5498 | int idx_number = 3; |
5499 | struct ospf *ospf; | |
5500 | u_short instance = 0; | |
5501 | u_char uj = use_json(argc, argv); | |
b1c3ae8c CS |
5502 | json_object *json = NULL; |
5503 | int ret = CMD_SUCCESS; | |
7c8ff89e | 5504 | |
d62a17ae | 5505 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
5506 | ospf = ospf_lookup_instance(instance); |
5507 | if (ospf == NULL) | |
5508 | return CMD_NOT_MY_INSTANCE; | |
5509 | ||
5510 | if (!ospf->oi_running) | |
d62a17ae | 5511 | return CMD_SUCCESS; |
7c8ff89e | 5512 | |
b1c3ae8c CS |
5513 | if (uj) |
5514 | json = json_object_new_object(); | |
5515 | ||
5516 | ret = show_ip_ospf_neighbor_detail_all_common(vty, ospf, json, uj, 0); | |
5517 | ||
5518 | if (uj) { | |
996c9314 LB |
5519 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
5520 | json, JSON_C_TO_STRING_PRETTY)); | |
b1c3ae8c CS |
5521 | json_object_free(json); |
5522 | } | |
5523 | ||
5524 | return ret; | |
7c8ff89e DS |
5525 | } |
5526 | ||
d62a17ae | 5527 | static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty, |
5528 | struct ospf *ospf, | |
5529 | int arg_base, | |
5530 | struct cmd_token **argv, | |
5531 | u_char use_json) | |
5532 | { | |
5533 | struct ospf_interface *oi; | |
5534 | struct interface *ifp; | |
5535 | struct route_node *rn, *nrn; | |
5536 | struct ospf_neighbor *nbr; | |
5537 | json_object *json = NULL; | |
718e3744 | 5538 | |
d62a17ae | 5539 | if (use_json) |
5540 | json = json_object_new_object(); | |
5541 | ||
5542 | if (ospf->instance) { | |
5543 | if (use_json) | |
5544 | json_object_int_add(json, "ospfInstance", | |
5545 | ospf->instance); | |
5546 | else | |
5547 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
5548 | } | |
5549 | ||
b5a8894d | 5550 | ifp = if_lookup_by_name_all_vrf(argv[arg_base]->arg); |
d62a17ae | 5551 | if (!ifp) { |
5552 | if (!use_json) | |
5553 | vty_out(vty, "No such interface.\n"); | |
16307668 RW |
5554 | else { |
5555 | vty_out(vty, "{}\n"); | |
5556 | json_object_free(json); | |
5557 | } | |
d62a17ae | 5558 | return CMD_WARNING; |
5559 | } | |
5560 | ||
5561 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
5562 | if ((oi = rn->info)) { | |
5563 | for (nrn = route_top(oi->nbrs); nrn; | |
5564 | nrn = route_next(nrn)) { | |
5565 | if ((nbr = nrn->info)) { | |
5566 | if (nbr != oi->nbr_self) { | |
5567 | if (nbr->state != NSM_Down) | |
5568 | show_ip_ospf_neighbor_detail_sub( | |
5569 | vty, oi, nbr, | |
b1c3ae8c | 5570 | json, use_json); |
d62a17ae | 5571 | } |
5572 | } | |
5573 | } | |
5574 | } | |
5575 | } | |
5576 | ||
5577 | if (use_json) { | |
9d303b37 DL |
5578 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
5579 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 5580 | json_object_free(json); |
5581 | } else | |
5582 | vty_out(vty, "\n"); | |
5583 | ||
5584 | return CMD_SUCCESS; | |
718e3744 | 5585 | } |
5586 | ||
7c8ff89e DS |
5587 | DEFUN (show_ip_ospf_neighbor_int_detail, |
5588 | show_ip_ospf_neighbor_int_detail_cmd, | |
b162fa78 | 5589 | "show ip ospf neighbor IFNAME detail [json]", |
7c8ff89e DS |
5590 | SHOW_STR |
5591 | IP_STR | |
5592 | "OSPF information\n" | |
5593 | "Neighbor list\n" | |
5594 | "Interface name\n" | |
3ac237f8 | 5595 | "detail of all neighbors\n" |
9973d184 | 5596 | JSON_STR) |
7c8ff89e | 5597 | { |
d62a17ae | 5598 | struct ospf *ospf; |
5599 | u_char uj = use_json(argc, argv); | |
b5a8894d CS |
5600 | struct listnode *node = NULL; |
5601 | int ret = CMD_SUCCESS; | |
7c8ff89e | 5602 | |
b5a8894d CS |
5603 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { |
5604 | if (!ospf->oi_running) | |
5605 | continue; | |
5606 | ret = show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, | |
5607 | argv, uj); | |
5608 | } | |
7c8ff89e | 5609 | |
b5a8894d | 5610 | return ret; |
7c8ff89e DS |
5611 | } |
5612 | ||
5613 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
5614 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
6147e2c6 | 5615 | "show ip ospf (1-65535) neighbor IFNAME detail [json]", |
7c8ff89e DS |
5616 | SHOW_STR |
5617 | IP_STR | |
5618 | "OSPF information\n" | |
5619 | "Instance ID\n" | |
5620 | "Neighbor list\n" | |
5621 | "Interface name\n" | |
3ac237f8 | 5622 | "detail of all neighbors\n" |
9973d184 | 5623 | JSON_STR) |
7c8ff89e | 5624 | { |
d62a17ae | 5625 | int idx_number = 3; |
b4e84315 | 5626 | int idx_ifname = 5; |
d62a17ae | 5627 | struct ospf *ospf; |
5628 | u_short instance = 0; | |
5629 | u_char uj = use_json(argc, argv); | |
7c8ff89e | 5630 | |
d62a17ae | 5631 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
5632 | ospf = ospf_lookup_instance(instance); |
5633 | if (ospf == NULL) | |
5634 | return CMD_NOT_MY_INSTANCE; | |
5635 | ||
5636 | if (!ospf->oi_running) | |
d62a17ae | 5637 | return CMD_SUCCESS; |
7c8ff89e | 5638 | |
996c9314 LB |
5639 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, idx_ifname, |
5640 | argv, uj); | |
7c8ff89e | 5641 | } |
6b0655a2 | 5642 | |
718e3744 | 5643 | /* Show functions */ |
d62a17ae | 5644 | static int show_lsa_summary(struct vty *vty, struct ospf_lsa *lsa, int self) |
5645 | { | |
5646 | struct router_lsa *rl; | |
5647 | struct summary_lsa *sl; | |
5648 | struct as_external_lsa *asel; | |
5649 | struct prefix_ipv4 p; | |
5650 | ||
5651 | if (lsa != NULL) | |
5652 | /* If self option is set, check LSA self flag. */ | |
5653 | if (self == 0 || IS_LSA_SELF(lsa)) { | |
5654 | /* LSA common part show. */ | |
5655 | vty_out(vty, "%-15s ", inet_ntoa(lsa->data->id)); | |
5656 | vty_out(vty, "%-15s %4d 0x%08lx 0x%04x", | |
5657 | inet_ntoa(lsa->data->adv_router), LS_AGE(lsa), | |
5658 | (u_long)ntohl(lsa->data->ls_seqnum), | |
5659 | ntohs(lsa->data->checksum)); | |
5660 | /* LSA specific part show. */ | |
5661 | switch (lsa->data->type) { | |
5662 | case OSPF_ROUTER_LSA: | |
5663 | rl = (struct router_lsa *)lsa->data; | |
5664 | vty_out(vty, " %-d", ntohs(rl->links)); | |
5665 | break; | |
5666 | case OSPF_SUMMARY_LSA: | |
5667 | sl = (struct summary_lsa *)lsa->data; | |
5668 | ||
5669 | p.family = AF_INET; | |
5670 | p.prefix = sl->header.id; | |
5671 | p.prefixlen = ip_masklen(sl->mask); | |
5672 | apply_mask_ipv4(&p); | |
5673 | ||
5674 | vty_out(vty, " %s/%d", inet_ntoa(p.prefix), | |
5675 | p.prefixlen); | |
5676 | break; | |
5677 | case OSPF_AS_EXTERNAL_LSA: | |
5678 | case OSPF_AS_NSSA_LSA: | |
5679 | asel = (struct as_external_lsa *)lsa->data; | |
5680 | ||
5681 | p.family = AF_INET; | |
5682 | p.prefix = asel->header.id; | |
5683 | p.prefixlen = ip_masklen(asel->mask); | |
5684 | apply_mask_ipv4(&p); | |
5685 | ||
5686 | vty_out(vty, " %s %s/%d [0x%lx]", | |
5687 | IS_EXTERNAL_METRIC(asel->e[0].tos) | |
5688 | ? "E2" | |
5689 | : "E1", | |
5690 | inet_ntoa(p.prefix), p.prefixlen, | |
5691 | (u_long)ntohl(asel->e[0].route_tag)); | |
5692 | break; | |
5693 | case OSPF_NETWORK_LSA: | |
5694 | case OSPF_ASBR_SUMMARY_LSA: | |
5695 | case OSPF_OPAQUE_LINK_LSA: | |
5696 | case OSPF_OPAQUE_AREA_LSA: | |
5697 | case OSPF_OPAQUE_AS_LSA: | |
5698 | default: | |
5699 | break; | |
5700 | } | |
5701 | vty_out(vty, "\n"); | |
5702 | } | |
718e3744 | 5703 | |
d62a17ae | 5704 | return 0; |
5705 | } | |
5706 | ||
5707 | static const char *show_database_desc[] = { | |
5708 | "unknown", | |
5709 | "Router Link States", | |
5710 | "Net Link States", | |
5711 | "Summary Link States", | |
5712 | "ASBR-Summary Link States", | |
5713 | "AS External Link States", | |
5714 | "Group Membership LSA", | |
5715 | "NSSA-external Link States", | |
5716 | "Type-8 LSA", | |
5717 | "Link-Local Opaque-LSA", | |
5718 | "Area-Local Opaque-LSA", | |
5719 | "AS-external Opaque-LSA", | |
718e3744 | 5720 | }; |
5721 | ||
d62a17ae | 5722 | static const char *show_database_header[] = { |
5723 | "", | |
5724 | "Link ID ADV Router Age Seq# CkSum Link count", | |
5725 | "Link ID ADV Router Age Seq# CkSum", | |
5726 | "Link ID ADV Router Age Seq# CkSum Route", | |
5727 | "Link ID ADV Router Age Seq# CkSum", | |
5728 | "Link ID ADV Router Age Seq# CkSum Route", | |
5729 | " --- header for Group Member ----", | |
5730 | "Link ID ADV Router Age Seq# CkSum Route", | |
5731 | " --- type-8 ---", | |
5732 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5733 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
5734 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
718e3744 | 5735 | }; |
5736 | ||
d62a17ae | 5737 | static void show_ip_ospf_database_header(struct vty *vty, struct ospf_lsa *lsa) |
5738 | { | |
5739 | struct router_lsa *rlsa = (struct router_lsa *)lsa->data; | |
5740 | ||
5741 | vty_out(vty, " LS age: %d\n", LS_AGE(lsa)); | |
5742 | vty_out(vty, " Options: 0x%-2x : %s\n", lsa->data->options, | |
5743 | ospf_options_dump(lsa->data->options)); | |
5744 | vty_out(vty, " LS Flags: 0x%-2x %s\n", lsa->flags, | |
5745 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" | |
5746 | : "")); | |
5747 | ||
5748 | if (lsa->data->type == OSPF_ROUTER_LSA) { | |
5749 | vty_out(vty, " Flags: 0x%x", rlsa->flags); | |
5750 | ||
5751 | if (rlsa->flags) | |
5752 | vty_out(vty, " :%s%s%s%s", | |
5753 | IS_ROUTER_LSA_BORDER(rlsa) ? " ABR" : "", | |
5754 | IS_ROUTER_LSA_EXTERNAL(rlsa) ? " ASBR" : "", | |
5755 | IS_ROUTER_LSA_VIRTUAL(rlsa) ? " VL-endpoint" | |
5756 | : "", | |
5757 | IS_ROUTER_LSA_SHORTCUT(rlsa) ? " Shortcut" | |
5758 | : ""); | |
5759 | ||
5760 | vty_out(vty, "\n"); | |
5761 | } | |
5762 | vty_out(vty, " LS Type: %s\n", | |
5763 | lookup_msg(ospf_lsa_type_msg, lsa->data->type, NULL)); | |
5764 | vty_out(vty, " Link State ID: %s %s\n", inet_ntoa(lsa->data->id), | |
5765 | lookup_msg(ospf_link_state_id_type_msg, lsa->data->type, NULL)); | |
5766 | vty_out(vty, " Advertising Router: %s\n", | |
5767 | inet_ntoa(lsa->data->adv_router)); | |
5768 | vty_out(vty, " LS Seq Number: %08lx\n", | |
5769 | (u_long)ntohl(lsa->data->ls_seqnum)); | |
5770 | vty_out(vty, " Checksum: 0x%04x\n", ntohs(lsa->data->checksum)); | |
5771 | vty_out(vty, " Length: %d\n\n", ntohs(lsa->data->length)); | |
5772 | } | |
5773 | ||
5774 | const char *link_type_desc[] = { | |
5775 | "(null)", | |
5776 | "another Router (point-to-point)", | |
5777 | "a Transit Network", | |
5778 | "Stub Network", | |
5779 | "a Virtual Link", | |
718e3744 | 5780 | }; |
5781 | ||
d62a17ae | 5782 | const char *link_id_desc[] = { |
5783 | "(null)", "Neighboring Router ID", "Designated Router address", | |
5784 | "Net", "Neighboring Router ID", | |
718e3744 | 5785 | }; |
5786 | ||
d62a17ae | 5787 | const char *link_data_desc[] = { |
5788 | "(null)", "Router Interface address", "Router Interface address", | |
5789 | "Network Mask", "Router Interface address", | |
718e3744 | 5790 | }; |
5791 | ||
5792 | /* Show router-LSA each Link information. */ | |
d62a17ae | 5793 | static void show_ip_ospf_database_router_links(struct vty *vty, |
5794 | struct router_lsa *rl) | |
5795 | { | |
5796 | int len, type; | |
5797 | unsigned int i; | |
5798 | ||
5799 | len = ntohs(rl->header.length) - 4; | |
5800 | for (i = 0; i < ntohs(rl->links) && len > 0; len -= 12, i++) { | |
5801 | type = rl->link[i].type; | |
5802 | ||
5803 | vty_out(vty, " Link connected to: %s\n", | |
5804 | link_type_desc[type]); | |
5805 | vty_out(vty, " (Link ID) %s: %s\n", link_id_desc[type], | |
5806 | inet_ntoa(rl->link[i].link_id)); | |
5807 | vty_out(vty, " (Link Data) %s: %s\n", link_data_desc[type], | |
5808 | inet_ntoa(rl->link[i].link_data)); | |
5809 | vty_out(vty, " Number of TOS metrics: 0\n"); | |
5810 | vty_out(vty, " TOS 0 Metric: %d\n", | |
5811 | ntohs(rl->link[i].metric)); | |
5812 | vty_out(vty, "\n"); | |
5813 | } | |
718e3744 | 5814 | } |
5815 | ||
5816 | /* Show router-LSA detail information. */ | |
d62a17ae | 5817 | static int show_router_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
718e3744 | 5818 | { |
d62a17ae | 5819 | if (lsa != NULL) { |
5820 | struct router_lsa *rl = (struct router_lsa *)lsa->data; | |
718e3744 | 5821 | |
d62a17ae | 5822 | show_ip_ospf_database_header(vty, lsa); |
718e3744 | 5823 | |
d62a17ae | 5824 | vty_out(vty, " Number of Links: %d\n\n", ntohs(rl->links)); |
718e3744 | 5825 | |
d62a17ae | 5826 | show_ip_ospf_database_router_links(vty, rl); |
5827 | vty_out(vty, "\n"); | |
5828 | } | |
5829 | ||
5830 | return 0; | |
718e3744 | 5831 | } |
5832 | ||
5833 | /* Show network-LSA detail information. */ | |
d62a17ae | 5834 | static int show_network_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
718e3744 | 5835 | { |
d62a17ae | 5836 | int length, i; |
718e3744 | 5837 | |
d62a17ae | 5838 | if (lsa != NULL) { |
5839 | struct network_lsa *nl = (struct network_lsa *)lsa->data; | |
718e3744 | 5840 | |
d62a17ae | 5841 | show_ip_ospf_database_header(vty, lsa); |
718e3744 | 5842 | |
d62a17ae | 5843 | vty_out(vty, " Network Mask: /%d\n", ip_masklen(nl->mask)); |
718e3744 | 5844 | |
d62a17ae | 5845 | length = ntohs(lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
718e3744 | 5846 | |
d62a17ae | 5847 | for (i = 0; length > 0; i++, length -= 4) |
5848 | vty_out(vty, " Attached Router: %s\n", | |
5849 | inet_ntoa(nl->routers[i])); | |
718e3744 | 5850 | |
d62a17ae | 5851 | vty_out(vty, "\n"); |
5852 | } | |
718e3744 | 5853 | |
d62a17ae | 5854 | return 0; |
718e3744 | 5855 | } |
5856 | ||
5857 | /* Show summary-LSA detail information. */ | |
d62a17ae | 5858 | static int show_summary_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
718e3744 | 5859 | { |
d62a17ae | 5860 | if (lsa != NULL) { |
5861 | struct summary_lsa *sl = (struct summary_lsa *)lsa->data; | |
718e3744 | 5862 | |
d62a17ae | 5863 | show_ip_ospf_database_header(vty, lsa); |
718e3744 | 5864 | |
d62a17ae | 5865 | vty_out(vty, " Network Mask: /%d\n", ip_masklen(sl->mask)); |
5866 | vty_out(vty, " TOS: 0 Metric: %d\n", | |
5867 | GET_METRIC(sl->metric)); | |
5868 | vty_out(vty, "\n"); | |
5869 | } | |
718e3744 | 5870 | |
d62a17ae | 5871 | return 0; |
718e3744 | 5872 | } |
5873 | ||
5874 | /* Show summary-ASBR-LSA detail information. */ | |
d62a17ae | 5875 | static int show_summary_asbr_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
718e3744 | 5876 | { |
d62a17ae | 5877 | if (lsa != NULL) { |
5878 | struct summary_lsa *sl = (struct summary_lsa *)lsa->data; | |
718e3744 | 5879 | |
d62a17ae | 5880 | show_ip_ospf_database_header(vty, lsa); |
718e3744 | 5881 | |
d62a17ae | 5882 | vty_out(vty, " Network Mask: /%d\n", ip_masklen(sl->mask)); |
5883 | vty_out(vty, " TOS: 0 Metric: %d\n", | |
5884 | GET_METRIC(sl->metric)); | |
5885 | vty_out(vty, "\n"); | |
5886 | } | |
718e3744 | 5887 | |
d62a17ae | 5888 | return 0; |
718e3744 | 5889 | } |
5890 | ||
5891 | /* Show AS-external-LSA detail information. */ | |
d62a17ae | 5892 | static int show_as_external_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
5893 | { | |
5894 | if (lsa != NULL) { | |
5895 | struct as_external_lsa *al = | |
5896 | (struct as_external_lsa *)lsa->data; | |
5897 | ||
5898 | show_ip_ospf_database_header(vty, lsa); | |
5899 | ||
5900 | vty_out(vty, " Network Mask: /%d\n", ip_masklen(al->mask)); | |
5901 | vty_out(vty, " Metric Type: %s\n", | |
5902 | IS_EXTERNAL_METRIC(al->e[0].tos) | |
5903 | ? "2 (Larger than any link state path)" | |
5904 | : "1"); | |
5905 | vty_out(vty, " TOS: 0\n"); | |
5906 | vty_out(vty, " Metric: %d\n", | |
5907 | GET_METRIC(al->e[0].metric)); | |
5908 | vty_out(vty, " Forward Address: %s\n", | |
5909 | inet_ntoa(al->e[0].fwd_addr)); | |
5910 | ||
5911 | vty_out(vty, | |
5912 | " External Route Tag: %" ROUTE_TAG_PRI "\n\n", | |
5913 | (route_tag_t)ntohl(al->e[0].route_tag)); | |
5914 | } | |
718e3744 | 5915 | |
d62a17ae | 5916 | return 0; |
718e3744 | 5917 | } |
075e12f5 | 5918 | #if 0 |
4dadc291 | 5919 | static int |
718e3744 | 5920 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
5921 | { | |
5922 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5923 | ||
5924 | /* show_ip_ospf_database_header (vty, lsa); */ | |
5925 | ||
2a42e285 | 5926 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 5927 | ip_masklen (al->mask), "\n"); |
2a42e285 | 5928 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 5929 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
5930 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 5931 | zlog_debug( " TOS: 0%s", "\n"); |
5932 | zlog_debug( " Metric: %d%s", | |
718e3744 | 5933 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 5934 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 5935 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
5936 | ||
dc9ffce8 CF |
5937 | zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
5938 | (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n"); | |
718e3744 | 5939 | |
5940 | return 0; | |
5941 | } | |
075e12f5 | 5942 | #endif |
718e3744 | 5943 | /* Show AS-NSSA-LSA detail information. */ |
d62a17ae | 5944 | static int show_as_nssa_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
5945 | { | |
5946 | if (lsa != NULL) { | |
5947 | struct as_external_lsa *al = | |
5948 | (struct as_external_lsa *)lsa->data; | |
5949 | ||
5950 | show_ip_ospf_database_header(vty, lsa); | |
5951 | ||
5952 | vty_out(vty, " Network Mask: /%d\n", ip_masklen(al->mask)); | |
5953 | vty_out(vty, " Metric Type: %s\n", | |
5954 | IS_EXTERNAL_METRIC(al->e[0].tos) | |
5955 | ? "2 (Larger than any link state path)" | |
5956 | : "1"); | |
5957 | vty_out(vty, " TOS: 0\n"); | |
5958 | vty_out(vty, " Metric: %d\n", | |
5959 | GET_METRIC(al->e[0].metric)); | |
5960 | vty_out(vty, " NSSA: Forward Address: %s\n", | |
5961 | inet_ntoa(al->e[0].fwd_addr)); | |
5962 | ||
5963 | vty_out(vty, | |
5964 | " External Route Tag: %" ROUTE_TAG_PRI "\n\n", | |
5965 | (route_tag_t)ntohl(al->e[0].route_tag)); | |
5966 | } | |
718e3744 | 5967 | |
d62a17ae | 5968 | return 0; |
718e3744 | 5969 | } |
5970 | ||
d62a17ae | 5971 | static int show_func_dummy(struct vty *vty, struct ospf_lsa *lsa) |
718e3744 | 5972 | { |
d62a17ae | 5973 | return 0; |
718e3744 | 5974 | } |
5975 | ||
d62a17ae | 5976 | static int show_opaque_lsa_detail(struct vty *vty, struct ospf_lsa *lsa) |
718e3744 | 5977 | { |
d62a17ae | 5978 | if (lsa != NULL) { |
5979 | show_ip_ospf_database_header(vty, lsa); | |
5980 | show_opaque_info_detail(vty, lsa); | |
718e3744 | 5981 | |
d62a17ae | 5982 | vty_out(vty, "\n"); |
5983 | } | |
5984 | return 0; | |
5985 | } | |
5986 | ||
5987 | int (*show_function[])(struct vty *, struct ospf_lsa *) = { | |
5988 | NULL, | |
5989 | show_router_lsa_detail, | |
5990 | show_network_lsa_detail, | |
5991 | show_summary_lsa_detail, | |
5992 | show_summary_asbr_lsa_detail, | |
5993 | show_as_external_lsa_detail, | |
5994 | show_func_dummy, | |
5995 | show_as_nssa_lsa_detail, /* almost same as external */ | |
5996 | NULL, /* type-8 */ | |
5997 | show_opaque_lsa_detail, | |
5998 | show_opaque_lsa_detail, | |
5999 | show_opaque_lsa_detail, | |
6000 | }; | |
6001 | ||
6002 | static void show_lsa_prefix_set(struct vty *vty, struct prefix_ls *lp, | |
6003 | struct in_addr *id, struct in_addr *adv_router) | |
6004 | { | |
6005 | memset(lp, 0, sizeof(struct prefix_ls)); | |
6006 | lp->family = 0; | |
6007 | if (id == NULL) | |
6008 | lp->prefixlen = 0; | |
6009 | else if (adv_router == NULL) { | |
6010 | lp->prefixlen = 32; | |
6011 | lp->id = *id; | |
6012 | } else { | |
6013 | lp->prefixlen = 64; | |
6014 | lp->id = *id; | |
6015 | lp->adv_router = *adv_router; | |
6016 | } | |
718e3744 | 6017 | } |
718e3744 | 6018 | |
d62a17ae | 6019 | static void show_lsa_detail_proc(struct vty *vty, struct route_table *rt, |
6020 | struct in_addr *id, struct in_addr *adv_router) | |
6021 | { | |
6022 | struct prefix_ls lp; | |
6023 | struct route_node *rn, *start; | |
6024 | struct ospf_lsa *lsa; | |
718e3744 | 6025 | |
d62a17ae | 6026 | show_lsa_prefix_set(vty, &lp, id, adv_router); |
6027 | start = route_node_get(rt, (struct prefix *)&lp); | |
6028 | if (start) { | |
6029 | route_lock_node(start); | |
6030 | for (rn = start; rn; rn = route_next_until(rn, start)) | |
6031 | if ((lsa = rn->info)) { | |
6032 | if (show_function[lsa->data->type] != NULL) | |
6033 | show_function[lsa->data->type](vty, | |
6034 | lsa); | |
6035 | } | |
6036 | route_unlock_node(start); | |
6037 | } | |
718e3744 | 6038 | } |
6039 | ||
6040 | /* Show detail LSA information | |
6041 | -- if id is NULL then show all LSAs. */ | |
d62a17ae | 6042 | static void show_lsa_detail(struct vty *vty, struct ospf *ospf, int type, |
6043 | struct in_addr *id, struct in_addr *adv_router) | |
6044 | { | |
6045 | struct listnode *node; | |
6046 | struct ospf_area *area; | |
6047 | ||
6048 | switch (type) { | |
6049 | case OSPF_AS_EXTERNAL_LSA: | |
6050 | case OSPF_OPAQUE_AS_LSA: | |
6051 | vty_out(vty, " %s \n\n", | |
6052 | show_database_desc[type]); | |
6053 | show_lsa_detail_proc(vty, AS_LSDB(ospf, type), id, adv_router); | |
6054 | break; | |
6055 | default: | |
6056 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { | |
6057 | vty_out(vty, "\n %s (Area %s)\n\n", | |
6058 | show_database_desc[type], | |
6059 | ospf_area_desc_string(area)); | |
6060 | show_lsa_detail_proc(vty, AREA_LSDB(area, type), id, | |
6061 | adv_router); | |
6062 | } | |
6063 | break; | |
718e3744 | 6064 | } |
6065 | } | |
6066 | ||
d62a17ae | 6067 | static void show_lsa_detail_adv_router_proc(struct vty *vty, |
6068 | struct route_table *rt, | |
6069 | struct in_addr *adv_router) | |
6070 | { | |
6071 | struct route_node *rn; | |
6072 | struct ospf_lsa *lsa; | |
6073 | ||
6074 | for (rn = route_top(rt); rn; rn = route_next(rn)) | |
6075 | if ((lsa = rn->info)) | |
6076 | if (IPV4_ADDR_SAME(adv_router, | |
6077 | &lsa->data->adv_router)) { | |
6078 | if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) | |
6079 | continue; | |
6080 | if (show_function[lsa->data->type] != NULL) | |
6081 | show_function[lsa->data->type](vty, | |
6082 | lsa); | |
6083 | } | |
6084 | } | |
6085 | ||
718e3744 | 6086 | /* Show detail LSA information. */ |
d62a17ae | 6087 | static void show_lsa_detail_adv_router(struct vty *vty, struct ospf *ospf, |
6088 | int type, struct in_addr *adv_router) | |
6089 | { | |
6090 | struct listnode *node; | |
6091 | struct ospf_area *area; | |
6092 | ||
6093 | switch (type) { | |
6094 | case OSPF_AS_EXTERNAL_LSA: | |
6095 | case OSPF_OPAQUE_AS_LSA: | |
6096 | vty_out(vty, " %s \n\n", | |
6097 | show_database_desc[type]); | |
6098 | show_lsa_detail_adv_router_proc(vty, AS_LSDB(ospf, type), | |
6099 | adv_router); | |
6100 | break; | |
6101 | default: | |
6102 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { | |
6103 | vty_out(vty, "\n %s (Area %s)\n\n", | |
6104 | show_database_desc[type], | |
6105 | ospf_area_desc_string(area)); | |
6106 | show_lsa_detail_adv_router_proc( | |
6107 | vty, AREA_LSDB(area, type), adv_router); | |
6108 | } | |
6109 | break; | |
6110 | } | |
6111 | } | |
6112 | ||
6113 | static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, | |
6114 | int self) | |
6115 | { | |
6116 | struct ospf_lsa *lsa; | |
6117 | struct route_node *rn; | |
6118 | struct ospf_area *area; | |
6119 | struct listnode *node; | |
6120 | int type; | |
6121 | ||
6122 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { | |
6123 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) { | |
6124 | switch (type) { | |
6125 | case OSPF_AS_EXTERNAL_LSA: | |
6126 | case OSPF_OPAQUE_AS_LSA: | |
6127 | continue; | |
6128 | default: | |
6129 | break; | |
6130 | } | |
6131 | if (ospf_lsdb_count_self(area->lsdb, type) > 0 | |
6132 | || (!self | |
6133 | && ospf_lsdb_count(area->lsdb, type) > 0)) { | |
6134 | vty_out(vty, " %s (Area %s)\n\n", | |
6135 | show_database_desc[type], | |
6136 | ospf_area_desc_string(area)); | |
6137 | vty_out(vty, "%s\n", | |
6138 | show_database_header[type]); | |
6139 | ||
996c9314 | 6140 | LSDB_LOOP (AREA_LSDB(area, type), rn, lsa) |
044506e7 | 6141 | show_lsa_summary(vty, lsa, self); |
d62a17ae | 6142 | |
6143 | vty_out(vty, "\n"); | |
6144 | } | |
6145 | } | |
6146 | } | |
6147 | ||
6148 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) { | |
6149 | switch (type) { | |
6150 | case OSPF_AS_EXTERNAL_LSA: | |
6151 | case OSPF_OPAQUE_AS_LSA: | |
6152 | break; | |
6153 | default: | |
6154 | continue; | |
6155 | } | |
6156 | if (ospf_lsdb_count_self(ospf->lsdb, type) | |
6157 | || (!self && ospf_lsdb_count(ospf->lsdb, type))) { | |
6158 | vty_out(vty, " %s\n\n", | |
6159 | show_database_desc[type]); | |
6160 | vty_out(vty, "%s\n", show_database_header[type]); | |
6161 | ||
996c9314 | 6162 | LSDB_LOOP (AS_LSDB(ospf, type), rn, lsa) |
044506e7 | 6163 | show_lsa_summary(vty, lsa, self); |
d62a17ae | 6164 | |
6165 | vty_out(vty, "\n"); | |
6166 | } | |
6167 | } | |
6168 | ||
6169 | vty_out(vty, "\n"); | |
6170 | } | |
6171 | ||
6172 | static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf) | |
6173 | { | |
6174 | struct route_node *rn; | |
6175 | ||
6176 | vty_out(vty, "\n MaxAge Link States:\n\n"); | |
6177 | ||
6178 | for (rn = route_top(ospf->maxage_lsa); rn; rn = route_next(rn)) { | |
6179 | struct ospf_lsa *lsa; | |
6180 | ||
6181 | if ((lsa = rn->info) != NULL) { | |
6182 | vty_out(vty, "Link type: %d\n", lsa->data->type); | |
6183 | vty_out(vty, "Link State ID: %s\n", | |
6184 | inet_ntoa(lsa->data->id)); | |
6185 | vty_out(vty, "Advertising Router: %s\n", | |
6186 | inet_ntoa(lsa->data->adv_router)); | |
6187 | vty_out(vty, "LSA lock count: %d\n", lsa->lock); | |
6188 | vty_out(vty, "\n"); | |
6189 | } | |
91e6a0e5 | 6190 | } |
718e3744 | 6191 | } |
6192 | ||
718e3744 | 6193 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
6194 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 6195 | |
718e3744 | 6196 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
6197 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
6198 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
6199 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
718e3744 | 6200 | |
d62a17ae | 6201 | #define OSPF_LSA_TYPES_DESC \ |
6202 | "ASBR summary link states\n" \ | |
6203 | "External link states\n" \ | |
6204 | "Network link states\n" \ | |
6205 | "Router link states\n" \ | |
6206 | "Network summary link states\n" OSPF_LSA_TYPE_NSSA_DESC \ | |
6207 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
6208 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
6209 | ||
6210 | static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf, | |
6211 | int arg_base, int argc, | |
996c9314 | 6212 | struct cmd_token **argv, u_char use_vrf) |
d62a17ae | 6213 | { |
6214 | int idx_type = 4; | |
6215 | int type, ret; | |
6216 | struct in_addr id, adv_router; | |
6217 | ||
6218 | if (ospf->instance) | |
6219 | vty_out(vty, "\nOSPF Instance: %d\n", ospf->instance); | |
6220 | ||
b1c3ae8c | 6221 | ospf_show_vrf_name(ospf, vty, NULL, use_vrf); |
87bd50e8 | 6222 | |
d62a17ae | 6223 | vty_out(vty, "\n OSPF Router with ID (%s)\n\n", |
6224 | inet_ntoa(ospf->router_id)); | |
6225 | ||
6226 | /* Show all LSA. */ | |
6227 | if (argc == arg_base + 4) { | |
6228 | show_ip_ospf_database_summary(vty, ospf, 0); | |
6229 | return CMD_SUCCESS; | |
6230 | } | |
718e3744 | 6231 | |
d62a17ae | 6232 | /* Set database type to show. */ |
6233 | if (strncmp(argv[arg_base + idx_type]->text, "r", 1) == 0) | |
6234 | type = OSPF_ROUTER_LSA; | |
6235 | else if (strncmp(argv[arg_base + idx_type]->text, "ne", 2) == 0) | |
6236 | type = OSPF_NETWORK_LSA; | |
6237 | else if (strncmp(argv[arg_base + idx_type]->text, "ns", 2) == 0) | |
6238 | type = OSPF_AS_NSSA_LSA; | |
6239 | else if (strncmp(argv[arg_base + idx_type]->text, "su", 2) == 0) | |
6240 | type = OSPF_SUMMARY_LSA; | |
6241 | else if (strncmp(argv[arg_base + idx_type]->text, "a", 1) == 0) | |
6242 | type = OSPF_ASBR_SUMMARY_LSA; | |
6243 | else if (strncmp(argv[arg_base + idx_type]->text, "e", 1) == 0) | |
6244 | type = OSPF_AS_EXTERNAL_LSA; | |
6245 | else if (strncmp(argv[arg_base + idx_type]->text, "se", 2) == 0) { | |
6246 | show_ip_ospf_database_summary(vty, ospf, 1); | |
6247 | return CMD_SUCCESS; | |
6248 | } else if (strncmp(argv[arg_base + idx_type]->text, "m", 1) == 0) { | |
6249 | show_ip_ospf_database_maxage(vty, ospf); | |
6250 | return CMD_SUCCESS; | |
6251 | } else if (strncmp(argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) | |
6252 | type = OSPF_OPAQUE_LINK_LSA; | |
6253 | else if (strncmp(argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) | |
6254 | type = OSPF_OPAQUE_AREA_LSA; | |
6255 | else if (strncmp(argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) | |
6256 | type = OSPF_OPAQUE_AS_LSA; | |
6257 | else | |
718e3744 | 6258 | return CMD_WARNING; |
d62a17ae | 6259 | |
6260 | /* `show ip ospf database LSA'. */ | |
6261 | if (argc == arg_base + 5) | |
6262 | show_lsa_detail(vty, ospf, type, NULL, NULL); | |
6263 | else if (argc >= arg_base + 6) { | |
6264 | ret = inet_aton(argv[arg_base + 5]->arg, &id); | |
6265 | if (!ret) | |
6266 | return CMD_WARNING; | |
6267 | ||
6268 | /* `show ip ospf database LSA ID'. */ | |
6269 | if (argc == arg_base + 6) | |
6270 | show_lsa_detail(vty, ospf, type, &id, NULL); | |
6271 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ | |
6272 | else if (argc == arg_base + 7) { | |
6273 | if (strncmp(argv[arg_base + 6]->text, "s", 1) == 0) | |
6274 | adv_router = ospf->router_id; | |
6275 | else { | |
6276 | ret = inet_aton(argv[arg_base + 7]->arg, | |
6277 | &adv_router); | |
6278 | if (!ret) | |
6279 | return CMD_WARNING; | |
6280 | } | |
6281 | show_lsa_detail(vty, ospf, type, &id, &adv_router); | |
6282 | } | |
718e3744 | 6283 | } |
718e3744 | 6284 | |
d62a17ae | 6285 | return CMD_SUCCESS; |
718e3744 | 6286 | } |
6287 | ||
7a7be519 | 6288 | DEFUN (show_ip_ospf_database_max, |
6289 | show_ip_ospf_database_max_cmd, | |
b5a8894d | 6290 | "show ip ospf [vrf <NAME|all>] database <max-age|self-originate>", |
7a7be519 | 6291 | SHOW_STR |
6292 | IP_STR | |
6293 | "OSPF information\n" | |
b5a8894d CS |
6294 | VRF_CMD_HELP_STR |
6295 | "All VRFs\n" | |
7a7be519 | 6296 | "Database summary\n" |
6297 | "LSAs in MaxAge list\n" | |
6298 | "Self-originated link states\n") | |
6299 | { | |
b5a8894d CS |
6300 | struct ospf *ospf = NULL; |
6301 | struct listnode *node = NULL; | |
6302 | char *vrf_name = NULL; | |
6303 | bool all_vrf = FALSE; | |
6304 | int ret = CMD_SUCCESS; | |
6305 | int inst = 0; | |
6306 | int idx_vrf = 0; | |
b1c3ae8c | 6307 | u_char use_vrf = 0; |
f412b39a | 6308 | |
43b8d1d8 | 6309 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
f412b39a | 6310 | |
b5a8894d | 6311 | if (vrf_name) { |
b1c3ae8c | 6312 | use_vrf = 1; |
b5a8894d CS |
6313 | if (all_vrf) { |
6314 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
6315 | if (!ospf->oi_running) | |
6316 | continue; | |
996c9314 LB |
6317 | ret = show_ip_ospf_database_common( |
6318 | vty, ospf, idx_vrf ? 2 : 0, argc, argv, | |
6319 | use_vrf); | |
b5a8894d CS |
6320 | } |
6321 | } else { | |
6322 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
6323 | if (ospf == NULL || !ospf->oi_running) | |
6324 | return CMD_SUCCESS; | |
996c9314 LB |
6325 | ret = (show_ip_ospf_database_common( |
6326 | vty, ospf, idx_vrf ? 2 : 0, argc, argv, | |
6327 | use_vrf)); | |
b5a8894d CS |
6328 | } |
6329 | } else { | |
6330 | /* Display default ospf (instance 0) info */ | |
6331 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
6332 | if (ospf == NULL || !ospf->oi_running) | |
6333 | return CMD_SUCCESS; | |
b1c3ae8c CS |
6334 | ret = show_ip_ospf_database_common(vty, ospf, 0, argc, argv, |
6335 | use_vrf); | |
b5a8894d CS |
6336 | } |
6337 | ||
6338 | return ret; | |
7a7be519 | 6339 | } |
f412b39a | 6340 | |
f412b39a DW |
6341 | DEFUN (show_ip_ospf_instance_database, |
6342 | show_ip_ospf_instance_database_cmd, | |
43b8d1d8 | 6343 | "show ip ospf [{(1-65535)|vrf NAME}] 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 | 6344 | SHOW_STR |
6345 | IP_STR | |
6346 | "OSPF information\n" | |
7c8ff89e | 6347 | "Instance ID\n" |
b5a8894d | 6348 | VRF_CMD_HELP_STR |
7a7be519 | 6349 | "Database summary\n" |
6350 | OSPF_LSA_TYPES_DESC | |
6351 | "Link State ID (as an IP address)\n" | |
6352 | "Self-originated link states\n" | |
6353 | "Advertising Router link states\n" | |
6354 | "Advertising Router (as an IP address)\n") | |
7c8ff89e | 6355 | { |
d62a17ae | 6356 | struct ospf *ospf; |
6357 | u_short instance = 0; | |
b5a8894d CS |
6358 | struct listnode *node = NULL; |
6359 | char *vrf_name = NULL; | |
6360 | bool all_vrf = FALSE; | |
6361 | int ret = CMD_SUCCESS; | |
6362 | int inst = 0; | |
d62a17ae | 6363 | int idx = 0; |
b1c3ae8c | 6364 | u_char use_vrf = 0; |
b5a8894d | 6365 | |
d62a17ae | 6366 | if (argv_find(argv, argc, "(1-65535)", &idx)) { |
6367 | instance = strtoul(argv[idx]->arg, NULL, 10); | |
6368 | ospf = ospf_lookup_instance(instance); | |
ac28e4ec CS |
6369 | if (ospf == NULL) |
6370 | return CMD_NOT_MY_INSTANCE; | |
b5a8894d CS |
6371 | if (!ospf->oi_running) |
6372 | return CMD_SUCCESS; | |
6373 | ||
6374 | return (show_ip_ospf_database_common(vty, ospf, idx ? 1 : 0, | |
b1c3ae8c | 6375 | argc, argv, use_vrf)); |
b5a8894d CS |
6376 | } else if (argv_find(argv, argc, "vrf", &idx)) { |
6377 | vrf_name = argv[++idx]->arg; | |
6378 | all_vrf = strmatch(vrf_name, "all"); | |
d62a17ae | 6379 | } |
7c8ff89e | 6380 | |
b5a8894d | 6381 | if (vrf_name) { |
b1c3ae8c | 6382 | use_vrf = 1; |
b5a8894d CS |
6383 | if (all_vrf) { |
6384 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
6385 | if (!ospf->oi_running) | |
6386 | continue; | |
996c9314 LB |
6387 | ret = (show_ip_ospf_database_common( |
6388 | vty, ospf, idx ? 2 : 0, argc, argv, | |
6389 | use_vrf)); | |
b5a8894d CS |
6390 | } |
6391 | } else { | |
6392 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
6393 | if ((ospf == NULL) || !ospf->oi_running) | |
6394 | return CMD_SUCCESS; | |
996c9314 LB |
6395 | ret = (show_ip_ospf_database_common( |
6396 | vty, ospf, idx ? 2 : 0, argc, argv, use_vrf)); | |
b5a8894d CS |
6397 | } |
6398 | } else { | |
6399 | /* Display default ospf (instance 0) info */ | |
6400 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
6401 | if (ospf == NULL || !ospf->oi_running) | |
6402 | return CMD_SUCCESS; | |
b1c3ae8c CS |
6403 | ret = (show_ip_ospf_database_common(vty, ospf, 0, argc, argv, |
6404 | use_vrf)); | |
b5a8894d | 6405 | } |
7c8ff89e | 6406 | |
b5a8894d | 6407 | return ret; |
7c8ff89e DS |
6408 | } |
6409 | ||
7a7be519 | 6410 | DEFUN (show_ip_ospf_instance_database_max, |
6411 | show_ip_ospf_instance_database_max_cmd, | |
6412 | "show ip ospf (1-65535) database <max-age|self-originate>", | |
6413 | SHOW_STR | |
6414 | IP_STR | |
6415 | "OSPF information\n" | |
6416 | "Instance ID\n" | |
6417 | "Database summary\n" | |
6418 | "LSAs in MaxAge list\n" | |
6419 | "Self-originated link states\n") | |
6420 | { | |
d62a17ae | 6421 | int idx_number = 3; |
6422 | struct ospf *ospf; | |
6423 | u_short instance = 0; | |
6424 | ||
6425 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
6426 | ||
ac28e4ec CS |
6427 | ospf = ospf_lookup_instance(instance); |
6428 | if (ospf == NULL) | |
6429 | return CMD_NOT_MY_INSTANCE; | |
6430 | ||
6431 | if (!ospf->oi_running) | |
d62a17ae | 6432 | return CMD_SUCCESS; |
6433 | ||
b1c3ae8c | 6434 | return show_ip_ospf_database_common(vty, ospf, 1, argc, argv, 0); |
d62a17ae | 6435 | } |
6436 | ||
6437 | ||
6438 | static int show_ip_ospf_database_type_adv_router_common(struct vty *vty, | |
6439 | struct ospf *ospf, | |
6440 | int arg_base, int argc, | |
b1c3ae8c CS |
6441 | struct cmd_token **argv, |
6442 | u_char use_vrf) | |
d62a17ae | 6443 | { |
6444 | int idx_type = 4; | |
6445 | int type, ret; | |
6446 | struct in_addr adv_router; | |
6447 | ||
6448 | if (ospf->instance) | |
6449 | vty_out(vty, "\nOSPF Instance: %d\n", ospf->instance); | |
6450 | ||
b1c3ae8c | 6451 | ospf_show_vrf_name(ospf, vty, NULL, use_vrf); |
87bd50e8 | 6452 | |
d62a17ae | 6453 | vty_out(vty, "\n OSPF Router with ID (%s)\n\n", |
6454 | inet_ntoa(ospf->router_id)); | |
6455 | ||
6456 | /* Set database type to show. */ | |
6457 | if (strncmp(argv[arg_base + idx_type]->text, "r", 1) == 0) | |
6458 | type = OSPF_ROUTER_LSA; | |
6459 | else if (strncmp(argv[arg_base + idx_type]->text, "ne", 2) == 0) | |
6460 | type = OSPF_NETWORK_LSA; | |
6461 | else if (strncmp(argv[arg_base + idx_type]->text, "ns", 2) == 0) | |
6462 | type = OSPF_AS_NSSA_LSA; | |
6463 | else if (strncmp(argv[arg_base + idx_type]->text, "s", 1) == 0) | |
6464 | type = OSPF_SUMMARY_LSA; | |
6465 | else if (strncmp(argv[arg_base + idx_type]->text, "a", 1) == 0) | |
6466 | type = OSPF_ASBR_SUMMARY_LSA; | |
6467 | else if (strncmp(argv[arg_base + idx_type]->text, "e", 1) == 0) | |
6468 | type = OSPF_AS_EXTERNAL_LSA; | |
6469 | else if (strncmp(argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) | |
6470 | type = OSPF_OPAQUE_LINK_LSA; | |
6471 | else if (strncmp(argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) | |
6472 | type = OSPF_OPAQUE_AREA_LSA; | |
6473 | else if (strncmp(argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) | |
6474 | type = OSPF_OPAQUE_AS_LSA; | |
6475 | else | |
6476 | return CMD_WARNING; | |
7c8ff89e | 6477 | |
d62a17ae | 6478 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
6479 | if (strncmp(argv[arg_base + 5]->text, "s", 1) == 0) | |
6480 | adv_router = ospf->router_id; | |
6481 | else { | |
6482 | ret = inet_aton(argv[arg_base + 6]->arg, &adv_router); | |
6483 | if (!ret) | |
6484 | return CMD_WARNING; | |
6485 | } | |
7c8ff89e | 6486 | |
d62a17ae | 6487 | show_lsa_detail_adv_router(vty, ospf, type, &adv_router); |
7c8ff89e | 6488 | |
d62a17ae | 6489 | return CMD_SUCCESS; |
7c8ff89e DS |
6490 | } |
6491 | ||
7c8ff89e DS |
6492 | DEFUN (show_ip_ospf_instance_database_type_adv_router, |
6493 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
43b8d1d8 | 6494 | "show ip ospf [{(1-65535)|vrf NAME}] 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 |
6495 | SHOW_STR |
6496 | IP_STR | |
6497 | "OSPF information\n" | |
6498 | "Instance ID\n" | |
b5a8894d | 6499 | VRF_CMD_HELP_STR |
7c8ff89e DS |
6500 | "Database summary\n" |
6501 | OSPF_LSA_TYPES_DESC | |
6502 | "Advertising Router link states\n" | |
3a2d747c QY |
6503 | "Advertising Router (as an IP address)\n" |
6504 | "Self-originated link states\n") | |
7c8ff89e | 6505 | { |
b5a8894d | 6506 | struct ospf *ospf = NULL; |
d62a17ae | 6507 | u_short instance = 0; |
b5a8894d CS |
6508 | struct listnode *node = NULL; |
6509 | char *vrf_name = NULL; | |
6510 | bool all_vrf = FALSE; | |
6511 | int ret = CMD_SUCCESS; | |
6512 | int inst = 0; | |
43b8d1d8 | 6513 | int idx = 0, idx_vrf = 0; |
b1c3ae8c | 6514 | u_char use_vrf = 0; |
7c8ff89e | 6515 | |
d62a17ae | 6516 | if (argv_find(argv, argc, "(1-65535)", &idx)) { |
6517 | instance = strtoul(argv[idx]->arg, NULL, 10); | |
6518 | ospf = ospf_lookup_instance(instance); | |
ac28e4ec CS |
6519 | if (ospf == NULL) |
6520 | return CMD_NOT_MY_INSTANCE; | |
b5a8894d CS |
6521 | if (!ospf->oi_running) |
6522 | return CMD_SUCCESS; | |
996c9314 LB |
6523 | return (show_ip_ospf_database_type_adv_router_common( |
6524 | vty, ospf, idx ? 1 : 0, argc, argv, use_vrf)); | |
b5a8894d | 6525 | } |
43b8d1d8 CS |
6526 | |
6527 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); | |
6528 | ||
b5a8894d | 6529 | if (vrf_name) { |
b1c3ae8c | 6530 | use_vrf = 1; |
b5a8894d CS |
6531 | if (all_vrf) { |
6532 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
6533 | if (!ospf->oi_running) | |
6534 | continue; | |
996c9314 LB |
6535 | ret = show_ip_ospf_database_type_adv_router_common( |
6536 | vty, ospf, idx ? 1 : 0, argc, argv, | |
6537 | use_vrf); | |
b5a8894d CS |
6538 | } |
6539 | } else { | |
6540 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
6541 | if ((ospf == NULL) || !ospf->oi_running) | |
6542 | return CMD_SUCCESS; | |
996c9314 LB |
6543 | ret = show_ip_ospf_database_type_adv_router_common( |
6544 | vty, ospf, idx ? 1 : 0, argc, argv, use_vrf); | |
b5a8894d CS |
6545 | } |
6546 | } else { | |
6547 | /* Display default ospf (instance 0) info */ | |
6548 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
6549 | if (ospf == NULL || !ospf->oi_running) | |
6550 | return CMD_SUCCESS; | |
996c9314 LB |
6551 | ret = show_ip_ospf_database_type_adv_router_common( |
6552 | vty, ospf, idx ? 1 : 0, argc, argv, use_vrf); | |
b5a8894d CS |
6553 | } |
6554 | return ret; | |
6555 | /*return (show_ip_ospf_database_type_adv_router_common( | |
6556 | vty, ospf, idx ? 1 : 0, argc, argv));*/ | |
718e3744 | 6557 | } |
6558 | ||
718e3744 | 6559 | DEFUN (ip_ospf_authentication_args, |
6560 | ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 6561 | "ip ospf authentication <null|message-digest> [A.B.C.D]", |
718e3744 | 6562 | "IP Information\n" |
6563 | "OSPF interface commands\n" | |
6564 | "Enable authentication on this interface\n" | |
6565 | "Use null authentication\n" | |
6566 | "Use message-digest authentication\n" | |
7a7be519 | 6567 | "Address of interface\n") |
718e3744 | 6568 | { |
d62a17ae | 6569 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6570 | int idx_encryption = 3; | |
6571 | int idx_ipv4 = 4; | |
6572 | struct in_addr addr; | |
6573 | int ret; | |
6574 | struct ospf_if_params *params; | |
6575 | ||
6576 | params = IF_DEF_PARAMS(ifp); | |
6577 | ||
6578 | if (argc == 5) { | |
6579 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
6580 | if (!ret) { | |
6581 | vty_out(vty, | |
6582 | "Please specify interface address by A.B.C.D\n"); | |
6583 | return CMD_WARNING_CONFIG_FAILED; | |
6584 | } | |
718e3744 | 6585 | |
d62a17ae | 6586 | params = ospf_get_if_params(ifp, addr); |
6587 | ospf_if_update_params(ifp, addr); | |
6588 | } | |
718e3744 | 6589 | |
d62a17ae | 6590 | /* Handle null authentication */ |
6591 | if (argv[idx_encryption]->arg[0] == 'n') { | |
6592 | SET_IF_PARAM(params, auth_type); | |
6593 | params->auth_type = OSPF_AUTH_NULL; | |
6594 | return CMD_SUCCESS; | |
6595 | } | |
718e3744 | 6596 | |
d62a17ae | 6597 | /* Handle message-digest authentication */ |
6598 | if (argv[idx_encryption]->arg[0] == 'm') { | |
6599 | SET_IF_PARAM(params, auth_type); | |
6600 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6601 | return CMD_SUCCESS; | |
6602 | } | |
718e3744 | 6603 | |
d62a17ae | 6604 | vty_out(vty, "You shouldn't get here!\n"); |
6605 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6606 | } |
6607 | ||
718e3744 | 6608 | DEFUN (ip_ospf_authentication, |
6609 | ip_ospf_authentication_addr_cmd, | |
7a7be519 | 6610 | "ip ospf authentication [A.B.C.D]", |
718e3744 | 6611 | "IP Information\n" |
6612 | "OSPF interface commands\n" | |
6613 | "Enable authentication on this interface\n" | |
efd7904e | 6614 | "Address of interface\n") |
718e3744 | 6615 | { |
d62a17ae | 6616 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6617 | int idx_ipv4 = 3; | |
6618 | struct in_addr addr; | |
6619 | int ret; | |
6620 | struct ospf_if_params *params; | |
6621 | ||
6622 | params = IF_DEF_PARAMS(ifp); | |
6623 | ||
6624 | if (argc == 4) { | |
6625 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
6626 | if (!ret) { | |
6627 | vty_out(vty, | |
6628 | "Please specify interface address by A.B.C.D\n"); | |
6629 | return CMD_WARNING_CONFIG_FAILED; | |
6630 | } | |
6631 | ||
6632 | params = ospf_get_if_params(ifp, addr); | |
6633 | ospf_if_update_params(ifp, addr); | |
718e3744 | 6634 | } |
6635 | ||
d62a17ae | 6636 | SET_IF_PARAM(params, auth_type); |
6637 | params->auth_type = OSPF_AUTH_SIMPLE; | |
718e3744 | 6638 | |
d62a17ae | 6639 | return CMD_SUCCESS; |
718e3744 | 6640 | } |
6641 | ||
b4a039bf DS |
6642 | DEFUN (no_ip_ospf_authentication_args, |
6643 | no_ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 6644 | "no ip ospf authentication <null|message-digest> [A.B.C.D]", |
b4a039bf DS |
6645 | NO_STR |
6646 | "IP Information\n" | |
6647 | "OSPF interface commands\n" | |
6648 | "Enable authentication on this interface\n" | |
6649 | "Use null authentication\n" | |
6650 | "Use message-digest authentication\n" | |
efd7904e | 6651 | "Address of interface\n") |
b4a039bf | 6652 | { |
d62a17ae | 6653 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6654 | int idx_encryption = 4; | |
6655 | int idx_ipv4 = 5; | |
6656 | struct in_addr addr; | |
6657 | int ret; | |
6658 | struct ospf_if_params *params; | |
6659 | struct route_node *rn; | |
6660 | int auth_type; | |
6661 | ||
6662 | params = IF_DEF_PARAMS(ifp); | |
6663 | ||
6664 | if (argc == 6) { | |
6665 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
6666 | if (!ret) { | |
6667 | vty_out(vty, | |
6668 | "Please specify interface address by A.B.C.D\n"); | |
6669 | return CMD_WARNING_CONFIG_FAILED; | |
6670 | } | |
b4a039bf | 6671 | |
d62a17ae | 6672 | params = ospf_lookup_if_params(ifp, addr); |
6673 | if (params == NULL) { | |
6674 | vty_out(vty, "Ip Address specified is unknown\n"); | |
6675 | return CMD_WARNING_CONFIG_FAILED; | |
6676 | } | |
6677 | params->auth_type = OSPF_AUTH_NOTSET; | |
6678 | UNSET_IF_PARAM(params, auth_type); | |
6679 | if (params != IF_DEF_PARAMS(ifp)) { | |
6680 | ospf_free_if_params(ifp, addr); | |
6681 | ospf_if_update_params(ifp, addr); | |
6682 | } | |
6683 | } else { | |
6684 | if (argv[idx_encryption]->arg[0] == 'n') { | |
6685 | auth_type = OSPF_AUTH_NULL; | |
6686 | } else if (argv[idx_encryption]->arg[0] == 'm') { | |
6687 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
6688 | } else { | |
6689 | vty_out(vty, "Unexpected input encountered\n"); | |
6690 | return CMD_WARNING_CONFIG_FAILED; | |
6691 | } | |
6692 | /* | |
6693 | * Here we have a case where the user has entered | |
6694 | * 'no ip ospf authentication (null | message_digest )' | |
6695 | * we need to find if we have any ip addresses underneath it | |
6696 | * that | |
6697 | * correspond to the associated type. | |
6698 | */ | |
6699 | if (params->auth_type == auth_type) { | |
6700 | params->auth_type = OSPF_AUTH_NOTSET; | |
6701 | UNSET_IF_PARAM(params, auth_type); | |
6702 | } | |
6703 | ||
6704 | for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; | |
6705 | rn = route_next(rn)) { | |
6706 | if ((params = rn->info)) { | |
6707 | if (params->auth_type == auth_type) { | |
6708 | params->auth_type = OSPF_AUTH_NOTSET; | |
6709 | UNSET_IF_PARAM(params, auth_type); | |
6710 | if (params != IF_DEF_PARAMS(ifp)) { | |
6711 | ospf_free_if_params( | |
6712 | ifp, rn->p.u.prefix4); | |
6713 | ospf_if_update_params( | |
6714 | ifp, rn->p.u.prefix4); | |
6715 | } | |
6716 | } | |
6717 | } | |
b4a039bf | 6718 | } |
b4a039bf | 6719 | } |
b4a039bf | 6720 | |
d62a17ae | 6721 | return CMD_SUCCESS; |
b4a039bf DS |
6722 | } |
6723 | ||
718e3744 | 6724 | DEFUN (no_ip_ospf_authentication, |
6725 | no_ip_ospf_authentication_addr_cmd, | |
7a7be519 | 6726 | "no ip ospf authentication [A.B.C.D]", |
718e3744 | 6727 | NO_STR |
6728 | "IP Information\n" | |
6729 | "OSPF interface commands\n" | |
6730 | "Enable authentication on this interface\n" | |
efd7904e | 6731 | "Address of interface\n") |
718e3744 | 6732 | { |
d62a17ae | 6733 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6734 | int idx_ipv4 = 4; | |
6735 | struct in_addr addr; | |
6736 | int ret; | |
6737 | struct ospf_if_params *params; | |
6738 | struct route_node *rn; | |
6739 | ||
6740 | params = IF_DEF_PARAMS(ifp); | |
6741 | ||
6742 | if (argc == 5) { | |
6743 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
6744 | if (!ret) { | |
6745 | vty_out(vty, | |
6746 | "Please specify interface address by A.B.C.D\n"); | |
6747 | return CMD_WARNING_CONFIG_FAILED; | |
6748 | } | |
718e3744 | 6749 | |
d62a17ae | 6750 | params = ospf_lookup_if_params(ifp, addr); |
6751 | if (params == NULL) { | |
6752 | vty_out(vty, "Ip Address specified is unknown\n"); | |
6753 | return CMD_WARNING_CONFIG_FAILED; | |
6754 | } | |
718e3744 | 6755 | |
d62a17ae | 6756 | params->auth_type = OSPF_AUTH_NOTSET; |
6757 | UNSET_IF_PARAM(params, auth_type); | |
6758 | if (params != IF_DEF_PARAMS(ifp)) { | |
6759 | ospf_free_if_params(ifp, addr); | |
6760 | ospf_if_update_params(ifp, addr); | |
6761 | } | |
6762 | } else { | |
6763 | /* | |
6764 | * When a user enters 'no ip ospf authentication' | |
6765 | * We should remove all authentication types from | |
6766 | * the interface. | |
6767 | */ | |
6768 | if ((params->auth_type == OSPF_AUTH_NULL) | |
6769 | || (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
6770 | || (params->auth_type == OSPF_AUTH_SIMPLE)) { | |
6771 | params->auth_type = OSPF_AUTH_NOTSET; | |
6772 | UNSET_IF_PARAM(params, auth_type); | |
6773 | } | |
813d4307 | 6774 | |
d62a17ae | 6775 | for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; |
6776 | rn = route_next(rn)) { | |
6777 | if ((params = rn->info)) { | |
6778 | ||
6779 | if ((params->auth_type == OSPF_AUTH_NULL) | |
6780 | || (params->auth_type | |
6781 | == OSPF_AUTH_CRYPTOGRAPHIC) | |
6782 | || (params->auth_type | |
6783 | == OSPF_AUTH_SIMPLE)) { | |
6784 | params->auth_type = OSPF_AUTH_NOTSET; | |
6785 | UNSET_IF_PARAM(params, auth_type); | |
6786 | if (params != IF_DEF_PARAMS(ifp)) { | |
6787 | ospf_free_if_params( | |
6788 | ifp, rn->p.u.prefix4); | |
6789 | ospf_if_update_params( | |
6790 | ifp, rn->p.u.prefix4); | |
6791 | } | |
6792 | } | |
6793 | } | |
b4a039bf | 6794 | } |
b4a039bf | 6795 | } |
d62a17ae | 6796 | |
6797 | return CMD_SUCCESS; | |
718e3744 | 6798 | } |
6799 | ||
0d829fa7 | 6800 | |
718e3744 | 6801 | DEFUN (ip_ospf_authentication_key, |
6802 | ip_ospf_authentication_key_addr_cmd, | |
7a7be519 | 6803 | "ip ospf authentication-key AUTH_KEY [A.B.C.D]", |
718e3744 | 6804 | "IP Information\n" |
6805 | "OSPF interface commands\n" | |
6806 | "Authentication password (key)\n" | |
6807 | "The OSPF password (key)\n" | |
efd7904e | 6808 | "Address of interface\n") |
718e3744 | 6809 | { |
d62a17ae | 6810 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6811 | int idx = 0; | |
6812 | struct in_addr addr; | |
6813 | struct ospf_if_params *params; | |
718e3744 | 6814 | |
d62a17ae | 6815 | params = IF_DEF_PARAMS(ifp); |
6816 | ||
6817 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6818 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
6819 | vty_out(vty, | |
6820 | "Please specify interface address by A.B.C.D\n"); | |
6821 | return CMD_WARNING_CONFIG_FAILED; | |
6822 | } | |
718e3744 | 6823 | |
d62a17ae | 6824 | params = ospf_get_if_params(ifp, addr); |
6825 | ospf_if_update_params(ifp, addr); | |
6826 | } | |
718e3744 | 6827 | |
d62a17ae | 6828 | memset(params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
6829 | strncpy((char *)params->auth_simple, argv[3]->arg, | |
6830 | OSPF_AUTH_SIMPLE_SIZE); | |
6831 | SET_IF_PARAM(params, auth_simple); | |
718e3744 | 6832 | |
d62a17ae | 6833 | return CMD_SUCCESS; |
718e3744 | 6834 | } |
6835 | ||
7a7be519 | 6836 | DEFUN_HIDDEN (ospf_authentication_key, |
747e489c | 6837 | ospf_authentication_key_cmd, |
0d829fa7 | 6838 | "ospf authentication-key AUTH_KEY [A.B.C.D]", |
747e489c | 6839 | "OSPF interface commands\n" |
baf9eaad | 6840 | VLINK_HELPSTR_AUTH_SIMPLE |
0d829fa7 | 6841 | "Address of interface\n") |
718e3744 | 6842 | { |
d62a17ae | 6843 | return ip_ospf_authentication_key(self, vty, argc, argv); |
718e3744 | 6844 | } |
6845 | ||
7a7be519 | 6846 | DEFUN (no_ip_ospf_authentication_key, |
6847 | no_ip_ospf_authentication_key_authkey_addr_cmd, | |
6848 | "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
6849 | NO_STR | |
6850 | "IP Information\n" | |
6851 | "OSPF interface commands\n" | |
baf9eaad CS |
6852 | VLINK_HELPSTR_AUTH_SIMPLE |
6853 | "Address of interface\n") | |
7a7be519 | 6854 | { |
d62a17ae | 6855 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6856 | int idx = 0; | |
6857 | struct in_addr addr; | |
6858 | struct ospf_if_params *params; | |
6859 | params = IF_DEF_PARAMS(ifp); | |
6860 | ||
6861 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6862 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
6863 | vty_out(vty, | |
6864 | "Please specify interface address by A.B.C.D\n"); | |
6865 | return CMD_WARNING_CONFIG_FAILED; | |
6866 | } | |
7a7be519 | 6867 | |
d62a17ae | 6868 | params = ospf_lookup_if_params(ifp, addr); |
6869 | if (params == NULL) | |
6870 | return CMD_SUCCESS; | |
7a7be519 | 6871 | } |
813d4307 | 6872 | |
d62a17ae | 6873 | memset(params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
6874 | UNSET_IF_PARAM(params, auth_simple); | |
718e3744 | 6875 | |
d62a17ae | 6876 | if (params != IF_DEF_PARAMS(ifp)) { |
6877 | ospf_free_if_params(ifp, addr); | |
6878 | ospf_if_update_params(ifp, addr); | |
6879 | } | |
813d4307 | 6880 | |
d62a17ae | 6881 | return CMD_SUCCESS; |
7a7be519 | 6882 | } |
813d4307 | 6883 | |
0d829fa7 QY |
6884 | DEFUN_HIDDEN (no_ospf_authentication_key, |
6885 | no_ospf_authentication_key_authkey_addr_cmd, | |
6886 | "no ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
6887 | NO_STR | |
6888 | "OSPF interface commands\n" | |
baf9eaad CS |
6889 | VLINK_HELPSTR_AUTH_SIMPLE |
6890 | "Address of interface\n") | |
0d829fa7 | 6891 | { |
d62a17ae | 6892 | return no_ip_ospf_authentication_key(self, vty, argc, argv); |
0d829fa7 QY |
6893 | } |
6894 | ||
718e3744 | 6895 | DEFUN (ip_ospf_message_digest_key, |
537eae3f | 6896 | ip_ospf_message_digest_key_cmd, |
7a7be519 | 6897 | "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
718e3744 | 6898 | "IP Information\n" |
6899 | "OSPF interface commands\n" | |
6900 | "Message digest authentication password (key)\n" | |
6901 | "Key ID\n" | |
6902 | "Use MD5 algorithm\n" | |
fefa0d82 QY |
6903 | "The OSPF password (key)\n" |
6904 | "Address of interface\n") | |
718e3744 | 6905 | { |
d62a17ae | 6906 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6907 | struct crypt_key *ck; | |
6908 | u_char key_id; | |
6909 | struct in_addr addr; | |
6910 | struct ospf_if_params *params; | |
6911 | ||
6912 | params = IF_DEF_PARAMS(ifp); | |
6913 | int idx = 0; | |
6914 | ||
6915 | argv_find(argv, argc, "(1-255)", &idx); | |
6916 | char *keyid = argv[idx]->arg; | |
6917 | argv_find(argv, argc, "KEY", &idx); | |
6918 | char *cryptkey = argv[idx]->arg; | |
6919 | ||
6920 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6921 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
6922 | vty_out(vty, | |
6923 | "Please specify interface address by A.B.C.D\n"); | |
6924 | return CMD_WARNING_CONFIG_FAILED; | |
6925 | } | |
6926 | ||
6927 | params = ospf_get_if_params(ifp, addr); | |
6928 | ospf_if_update_params(ifp, addr); | |
718e3744 | 6929 | } |
6930 | ||
d62a17ae | 6931 | key_id = strtol(keyid, NULL, 10); |
6932 | if (ospf_crypt_key_lookup(params->auth_crypt, key_id) != NULL) { | |
6933 | vty_out(vty, "OSPF: Key %d already exists\n", key_id); | |
851fcbae | 6934 | return CMD_WARNING; |
d62a17ae | 6935 | } |
718e3744 | 6936 | |
d62a17ae | 6937 | ck = ospf_crypt_key_new(); |
6938 | ck->key_id = (u_char)key_id; | |
6939 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE + 1); | |
6940 | strncpy((char *)ck->auth_key, cryptkey, OSPF_AUTH_MD5_SIZE); | |
718e3744 | 6941 | |
d62a17ae | 6942 | ospf_crypt_key_add(params->auth_crypt, ck); |
6943 | SET_IF_PARAM(params, auth_crypt); | |
718e3744 | 6944 | |
d62a17ae | 6945 | return CMD_SUCCESS; |
718e3744 | 6946 | } |
6947 | ||
7a7be519 | 6948 | DEFUN_HIDDEN (ospf_message_digest_key, |
747e489c | 6949 | ospf_message_digest_key_cmd, |
0d829fa7 | 6950 | "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
747e489c DW |
6951 | "OSPF interface commands\n" |
6952 | "Message digest authentication password (key)\n" | |
6953 | "Key ID\n" | |
6954 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
6955 | "The OSPF password (key)\n" |
6956 | "Address of interface\n") | |
7a7be519 | 6957 | { |
d62a17ae | 6958 | return ip_ospf_message_digest_key(self, vty, argc, argv); |
7a7be519 | 6959 | } |
718e3744 | 6960 | |
537eae3f QY |
6961 | DEFUN (no_ip_ospf_message_digest_key, |
6962 | no_ip_ospf_message_digest_key_cmd, | |
0d829fa7 | 6963 | "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
813d4307 DW |
6964 | NO_STR |
6965 | "IP Information\n" | |
6966 | "OSPF interface commands\n" | |
6967 | "Message digest authentication password (key)\n" | |
6968 | "Key ID\n" | |
6969 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
6970 | "The OSPF password (key)\n" |
6971 | "Address of interface\n") | |
813d4307 | 6972 | { |
d62a17ae | 6973 | VTY_DECLVAR_CONTEXT(interface, ifp); |
6974 | int idx = 0; | |
6975 | struct crypt_key *ck; | |
6976 | int key_id; | |
6977 | struct in_addr addr; | |
6978 | struct ospf_if_params *params; | |
6979 | params = IF_DEF_PARAMS(ifp); | |
6980 | ||
6981 | argv_find(argv, argc, "(1-255)", &idx); | |
6982 | char *keyid = argv[idx]->arg; | |
6983 | ||
6984 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6985 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
6986 | vty_out(vty, | |
6987 | "Please specify interface address by A.B.C.D\n"); | |
6988 | return CMD_WARNING_CONFIG_FAILED; | |
6989 | } | |
7a7be519 | 6990 | |
d62a17ae | 6991 | params = ospf_lookup_if_params(ifp, addr); |
6992 | if (params == NULL) | |
6993 | return CMD_SUCCESS; | |
7a7be519 | 6994 | } |
6995 | ||
d62a17ae | 6996 | key_id = strtol(keyid, NULL, 10); |
6997 | ck = ospf_crypt_key_lookup(params->auth_crypt, key_id); | |
6998 | if (ck == NULL) { | |
6999 | vty_out(vty, "OSPF: Key %d does not exist\n", key_id); | |
7000 | return CMD_WARNING_CONFIG_FAILED; | |
7001 | } | |
7a7be519 | 7002 | |
d62a17ae | 7003 | ospf_crypt_key_delete(params->auth_crypt, key_id); |
7a7be519 | 7004 | |
d62a17ae | 7005 | if (params != IF_DEF_PARAMS(ifp)) { |
7006 | ospf_free_if_params(ifp, addr); | |
7007 | ospf_if_update_params(ifp, addr); | |
7008 | } | |
7a7be519 | 7009 | |
d62a17ae | 7010 | return CMD_SUCCESS; |
7a7be519 | 7011 | } |
813d4307 | 7012 | |
0d829fa7 | 7013 | DEFUN_HIDDEN (no_ospf_message_digest_key, |
537eae3f | 7014 | no_ospf_message_digest_key_cmd, |
0d829fa7 QY |
7015 | "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
7016 | NO_STR | |
7017 | "OSPF interface commands\n" | |
7018 | "Message digest authentication password (key)\n" | |
7019 | "Key ID\n" | |
efd7904e RW |
7020 | "Use MD5 algorithm\n" |
7021 | "The OSPF password (key)\n" | |
7022 | "Address of interface\n") | |
718e3744 | 7023 | { |
d62a17ae | 7024 | return no_ip_ospf_message_digest_key(self, vty, argc, argv); |
718e3744 | 7025 | } |
7026 | ||
718e3744 | 7027 | DEFUN (ip_ospf_cost, |
5c2fc921 | 7028 | ip_ospf_cost_cmd, |
7a7be519 | 7029 | "ip ospf cost (1-65535) [A.B.C.D]", |
718e3744 | 7030 | "IP Information\n" |
7031 | "OSPF interface commands\n" | |
7032 | "Interface cost\n" | |
7033 | "Cost\n" | |
5c2fc921 | 7034 | "Address of interface\n") |
718e3744 | 7035 | { |
d62a17ae | 7036 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7037 | int idx = 0; | |
35955c14 | 7038 | u_int32_t cost = OSPF_OUTPUT_COST_DEFAULT; |
d62a17ae | 7039 | struct in_addr addr; |
7040 | struct ospf_if_params *params; | |
7041 | params = IF_DEF_PARAMS(ifp); | |
7042 | ||
7043 | // get arguments | |
7044 | char *coststr = NULL, *ifaddr = NULL; | |
35955c14 | 7045 | |
c31a793b VJ |
7046 | argv_find(argv, argc, "(1-65535)", &idx); |
7047 | coststr = argv[idx]->arg; | |
d62a17ae | 7048 | cost = strtol(coststr, NULL, 10); |
7049 | ||
c31a793b | 7050 | ifaddr = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; |
d62a17ae | 7051 | if (ifaddr) { |
7052 | if (!inet_aton(ifaddr, &addr)) { | |
7053 | vty_out(vty, | |
7054 | "Please specify interface address by A.B.C.D\n"); | |
7055 | return CMD_WARNING_CONFIG_FAILED; | |
7056 | } | |
718e3744 | 7057 | |
d62a17ae | 7058 | params = ospf_get_if_params(ifp, addr); |
7059 | ospf_if_update_params(ifp, addr); | |
718e3744 | 7060 | } |
7061 | ||
d62a17ae | 7062 | SET_IF_PARAM(params, output_cost_cmd); |
7063 | params->output_cost_cmd = cost; | |
718e3744 | 7064 | |
d62a17ae | 7065 | ospf_if_recalculate_output_cost(ifp); |
5c2fc921 | 7066 | |
d62a17ae | 7067 | return CMD_SUCCESS; |
718e3744 | 7068 | } |
7069 | ||
7a7be519 | 7070 | DEFUN_HIDDEN (ospf_cost, |
5c2fc921 QY |
7071 | ospf_cost_cmd, |
7072 | "ospf cost (1-65535) [A.B.C.D]", | |
747e489c DW |
7073 | "OSPF interface commands\n" |
7074 | "Interface cost\n" | |
7075 | "Cost\n" | |
5c2fc921 | 7076 | "Address of interface\n") |
7a7be519 | 7077 | { |
d62a17ae | 7078 | return ip_ospf_cost(self, vty, argc, argv); |
7a7be519 | 7079 | } |
9eff36b3 | 7080 | |
718e3744 | 7081 | DEFUN (no_ip_ospf_cost, |
5c2fc921 QY |
7082 | no_ip_ospf_cost_cmd, |
7083 | "no ip ospf cost [(1-65535)] [A.B.C.D]", | |
718e3744 | 7084 | NO_STR |
efd7904e | 7085 | "IP Information\n" |
718e3744 | 7086 | "OSPF interface commands\n" |
7087 | "Interface cost\n" | |
efd7904e RW |
7088 | "Cost\n" |
7089 | "Address of interface\n") | |
718e3744 | 7090 | { |
d62a17ae | 7091 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7092 | int idx = 0; | |
7093 | struct in_addr addr; | |
7094 | struct ospf_if_params *params; | |
7a7be519 | 7095 | |
d62a17ae | 7096 | params = IF_DEF_PARAMS(ifp); |
718e3744 | 7097 | |
d62a17ae | 7098 | // get arguments |
7099 | char *ifaddr = NULL; | |
7100 | ifaddr = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 7101 | |
d62a17ae | 7102 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
7103 | * always treated as "no ip ospf cost" regardless of the actual value | |
7104 | * of N already configured for the interface. Thus ignore cost. */ | |
7a7be519 | 7105 | |
d62a17ae | 7106 | if (ifaddr) { |
7107 | if (!inet_aton(ifaddr, &addr)) { | |
7108 | vty_out(vty, | |
7109 | "Please specify interface address by A.B.C.D\n"); | |
7110 | return CMD_WARNING_CONFIG_FAILED; | |
7111 | } | |
7a7be519 | 7112 | |
d62a17ae | 7113 | params = ospf_lookup_if_params(ifp, addr); |
7114 | if (params == NULL) | |
7115 | return CMD_SUCCESS; | |
7116 | } | |
7a7be519 | 7117 | |
d62a17ae | 7118 | UNSET_IF_PARAM(params, output_cost_cmd); |
7a7be519 | 7119 | |
d62a17ae | 7120 | if (params != IF_DEF_PARAMS(ifp)) { |
7121 | ospf_free_if_params(ifp, addr); | |
7122 | ospf_if_update_params(ifp, addr); | |
7123 | } | |
7a7be519 | 7124 | |
d62a17ae | 7125 | ospf_if_recalculate_output_cost(ifp); |
7a7be519 | 7126 | |
d62a17ae | 7127 | return CMD_SUCCESS; |
7a7be519 | 7128 | } |
9eff36b3 | 7129 | |
5c2fc921 QY |
7130 | DEFUN_HIDDEN (no_ospf_cost, |
7131 | no_ospf_cost_cmd, | |
7132 | "no ospf cost [(1-65535)] [A.B.C.D]", | |
7133 | NO_STR | |
7134 | "OSPF interface commands\n" | |
7135 | "Interface cost\n" | |
7136 | "Cost\n" | |
7137 | "Address of interface\n") | |
827341b7 | 7138 | { |
d62a17ae | 7139 | return no_ip_ospf_cost(self, vty, argc, argv); |
827341b7 DO |
7140 | } |
7141 | ||
d62a17ae | 7142 | static void ospf_nbr_timer_update(struct ospf_interface *oi) |
718e3744 | 7143 | { |
d62a17ae | 7144 | struct route_node *rn; |
7145 | struct ospf_neighbor *nbr; | |
718e3744 | 7146 | |
d62a17ae | 7147 | for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) |
7148 | if ((nbr = rn->info)) { | |
7149 | nbr->v_inactivity = OSPF_IF_PARAM(oi, v_wait); | |
7150 | nbr->v_db_desc = OSPF_IF_PARAM(oi, retransmit_interval); | |
7151 | nbr->v_ls_req = OSPF_IF_PARAM(oi, retransmit_interval); | |
7152 | nbr->v_ls_upd = OSPF_IF_PARAM(oi, retransmit_interval); | |
7153 | } | |
718e3744 | 7154 | } |
7155 | ||
d62a17ae | 7156 | static int ospf_vty_dead_interval_set(struct vty *vty, const char *interval_str, |
7157 | const char *nbr_str, | |
7158 | const char *fast_hello_str) | |
7159 | { | |
7160 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
7161 | u_int32_t seconds; | |
7162 | u_char hellomult; | |
7163 | struct in_addr addr; | |
7164 | int ret; | |
7165 | struct ospf_if_params *params; | |
7166 | struct ospf_interface *oi; | |
7167 | struct route_node *rn; | |
718e3744 | 7168 | |
d62a17ae | 7169 | params = IF_DEF_PARAMS(ifp); |
7170 | ||
7171 | if (nbr_str) { | |
7172 | ret = inet_aton(nbr_str, &addr); | |
7173 | if (!ret) { | |
7174 | vty_out(vty, | |
7175 | "Please specify interface address by A.B.C.D\n"); | |
7176 | return CMD_WARNING_CONFIG_FAILED; | |
7177 | } | |
7178 | ||
7179 | params = ospf_get_if_params(ifp, addr); | |
7180 | ospf_if_update_params(ifp, addr); | |
7181 | } | |
7182 | ||
7183 | if (interval_str) { | |
7184 | seconds = strtoul(interval_str, NULL, 10); | |
7185 | ||
7186 | /* reset fast_hello too, just to be sure */ | |
7187 | UNSET_IF_PARAM(params, fast_hello); | |
7188 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
7189 | } else if (fast_hello_str) { | |
7190 | hellomult = strtoul(fast_hello_str, NULL, 10); | |
7191 | /* 1s dead-interval with sub-second hellos desired */ | |
7192 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
7193 | SET_IF_PARAM(params, fast_hello); | |
7194 | params->fast_hello = hellomult; | |
7195 | } else { | |
7196 | vty_out(vty, | |
7197 | "Please specify dead-interval or hello-multiplier\n"); | |
7198 | return CMD_WARNING_CONFIG_FAILED; | |
7199 | } | |
7200 | ||
7201 | SET_IF_PARAM(params, v_wait); | |
7202 | params->v_wait = seconds; | |
7203 | ||
7204 | /* Update timer values in neighbor structure. */ | |
7205 | if (nbr_str) { | |
b5a8894d CS |
7206 | struct ospf *ospf = NULL; |
7207 | ||
7208 | ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); | |
7209 | if (ospf) { | |
d62a17ae | 7210 | oi = ospf_if_lookup_by_local_addr(ospf, ifp, addr); |
7211 | if (oi) | |
7212 | ospf_nbr_timer_update(oi); | |
7213 | } | |
7214 | } else { | |
7215 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) | |
7216 | if ((oi = rn->info)) | |
7217 | ospf_nbr_timer_update(oi); | |
7218 | } | |
7219 | ||
7220 | return CMD_SUCCESS; | |
718e3744 | 7221 | } |
7222 | ||
f9ad937f | 7223 | DEFUN (ip_ospf_dead_interval, |
0d829fa7 | 7224 | ip_ospf_dead_interval_cmd, |
7a7be519 | 7225 | "ip ospf dead-interval (1-65535) [A.B.C.D]", |
f9ad937f | 7226 | "IP Information\n" |
7227 | "OSPF interface commands\n" | |
99a522c7 | 7228 | "Interval time after which a neighbor is declared down\n" |
f9ad937f | 7229 | "Seconds\n" |
7230 | "Address of interface\n") | |
7231 | { | |
d62a17ae | 7232 | int idx = 0; |
7233 | char *interval = argv_find(argv, argc, "(1-65535)", &idx) | |
7234 | ? argv[idx]->arg | |
7235 | : NULL; | |
7236 | char *ifaddr = | |
7237 | argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
7238 | return ospf_vty_dead_interval_set(vty, interval, ifaddr, NULL); | |
f9ad937f | 7239 | } |
7240 | ||
718e3744 | 7241 | |
7a7be519 | 7242 | DEFUN_HIDDEN (ospf_dead_interval, |
747e489c | 7243 | ospf_dead_interval_cmd, |
0d829fa7 | 7244 | "ospf dead-interval (1-65535) [A.B.C.D]", |
747e489c | 7245 | "OSPF interface commands\n" |
99a522c7 | 7246 | "Interval time after which a neighbor is declared down\n" |
0d829fa7 QY |
7247 | "Seconds\n" |
7248 | "Address of interface\n") | |
7a7be519 | 7249 | { |
d62a17ae | 7250 | return ip_ospf_dead_interval(self, vty, argc, argv); |
7a7be519 | 7251 | } |
718e3744 | 7252 | |
f9ad937f | 7253 | DEFUN (ip_ospf_dead_interval_minimal, |
7254 | ip_ospf_dead_interval_minimal_addr_cmd, | |
7a7be519 | 7255 | "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]", |
f9ad937f | 7256 | "IP Information\n" |
7257 | "OSPF interface commands\n" | |
99a522c7 | 7258 | "Interval time after which a neighbor is declared down\n" |
f9ad937f | 7259 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
7260 | "Hello multiplier factor\n" | |
7261 | "Number of Hellos to send each second\n" | |
7262 | "Address of interface\n") | |
7263 | { | |
d62a17ae | 7264 | int idx_number = 5; |
7265 | int idx_ipv4 = 6; | |
7266 | if (argc == 7) | |
7267 | return ospf_vty_dead_interval_set( | |
7268 | vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); | |
7269 | else | |
7270 | return ospf_vty_dead_interval_set(vty, NULL, NULL, | |
7271 | argv[idx_number]->arg); | |
f9ad937f | 7272 | } |
7273 | ||
718e3744 | 7274 | DEFUN (no_ip_ospf_dead_interval, |
0d829fa7 | 7275 | no_ip_ospf_dead_interval_cmd, |
e83a9414 | 7276 | "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", |
718e3744 | 7277 | NO_STR |
7278 | "IP Information\n" | |
7279 | "OSPF interface commands\n" | |
99a522c7 | 7280 | "Interval time after which a neighbor is declared down\n" |
f9dfba8d | 7281 | "Seconds\n" |
efd7904e RW |
7282 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
7283 | "Hello multiplier factor\n" | |
7284 | "Number of Hellos to send each second\n" | |
7285 | "Address of interface\n") | |
718e3744 | 7286 | { |
d62a17ae | 7287 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7288 | int idx_ipv4 = argc - 1; | |
7289 | struct in_addr addr = {.s_addr = 0L}; | |
7290 | int ret; | |
7291 | struct ospf_if_params *params; | |
7292 | struct ospf_interface *oi; | |
7293 | struct route_node *rn; | |
7294 | ||
7295 | params = IF_DEF_PARAMS(ifp); | |
7296 | ||
7297 | if (argv[idx_ipv4]->type == IPV4_TKN) { | |
7298 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
7299 | if (!ret) { | |
7300 | vty_out(vty, | |
7301 | "Please specify interface address by A.B.C.D\n"); | |
7302 | return CMD_WARNING_CONFIG_FAILED; | |
7303 | } | |
020709f9 | 7304 | |
d62a17ae | 7305 | params = ospf_lookup_if_params(ifp, addr); |
7306 | if (params == NULL) | |
7307 | return CMD_SUCCESS; | |
7308 | } | |
718e3744 | 7309 | |
d62a17ae | 7310 | UNSET_IF_PARAM(params, v_wait); |
7311 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
7312 | ||
7313 | UNSET_IF_PARAM(params, fast_hello); | |
7314 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
7315 | ||
7316 | if (params != IF_DEF_PARAMS(ifp)) { | |
7317 | ospf_free_if_params(ifp, addr); | |
7318 | ospf_if_update_params(ifp, addr); | |
718e3744 | 7319 | } |
7320 | ||
d62a17ae | 7321 | /* Update timer values in neighbor structure. */ |
7322 | if (argc == 1) { | |
b5a8894d | 7323 | struct ospf *ospf = NULL; |
718e3744 | 7324 | |
b5a8894d CS |
7325 | ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); |
7326 | if (ospf) { | |
d62a17ae | 7327 | oi = ospf_if_lookup_by_local_addr(ospf, ifp, addr); |
7328 | if (oi) | |
7329 | ospf_nbr_timer_update(oi); | |
7330 | } | |
7331 | } else { | |
7332 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) | |
7333 | if ((oi = rn->info)) | |
7334 | ospf_nbr_timer_update(oi); | |
7335 | } | |
7336 | ||
7337 | return CMD_SUCCESS; | |
718e3744 | 7338 | } |
7339 | ||
0d829fa7 QY |
7340 | DEFUN_HIDDEN (no_ospf_dead_interval, |
7341 | no_ospf_dead_interval_cmd, | |
7342 | "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", | |
7343 | NO_STR | |
7344 | "OSPF interface commands\n" | |
99a522c7 | 7345 | "Interval time after which a neighbor is declared down\n" |
0d829fa7 | 7346 | "Seconds\n" |
efd7904e RW |
7347 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
7348 | "Hello multiplier factor\n" | |
7349 | "Number of Hellos to send each second\n" | |
7350 | "Address of interface\n") | |
0d829fa7 | 7351 | { |
d62a17ae | 7352 | return no_ip_ospf_dead_interval(self, vty, argc, argv); |
0d829fa7 QY |
7353 | } |
7354 | ||
718e3744 | 7355 | DEFUN (ip_ospf_hello_interval, |
0d829fa7 | 7356 | ip_ospf_hello_interval_cmd, |
7a7be519 | 7357 | "ip ospf hello-interval (1-65535) [A.B.C.D]", |
718e3744 | 7358 | "IP Information\n" |
7359 | "OSPF interface commands\n" | |
7360 | "Time between HELLO packets\n" | |
7361 | "Seconds\n" | |
0d829fa7 | 7362 | "Address of interface\n") |
718e3744 | 7363 | { |
d62a17ae | 7364 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7365 | int idx = 0; | |
7366 | struct in_addr addr; | |
7367 | struct ospf_if_params *params; | |
7368 | params = IF_DEF_PARAMS(ifp); | |
7369 | u_int32_t seconds = 0; | |
7370 | ||
7371 | argv_find(argv, argc, "(1-65535)", &idx); | |
7372 | seconds = strtol(argv[idx]->arg, NULL, 10); | |
7373 | ||
7374 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7375 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7376 | vty_out(vty, | |
7377 | "Please specify interface address by A.B.C.D\n"); | |
7378 | return CMD_WARNING_CONFIG_FAILED; | |
7379 | } | |
718e3744 | 7380 | |
d62a17ae | 7381 | params = ospf_get_if_params(ifp, addr); |
7382 | ospf_if_update_params(ifp, addr); | |
7383 | } | |
718e3744 | 7384 | |
d62a17ae | 7385 | SET_IF_PARAM(params, v_hello); |
7386 | params->v_hello = seconds; | |
718e3744 | 7387 | |
d62a17ae | 7388 | return CMD_SUCCESS; |
718e3744 | 7389 | } |
7390 | ||
7a7be519 | 7391 | DEFUN_HIDDEN (ospf_hello_interval, |
747e489c | 7392 | ospf_hello_interval_cmd, |
0d829fa7 | 7393 | "ospf hello-interval (1-65535) [A.B.C.D]", |
747e489c DW |
7394 | "OSPF interface commands\n" |
7395 | "Time between HELLO packets\n" | |
0d829fa7 QY |
7396 | "Seconds\n" |
7397 | "Address of interface\n") | |
7a7be519 | 7398 | { |
d62a17ae | 7399 | return ip_ospf_hello_interval(self, vty, argc, argv); |
7a7be519 | 7400 | } |
718e3744 | 7401 | |
7402 | DEFUN (no_ip_ospf_hello_interval, | |
0d829fa7 QY |
7403 | no_ip_ospf_hello_interval_cmd, |
7404 | "no ip ospf hello-interval [(1-65535) [A.B.C.D]]", | |
718e3744 | 7405 | NO_STR |
7406 | "IP Information\n" | |
7407 | "OSPF interface commands\n" | |
0d829fa7 | 7408 | "Time between HELLO packets\n" // ignored |
f9dfba8d | 7409 | "Seconds\n" |
0d829fa7 | 7410 | "Address of interface\n") |
718e3744 | 7411 | { |
d62a17ae | 7412 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7413 | int idx = 0; | |
7414 | struct in_addr addr; | |
7415 | struct ospf_if_params *params; | |
df581cd3 | 7416 | |
d62a17ae | 7417 | params = IF_DEF_PARAMS(ifp); |
718e3744 | 7418 | |
d62a17ae | 7419 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { |
7420 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7421 | vty_out(vty, | |
7422 | "Please specify interface address by A.B.C.D\n"); | |
7423 | return CMD_WARNING_CONFIG_FAILED; | |
7424 | } | |
718e3744 | 7425 | |
d62a17ae | 7426 | params = ospf_lookup_if_params(ifp, addr); |
7427 | if (params == NULL) | |
7428 | return CMD_SUCCESS; | |
7429 | } | |
718e3744 | 7430 | |
d62a17ae | 7431 | UNSET_IF_PARAM(params, v_hello); |
7432 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; | |
718e3744 | 7433 | |
d62a17ae | 7434 | if (params != IF_DEF_PARAMS(ifp)) { |
7435 | ospf_free_if_params(ifp, addr); | |
7436 | ospf_if_update_params(ifp, addr); | |
7437 | } | |
718e3744 | 7438 | |
d62a17ae | 7439 | return CMD_SUCCESS; |
718e3744 | 7440 | } |
7441 | ||
0d829fa7 QY |
7442 | DEFUN_HIDDEN (no_ospf_hello_interval, |
7443 | no_ospf_hello_interval_cmd, | |
7444 | "no ospf hello-interval [(1-65535) [A.B.C.D]]", | |
7445 | NO_STR | |
7446 | "OSPF interface commands\n" | |
7447 | "Time between HELLO packets\n" // ignored | |
7448 | "Seconds\n" | |
7449 | "Address of interface\n") | |
7450 | { | |
d62a17ae | 7451 | return no_ip_ospf_hello_interval(self, vty, argc, argv); |
0d829fa7 | 7452 | } |
718e3744 | 7453 | |
7454 | DEFUN (ip_ospf_network, | |
7455 | ip_ospf_network_cmd, | |
6147e2c6 | 7456 | "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
718e3744 | 7457 | "IP Information\n" |
7458 | "OSPF interface commands\n" | |
7459 | "Network type\n" | |
7460 | "Specify OSPF broadcast multi-access network\n" | |
7461 | "Specify OSPF NBMA network\n" | |
7462 | "Specify OSPF point-to-multipoint network\n" | |
7463 | "Specify OSPF point-to-point network\n") | |
7464 | { | |
d62a17ae | 7465 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7466 | int idx = 0; | |
7467 | int old_type = IF_DEF_PARAMS(ifp)->type; | |
7468 | struct route_node *rn; | |
718e3744 | 7469 | |
d62a17ae | 7470 | if (old_type == OSPF_IFTYPE_LOOPBACK) { |
7471 | vty_out(vty, | |
7472 | "This is a loopback interface. Can't set network type.\n"); | |
7473 | return CMD_WARNING_CONFIG_FAILED; | |
7474 | } | |
718e3744 | 7475 | |
d62a17ae | 7476 | if (argv_find(argv, argc, "broadcast", &idx)) |
7477 | IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_BROADCAST; | |
7478 | else if (argv_find(argv, argc, "non-broadcast", &idx)) | |
7479 | IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_NBMA; | |
7480 | else if (argv_find(argv, argc, "point-to-multipoint", &idx)) | |
7481 | IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; | |
7482 | else if (argv_find(argv, argc, "point-to-point", &idx)) | |
7483 | IF_DEF_PARAMS(ifp)->type = OSPF_IFTYPE_POINTOPOINT; | |
718e3744 | 7484 | |
d62a17ae | 7485 | if (IF_DEF_PARAMS(ifp)->type == old_type) |
7486 | return CMD_SUCCESS; | |
7487 | ||
7488 | SET_IF_PARAM(IF_DEF_PARAMS(ifp), type); | |
7489 | ||
7490 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
7491 | struct ospf_interface *oi = rn->info; | |
7492 | ||
7493 | if (!oi) | |
7494 | continue; | |
7495 | ||
7496 | oi->type = IF_DEF_PARAMS(ifp)->type; | |
7497 | ||
7498 | if (oi->state > ISM_Down) { | |
7499 | OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceDown); | |
7500 | OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceUp); | |
7501 | } | |
7a7be519 | 7502 | } |
7a7be519 | 7503 | |
d62a17ae | 7504 | return CMD_SUCCESS; |
7a7be519 | 7505 | } |
7506 | ||
7507 | DEFUN_HIDDEN (ospf_network, | |
7508 | ospf_network_cmd, | |
e83a9414 | 7509 | "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
7a7be519 | 7510 | "OSPF interface commands\n" |
7511 | "Network type\n" | |
7512 | "Specify OSPF broadcast multi-access network\n" | |
7513 | "Specify OSPF NBMA network\n" | |
7514 | "Specify OSPF point-to-multipoint network\n" | |
7515 | "Specify OSPF point-to-point network\n") | |
7516 | { | |
d62a17ae | 7517 | return ip_ospf_network(self, vty, argc, argv); |
7a7be519 | 7518 | } |
7519 | ||
7520 | DEFUN (no_ip_ospf_network, | |
7521 | no_ip_ospf_network_cmd, | |
7522 | "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
7523 | NO_STR | |
7524 | "IP Information\n" | |
7525 | "OSPF interface commands\n" | |
7526 | "Network type\n" | |
7527 | "Specify OSPF broadcast multi-access network\n" | |
7528 | "Specify OSPF NBMA network\n" | |
7529 | "Specify OSPF point-to-multipoint network\n" | |
7530 | "Specify OSPF point-to-point network\n") | |
22b27e95 | 7531 | { |
d62a17ae | 7532 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7533 | int old_type = IF_DEF_PARAMS(ifp)->type; | |
7534 | struct route_node *rn; | |
7a7be519 | 7535 | |
d62a17ae | 7536 | IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp); |
7a7be519 | 7537 | |
d62a17ae | 7538 | if (IF_DEF_PARAMS(ifp)->type == old_type) |
7539 | return CMD_SUCCESS; | |
7a7be519 | 7540 | |
d62a17ae | 7541 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { |
7542 | struct ospf_interface *oi = rn->info; | |
7a7be519 | 7543 | |
d62a17ae | 7544 | if (!oi) |
7545 | continue; | |
7a7be519 | 7546 | |
d62a17ae | 7547 | oi->type = IF_DEF_PARAMS(ifp)->type; |
7a7be519 | 7548 | |
d62a17ae | 7549 | if (oi->state > ISM_Down) { |
7550 | OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceDown); | |
7551 | OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceUp); | |
7552 | } | |
7a7be519 | 7553 | } |
7a7be519 | 7554 | |
d62a17ae | 7555 | return CMD_SUCCESS; |
7a7be519 | 7556 | } |
7557 | ||
0d829fa7 QY |
7558 | DEFUN_HIDDEN (no_ospf_network, |
7559 | no_ospf_network_cmd, | |
7560 | "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
7561 | NO_STR | |
7562 | "OSPF interface commands\n" | |
7563 | "Network type\n" | |
7564 | "Specify OSPF broadcast multi-access network\n" | |
7565 | "Specify OSPF NBMA network\n" | |
7566 | "Specify OSPF point-to-multipoint network\n" | |
7567 | "Specify OSPF point-to-point network\n") | |
7568 | { | |
d62a17ae | 7569 | return no_ip_ospf_network(self, vty, argc, argv); |
0d829fa7 QY |
7570 | } |
7571 | ||
7a7be519 | 7572 | DEFUN (ip_ospf_priority, |
537eae3f | 7573 | ip_ospf_priority_cmd, |
7a7be519 | 7574 | "ip ospf priority (0-255) [A.B.C.D]", |
7575 | "IP Information\n" | |
7576 | "OSPF interface commands\n" | |
7577 | "Router priority\n" | |
7578 | "Priority\n" | |
efd7904e | 7579 | "Address of interface\n") |
7a7be519 | 7580 | { |
d62a17ae | 7581 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7582 | int idx = 0; | |
7583 | long priority; | |
7584 | struct route_node *rn; | |
7585 | struct in_addr addr; | |
7586 | struct ospf_if_params *params; | |
7587 | params = IF_DEF_PARAMS(ifp); | |
7588 | ||
7589 | argv_find(argv, argc, "(0-255)", &idx); | |
7590 | priority = strtol(argv[idx]->arg, NULL, 10); | |
7591 | ||
7592 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7593 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7594 | vty_out(vty, | |
7595 | "Please specify interface address by A.B.C.D\n"); | |
7596 | return CMD_WARNING_CONFIG_FAILED; | |
7597 | } | |
7a7be519 | 7598 | |
d62a17ae | 7599 | params = ospf_get_if_params(ifp, addr); |
7600 | ospf_if_update_params(ifp, addr); | |
7a7be519 | 7601 | } |
7602 | ||
d62a17ae | 7603 | SET_IF_PARAM(params, priority); |
7604 | params->priority = priority; | |
7a7be519 | 7605 | |
d62a17ae | 7606 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { |
7607 | struct ospf_interface *oi = rn->info; | |
7a7be519 | 7608 | |
d62a17ae | 7609 | if (!oi) |
7610 | continue; | |
7a7be519 | 7611 | |
d62a17ae | 7612 | if (PRIORITY(oi) != OSPF_IF_PARAM(oi, priority)) { |
7613 | PRIORITY(oi) = OSPF_IF_PARAM(oi, priority); | |
7614 | OSPF_ISM_EVENT_SCHEDULE(oi, ISM_NeighborChange); | |
7615 | } | |
718e3744 | 7616 | } |
718e3744 | 7617 | |
d62a17ae | 7618 | return CMD_SUCCESS; |
718e3744 | 7619 | } |
7620 | ||
7a7be519 | 7621 | DEFUN_HIDDEN (ospf_priority, |
7622 | ospf_priority_cmd, | |
0d829fa7 | 7623 | "ospf priority (0-255) [A.B.C.D]", |
7a7be519 | 7624 | "OSPF interface commands\n" |
7625 | "Router priority\n" | |
3a2d747c | 7626 | "Priority\n" |
efd7904e | 7627 | "Address of interface\n") |
718e3744 | 7628 | { |
d62a17ae | 7629 | return ip_ospf_priority(self, vty, argc, argv); |
718e3744 | 7630 | } |
7631 | ||
718e3744 | 7632 | DEFUN (no_ip_ospf_priority, |
537eae3f | 7633 | no_ip_ospf_priority_cmd, |
7a7be519 | 7634 | "no ip ospf priority [(0-255) [A.B.C.D]]", |
718e3744 | 7635 | NO_STR |
7636 | "IP Information\n" | |
7637 | "OSPF interface commands\n" | |
0d829fa7 | 7638 | "Router priority\n" // ignored |
813d4307 | 7639 | "Priority\n" |
efd7904e | 7640 | "Address of interface\n") |
718e3744 | 7641 | { |
d62a17ae | 7642 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7643 | int idx = 0; | |
7644 | struct route_node *rn; | |
7645 | struct in_addr addr; | |
7646 | struct ospf_if_params *params; | |
7647 | ||
7648 | params = IF_DEF_PARAMS(ifp); | |
7649 | ||
7650 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7651 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7652 | vty_out(vty, | |
7653 | "Please specify interface address by A.B.C.D\n"); | |
7654 | return CMD_WARNING_CONFIG_FAILED; | |
7655 | } | |
7656 | ||
7657 | params = ospf_lookup_if_params(ifp, addr); | |
7658 | if (params == NULL) | |
7659 | return CMD_SUCCESS; | |
718e3744 | 7660 | } |
7661 | ||
d62a17ae | 7662 | UNSET_IF_PARAM(params, priority); |
7663 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
7664 | ||
7665 | if (params != IF_DEF_PARAMS(ifp)) { | |
7666 | ospf_free_if_params(ifp, addr); | |
7667 | ospf_if_update_params(ifp, addr); | |
718e3744 | 7668 | } |
d62a17ae | 7669 | |
7670 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { | |
7671 | struct ospf_interface *oi = rn->info; | |
7672 | ||
7673 | if (!oi) | |
7674 | continue; | |
7675 | ||
7676 | if (PRIORITY(oi) != OSPF_IF_PARAM(oi, priority)) { | |
7677 | PRIORITY(oi) = OSPF_IF_PARAM(oi, priority); | |
7678 | OSPF_ISM_EVENT_SCHEDULE(oi, ISM_NeighborChange); | |
7679 | } | |
7680 | } | |
7681 | ||
7682 | return CMD_SUCCESS; | |
718e3744 | 7683 | } |
7684 | ||
0d829fa7 | 7685 | DEFUN_HIDDEN (no_ospf_priority, |
537eae3f | 7686 | no_ospf_priority_cmd, |
0d829fa7 QY |
7687 | "no ospf priority [(0-255) [A.B.C.D]]", |
7688 | NO_STR | |
7689 | "OSPF interface commands\n" | |
7690 | "Router priority\n" | |
7691 | "Priority\n" | |
efd7904e | 7692 | "Address of interface\n") |
0d829fa7 | 7693 | { |
d62a17ae | 7694 | return no_ip_ospf_priority(self, vty, argc, argv); |
0d829fa7 | 7695 | } |
a1afa410 | 7696 | |
718e3744 | 7697 | DEFUN (ip_ospf_retransmit_interval, |
7698 | ip_ospf_retransmit_interval_addr_cmd, | |
7a7be519 | 7699 | "ip ospf retransmit-interval (3-65535) [A.B.C.D]", |
718e3744 | 7700 | "IP Information\n" |
7701 | "OSPF interface commands\n" | |
7702 | "Time between retransmitting lost link state advertisements\n" | |
7703 | "Seconds\n" | |
efd7904e | 7704 | "Address of interface\n") |
718e3744 | 7705 | { |
d62a17ae | 7706 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7707 | int idx = 0; | |
7708 | u_int32_t seconds; | |
7709 | struct in_addr addr; | |
7710 | struct ospf_if_params *params; | |
7711 | params = IF_DEF_PARAMS(ifp); | |
7712 | ||
7713 | argv_find(argv, argc, "(3-65535)", &idx); | |
7714 | seconds = strtol(argv[idx]->arg, NULL, 10); | |
7715 | ||
7716 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7717 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7718 | vty_out(vty, | |
7719 | "Please specify interface address by A.B.C.D\n"); | |
7720 | return CMD_WARNING_CONFIG_FAILED; | |
7721 | } | |
718e3744 | 7722 | |
d62a17ae | 7723 | params = ospf_get_if_params(ifp, addr); |
7724 | ospf_if_update_params(ifp, addr); | |
718e3744 | 7725 | } |
7726 | ||
d62a17ae | 7727 | SET_IF_PARAM(params, retransmit_interval); |
7728 | params->retransmit_interval = seconds; | |
718e3744 | 7729 | |
d62a17ae | 7730 | return CMD_SUCCESS; |
718e3744 | 7731 | } |
7732 | ||
7a7be519 | 7733 | DEFUN_HIDDEN (ospf_retransmit_interval, |
747e489c | 7734 | ospf_retransmit_interval_cmd, |
0d829fa7 | 7735 | "ospf retransmit-interval (3-65535) [A.B.C.D]", |
747e489c DW |
7736 | "OSPF interface commands\n" |
7737 | "Time between retransmitting lost link state advertisements\n" | |
3a2d747c | 7738 | "Seconds\n" |
efd7904e | 7739 | "Address of interface\n") |
7a7be519 | 7740 | { |
d62a17ae | 7741 | return ip_ospf_retransmit_interval(self, vty, argc, argv); |
7a7be519 | 7742 | } |
718e3744 | 7743 | |
7744 | DEFUN (no_ip_ospf_retransmit_interval, | |
7745 | no_ip_ospf_retransmit_interval_addr_cmd, | |
0d829fa7 | 7746 | "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]", |
718e3744 | 7747 | NO_STR |
7748 | "IP Information\n" | |
7749 | "OSPF interface commands\n" | |
3a2d747c QY |
7750 | "Time between retransmitting lost link state advertisements\n" |
7751 | "Seconds\n" | |
0d829fa7 | 7752 | "Address of interface\n") |
718e3744 | 7753 | { |
d62a17ae | 7754 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7755 | int idx = 0; | |
7756 | struct in_addr addr; | |
7757 | struct ospf_if_params *params; | |
47b91972 | 7758 | |
d62a17ae | 7759 | params = IF_DEF_PARAMS(ifp); |
718e3744 | 7760 | |
d62a17ae | 7761 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { |
7762 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7763 | vty_out(vty, | |
7764 | "Please specify interface address by A.B.C.D\n"); | |
7765 | return CMD_WARNING_CONFIG_FAILED; | |
7766 | } | |
718e3744 | 7767 | |
d62a17ae | 7768 | params = ospf_lookup_if_params(ifp, addr); |
7769 | if (params == NULL) | |
7770 | return CMD_SUCCESS; | |
7771 | } | |
718e3744 | 7772 | |
d62a17ae | 7773 | UNSET_IF_PARAM(params, retransmit_interval); |
7774 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
718e3744 | 7775 | |
d62a17ae | 7776 | if (params != IF_DEF_PARAMS(ifp)) { |
7777 | ospf_free_if_params(ifp, addr); | |
7778 | ospf_if_update_params(ifp, addr); | |
7779 | } | |
718e3744 | 7780 | |
d62a17ae | 7781 | return CMD_SUCCESS; |
718e3744 | 7782 | } |
7783 | ||
0d829fa7 QY |
7784 | DEFUN_HIDDEN (no_ospf_retransmit_interval, |
7785 | no_ospf_retransmit_interval_cmd, | |
7786 | "no ospf retransmit-interval [(3-65535)] [A.B.C.D]", | |
7787 | NO_STR | |
7788 | "OSPF interface commands\n" | |
3a2d747c QY |
7789 | "Time between retransmitting lost link state advertisements\n" |
7790 | "Seconds\n" | |
7791 | "Address of interface\n") | |
0d829fa7 | 7792 | { |
d62a17ae | 7793 | return no_ip_ospf_retransmit_interval(self, vty, argc, argv); |
0d829fa7 | 7794 | } |
813d4307 | 7795 | |
718e3744 | 7796 | DEFUN (ip_ospf_transmit_delay, |
7797 | ip_ospf_transmit_delay_addr_cmd, | |
7a7be519 | 7798 | "ip ospf transmit-delay (1-65535) [A.B.C.D]", |
718e3744 | 7799 | "IP Information\n" |
7800 | "OSPF interface commands\n" | |
7801 | "Link state transmit delay\n" | |
7802 | "Seconds\n" | |
efd7904e | 7803 | "Address of interface\n") |
718e3744 | 7804 | { |
d62a17ae | 7805 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7806 | int idx = 0; | |
7807 | u_int32_t seconds; | |
7808 | struct in_addr addr; | |
7809 | struct ospf_if_params *params; | |
7810 | ||
7811 | params = IF_DEF_PARAMS(ifp); | |
7812 | argv_find(argv, argc, "(1-65535)", &idx); | |
7813 | seconds = strtol(argv[idx]->arg, NULL, 10); | |
7814 | ||
7815 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7816 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7817 | vty_out(vty, | |
7818 | "Please specify interface address by A.B.C.D\n"); | |
7819 | return CMD_WARNING_CONFIG_FAILED; | |
7820 | } | |
718e3744 | 7821 | |
d62a17ae | 7822 | params = ospf_get_if_params(ifp, addr); |
7823 | ospf_if_update_params(ifp, addr); | |
718e3744 | 7824 | } |
7825 | ||
d62a17ae | 7826 | SET_IF_PARAM(params, transmit_delay); |
7827 | params->transmit_delay = seconds; | |
718e3744 | 7828 | |
d62a17ae | 7829 | return CMD_SUCCESS; |
718e3744 | 7830 | } |
7831 | ||
7a7be519 | 7832 | DEFUN_HIDDEN (ospf_transmit_delay, |
747e489c | 7833 | ospf_transmit_delay_cmd, |
0d829fa7 | 7834 | "ospf transmit-delay (1-65535) [A.B.C.D]", |
747e489c DW |
7835 | "OSPF interface commands\n" |
7836 | "Link state transmit delay\n" | |
3a2d747c | 7837 | "Seconds\n" |
efd7904e | 7838 | "Address of interface\n") |
7a7be519 | 7839 | { |
d62a17ae | 7840 | return ip_ospf_transmit_delay(self, vty, argc, argv); |
7a7be519 | 7841 | } |
718e3744 | 7842 | |
7843 | DEFUN (no_ip_ospf_transmit_delay, | |
7844 | no_ip_ospf_transmit_delay_addr_cmd, | |
0d829fa7 | 7845 | "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]", |
718e3744 | 7846 | NO_STR |
7847 | "IP Information\n" | |
7848 | "OSPF interface commands\n" | |
7849 | "Link state transmit delay\n" | |
efd7904e RW |
7850 | "Seconds\n" |
7851 | "Address of interface\n") | |
718e3744 | 7852 | { |
d62a17ae | 7853 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7854 | int idx = 0; | |
7855 | struct in_addr addr; | |
7856 | struct ospf_if_params *params; | |
718e3744 | 7857 | |
d62a17ae | 7858 | params = IF_DEF_PARAMS(ifp); |
718e3744 | 7859 | |
d62a17ae | 7860 | if (argv_find(argv, argc, "A.B.C.D", &idx)) { |
7861 | if (!inet_aton(argv[idx]->arg, &addr)) { | |
7862 | vty_out(vty, | |
7863 | "Please specify interface address by A.B.C.D\n"); | |
7864 | return CMD_WARNING_CONFIG_FAILED; | |
7865 | } | |
718e3744 | 7866 | |
d62a17ae | 7867 | params = ospf_lookup_if_params(ifp, addr); |
7868 | if (params == NULL) | |
7869 | return CMD_SUCCESS; | |
7870 | } | |
718e3744 | 7871 | |
d62a17ae | 7872 | UNSET_IF_PARAM(params, transmit_delay); |
7873 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
718e3744 | 7874 | |
d62a17ae | 7875 | if (params != IF_DEF_PARAMS(ifp)) { |
7876 | ospf_free_if_params(ifp, addr); | |
7877 | ospf_if_update_params(ifp, addr); | |
7878 | } | |
7879 | ||
7880 | return CMD_SUCCESS; | |
718e3744 | 7881 | } |
7882 | ||
813d4307 | 7883 | |
0d829fa7 QY |
7884 | DEFUN_HIDDEN (no_ospf_transmit_delay, |
7885 | no_ospf_transmit_delay_cmd, | |
32573073 | 7886 | "no ospf transmit-delay [(1-65535) [A.B.C.D]]", |
0d829fa7 QY |
7887 | NO_STR |
7888 | "OSPF interface commands\n" | |
32573073 QY |
7889 | "Link state transmit delay\n" |
7890 | "Seconds\n" | |
efd7904e | 7891 | "Address of interface\n") |
813d4307 | 7892 | { |
d62a17ae | 7893 | return no_ip_ospf_transmit_delay(self, vty, argc, argv); |
813d4307 DW |
7894 | } |
7895 | ||
e723861d DS |
7896 | DEFUN (ip_ospf_area, |
7897 | ip_ospf_area_cmd, | |
52c62ab8 | 7898 | "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]", |
e723861d DS |
7899 | "IP Information\n" |
7900 | "OSPF interface commands\n" | |
7a7be519 | 7901 | "Instance ID\n" |
e723861d DS |
7902 | "Enable OSPF on this interface\n" |
7903 | "OSPF area ID in IP address format\n" | |
52c62ab8 JAG |
7904 | "OSPF area ID as a decimal value\n" |
7905 | "Address of interface\n") | |
e723861d | 7906 | { |
d62a17ae | 7907 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7908 | int idx = 0; | |
7909 | int format, ret; | |
7910 | struct in_addr area_id; | |
7911 | struct in_addr addr; | |
35955c14 | 7912 | struct ospf_if_params *params = NULL; |
d62a17ae | 7913 | struct route_node *rn; |
b5a8894d | 7914 | struct ospf *ospf = NULL; |
d62a17ae | 7915 | u_short instance = 0; |
7916 | char *areaid; | |
7917 | ||
7918 | if (argv_find(argv, argc, "(1-65535)", &idx)) | |
7919 | instance = strtol(argv[idx]->arg, NULL, 10); | |
7920 | ||
7921 | argv_find(argv, argc, "area", &idx); | |
7922 | areaid = argv[idx + 1]->arg; | |
7923 | ||
b5a8894d CS |
7924 | if (ifp->vrf_id && !instance) |
7925 | ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); | |
7926 | else | |
7927 | ospf = ospf_lookup_instance(instance); | |
7928 | ||
aed7cc62 | 7929 | if (instance && ospf == NULL) { |
d62a17ae | 7930 | params = IF_DEF_PARAMS(ifp); |
7931 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) { | |
7932 | UNSET_IF_PARAM(params, if_area); | |
b5a8894d CS |
7933 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); |
7934 | ospf_interface_area_unset(ospf, ifp); | |
d62a17ae | 7935 | ospf->if_ospf_cli_count--; |
7936 | } | |
ac28e4ec | 7937 | return CMD_NOT_MY_INSTANCE; |
d62a17ae | 7938 | } |
e723861d | 7939 | |
d62a17ae | 7940 | ret = str2area_id(areaid, &area_id, &format); |
7941 | if (ret < 0) { | |
7942 | vty_out(vty, "Please specify area by A.B.C.D|<0-4294967295>\n"); | |
7943 | return CMD_WARNING_CONFIG_FAILED; | |
7944 | } | |
7945 | if (memcmp(ifp->name, "VLINK", 5) == 0) { | |
7946 | vty_out(vty, "Cannot enable OSPF on a virtual link.\n"); | |
7947 | return CMD_WARNING_CONFIG_FAILED; | |
7948 | } | |
7949 | ||
7950 | params = IF_DEF_PARAMS(ifp); | |
7951 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area) | |
7952 | && !IPV4_ADDR_SAME(¶ms->if_area, &area_id)) { | |
7953 | vty_out(vty, | |
7954 | "Must remove previous area config before changing ospf area \n"); | |
7955 | return CMD_WARNING_CONFIG_FAILED; | |
7956 | } | |
7957 | ||
7958 | // Check if we have an address arg and proccess it | |
7959 | if (argc == idx + 3) { | |
cc9b06ad | 7960 | if (!inet_aton(argv[idx + 2]->arg, &addr)) { |
996c9314 LB |
7961 | vty_out(vty, |
7962 | "Please specify Intf Address by A.B.C.D\n"); | |
cc9b06ad DS |
7963 | return CMD_WARNING_CONFIG_FAILED; |
7964 | } | |
d62a17ae | 7965 | // update/create address-level params |
7966 | params = ospf_get_if_params((ifp), (addr)); | |
7967 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) { | |
7968 | vty_out(vty, | |
7969 | "Must remove previous area/address config before changing ospf area"); | |
7970 | return CMD_WARNING_CONFIG_FAILED; | |
7971 | } | |
7972 | ospf_if_update_params((ifp), (addr)); | |
7973 | } | |
7974 | ||
aed7cc62 CS |
7975 | if (ospf) { |
7976 | for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) { | |
7977 | if (rn->info != NULL) { | |
7978 | vty_out(vty, | |
7979 | "Please remove all network commands first.\n"); | |
7980 | return CMD_WARNING_CONFIG_FAILED; | |
7981 | } | |
d62a17ae | 7982 | } |
7983 | } | |
7984 | ||
7985 | /* enable ospf on this interface with area_id */ | |
35955c14 CS |
7986 | if (params) { |
7987 | SET_IF_PARAM(params, if_area); | |
7988 | params->if_area = area_id; | |
7989 | params->if_area_id_fmt = format; | |
7990 | } | |
aed7cc62 CS |
7991 | |
7992 | if (ospf) { | |
7993 | ospf_interface_area_set(ospf, ifp); | |
7994 | ospf->if_ospf_cli_count++; | |
7995 | } | |
d62a17ae | 7996 | |
7997 | return CMD_SUCCESS; | |
e723861d DS |
7998 | } |
7999 | ||
8000 | DEFUN (no_ip_ospf_area, | |
8001 | no_ip_ospf_area_cmd, | |
52c62ab8 | 8002 | "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]", |
e723861d DS |
8003 | NO_STR |
8004 | "IP Information\n" | |
8005 | "OSPF interface commands\n" | |
3a2d747c | 8006 | "Instance ID\n" |
7a7be519 | 8007 | "Disable OSPF on this interface\n" |
8008 | "OSPF area ID in IP address format\n" | |
52c62ab8 JAG |
8009 | "OSPF area ID as a decimal value\n" |
8010 | "Address of interface\n") | |
e723861d | 8011 | { |
d62a17ae | 8012 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8013 | int idx = 0; | |
8014 | struct ospf *ospf; | |
8015 | struct ospf_if_params *params; | |
8016 | u_short instance = 0; | |
8017 | struct in_addr addr; | |
8018 | ||
8019 | if (argv_find(argv, argc, "(1-65535)", &idx)) | |
8020 | instance = strtol(argv[idx]->arg, NULL, 10); | |
8021 | ||
b5a8894d CS |
8022 | if (ifp->vrf_id && !instance) |
8023 | ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); | |
8024 | else | |
8025 | ospf = ospf_lookup_instance(instance); | |
8026 | ||
ac28e4ec CS |
8027 | if (ospf == NULL) |
8028 | return CMD_NOT_MY_INSTANCE; | |
d62a17ae | 8029 | |
8030 | argv_find(argv, argc, "area", &idx); | |
8031 | ||
8032 | // Check if we have an address arg and proccess it | |
8033 | if (argc == idx + 3) { | |
cc9b06ad | 8034 | if (!inet_aton(argv[idx + 2]->arg, &addr)) { |
996c9314 LB |
8035 | vty_out(vty, |
8036 | "Please specify Intf Address by A.B.C.D\n"); | |
cc9b06ad DS |
8037 | return CMD_WARNING_CONFIG_FAILED; |
8038 | } | |
d62a17ae | 8039 | params = ospf_lookup_if_params(ifp, addr); |
8040 | if ((params) == NULL) | |
8041 | return CMD_SUCCESS; | |
8042 | } else | |
8043 | params = IF_DEF_PARAMS(ifp); | |
8044 | ||
8045 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) { | |
8046 | vty_out(vty, | |
8047 | "Can't find specified interface area configuration.\n"); | |
8048 | return CMD_WARNING_CONFIG_FAILED; | |
8049 | } | |
813d4307 | 8050 | |
d62a17ae | 8051 | UNSET_IF_PARAM(params, if_area); |
8052 | if (params != IF_DEF_PARAMS((ifp))) { | |
8053 | ospf_free_if_params((ifp), (addr)); | |
8054 | ospf_if_update_params((ifp), (addr)); | |
8055 | } | |
8056 | ||
b5a8894d | 8057 | ospf_interface_area_unset(ospf, ifp); |
d62a17ae | 8058 | ospf->if_ospf_cli_count--; |
8059 | return CMD_SUCCESS; | |
813d4307 DW |
8060 | } |
8061 | ||
6f2a6703 CF |
8062 | DEFUN (ospf_redistribute_source, |
8063 | ospf_redistribute_source_cmd, | |
ea38ced1 | 8064 | "redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
d1c65c21 | 8065 | REDIST_STR |
ab0181ee | 8066 | FRR_REDIST_HELP_STR_OSPFD |
718e3744 | 8067 | "Metric for redistributed routes\n" |
8068 | "OSPF default metric\n" | |
8069 | "OSPF exterior metric type for redistributed routes\n" | |
7111c1a0 | 8070 | "Set OSPF External Type 1/2 metrics\n" |
718e3744 | 8071 | "Route map reference\n" |
8072 | "Pointer to route-map entries\n") | |
8073 | { | |
a3d826f0 | 8074 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8075 | int idx_protocol = 1; |
8076 | int source; | |
8077 | int type = -1; | |
8078 | int metric = -1; | |
8079 | struct ospf_redist *red; | |
8080 | int idx = 0; | |
6f2a6703 | 8081 | |
d62a17ae | 8082 | if (!ospf) |
8083 | return CMD_SUCCESS; | |
8084 | ||
8085 | /* Get distribute source. */ | |
8086 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
8087 | if (source < 0) | |
8088 | return CMD_WARNING_CONFIG_FAILED; | |
8089 | ||
8090 | red = ospf_redist_add(ospf, source, 0); | |
8091 | ||
8092 | /* Get metric value. */ | |
8093 | if (argv_find(argv, argc, "(0-16777214)", &idx)) { | |
8094 | if (!str2metric(argv[idx]->arg, &metric)) | |
8095 | return CMD_WARNING_CONFIG_FAILED; | |
8096 | } | |
951da435 | 8097 | idx = 1; |
d62a17ae | 8098 | /* Get metric type. */ |
ea38ced1 | 8099 | if (argv_find(argv, argc, "(1-2)", &idx)) { |
d62a17ae | 8100 | if (!str2metric_type(argv[idx]->arg, &type)) |
8101 | return CMD_WARNING_CONFIG_FAILED; | |
8102 | } | |
951da435 | 8103 | idx = 1; |
d62a17ae | 8104 | /* Get route-map */ |
ea38ced1 | 8105 | if (argv_find(argv, argc, "WORD", &idx)) { |
d62a17ae | 8106 | ospf_routemap_set(red, argv[idx]->arg); |
8107 | } else | |
8108 | ospf_routemap_unset(red); | |
7c8ff89e | 8109 | |
d62a17ae | 8110 | return ospf_redistribute_set(ospf, source, 0, type, metric); |
718e3744 | 8111 | } |
8112 | ||
718e3744 | 8113 | DEFUN (no_ospf_redistribute_source, |
8114 | no_ospf_redistribute_source_cmd, | |
ea38ced1 | 8115 | "no redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
718e3744 | 8116 | NO_STR |
d1c65c21 | 8117 | REDIST_STR |
ab0181ee | 8118 | FRR_REDIST_HELP_STR_OSPFD |
813d4307 DW |
8119 | "Metric for redistributed routes\n" |
8120 | "OSPF default metric\n" | |
8121 | "OSPF exterior metric type for redistributed routes\n" | |
7111c1a0 | 8122 | "Set OSPF External Type 1/2 metrics\n" |
813d4307 DW |
8123 | "Route map reference\n" |
8124 | "Pointer to route-map entries\n") | |
718e3744 | 8125 | { |
a3d826f0 | 8126 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8127 | int idx_protocol = 2; |
8128 | int source; | |
8129 | struct ospf_redist *red; | |
718e3744 | 8130 | |
d62a17ae | 8131 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
8132 | if (source < 0) | |
8133 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8134 | |
d62a17ae | 8135 | red = ospf_redist_lookup(ospf, source, 0); |
8136 | if (!red) | |
8137 | return CMD_SUCCESS; | |
7c8ff89e | 8138 | |
d62a17ae | 8139 | ospf_routemap_unset(red); |
8140 | return ospf_redistribute_unset(ospf, source, 0); | |
7c8ff89e DS |
8141 | } |
8142 | ||
8143 | DEFUN (ospf_redistribute_instance_source, | |
8144 | ospf_redistribute_instance_source_cmd, | |
1a5ce38b | 8145 | "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
7c8ff89e DS |
8146 | REDIST_STR |
8147 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8148 | "Non-main Kernel Routing Table\n" |
8149 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
8150 | "Metric for redistributed routes\n" |
8151 | "OSPF default metric\n" | |
8152 | "OSPF exterior metric type for redistributed routes\n" | |
7111c1a0 | 8153 | "Set OSPF External Type 1/2 metrics\n" |
7c8ff89e DS |
8154 | "Route map reference\n" |
8155 | "Pointer to route-map entries\n") | |
8156 | { | |
a3d826f0 | 8157 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8158 | int idx_ospf_table = 1; |
8159 | int idx_number = 2; | |
8160 | int idx = 3; | |
8161 | int source; | |
8162 | int type = -1; | |
8163 | int metric = -1; | |
8164 | u_short instance; | |
8165 | struct ospf_redist *red; | |
7c8ff89e | 8166 | |
d62a17ae | 8167 | if (!ospf) |
8168 | return CMD_SUCCESS; | |
d8f70b86 | 8169 | |
d62a17ae | 8170 | source = proto_redistnum(AFI_IP, argv[idx_ospf_table]->text); |
2d627ff5 | 8171 | |
d62a17ae | 8172 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7c8ff89e | 8173 | |
d62a17ae | 8174 | if (!ospf) |
8175 | return CMD_SUCCESS; | |
7c8ff89e | 8176 | |
d62a17ae | 8177 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) { |
8178 | vty_out(vty, | |
8179 | "Instance redistribution in non-instanced OSPF not allowed\n"); | |
8180 | return CMD_WARNING_CONFIG_FAILED; | |
8181 | } | |
7c8ff89e | 8182 | |
d62a17ae | 8183 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) { |
8184 | vty_out(vty, "Same instance OSPF redistribution not allowed\n"); | |
8185 | return CMD_WARNING_CONFIG_FAILED; | |
8186 | } | |
7c8ff89e | 8187 | |
d62a17ae | 8188 | /* Get metric value. */ |
8189 | if (argv_find(argv, argc, "metric", &idx)) | |
8190 | if (!str2metric(argv[idx + 1]->arg, &metric)) | |
8191 | return CMD_WARNING_CONFIG_FAILED; | |
7c8ff89e | 8192 | |
d62a17ae | 8193 | idx = 3; |
8194 | /* Get metric type. */ | |
8195 | if (argv_find(argv, argc, "metric-type", &idx)) | |
8196 | if (!str2metric_type(argv[idx + 1]->arg, &type)) | |
8197 | return CMD_WARNING_CONFIG_FAILED; | |
7c8ff89e | 8198 | |
d62a17ae | 8199 | red = ospf_redist_add(ospf, source, instance); |
7a7be519 | 8200 | |
d62a17ae | 8201 | idx = 3; |
8202 | if (argv_find(argv, argc, "route-map", &idx)) | |
8203 | ospf_routemap_set(red, argv[idx + 1]->arg); | |
8204 | else | |
8205 | ospf_routemap_unset(red); | |
7c8ff89e | 8206 | |
d62a17ae | 8207 | return ospf_redistribute_set(ospf, source, instance, type, metric); |
7c8ff89e DS |
8208 | } |
8209 | ||
8210 | DEFUN (no_ospf_redistribute_instance_source, | |
8211 | no_ospf_redistribute_instance_source_cmd, | |
1a5ce38b | 8212 | "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
7c8ff89e DS |
8213 | NO_STR |
8214 | REDIST_STR | |
8215 | "Open Shortest Path First\n" | |
2d627ff5 DS |
8216 | "Non-main Kernel Routing Table\n" |
8217 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
8218 | "Metric for redistributed routes\n" |
8219 | "OSPF default metric\n" | |
8220 | "OSPF exterior metric type for redistributed routes\n" | |
7111c1a0 | 8221 | "Set OSPF External Type 1/2 metrics\n" |
7c8ff89e DS |
8222 | "Route map reference\n" |
8223 | "Pointer to route-map entries\n") | |
8224 | { | |
a3d826f0 | 8225 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8226 | int idx_ospf_table = 2; |
8227 | int idx_number = 3; | |
8228 | u_int instance; | |
8229 | struct ospf_redist *red; | |
8230 | int source; | |
8231 | ||
8232 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
8233 | source = ZEBRA_ROUTE_OSPF; | |
8234 | else | |
8235 | source = ZEBRA_ROUTE_TABLE; | |
8236 | ||
8237 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
7c8ff89e | 8238 | |
d62a17ae | 8239 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) { |
8240 | vty_out(vty, | |
8241 | "Instance redistribution in non-instanced OSPF not allowed\n"); | |
8242 | return CMD_WARNING_CONFIG_FAILED; | |
8243 | } | |
8244 | ||
8245 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) { | |
8246 | vty_out(vty, "Same instance OSPF redistribution not allowed\n"); | |
8247 | return CMD_WARNING_CONFIG_FAILED; | |
8248 | } | |
8249 | ||
8250 | red = ospf_redist_lookup(ospf, source, instance); | |
8251 | if (!red) | |
8252 | return CMD_SUCCESS; | |
8253 | ||
8254 | ospf_routemap_unset(red); | |
8255 | return ospf_redistribute_unset(ospf, source, instance); | |
718e3744 | 8256 | } |
8257 | ||
8258 | DEFUN (ospf_distribute_list_out, | |
8259 | ospf_distribute_list_out_cmd, | |
40d1cbfb | 8260 | "distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
718e3744 | 8261 | "Filter networks in routing updates\n" |
6f2a6703 CF |
8262 | "Access-list name\n" |
8263 | OUT_STR | |
ab0181ee | 8264 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 8265 | { |
a3d826f0 | 8266 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8267 | int idx_word = 1; |
8268 | int source; | |
718e3744 | 8269 | |
d62a17ae | 8270 | char *proto = argv[argc - 1]->text; |
6d681bd8 | 8271 | |
d62a17ae | 8272 | /* Get distribute source. */ |
8273 | source = proto_redistnum(AFI_IP, proto); | |
8274 | if (source < 0) | |
8275 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8276 | |
d62a17ae | 8277 | return ospf_distribute_list_out_set(ospf, source, argv[idx_word]->arg); |
718e3744 | 8278 | } |
8279 | ||
6f2a6703 CF |
8280 | DEFUN (no_ospf_distribute_list_out, |
8281 | no_ospf_distribute_list_out_cmd, | |
40d1cbfb | 8282 | "no distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
6f2a6703 CF |
8283 | NO_STR |
8284 | "Filter networks in routing updates\n" | |
8285 | "Access-list name\n" | |
8286 | OUT_STR | |
ab0181ee | 8287 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 8288 | { |
a3d826f0 | 8289 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8290 | int idx_word = 2; |
8291 | int source; | |
020709f9 | 8292 | |
d62a17ae | 8293 | char *proto = argv[argc - 1]->text; |
8294 | source = proto_redistnum(AFI_IP, proto); | |
8295 | if (source < 0) | |
8296 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8297 | |
d62a17ae | 8298 | return ospf_distribute_list_out_unset(ospf, source, |
8299 | argv[idx_word]->arg); | |
718e3744 | 8300 | } |
8301 | ||
6f2a6703 CF |
8302 | /* Default information originate. */ |
8303 | DEFUN (ospf_default_information_originate, | |
8304 | ospf_default_information_originate_cmd, | |
ea38ced1 | 8305 | "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
718e3744 | 8306 | "Control distribution of default information\n" |
8307 | "Distribute a default route\n" | |
8308 | "Always advertise default route\n" | |
6f2a6703 CF |
8309 | "OSPF default metric\n" |
8310 | "OSPF metric\n" | |
718e3744 | 8311 | "OSPF metric type for default routes\n" |
7111c1a0 | 8312 | "Set OSPF External Type 1/2 metrics\n" |
718e3744 | 8313 | "Route map reference\n" |
8314 | "Pointer to route-map entries\n") | |
8315 | { | |
a3d826f0 | 8316 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8317 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
8318 | int type = -1; | |
8319 | int metric = -1; | |
8320 | struct ospf_redist *red; | |
8321 | int idx = 0; | |
8322 | ||
8323 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); | |
8324 | ||
8325 | /* Check whether "always" was specified */ | |
8326 | if (argv_find(argv, argc, "always", &idx)) | |
8327 | default_originate = DEFAULT_ORIGINATE_ALWAYS; | |
951da435 | 8328 | idx = 1; |
d62a17ae | 8329 | /* Get metric value */ |
ea38ced1 | 8330 | if (argv_find(argv, argc, "(0-16777214)", &idx)) { |
d62a17ae | 8331 | if (!str2metric(argv[idx]->arg, &metric)) |
8332 | return CMD_WARNING_CONFIG_FAILED; | |
8333 | } | |
951da435 | 8334 | idx = 1; |
d62a17ae | 8335 | /* Get metric type. */ |
ea38ced1 | 8336 | if (argv_find(argv, argc, "(1-2)", &idx)) { |
d62a17ae | 8337 | if (!str2metric_type(argv[idx]->arg, &type)) |
8338 | return CMD_WARNING_CONFIG_FAILED; | |
8339 | } | |
951da435 | 8340 | idx = 1; |
d62a17ae | 8341 | /* Get route-map */ |
ea38ced1 | 8342 | if (argv_find(argv, argc, "WORD", &idx)) |
d62a17ae | 8343 | ospf_routemap_set(red, argv[idx]->arg); |
8344 | else | |
8345 | ospf_routemap_unset(red); | |
8346 | ||
8347 | return ospf_redistribute_default_set(ospf, default_originate, type, | |
8348 | metric); | |
718e3744 | 8349 | } |
8350 | ||
8351 | DEFUN (no_ospf_default_information_originate, | |
8352 | no_ospf_default_information_originate_cmd, | |
ea38ced1 | 8353 | "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
718e3744 | 8354 | NO_STR |
8355 | "Control distribution of default information\n" | |
813d4307 DW |
8356 | "Distribute a default route\n" |
8357 | "Always advertise default route\n" | |
8358 | "OSPF default metric\n" | |
8359 | "OSPF metric\n" | |
8360 | "OSPF metric type for default routes\n" | |
7111c1a0 | 8361 | "Set OSPF External Type 1/2 metrics\n" |
813d4307 DW |
8362 | "Route map reference\n" |
8363 | "Pointer to route-map entries\n") | |
718e3744 | 8364 | { |
a3d826f0 | 8365 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8366 | struct prefix_ipv4 p; |
8367 | struct ospf_external *ext; | |
8368 | struct ospf_redist *red; | |
7c8ff89e | 8369 | |
d62a17ae | 8370 | p.family = AF_INET; |
8371 | p.prefix.s_addr = 0; | |
8372 | p.prefixlen = 0; | |
718e3744 | 8373 | |
d62a17ae | 8374 | ospf_external_lsa_flush(ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 8375 | |
de1ac5fd CS |
8376 | ext = ospf_external_lookup(ospf, DEFAULT_ROUTE, 0); |
8377 | if (ext && EXTERNAL_INFO(ext)) { | |
8378 | ospf_external_info_delete(ospf, DEFAULT_ROUTE, 0, p); | |
8379 | ospf_external_del(ospf, DEFAULT_ROUTE, 0); | |
d62a17ae | 8380 | } |
718e3744 | 8381 | |
d62a17ae | 8382 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8383 | if (!red) | |
8384 | return CMD_SUCCESS; | |
7c8ff89e | 8385 | |
d62a17ae | 8386 | ospf_routemap_unset(red); |
8387 | return ospf_redistribute_default_unset(ospf); | |
718e3744 | 8388 | } |
8389 | ||
8390 | DEFUN (ospf_default_metric, | |
8391 | ospf_default_metric_cmd, | |
6147e2c6 | 8392 | "default-metric (0-16777214)", |
718e3744 | 8393 | "Set metric of redistributed routes\n" |
8394 | "Default metric\n") | |
8395 | { | |
a3d826f0 | 8396 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8397 | int idx_number = 1; |
8398 | int metric = -1; | |
718e3744 | 8399 | |
d62a17ae | 8400 | if (!str2metric(argv[idx_number]->arg, &metric)) |
8401 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8402 | |
d62a17ae | 8403 | ospf->default_metric = metric; |
718e3744 | 8404 | |
d62a17ae | 8405 | return CMD_SUCCESS; |
718e3744 | 8406 | } |
8407 | ||
8408 | DEFUN (no_ospf_default_metric, | |
8409 | no_ospf_default_metric_cmd, | |
7a7be519 | 8410 | "no default-metric [(0-16777214)]", |
718e3744 | 8411 | NO_STR |
7a7be519 | 8412 | "Set metric of redistributed routes\n" |
8413 | "Default metric\n") | |
718e3744 | 8414 | { |
a3d826f0 | 8415 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
68980084 | 8416 | |
d62a17ae | 8417 | ospf->default_metric = -1; |
68980084 | 8418 | |
d62a17ae | 8419 | return CMD_SUCCESS; |
718e3744 | 8420 | } |
8421 | ||
718e3744 | 8422 | |
8423 | DEFUN (ospf_distance, | |
8424 | ospf_distance_cmd, | |
6147e2c6 | 8425 | "distance (1-255)", |
eaa1ae0d | 8426 | "Administrative distance\n" |
718e3744 | 8427 | "OSPF Administrative distance\n") |
8428 | { | |
a3d826f0 | 8429 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8430 | int idx_number = 1; |
68980084 | 8431 | |
d62a17ae | 8432 | ospf->distance_all = atoi(argv[idx_number]->arg); |
68980084 | 8433 | |
d62a17ae | 8434 | return CMD_SUCCESS; |
718e3744 | 8435 | } |
8436 | ||
8437 | DEFUN (no_ospf_distance, | |
8438 | no_ospf_distance_cmd, | |
6147e2c6 | 8439 | "no distance (1-255)", |
718e3744 | 8440 | NO_STR |
eaa1ae0d | 8441 | "Administrative distance\n" |
718e3744 | 8442 | "OSPF Administrative distance\n") |
8443 | { | |
a3d826f0 | 8444 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
68980084 | 8445 | |
d62a17ae | 8446 | ospf->distance_all = 0; |
68980084 | 8447 | |
d62a17ae | 8448 | return CMD_SUCCESS; |
718e3744 | 8449 | } |
8450 | ||
8451 | DEFUN (no_ospf_distance_ospf, | |
8452 | no_ospf_distance_ospf_cmd, | |
eaa1ae0d | 8453 | "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]", |
718e3744 | 8454 | NO_STR |
eaa1ae0d QY |
8455 | "Administrative distance\n" |
8456 | "OSPF administrative distance\n" | |
718e3744 | 8457 | "Intra-area routes\n" |
813d4307 | 8458 | "Distance for intra-area routes\n" |
718e3744 | 8459 | "Inter-area routes\n" |
813d4307 DW |
8460 | "Distance for inter-area routes\n" |
8461 | "External routes\n" | |
8462 | "Distance for external routes\n") | |
718e3744 | 8463 | { |
a3d826f0 | 8464 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8465 | int idx = 0; |
718e3744 | 8466 | |
d62a17ae | 8467 | if (!ospf) |
8468 | return CMD_SUCCESS; | |
7c8ff89e | 8469 | |
d62a17ae | 8470 | if (argv_find(argv, argc, "intra-area", &idx) || argc == 3) |
8471 | idx = ospf->distance_intra = 0; | |
8472 | if (argv_find(argv, argc, "inter-area", &idx) || argc == 3) | |
8473 | idx = ospf->distance_inter = 0; | |
8474 | if (argv_find(argv, argc, "external", &idx) || argc == 3) | |
8475 | ospf->distance_external = 0; | |
718e3744 | 8476 | |
d62a17ae | 8477 | return CMD_SUCCESS; |
718e3744 | 8478 | } |
8479 | ||
6f2a6703 CF |
8480 | DEFUN (ospf_distance_ospf, |
8481 | ospf_distance_ospf_cmd, | |
eaa1ae0d QY |
8482 | "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}", |
8483 | "Administrative distance\n" | |
8484 | "OSPF administrative distance\n" | |
718e3744 | 8485 | "Intra-area routes\n" |
8486 | "Distance for intra-area routes\n" | |
718e3744 | 8487 | "Inter-area routes\n" |
8488 | "Distance for inter-area routes\n" | |
8489 | "External routes\n" | |
718e3744 | 8490 | "Distance for external routes\n") |
8491 | { | |
a3d826f0 | 8492 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8493 | int idx = 0; |
68980084 | 8494 | |
926b88f0 CS |
8495 | ospf->distance_intra = 0; |
8496 | ospf->distance_inter = 0; | |
8497 | ospf->distance_external = 0; | |
8498 | ||
d62a17ae | 8499 | if (argv_find(argv, argc, "intra-area", &idx)) |
8500 | ospf->distance_intra = atoi(argv[idx + 1]->arg); | |
8501 | idx = 0; | |
8502 | if (argv_find(argv, argc, "inter-area", &idx)) | |
8503 | ospf->distance_inter = atoi(argv[idx + 1]->arg); | |
8504 | idx = 0; | |
8505 | if (argv_find(argv, argc, "external", &idx)) | |
8506 | ospf->distance_external = atoi(argv[idx + 1]->arg); | |
68980084 | 8507 | |
d62a17ae | 8508 | return CMD_SUCCESS; |
718e3744 | 8509 | } |
8510 | ||
d7d73ffc | 8511 | #if 0 |
718e3744 | 8512 | DEFUN (ospf_distance_source, |
8513 | ospf_distance_source_cmd, | |
6147e2c6 | 8514 | "distance (1-255) A.B.C.D/M", |
718e3744 | 8515 | "Administrative distance\n" |
8516 | "Distance value\n" | |
8517 | "IP source prefix\n") | |
8518 | { | |
cdc2d765 | 8519 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
8520 | int idx_number = 1; |
8521 | int idx_ipv4_prefixlen = 2; | |
020709f9 | 8522 | |
7c8ff89e DS |
8523 | if (!ospf) |
8524 | return CMD_SUCCESS; | |
8525 | ||
8d769265 | 8526 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
68980084 | 8527 | |
718e3744 | 8528 | return CMD_SUCCESS; |
8529 | } | |
8530 | ||
8531 | DEFUN (no_ospf_distance_source, | |
8532 | no_ospf_distance_source_cmd, | |
6147e2c6 | 8533 | "no distance (1-255) A.B.C.D/M", |
718e3744 | 8534 | NO_STR |
8535 | "Administrative distance\n" | |
8536 | "Distance value\n" | |
8537 | "IP source prefix\n") | |
8538 | { | |
cdc2d765 | 8539 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
8540 | int idx_number = 2; |
8541 | int idx_ipv4_prefixlen = 3; | |
020709f9 | 8542 | |
7c8ff89e DS |
8543 | if (!ospf) |
8544 | return CMD_SUCCESS; | |
8545 | ||
8d769265 | 8546 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
020709f9 | 8547 | |
718e3744 | 8548 | return CMD_SUCCESS; |
8549 | } | |
8550 | ||
8551 | DEFUN (ospf_distance_source_access_list, | |
8552 | ospf_distance_source_access_list_cmd, | |
6147e2c6 | 8553 | "distance (1-255) A.B.C.D/M WORD", |
718e3744 | 8554 | "Administrative distance\n" |
8555 | "Distance value\n" | |
8556 | "IP source prefix\n" | |
8557 | "Access list name\n") | |
8558 | { | |
cdc2d765 | 8559 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
8560 | int idx_number = 1; |
8561 | int idx_ipv4_prefixlen = 2; | |
8562 | int idx_word = 3; | |
020709f9 | 8563 | |
7c8ff89e DS |
8564 | if (!ospf) |
8565 | return CMD_SUCCESS; | |
8566 | ||
8d769265 | 8567 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 8568 | |
718e3744 | 8569 | return CMD_SUCCESS; |
8570 | } | |
8571 | ||
8572 | DEFUN (no_ospf_distance_source_access_list, | |
8573 | no_ospf_distance_source_access_list_cmd, | |
6147e2c6 | 8574 | "no distance (1-255) A.B.C.D/M WORD", |
718e3744 | 8575 | NO_STR |
8576 | "Administrative distance\n" | |
8577 | "Distance value\n" | |
8578 | "IP source prefix\n" | |
8579 | "Access list name\n") | |
8580 | { | |
cdc2d765 | 8581 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
8582 | int idx_number = 2; |
8583 | int idx_ipv4_prefixlen = 3; | |
8584 | int idx_word = 4; | |
020709f9 | 8585 | |
7c8ff89e DS |
8586 | if (!ospf) |
8587 | return CMD_SUCCESS; | |
8588 | ||
8d769265 | 8589 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 8590 | |
718e3744 | 8591 | return CMD_SUCCESS; |
8592 | } | |
d7d73ffc | 8593 | #endif |
718e3744 | 8594 | |
ba682537 | 8595 | DEFUN (ip_ospf_mtu_ignore, |
8596 | ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 8597 | "ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 8598 | "IP Information\n" |
8599 | "OSPF interface commands\n" | |
99a522c7 | 8600 | "Disable MTU mismatch detection on this interface\n" |
efd7904e | 8601 | "Address of interface\n") |
ba682537 | 8602 | { |
d62a17ae | 8603 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8604 | int idx_ipv4 = 3; | |
8605 | struct in_addr addr; | |
8606 | int ret; | |
8607 | ||
8608 | struct ospf_if_params *params; | |
8609 | params = IF_DEF_PARAMS(ifp); | |
8610 | ||
8611 | if (argc == 4) { | |
8612 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
8613 | if (!ret) { | |
8614 | vty_out(vty, | |
8615 | "Please specify interface address by A.B.C.D\n"); | |
8616 | return CMD_WARNING_CONFIG_FAILED; | |
8617 | } | |
8618 | params = ospf_get_if_params(ifp, addr); | |
8619 | ospf_if_update_params(ifp, addr); | |
8620 | } | |
8621 | params->mtu_ignore = 1; | |
8622 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8623 | SET_IF_PARAM(params, mtu_ignore); | |
8624 | else { | |
8625 | UNSET_IF_PARAM(params, mtu_ignore); | |
8626 | if (params != IF_DEF_PARAMS(ifp)) { | |
8627 | ospf_free_if_params(ifp, addr); | |
8628 | ospf_if_update_params(ifp, addr); | |
8629 | } | |
8630 | } | |
8631 | return CMD_SUCCESS; | |
ba682537 | 8632 | } |
8633 | ||
ba682537 | 8634 | DEFUN (no_ip_ospf_mtu_ignore, |
8635 | no_ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 8636 | "no ip ospf mtu-ignore [A.B.C.D]", |
efd7904e | 8637 | NO_STR |
ba682537 | 8638 | "IP Information\n" |
8639 | "OSPF interface commands\n" | |
99a522c7 | 8640 | "Disable MTU mismatch detection on this interface\n" |
efd7904e | 8641 | "Address of interface\n") |
ba682537 | 8642 | { |
d62a17ae | 8643 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8644 | int idx_ipv4 = 4; | |
8645 | struct in_addr addr; | |
8646 | int ret; | |
8647 | ||
8648 | struct ospf_if_params *params; | |
8649 | params = IF_DEF_PARAMS(ifp); | |
8650 | ||
8651 | if (argc == 5) { | |
8652 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); | |
8653 | if (!ret) { | |
8654 | vty_out(vty, | |
8655 | "Please specify interface address by A.B.C.D\n"); | |
8656 | return CMD_WARNING_CONFIG_FAILED; | |
8657 | } | |
8658 | params = ospf_get_if_params(ifp, addr); | |
8659 | ospf_if_update_params(ifp, addr); | |
8660 | } | |
8661 | params->mtu_ignore = 0; | |
8662 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8663 | SET_IF_PARAM(params, mtu_ignore); | |
8664 | else { | |
8665 | UNSET_IF_PARAM(params, mtu_ignore); | |
8666 | if (params != IF_DEF_PARAMS(ifp)) { | |
8667 | ospf_free_if_params(ifp, addr); | |
8668 | ospf_if_update_params(ifp, addr); | |
8669 | } | |
8670 | } | |
8671 | return CMD_SUCCESS; | |
ba682537 | 8672 | } |
8673 | ||
6b0655a2 | 8674 | |
88d6cf37 | 8675 | DEFUN (ospf_max_metric_router_lsa_admin, |
8676 | ospf_max_metric_router_lsa_admin_cmd, | |
8677 | "max-metric router-lsa administrative", | |
8678 | "OSPF maximum / infinite-distance metric\n" | |
8679 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8680 | "Administratively applied, for an indefinite period\n") | |
8681 | { | |
a3d826f0 | 8682 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8683 | struct listnode *ln; |
8684 | struct ospf_area *area; | |
7c8ff89e | 8685 | |
d62a17ae | 8686 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, ln, area)) { |
8687 | SET_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
4ba4fc85 | 8688 | |
d62a17ae | 8689 | if (!CHECK_FLAG(area->stub_router_state, |
8690 | OSPF_AREA_IS_STUB_ROUTED)) | |
8691 | ospf_router_lsa_update_area(area); | |
8692 | } | |
4ba4fc85 | 8693 | |
d62a17ae | 8694 | /* Allows for areas configured later to get the property */ |
8695 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
8696 | ||
8697 | return CMD_SUCCESS; | |
88d6cf37 | 8698 | } |
8699 | ||
8700 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
8701 | no_ospf_max_metric_router_lsa_admin_cmd, | |
8702 | "no max-metric router-lsa administrative", | |
8703 | NO_STR | |
8704 | "OSPF maximum / infinite-distance metric\n" | |
8705 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8706 | "Administratively applied, for an indefinite period\n") | |
8707 | { | |
a3d826f0 | 8708 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8709 | struct listnode *ln; |
8710 | struct ospf_area *area; | |
8711 | ||
8712 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, ln, area)) { | |
8713 | UNSET_FLAG(area->stub_router_state, | |
8714 | OSPF_AREA_ADMIN_STUB_ROUTED); | |
8715 | ||
8716 | /* Don't trample on the start-up stub timer */ | |
8717 | if (CHECK_FLAG(area->stub_router_state, | |
8718 | OSPF_AREA_IS_STUB_ROUTED) | |
8719 | && !area->t_stub_router) { | |
8720 | UNSET_FLAG(area->stub_router_state, | |
8721 | OSPF_AREA_IS_STUB_ROUTED); | |
8722 | ospf_router_lsa_update_area(area); | |
8723 | } | |
8724 | } | |
8725 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; | |
8726 | return CMD_SUCCESS; | |
88d6cf37 | 8727 | } |
8728 | ||
8729 | DEFUN (ospf_max_metric_router_lsa_startup, | |
8730 | ospf_max_metric_router_lsa_startup_cmd, | |
6147e2c6 | 8731 | "max-metric router-lsa on-startup (5-86400)", |
88d6cf37 | 8732 | "OSPF maximum / infinite-distance metric\n" |
8733 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8734 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
8735 | "Time (seconds) to advertise self as stub-router\n") | |
8736 | { | |
a3d826f0 | 8737 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8738 | int idx_number = 3; |
8739 | unsigned int seconds; | |
8740 | ||
b5a8894d | 8741 | if (argc < 4) { |
d62a17ae | 8742 | vty_out(vty, "%% Must supply stub-router period"); |
8743 | return CMD_WARNING_CONFIG_FAILED; | |
8744 | } | |
8745 | ||
8746 | seconds = strtoul(argv[idx_number]->arg, NULL, 10); | |
8747 | ||
8748 | ospf->stub_router_startup_time = seconds; | |
8749 | ||
8750 | return CMD_SUCCESS; | |
88d6cf37 | 8751 | } |
8752 | ||
8753 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
8754 | no_ospf_max_metric_router_lsa_startup_cmd, | |
7a7be519 | 8755 | "no max-metric router-lsa on-startup [(5-86400)]", |
88d6cf37 | 8756 | NO_STR |
8757 | "OSPF maximum / infinite-distance metric\n" | |
8758 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8759 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
8760 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 8761 | { |
a3d826f0 | 8762 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8763 | struct listnode *ln; |
8764 | struct ospf_area *area; | |
8765 | ||
8766 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; | |
8767 | ||
8768 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, ln, area)) { | |
8769 | SET_FLAG(area->stub_router_state, | |
8770 | OSPF_AREA_WAS_START_STUB_ROUTED); | |
8771 | OSPF_TIMER_OFF(area->t_stub_router); | |
8772 | ||
8773 | /* Don't trample on admin stub routed */ | |
8774 | if (!CHECK_FLAG(area->stub_router_state, | |
8775 | OSPF_AREA_ADMIN_STUB_ROUTED)) { | |
8776 | UNSET_FLAG(area->stub_router_state, | |
8777 | OSPF_AREA_IS_STUB_ROUTED); | |
8778 | ospf_router_lsa_update_area(area); | |
8779 | } | |
8780 | } | |
8781 | return CMD_SUCCESS; | |
88d6cf37 | 8782 | } |
8783 | ||
a1afa410 | 8784 | |
88d6cf37 | 8785 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
8786 | ospf_max_metric_router_lsa_shutdown_cmd, | |
6147e2c6 | 8787 | "max-metric router-lsa on-shutdown (5-100)", |
88d6cf37 | 8788 | "OSPF maximum / infinite-distance metric\n" |
8789 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
8790 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
8791 | "Time (seconds) to wait till full shutdown\n") | |
8792 | { | |
a3d826f0 | 8793 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
d62a17ae | 8794 | int idx_number = 3; |
8795 | unsigned int seconds; | |
8796 | ||
b5a8894d | 8797 | if (argc < 4) { |
d62a17ae | 8798 | vty_out(vty, "%% Must supply stub-router shutdown period"); |
8799 | return CMD_WARNING_CONFIG_FAILED; | |
8800 | } | |
8801 | ||
8802 | seconds = strtoul(argv[idx_number]->arg, NULL, 10); | |
8803 | ||
8804 | ospf->stub_router_shutdown_time = seconds; | |
8805 | ||
8806 | return CMD_SUCCESS; | |
88d6cf37 | 8807 | } |
8808 | ||
8809 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
8810 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
7a7be519 | 8811 | "no max-metric router-lsa on-shutdown [(5-100)]", |
88d6cf37 | 8812 | NO_STR |
8813 | "OSPF maximum / infinite-distance metric\n" | |
8814 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
8815 | "Advertise stub-router prior to full shutdown of OSPF\n" |
8816 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 8817 | { |
a3d826f0 | 8818 | VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); |
7c8ff89e | 8819 | |
d62a17ae | 8820 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
8821 | ||
8822 | return CMD_SUCCESS; | |
88d6cf37 | 8823 | } |
8824 | ||
d62a17ae | 8825 | static void config_write_stub_router(struct vty *vty, struct ospf *ospf) |
8826 | { | |
8827 | struct listnode *ln; | |
8828 | struct ospf_area *area; | |
8829 | ||
8830 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8831 | vty_out(vty, " max-metric router-lsa on-startup %u\n", | |
8832 | ospf->stub_router_startup_time); | |
8833 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
8834 | vty_out(vty, " max-metric router-lsa on-shutdown %u\n", | |
8835 | ospf->stub_router_shutdown_time); | |
8836 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, ln, area)) { | |
8837 | if (CHECK_FLAG(area->stub_router_state, | |
8838 | OSPF_AREA_ADMIN_STUB_ROUTED)) { | |
8839 | vty_out(vty, " max-metric router-lsa administrative\n"); | |
8840 | break; | |
8841 | } | |
8842 | } | |
8843 | return; | |
8844 | } | |
8845 | ||
b5a8894d | 8846 | static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf, |
0f478e30 CS |
8847 | struct route_table *rt, |
8848 | json_object *json) | |
d62a17ae | 8849 | { |
8850 | struct route_node *rn; | |
8851 | struct ospf_route * or ; | |
8852 | struct listnode *pnode, *pnnode; | |
8853 | struct ospf_path *path; | |
0f478e30 CS |
8854 | json_object *json_route = NULL, *json_nexthop_array = NULL, |
8855 | *json_nexthop = NULL; | |
d62a17ae | 8856 | |
0f478e30 | 8857 | if (!json) |
996c9314 LB |
8858 | vty_out(vty, |
8859 | "============ OSPF network routing table ============\n"); | |
d62a17ae | 8860 | |
0f478e30 CS |
8861 | for (rn = route_top(rt); rn; rn = route_next(rn)) { |
8862 | if ((or = rn->info) == NULL) | |
8863 | continue; | |
8864 | char buf1[PREFIX2STR_BUFFER]; | |
8865 | ||
8866 | memset(buf1, 0, sizeof(buf1)); | |
8867 | prefix2str(&rn->p, buf1, sizeof(buf1)); | |
8868 | ||
8869 | json_route = json_object_new_object(); | |
8870 | if (json) { | |
996c9314 LB |
8871 | json_object_object_add(json, buf1, json_route); |
8872 | json_object_to_json_string_ext( | |
8873 | json, JSON_C_TO_STRING_NOSLASHESCAPE); | |
0f478e30 CS |
8874 | } |
8875 | ||
8876 | switch (or->path_type) { | |
8877 | case OSPF_PATH_INTER_AREA: | |
8878 | if (or->type == OSPF_DESTINATION_NETWORK) { | |
8879 | if (json) { | |
8880 | json_object_string_add(json_route, | |
996c9314 LB |
8881 | "routeType", |
8882 | "N IA"); | |
8883 | json_object_int_add(json_route, "cost", | |
0f478e30 CS |
8884 | or->cost); |
8885 | json_object_string_add( | |
996c9314 LB |
8886 | json_route, "area", |
8887 | inet_ntoa(or->u.std.area_id)); | |
0f478e30 | 8888 | } else { |
d62a17ae | 8889 | vty_out(vty, |
996c9314 | 8890 | "N IA %-18s [%d] area: %s\n", |
d62a17ae | 8891 | buf1, or->cost, |
996c9314 | 8892 | inet_ntoa(or->u.std.area_id)); |
0f478e30 | 8893 | } |
996c9314 | 8894 | } else if (or->type == OSPF_DESTINATION_DISCARD) { |
0f478e30 CS |
8895 | if (json) { |
8896 | json_object_string_add(json_route, | |
996c9314 LB |
8897 | "routeType", |
8898 | "D IA"); | |
0f478e30 | 8899 | } else { |
d62a17ae | 8900 | vty_out(vty, |
8901 | "D IA %-18s Discard entry\n", | |
8902 | buf1); | |
0f478e30 CS |
8903 | } |
8904 | } | |
8905 | break; | |
8906 | case OSPF_PATH_INTRA_AREA: | |
8907 | if (json) { | |
996c9314 LB |
8908 | json_object_string_add(json_route, "routeType", |
8909 | "N"); | |
0f478e30 | 8910 | json_object_int_add(json_route, "cost", |
996c9314 LB |
8911 | or->cost); |
8912 | json_object_string_add( | |
8913 | json_route, "area", | |
8914 | inet_ntoa(or->u.std.area_id)); | |
0f478e30 | 8915 | } else { |
d62a17ae | 8916 | vty_out(vty, "N %-18s [%d] area: %s\n", |
8917 | buf1, or->cost, | |
8918 | inet_ntoa(or->u.std.area_id)); | |
0f478e30 CS |
8919 | } |
8920 | break; | |
8921 | default: | |
8922 | break; | |
8923 | } | |
8924 | ||
8925 | if (or->type == OSPF_DESTINATION_NETWORK) { | |
8926 | if (json) { | |
8927 | json_nexthop_array = json_object_new_array(); | |
8928 | json_object_object_add(json_route, "nexthops", | |
996c9314 | 8929 | json_nexthop_array); |
d62a17ae | 8930 | } |
8931 | ||
0f478e30 CS |
8932 | for (ALL_LIST_ELEMENTS(or->paths, pnode, pnnode, |
8933 | path)) { | |
8934 | if (json) { | |
996c9314 LB |
8935 | json_nexthop = json_object_new_object(); |
8936 | json_object_array_add( | |
8937 | json_nexthop_array, | |
8938 | json_nexthop); | |
0f478e30 CS |
8939 | } |
8940 | if (if_lookup_by_index(path->ifindex, | |
8941 | ospf->vrf_id)) { | |
8942 | ||
8943 | if (path->nexthop.s_addr == 0) { | |
8944 | if (json) { | |
8945 | json_object_string_add( | |
8946 | json_nexthop, | |
996c9314 | 8947 | "ip", " "); |
0f478e30 CS |
8948 | json_object_string_add( |
8949 | json_nexthop, | |
8950 | "directly attached to", | |
d62a17ae | 8951 | ifindex2ifname( |
996c9314 LB |
8952 | path->ifindex, |
8953 | ospf->vrf_id)); | |
0f478e30 | 8954 | } else { |
d62a17ae | 8955 | vty_out(vty, |
996c9314 LB |
8956 | "%24s directly attached to %s\n", |
8957 | "", | |
8958 | ifindex2ifname( | |
8959 | path->ifindex, | |
8960 | ospf->vrf_id)); | |
0f478e30 CS |
8961 | } |
8962 | } else { | |
8963 | if (json) { | |
8964 | json_object_string_add( | |
8965 | json_nexthop, | |
8966 | "ip", | |
d62a17ae | 8967 | inet_ntoa( |
996c9314 | 8968 | path->nexthop)); |
0f478e30 CS |
8969 | json_object_string_add( |
8970 | json_nexthop, | |
8971 | "via", | |
d62a17ae | 8972 | ifindex2ifname( |
996c9314 LB |
8973 | path->ifindex, |
8974 | ospf->vrf_id)); | |
0f478e30 CS |
8975 | } else { |
8976 | vty_out(vty, | |
996c9314 LB |
8977 | "%24s via %s, %s\n", |
8978 | "", | |
8979 | inet_ntoa( | |
8980 | path->nexthop), | |
8981 | ifindex2ifname( | |
8982 | path->ifindex, | |
8983 | ospf->vrf_id)); | |
0f478e30 | 8984 | } |
d62a17ae | 8985 | } |
8986 | } | |
0f478e30 | 8987 | } |
d62a17ae | 8988 | } |
0f478e30 CS |
8989 | if (!json) |
8990 | json_object_free(json_route); | |
8991 | } | |
8992 | if (!json) | |
8993 | vty_out(vty, "\n"); | |
d62a17ae | 8994 | } |
8995 | ||
b5a8894d | 8996 | static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf, |
0f478e30 CS |
8997 | struct route_table *rtrs, |
8998 | json_object *json) | |
d62a17ae | 8999 | { |
9000 | struct route_node *rn; | |
9001 | struct ospf_route * or ; | |
9002 | struct listnode *pnode; | |
9003 | struct listnode *node; | |
9004 | struct ospf_path *path; | |
0f478e30 CS |
9005 | json_object *json_route = NULL, *json_nexthop_array = NULL, |
9006 | *json_nexthop = NULL; | |
d62a17ae | 9007 | |
0f478e30 | 9008 | if (!json) |
996c9314 LB |
9009 | vty_out(vty, |
9010 | "============ OSPF router routing table =============\n"); | |
d62a17ae | 9011 | |
0f478e30 CS |
9012 | for (rn = route_top(rtrs); rn; rn = route_next(rn)) { |
9013 | if (rn->info == NULL) | |
9014 | continue; | |
9015 | int flag = 0; | |
9016 | ||
9017 | json_route = json_object_new_object(); | |
9018 | if (json) { | |
996c9314 LB |
9019 | json_object_object_add(json, inet_ntoa(rn->p.u.prefix4), |
9020 | json_route); | |
9021 | json_object_string_add(json_route, "routeType", "R "); | |
0f478e30 | 9022 | } else { |
d62a17ae | 9023 | vty_out(vty, "R %-15s ", |
9024 | inet_ntoa(rn->p.u.prefix4)); | |
0f478e30 | 9025 | } |
d62a17ae | 9026 | |
996c9314 | 9027 | for (ALL_LIST_ELEMENTS_RO((struct list *)rn->info, node, or)) { |
0f478e30 CS |
9028 | if (flag++) { |
9029 | if (!json) | |
d62a17ae | 9030 | vty_out(vty, "%24s", ""); |
0f478e30 | 9031 | } |
d62a17ae | 9032 | |
0f478e30 CS |
9033 | /* Show path. */ |
9034 | if (json) { | |
9035 | json_object_int_add(json_route, "cost", | |
9036 | or->cost); | |
996c9314 LB |
9037 | json_object_string_add( |
9038 | json_route, "area", | |
0f478e30 | 9039 | inet_ntoa(or->u.std.area_id)); |
996c9314 LB |
9040 | if (or->path_type == OSPF_PATH_INTER_AREA) |
9041 | json_object_boolean_true_add(json_route, | |
9042 | "IA"); | |
0f478e30 | 9043 | if (or->u.std.flags & ROUTER_LSA_BORDER) |
996c9314 LB |
9044 | json_object_string_add(json_route, |
9045 | "routerType", | |
9046 | "abr"); | |
9047 | else if (or->u.std.flags & ROUTER_LSA_EXTERNAL) | |
9048 | json_object_string_add(json_route, | |
9049 | "routerType", | |
9050 | "asbr"); | |
0f478e30 | 9051 | } else { |
d62a17ae | 9052 | vty_out(vty, "%s [%d] area: %s", |
996c9314 LB |
9053 | (or->path_type == OSPF_PATH_INTER_AREA |
9054 | ? "IA" | |
9055 | : " "), | |
9056 | or->cost, inet_ntoa(or->u.std.area_id)); | |
d62a17ae | 9057 | /* Show flags. */ |
9058 | vty_out(vty, "%s%s\n", | |
996c9314 LB |
9059 | (or->u.std.flags & ROUTER_LSA_BORDER |
9060 | ? ", ABR" | |
9061 | : ""), | |
9062 | (or->u.std.flags & ROUTER_LSA_EXTERNAL | |
9063 | ? ", ASBR" | |
9064 | : "")); | |
0f478e30 CS |
9065 | } |
9066 | ||
9067 | if (json) { | |
996c9314 | 9068 | json_nexthop_array = json_object_new_array(); |
0f478e30 | 9069 | json_object_object_add(json_route, "nexthops", |
996c9314 | 9070 | json_nexthop_array); |
0f478e30 CS |
9071 | } |
9072 | ||
996c9314 | 9073 | for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, path)) { |
0f478e30 | 9074 | if (json) { |
996c9314 | 9075 | json_nexthop = json_object_new_object(); |
0f478e30 CS |
9076 | json_object_array_add( |
9077 | json_nexthop_array, | |
9078 | json_nexthop); | |
9079 | } | |
9080 | if (if_lookup_by_index(path->ifindex, | |
9081 | ospf->vrf_id)) { | |
9082 | if (path->nexthop.s_addr == 0) { | |
9083 | if (json) { | |
9084 | json_object_string_add( | |
9085 | json_nexthop, | |
996c9314 | 9086 | "ip", " "); |
0f478e30 CS |
9087 | json_object_string_add( |
9088 | json_nexthop, | |
9089 | "directly attached to", | |
d62a17ae | 9090 | ifindex2ifname( |
9091 | path->ifindex, | |
b5a8894d | 9092 | ospf->vrf_id)); |
0f478e30 | 9093 | } else { |
d62a17ae | 9094 | vty_out(vty, |
996c9314 LB |
9095 | "%24s directly attached to %s\n", |
9096 | "", | |
9097 | ifindex2ifname( | |
9098 | path->ifindex, | |
9099 | ospf->vrf_id)); | |
0f478e30 CS |
9100 | } |
9101 | } else { | |
9102 | if (json) { | |
9103 | json_object_string_add( | |
9104 | json_nexthop, | |
9105 | "ip", | |
996c9314 LB |
9106 | inet_ntoa( |
9107 | path->nexthop)); | |
0f478e30 CS |
9108 | json_object_string_add( |
9109 | json_nexthop, | |
9110 | "via", | |
d62a17ae | 9111 | ifindex2ifname( |
9112 | path->ifindex, | |
b5a8894d | 9113 | ospf->vrf_id)); |
0f478e30 CS |
9114 | } else { |
9115 | vty_out(vty, | |
996c9314 LB |
9116 | "%24s via %s, %s\n", |
9117 | "", | |
9118 | inet_ntoa( | |
9119 | path->nexthop), | |
9120 | ifindex2ifname( | |
9121 | path->ifindex, | |
9122 | ospf->vrf_id)); | |
0f478e30 | 9123 | } |
d62a17ae | 9124 | } |
9125 | } | |
9126 | } | |
9127 | } | |
0f478e30 CS |
9128 | if (!json) |
9129 | json_object_free(json_route); | |
9130 | } | |
9131 | if (!json) | |
9132 | vty_out(vty, "\n"); | |
d62a17ae | 9133 | } |
9134 | ||
b5a8894d | 9135 | static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf, |
0f478e30 CS |
9136 | struct route_table *rt, |
9137 | json_object *json) | |
d62a17ae | 9138 | { |
9139 | struct route_node *rn; | |
9140 | struct ospf_route *er; | |
9141 | struct listnode *pnode, *pnnode; | |
9142 | struct ospf_path *path; | |
0f478e30 CS |
9143 | json_object *json_route = NULL, *json_nexthop_array = NULL, |
9144 | *json_nexthop = NULL; | |
d62a17ae | 9145 | |
0f478e30 | 9146 | if (!json) |
996c9314 LB |
9147 | vty_out(vty, |
9148 | "============ OSPF external routing table ===========\n"); | |
0f478e30 CS |
9149 | |
9150 | for (rn = route_top(rt); rn; rn = route_next(rn)) { | |
9151 | if ((er = rn->info) == NULL) | |
9152 | continue; | |
9153 | ||
9154 | char buf1[19]; | |
9155 | ||
9156 | snprintf(buf1, 19, "%s/%d", inet_ntoa(rn->p.u.prefix4), | |
9157 | rn->p.prefixlen); | |
9158 | json_route = json_object_new_object(); | |
9159 | if (json) { | |
996c9314 LB |
9160 | json_object_object_add(json, buf1, json_route); |
9161 | json_object_to_json_string_ext( | |
9162 | json, JSON_C_TO_STRING_NOSLASHESCAPE); | |
0f478e30 | 9163 | } |
d62a17ae | 9164 | |
0f478e30 CS |
9165 | switch (er->path_type) { |
9166 | case OSPF_PATH_TYPE1_EXTERNAL: | |
9167 | if (json) { | |
996c9314 | 9168 | json_object_string_add(json_route, "routeType", |
0f478e30 CS |
9169 | "N E1"); |
9170 | json_object_int_add(json_route, "cost", | |
996c9314 | 9171 | er->cost); |
0f478e30 | 9172 | } else { |
d62a17ae | 9173 | vty_out(vty, |
996c9314 LB |
9174 | "N E1 %-18s [%d] tag: %" ROUTE_TAG_PRI |
9175 | "\n", | |
9176 | buf1, er->cost, er->u.ext.tag); | |
0f478e30 CS |
9177 | } |
9178 | break; | |
9179 | case OSPF_PATH_TYPE2_EXTERNAL: | |
9180 | if (json) { | |
996c9314 | 9181 | json_object_string_add(json_route, "routeType", |
0f478e30 CS |
9182 | "N E2"); |
9183 | json_object_int_add(json_route, "cost", | |
996c9314 | 9184 | er->cost); |
0f478e30 | 9185 | } else { |
d62a17ae | 9186 | vty_out(vty, |
996c9314 LB |
9187 | "N E2 %-18s [%d/%d] tag: %" ROUTE_TAG_PRI |
9188 | "\n", | |
9189 | buf1, er->cost, er->u.ext.type2_cost, | |
d62a17ae | 9190 | er->u.ext.tag); |
d62a17ae | 9191 | } |
0f478e30 CS |
9192 | break; |
9193 | } | |
d62a17ae | 9194 | |
0f478e30 CS |
9195 | if (json) { |
9196 | json_nexthop_array = json_object_new_array(); | |
9197 | json_object_object_add(json_route, "nexthops", | |
996c9314 | 9198 | json_nexthop_array); |
0f478e30 CS |
9199 | } |
9200 | ||
996c9314 | 9201 | for (ALL_LIST_ELEMENTS(er->paths, pnode, pnnode, path)) { |
0f478e30 CS |
9202 | if (json) { |
9203 | json_nexthop = json_object_new_object(); | |
996c9314 LB |
9204 | json_object_array_add(json_nexthop_array, |
9205 | json_nexthop); | |
0f478e30 CS |
9206 | } |
9207 | ||
996c9314 | 9208 | if (if_lookup_by_index(path->ifindex, ospf->vrf_id)) { |
0f478e30 CS |
9209 | if (path->nexthop.s_addr == 0) { |
9210 | if (json) { | |
9211 | json_object_string_add( | |
996c9314 LB |
9212 | json_nexthop, "ip", |
9213 | " "); | |
0f478e30 CS |
9214 | json_object_string_add( |
9215 | json_nexthop, | |
9216 | "directly attached to", | |
d62a17ae | 9217 | ifindex2ifname( |
996c9314 LB |
9218 | path->ifindex, |
9219 | ospf->vrf_id)); | |
0f478e30 | 9220 | } else { |
d62a17ae | 9221 | vty_out(vty, |
996c9314 LB |
9222 | "%24s directly attached to %s\n", |
9223 | "", | |
9224 | ifindex2ifname( | |
9225 | path->ifindex, | |
9226 | ospf->vrf_id)); | |
0f478e30 CS |
9227 | } |
9228 | } else { | |
9229 | if (json) { | |
9230 | json_object_string_add( | |
996c9314 | 9231 | json_nexthop, "ip", |
d62a17ae | 9232 | inet_ntoa( |
996c9314 | 9233 | path->nexthop)); |
0f478e30 | 9234 | json_object_string_add( |
996c9314 | 9235 | json_nexthop, "via", |
d62a17ae | 9236 | ifindex2ifname( |
996c9314 LB |
9237 | path->ifindex, |
9238 | ospf->vrf_id)); | |
0f478e30 CS |
9239 | } else { |
9240 | vty_out(vty, | |
996c9314 LB |
9241 | "%24s via %s, %s\n", |
9242 | "", | |
9243 | inet_ntoa( | |
9244 | path->nexthop), | |
9245 | ifindex2ifname( | |
9246 | path->ifindex, | |
9247 | ospf->vrf_id)); | |
0f478e30 | 9248 | } |
d62a17ae | 9249 | } |
54bedb55 | 9250 | } |
d62a17ae | 9251 | } |
0f478e30 CS |
9252 | if (!json) |
9253 | json_object_free(json_route); | |
9254 | } | |
9255 | if (!json) | |
9256 | vty_out(vty, "\n"); | |
718e3744 | 9257 | } |
9258 | ||
d62a17ae | 9259 | static int show_ip_ospf_border_routers_common(struct vty *vty, |
996c9314 | 9260 | struct ospf *ospf, u_char use_vrf) |
718e3744 | 9261 | { |
d62a17ae | 9262 | if (ospf->instance) |
9263 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
718e3744 | 9264 | |
b1c3ae8c | 9265 | ospf_show_vrf_name(ospf, vty, NULL, use_vrf); |
87bd50e8 | 9266 | |
d62a17ae | 9267 | if (ospf->new_table == NULL) { |
9268 | vty_out(vty, "No OSPF routing information exist\n"); | |
9269 | return CMD_SUCCESS; | |
9270 | } | |
718e3744 | 9271 | |
d62a17ae | 9272 | /* Show Network routes. |
9273 | show_ip_ospf_route_network (vty, ospf->new_table); */ | |
718e3744 | 9274 | |
d62a17ae | 9275 | /* Show Router routes. */ |
0f478e30 | 9276 | show_ip_ospf_route_router(vty, ospf, ospf->new_rtrs, NULL); |
718e3744 | 9277 | |
d62a17ae | 9278 | vty_out(vty, "\n"); |
7c8ff89e | 9279 | |
d62a17ae | 9280 | return CMD_SUCCESS; |
718e3744 | 9281 | } |
718e3744 | 9282 | |
7c8ff89e DS |
9283 | DEFUN (show_ip_ospf_border_routers, |
9284 | show_ip_ospf_border_routers_cmd, | |
b5a8894d | 9285 | "show ip ospf [vrf <NAME|all>] border-routers", |
718e3744 | 9286 | SHOW_STR |
9287 | IP_STR | |
9288 | "OSPF information\n" | |
b5a8894d CS |
9289 | VRF_CMD_HELP_STR |
9290 | "All VRFs\n" | |
7c8ff89e | 9291 | "Show all the ABR's and ASBR's\n") |
718e3744 | 9292 | { |
b5a8894d CS |
9293 | struct ospf *ospf = NULL; |
9294 | struct listnode *node = NULL; | |
9295 | char *vrf_name = NULL; | |
9296 | bool all_vrf = FALSE; | |
9297 | int ret = CMD_SUCCESS; | |
9298 | int inst = 0; | |
9299 | int idx_vrf = 0; | |
b1c3ae8c | 9300 | u_char use_vrf = 0; |
68980084 | 9301 | |
43b8d1d8 | 9302 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
7c8ff89e | 9303 | |
b5a8894d | 9304 | if (vrf_name) { |
b1c3ae8c | 9305 | use_vrf = 1; |
b5a8894d CS |
9306 | if (all_vrf) { |
9307 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
9308 | if (!ospf->oi_running) | |
9309 | continue; | |
b5a8894d | 9310 | |
996c9314 LB |
9311 | ret = show_ip_ospf_border_routers_common( |
9312 | vty, ospf, use_vrf); | |
b5a8894d CS |
9313 | } |
9314 | } else { | |
9315 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
9316 | if (ospf == NULL || !ospf->oi_running) | |
9317 | return CMD_SUCCESS; | |
9318 | ||
b1c3ae8c CS |
9319 | ret = show_ip_ospf_border_routers_common(vty, ospf, |
9320 | use_vrf); | |
b5a8894d CS |
9321 | } |
9322 | } else { | |
9323 | /* Display default ospf (instance 0) info */ | |
9324 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
9325 | if (ospf == NULL || !ospf->oi_running) | |
9326 | return CMD_SUCCESS; | |
b1c3ae8c | 9327 | ret = show_ip_ospf_border_routers_common(vty, ospf, use_vrf); |
b5a8894d CS |
9328 | } |
9329 | ||
9330 | return ret; | |
7c8ff89e DS |
9331 | } |
9332 | ||
9333 | DEFUN (show_ip_ospf_instance_border_routers, | |
9334 | show_ip_ospf_instance_border_routers_cmd, | |
6147e2c6 | 9335 | "show ip ospf (1-65535) border-routers", |
7c8ff89e DS |
9336 | SHOW_STR |
9337 | IP_STR | |
9338 | "OSPF information\n" | |
9339 | "Instance ID\n" | |
9340 | "Show all the ABR's and ASBR's\n") | |
9341 | { | |
d62a17ae | 9342 | int idx_number = 3; |
9343 | struct ospf *ospf; | |
9344 | u_short instance = 0; | |
7c8ff89e | 9345 | |
d62a17ae | 9346 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
9347 | ospf = ospf_lookup_instance(instance); |
9348 | if (ospf == NULL) | |
9349 | return CMD_NOT_MY_INSTANCE; | |
9350 | ||
9351 | if (!ospf->oi_running) | |
d62a17ae | 9352 | return CMD_SUCCESS; |
7c8ff89e | 9353 | |
b1c3ae8c | 9354 | return show_ip_ospf_border_routers_common(vty, ospf, 0); |
7c8ff89e DS |
9355 | } |
9356 | ||
b1c3ae8c | 9357 | static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf, |
0f478e30 | 9358 | json_object *json, u_char use_vrf) |
7c8ff89e | 9359 | { |
0f478e30 CS |
9360 | json_object *json_vrf = NULL; |
9361 | ||
d62a17ae | 9362 | if (ospf->instance) |
9363 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); | |
718e3744 | 9364 | |
0f478e30 CS |
9365 | |
9366 | if (json) { | |
9367 | if (use_vrf) | |
9368 | json_vrf = json_object_new_object(); | |
9369 | else | |
9370 | json_vrf = json; | |
9371 | } | |
9372 | ||
9373 | ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); | |
87bd50e8 | 9374 | |
d62a17ae | 9375 | if (ospf->new_table == NULL) { |
9376 | vty_out(vty, "No OSPF routing information exist\n"); | |
9377 | return CMD_SUCCESS; | |
9378 | } | |
718e3744 | 9379 | |
d62a17ae | 9380 | /* Show Network routes. */ |
0f478e30 | 9381 | show_ip_ospf_route_network(vty, ospf, ospf->new_table, json_vrf); |
718e3744 | 9382 | |
d62a17ae | 9383 | /* Show Router routes. */ |
0f478e30 | 9384 | show_ip_ospf_route_router(vty, ospf, ospf->new_rtrs, json_vrf); |
718e3744 | 9385 | |
d62a17ae | 9386 | /* Show AS External routes. */ |
0f478e30 CS |
9387 | show_ip_ospf_route_external(vty, ospf, ospf->old_external_route, |
9388 | json_vrf); | |
718e3744 | 9389 | |
0f478e30 CS |
9390 | if (json) { |
9391 | if (use_vrf) { | |
996c9314 LB |
9392 | // json_object_object_add(json_vrf, "areas", |
9393 | // json_areas); | |
0f478e30 CS |
9394 | if (ospf->vrf_id == VRF_DEFAULT) |
9395 | json_object_object_add(json, "default", | |
9396 | json_vrf); | |
9397 | else | |
9398 | json_object_object_add(json, ospf->name, | |
9399 | json_vrf); | |
9400 | } | |
9401 | } else { | |
9402 | vty_out(vty, "\n"); | |
9403 | } | |
7c8ff89e | 9404 | |
d62a17ae | 9405 | return CMD_SUCCESS; |
718e3744 | 9406 | } |
9407 | ||
7c8ff89e DS |
9408 | DEFUN (show_ip_ospf_route, |
9409 | show_ip_ospf_route_cmd, | |
0f478e30 | 9410 | "show ip ospf [vrf <NAME|all>] route [json]", |
b5a8894d CS |
9411 | SHOW_STR |
9412 | IP_STR | |
9413 | "OSPF information\n" | |
9414 | VRF_CMD_HELP_STR | |
9415 | "All VRFs\n" | |
0f478e30 CS |
9416 | "OSPF routing table\n" |
9417 | JSON_STR) | |
b5a8894d CS |
9418 | { |
9419 | struct ospf *ospf = NULL; | |
9420 | struct listnode *node = NULL; | |
9421 | char *vrf_name = NULL; | |
9422 | bool all_vrf = FALSE; | |
9423 | int ret = CMD_SUCCESS; | |
9424 | int inst = 0; | |
9425 | int idx_vrf = 0; | |
b1c3ae8c | 9426 | u_char use_vrf = 0; |
0f478e30 CS |
9427 | u_char uj = use_json(argc, argv); |
9428 | json_object *json = NULL; | |
9429 | ||
9430 | if (uj) | |
9431 | json = json_object_new_object(); | |
7c8ff89e | 9432 | |
43b8d1d8 | 9433 | OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); |
7c8ff89e | 9434 | |
b5a8894d CS |
9435 | /* vrf input is provided could be all or specific vrf*/ |
9436 | if (vrf_name) { | |
b1c3ae8c | 9437 | use_vrf = 1; |
b5a8894d CS |
9438 | if (all_vrf) { |
9439 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
9440 | if (!ospf->oi_running) | |
9441 | continue; | |
0f478e30 | 9442 | ret = show_ip_ospf_route_common(vty, ospf, json, |
b1c3ae8c | 9443 | use_vrf); |
b5a8894d | 9444 | } |
0f478e30 CS |
9445 | |
9446 | if (uj) { | |
1406159f | 9447 | /* Keep Non-pretty format */ |
0f478e30 | 9448 | vty_out(vty, "%s\n", |
1406159f | 9449 | json_object_to_json_string(json)); |
0f478e30 CS |
9450 | json_object_free(json); |
9451 | } | |
9452 | ||
b5a8894d CS |
9453 | return ret; |
9454 | } | |
9455 | ospf = ospf_lookup_by_inst_name(inst, vrf_name); | |
0f478e30 CS |
9456 | if (ospf == NULL || !ospf->oi_running) { |
9457 | if (uj) | |
9458 | json_object_free(json); | |
b5a8894d | 9459 | return CMD_SUCCESS; |
0f478e30 | 9460 | } |
b5a8894d CS |
9461 | } else { |
9462 | /* Display default ospf (instance 0) info */ | |
9463 | ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); | |
0f478e30 CS |
9464 | if (ospf == NULL || !ospf->oi_running) { |
9465 | if (uj) | |
9466 | json_object_free(json); | |
b5a8894d | 9467 | return CMD_SUCCESS; |
0f478e30 CS |
9468 | } |
9469 | } | |
9470 | ||
9471 | if (ospf) { | |
9472 | ret = show_ip_ospf_route_common(vty, ospf, json, use_vrf); | |
1406159f | 9473 | /* Keep Non-pretty format */ |
0f478e30 | 9474 | if (uj) |
1406159f | 9475 | vty_out(vty, "%s\n", json_object_to_json_string(json)); |
b5a8894d CS |
9476 | } |
9477 | ||
0f478e30 CS |
9478 | if (uj) |
9479 | json_object_free(json); | |
b5a8894d CS |
9480 | |
9481 | return ret; | |
7c8ff89e DS |
9482 | } |
9483 | ||
9484 | DEFUN (show_ip_ospf_instance_route, | |
9485 | show_ip_ospf_instance_route_cmd, | |
6147e2c6 | 9486 | "show ip ospf (1-65535) route", |
7c8ff89e DS |
9487 | SHOW_STR |
9488 | IP_STR | |
9489 | "OSPF information\n" | |
9490 | "Instance ID\n" | |
9491 | "OSPF routing table\n") | |
9492 | { | |
d62a17ae | 9493 | int idx_number = 3; |
9494 | struct ospf *ospf; | |
9495 | u_short instance = 0; | |
7c8ff89e | 9496 | |
d62a17ae | 9497 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
ac28e4ec CS |
9498 | ospf = ospf_lookup_instance(instance); |
9499 | if (ospf == NULL) | |
9500 | return CMD_NOT_MY_INSTANCE; | |
9501 | ||
9502 | if (!ospf->oi_running) | |
d62a17ae | 9503 | return CMD_SUCCESS; |
7c8ff89e | 9504 | |
0f478e30 | 9505 | return show_ip_ospf_route_common(vty, ospf, NULL, 0); |
7c8ff89e | 9506 | } |
6b0655a2 | 9507 | |
b5a8894d CS |
9508 | |
9509 | DEFUN (show_ip_ospf_vrfs, | |
9510 | show_ip_ospf_vrfs_cmd, | |
9511 | "show ip ospf vrfs [json]", | |
9512 | SHOW_STR | |
9513 | IP_STR | |
9514 | "OSPF information\n" | |
9515 | "Show OSPF VRFs \n" | |
9516 | JSON_STR) | |
9517 | { | |
9518 | u_char uj = use_json(argc, argv); | |
9519 | json_object *json = NULL; | |
9520 | json_object *json_vrfs = NULL; | |
9521 | struct ospf *ospf = NULL; | |
9522 | struct listnode *node = NULL; | |
9523 | int count = 0; | |
9524 | static char header[] = "Name Id RouterId "; | |
9525 | ||
9526 | if (uj) { | |
9527 | json = json_object_new_object(); | |
9528 | json_vrfs = json_object_new_object(); | |
9529 | } | |
9530 | ||
9531 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { | |
9532 | json_object *json_vrf = NULL; | |
9533 | const char *name = NULL; | |
fe3da9e7 | 9534 | int64_t vrf_id_ui = 0; |
b5a8894d CS |
9535 | |
9536 | count++; | |
9537 | ||
9538 | if (!uj && count == 1) | |
9539 | vty_out(vty, "%s\n", header); | |
9540 | if (uj) | |
9541 | json_vrf = json_object_new_object(); | |
9542 | ||
9543 | if (ospf->vrf_id == 0) | |
9544 | name = VRF_DEFAULT_NAME; | |
9545 | else | |
9546 | name = ospf->name; | |
9547 | ||
996c9314 LB |
9548 | vrf_id_ui = (ospf->vrf_id == VRF_UNKNOWN) |
9549 | ? -1 | |
9550 | : (int64_t)ospf->vrf_id; | |
b5a8894d CS |
9551 | |
9552 | if (uj) { | |
9553 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
9554 | json_object_string_add(json_vrf, "routerId", | |
9555 | inet_ntoa(ospf->router_id)); | |
9556 | ||
9557 | json_object_object_add(json_vrfs, name, json_vrf); | |
9558 | ||
9559 | } else { | |
996c9314 LB |
9560 | vty_out(vty, "%-25s %-5d %-16s \n", name, |
9561 | ospf->vrf_id, inet_ntoa(ospf->router_id)); | |
b5a8894d CS |
9562 | } |
9563 | } | |
9564 | ||
9565 | if (uj) { | |
9566 | json_object_object_add(json, "vrfs", json_vrfs); | |
9567 | json_object_int_add(json, "totalVrfs", count); | |
9568 | ||
996c9314 LB |
9569 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9570 | json, JSON_C_TO_STRING_PRETTY)); | |
b5a8894d CS |
9571 | json_object_free(json); |
9572 | } else { | |
9573 | if (count) | |
34d6798f | 9574 | vty_out(vty, "\nTotal number of OSPF VRFs: %d\n", |
b5a8894d CS |
9575 | count); |
9576 | } | |
9577 | ||
9578 | return CMD_SUCCESS; | |
9579 | } | |
9580 | ||
d62a17ae | 9581 | const char *ospf_abr_type_str[] = {"unknown", "standard", "ibm", "cisco", |
9582 | "shortcut"}; | |
718e3744 | 9583 | |
d62a17ae | 9584 | const char *ospf_shortcut_mode_str[] = {"default", "enable", "disable"}; |
718e3744 | 9585 | |
d62a17ae | 9586 | const char *ospf_int_type_str[] = {"unknown", /* should never be used. */ |
9587 | "point-to-point", "broadcast", | |
9588 | "non-broadcast", "point-to-multipoint", | |
9589 | "virtual-link", /* should never be used. */ | |
9590 | "loopback"}; | |
718e3744 | 9591 | |
545f0503 | 9592 | static int config_write_interface_one(struct vty *vty, struct vrf *vrf) |
d62a17ae | 9593 | { |
f4e14fdb | 9594 | struct listnode *node; |
d62a17ae | 9595 | struct interface *ifp; |
9596 | struct crypt_key *ck; | |
d62a17ae | 9597 | struct route_node *rn = NULL; |
9598 | struct ospf_if_params *params; | |
43b8d1d8 | 9599 | int write = 0; |
545f0503 | 9600 | struct ospf *ospf = vrf->info; |
d62a17ae | 9601 | |
545f0503 | 9602 | FOR_ALL_INTERFACES (vrf, ifp) { |
d62a17ae | 9603 | |
545f0503 CS |
9604 | if (memcmp(ifp->name, "VLINK", 5) == 0) |
9605 | continue; | |
35955c14 | 9606 | |
545f0503 CS |
9607 | vty_frame(vty, "!\n"); |
9608 | if (ifp->vrf_id == VRF_DEFAULT) | |
9609 | vty_frame(vty, "interface %s\n", ifp->name); | |
9610 | else | |
996c9314 LB |
9611 | vty_frame(vty, "interface %s vrf %s\n", ifp->name, |
9612 | vrf->name); | |
545f0503 CS |
9613 | if (ifp->desc) |
9614 | vty_out(vty, " description %s\n", ifp->desc); | |
d62a17ae | 9615 | |
545f0503 | 9616 | write++; |
43b8d1d8 | 9617 | |
545f0503 | 9618 | params = IF_DEF_PARAMS(ifp); |
43b8d1d8 | 9619 | |
545f0503 CS |
9620 | do { |
9621 | /* Interface Network print. */ | |
9622 | if (OSPF_IF_PARAM_CONFIGURED(params, type) | |
9623 | && params->type != OSPF_IFTYPE_LOOPBACK) { | |
996c9314 | 9624 | if (params->type != ospf_default_iftype(ifp)) { |
545f0503 CS |
9625 | vty_out(vty, " ip ospf network %s", |
9626 | ospf_int_type_str | |
996c9314 | 9627 | [params->type]); |
545f0503 CS |
9628 | if (params != IF_DEF_PARAMS(ifp)) |
9629 | vty_out(vty, " %s", | |
9630 | inet_ntoa( | |
996c9314 | 9631 | rn->p.u.prefix4)); |
545f0503 | 9632 | vty_out(vty, "\n"); |
d62a17ae | 9633 | } |
545f0503 | 9634 | } |
d62a17ae | 9635 | |
545f0503 CS |
9636 | /* OSPF interface authentication print */ |
9637 | if (OSPF_IF_PARAM_CONFIGURED(params, auth_type) | |
996c9314 | 9638 | && params->auth_type != OSPF_AUTH_NOTSET) { |
545f0503 | 9639 | const char *auth_str; |
d62a17ae | 9640 | |
545f0503 CS |
9641 | /* Translation tables are not that much help |
9642 | * here due to syntax | |
9643 | * of the simple option */ | |
9644 | switch (params->auth_type) { | |
d62a17ae | 9645 | |
545f0503 CS |
9646 | case OSPF_AUTH_NULL: |
9647 | auth_str = " null"; | |
9648 | break; | |
d62a17ae | 9649 | |
545f0503 CS |
9650 | case OSPF_AUTH_SIMPLE: |
9651 | auth_str = ""; | |
9652 | break; | |
b5a8894d | 9653 | |
545f0503 CS |
9654 | case OSPF_AUTH_CRYPTOGRAPHIC: |
9655 | auth_str = " message-digest"; | |
9656 | break; | |
d62a17ae | 9657 | |
545f0503 CS |
9658 | default: |
9659 | auth_str = ""; | |
9660 | break; | |
c7fd72d2 | 9661 | } |
d62a17ae | 9662 | |
545f0503 CS |
9663 | vty_out(vty, " ip ospf authentication%s", |
9664 | auth_str); | |
9665 | if (params != IF_DEF_PARAMS(ifp)) | |
9666 | vty_out(vty, " %s", | |
c7fd72d2 | 9667 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9668 | vty_out(vty, "\n"); |
9669 | } | |
d62a17ae | 9670 | |
545f0503 CS |
9671 | /* Simple Authentication Password print. */ |
9672 | if (OSPF_IF_PARAM_CONFIGURED(params, auth_simple) | |
996c9314 | 9673 | && params->auth_simple[0] != '\0') { |
545f0503 CS |
9674 | vty_out(vty, " ip ospf authentication-key %s", |
9675 | params->auth_simple); | |
9676 | if (params != IF_DEF_PARAMS(ifp)) | |
9677 | vty_out(vty, " %s", | |
9678 | inet_ntoa(rn->p.u.prefix4)); | |
9679 | vty_out(vty, "\n"); | |
9680 | } | |
c7fd72d2 | 9681 | |
545f0503 CS |
9682 | /* Cryptographic Authentication Key print. */ |
9683 | if (params && params->auth_crypt) { | |
996c9314 LB |
9684 | for (ALL_LIST_ELEMENTS_RO(params->auth_crypt, |
9685 | node, ck)) { | |
545f0503 CS |
9686 | vty_out(vty, |
9687 | " ip ospf message-digest-key %d md5 %s", | |
996c9314 | 9688 | ck->key_id, ck->auth_key); |
c7fd72d2 CS |
9689 | if (params != IF_DEF_PARAMS(ifp)) |
9690 | vty_out(vty, " %s", | |
996c9314 LB |
9691 | inet_ntoa( |
9692 | rn->p.u.prefix4)); | |
c7fd72d2 CS |
9693 | vty_out(vty, "\n"); |
9694 | } | |
545f0503 | 9695 | } |
d62a17ae | 9696 | |
545f0503 | 9697 | /* Interface Output Cost print. */ |
996c9314 | 9698 | if (OSPF_IF_PARAM_CONFIGURED(params, output_cost_cmd)) { |
545f0503 CS |
9699 | vty_out(vty, " ip ospf cost %u", |
9700 | params->output_cost_cmd); | |
9701 | if (params != IF_DEF_PARAMS(ifp)) | |
9702 | vty_out(vty, " %s", | |
43b8d1d8 | 9703 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9704 | vty_out(vty, "\n"); |
9705 | } | |
d62a17ae | 9706 | |
545f0503 CS |
9707 | /* Hello Interval print. */ |
9708 | if (OSPF_IF_PARAM_CONFIGURED(params, v_hello) | |
996c9314 | 9709 | && params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) { |
545f0503 CS |
9710 | vty_out(vty, " ip ospf hello-interval %u", |
9711 | params->v_hello); | |
9712 | if (params != IF_DEF_PARAMS(ifp)) | |
9713 | vty_out(vty, " %s", | |
9714 | inet_ntoa(rn->p.u.prefix4)); | |
9715 | vty_out(vty, "\n"); | |
9716 | } | |
d62a17ae | 9717 | |
d62a17ae | 9718 | |
545f0503 CS |
9719 | /* Router Dead Interval print. */ |
9720 | if (OSPF_IF_PARAM_CONFIGURED(params, v_wait) | |
996c9314 LB |
9721 | && params->v_wait |
9722 | != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) { | |
545f0503 | 9723 | vty_out(vty, " ip ospf dead-interval "); |
d62a17ae | 9724 | |
545f0503 CS |
9725 | /* fast hello ? */ |
9726 | if (OSPF_IF_PARAM_CONFIGURED(params, | |
996c9314 | 9727 | fast_hello)) |
545f0503 CS |
9728 | vty_out(vty, |
9729 | "minimal hello-multiplier %d", | |
9730 | params->fast_hello); | |
9731 | else | |
996c9314 | 9732 | vty_out(vty, "%u", params->v_wait); |
d62a17ae | 9733 | |
545f0503 CS |
9734 | if (params != IF_DEF_PARAMS(ifp)) |
9735 | vty_out(vty, " %s", | |
43b8d1d8 | 9736 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9737 | vty_out(vty, "\n"); |
9738 | } | |
d62a17ae | 9739 | |
545f0503 CS |
9740 | /* Router Priority print. */ |
9741 | if (OSPF_IF_PARAM_CONFIGURED(params, priority) | |
996c9314 LB |
9742 | && params->priority |
9743 | != OSPF_ROUTER_PRIORITY_DEFAULT) { | |
545f0503 CS |
9744 | vty_out(vty, " ip ospf priority %u", |
9745 | params->priority); | |
9746 | if (params != IF_DEF_PARAMS(ifp)) | |
9747 | vty_out(vty, " %s", | |
43b8d1d8 | 9748 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9749 | vty_out(vty, "\n"); |
9750 | } | |
d62a17ae | 9751 | |
545f0503 CS |
9752 | /* Retransmit Interval print. */ |
9753 | if (OSPF_IF_PARAM_CONFIGURED(params, | |
996c9314 LB |
9754 | retransmit_interval) |
9755 | && params->retransmit_interval | |
9756 | != OSPF_RETRANSMIT_INTERVAL_DEFAULT) { | |
545f0503 CS |
9757 | vty_out(vty, " ip ospf retransmit-interval %u", |
9758 | params->retransmit_interval); | |
9759 | if (params != IF_DEF_PARAMS(ifp)) | |
9760 | vty_out(vty, " %s", | |
43b8d1d8 | 9761 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9762 | vty_out(vty, "\n"); |
9763 | } | |
d62a17ae | 9764 | |
545f0503 | 9765 | /* Transmit Delay print. */ |
996c9314 LB |
9766 | if (OSPF_IF_PARAM_CONFIGURED(params, transmit_delay) |
9767 | && params->transmit_delay | |
9768 | != OSPF_TRANSMIT_DELAY_DEFAULT) { | |
545f0503 CS |
9769 | vty_out(vty, " ip ospf transmit-delay %u", |
9770 | params->transmit_delay); | |
9771 | if (params != IF_DEF_PARAMS(ifp)) | |
9772 | vty_out(vty, " %s", | |
996c9314 | 9773 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9774 | vty_out(vty, "\n"); |
9775 | } | |
d62a17ae | 9776 | |
545f0503 CS |
9777 | /* Area print. */ |
9778 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) { | |
9779 | if (ospf && ospf->instance) | |
9780 | vty_out(vty, " ip ospf %d", | |
9781 | ospf->instance); | |
9782 | else | |
9783 | vty_out(vty, " ip ospf"); | |
d62a17ae | 9784 | |
c7fd72d2 | 9785 | |
545f0503 | 9786 | size_t buflen = MAX(strlen("4294967295"), |
996c9314 | 9787 | strlen("255.255.255.255")); |
545f0503 | 9788 | char buf[buflen]; |
d62a17ae | 9789 | |
996c9314 LB |
9790 | area_id2str(buf, sizeof(buf), ¶ms->if_area, |
9791 | params->if_area_id_fmt); | |
545f0503 CS |
9792 | vty_out(vty, " area %s", buf); |
9793 | if (params != IF_DEF_PARAMS(ifp)) | |
9794 | vty_out(vty, " %s", | |
996c9314 | 9795 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9796 | vty_out(vty, "\n"); |
9797 | } | |
d62a17ae | 9798 | |
545f0503 CS |
9799 | /* bfd print. */ |
9800 | if (params->bfd_info) | |
9801 | ospf_bfd_write_config(vty, params); | |
d62a17ae | 9802 | |
545f0503 CS |
9803 | /* MTU ignore print. */ |
9804 | if (OSPF_IF_PARAM_CONFIGURED(params, mtu_ignore) | |
996c9314 | 9805 | && params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) { |
545f0503 CS |
9806 | if (params->mtu_ignore == 0) |
9807 | vty_out(vty, " no ip ospf mtu-ignore"); | |
9808 | else | |
9809 | vty_out(vty, " ip ospf mtu-ignore"); | |
9810 | if (params != IF_DEF_PARAMS(ifp)) | |
9811 | vty_out(vty, " %s", | |
996c9314 | 9812 | inet_ntoa(rn->p.u.prefix4)); |
545f0503 CS |
9813 | vty_out(vty, "\n"); |
9814 | } | |
a8b828f3 | 9815 | |
d62a17ae | 9816 | |
545f0503 CS |
9817 | while (1) { |
9818 | if (rn == NULL) | |
996c9314 | 9819 | rn = route_top(IF_OIFS_PARAMS(ifp)); |
545f0503 CS |
9820 | else |
9821 | rn = route_next(rn); | |
43b8d1d8 | 9822 | |
545f0503 CS |
9823 | if (rn == NULL) |
9824 | break; | |
9825 | params = rn->info; | |
9826 | if (params != NULL) | |
9827 | break; | |
9828 | } | |
9829 | } while (rn); | |
43b8d1d8 | 9830 | |
545f0503 CS |
9831 | ospf_opaque_config_write_if(vty, ifp); |
9832 | ||
9833 | vty_endframe(vty, NULL); | |
b5a8894d | 9834 | } |
545f0503 | 9835 | |
d62a17ae | 9836 | return write; |
718e3744 | 9837 | } |
9838 | ||
43b8d1d8 CS |
9839 | /* Configuration write function for ospfd. */ |
9840 | static int config_write_interface(struct vty *vty) | |
9841 | { | |
9842 | int write = 0; | |
545f0503 | 9843 | struct vrf *vrf = NULL; |
43b8d1d8 | 9844 | |
545f0503 CS |
9845 | /* Display all VRF aware OSPF interface configuration */ |
9846 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { | |
9847 | write += config_write_interface_one(vty, vrf); | |
9848 | } | |
43b8d1d8 CS |
9849 | |
9850 | return write; | |
9851 | } | |
9852 | ||
d62a17ae | 9853 | static int config_write_network_area(struct vty *vty, struct ospf *ospf) |
718e3744 | 9854 | { |
d62a17ae | 9855 | struct route_node *rn; |
9856 | u_char buf[INET_ADDRSTRLEN]; | |
718e3744 | 9857 | |
d62a17ae | 9858 | /* `network area' print. */ |
9859 | for (rn = route_top(ospf->networks); rn; rn = route_next(rn)) | |
9860 | if (rn->info) { | |
9861 | struct ospf_network *n = rn->info; | |
718e3744 | 9862 | |
d62a17ae | 9863 | memset(buf, 0, INET_ADDRSTRLEN); |
718e3744 | 9864 | |
d62a17ae | 9865 | /* Create Area ID string by specified Area ID format. */ |
9866 | if (n->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) | |
9867 | strncpy((char *)buf, inet_ntoa(n->area_id), | |
9868 | INET_ADDRSTRLEN); | |
9869 | else | |
9870 | sprintf((char *)buf, "%lu", | |
9871 | (unsigned long int)ntohl( | |
9872 | n->area_id.s_addr)); | |
718e3744 | 9873 | |
d62a17ae | 9874 | /* Network print. */ |
9875 | vty_out(vty, " network %s/%d area %s\n", | |
9876 | inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen, | |
9877 | buf); | |
9878 | } | |
718e3744 | 9879 | |
d62a17ae | 9880 | return 0; |
718e3744 | 9881 | } |
9882 | ||
d62a17ae | 9883 | static int config_write_ospf_area(struct vty *vty, struct ospf *ospf) |
718e3744 | 9884 | { |
d62a17ae | 9885 | struct listnode *node; |
9886 | struct ospf_area *area; | |
9887 | u_char buf[INET_ADDRSTRLEN]; | |
718e3744 | 9888 | |
d62a17ae | 9889 | /* Area configuration print. */ |
9890 | for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { | |
9891 | struct route_node *rn1; | |
718e3744 | 9892 | |
d62a17ae | 9893 | area_id2str((char *)buf, INET_ADDRSTRLEN, &area->area_id, |
9894 | area->area_id_fmt); | |
718e3744 | 9895 | |
d62a17ae | 9896 | if (area->auth_type != OSPF_AUTH_NULL) { |
9897 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
9898 | vty_out(vty, " area %s authentication\n", buf); | |
9899 | else | |
9900 | vty_out(vty, | |
9901 | " area %s authentication message-digest\n", | |
9902 | buf); | |
9903 | } | |
718e3744 | 9904 | |
d62a17ae | 9905 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
9906 | vty_out(vty, " area %s shortcut %s\n", buf, | |
9907 | ospf_shortcut_mode_str | |
9908 | [area->shortcut_configured]); | |
9909 | ||
9910 | if ((area->external_routing == OSPF_AREA_STUB) | |
9911 | || (area->external_routing == OSPF_AREA_NSSA)) { | |
7ef56a73 | 9912 | if (area->external_routing == OSPF_AREA_STUB) { |
d62a17ae | 9913 | vty_out(vty, " area %s stub", buf); |
7ef56a73 CS |
9914 | if (area->no_summary) |
9915 | vty_out(vty, " no-summary\n"); | |
9916 | vty_out(vty, "\n"); | |
9917 | } else if (area->external_routing == OSPF_AREA_NSSA) { | |
d62a17ae | 9918 | switch (area->NSSATranslatorRole) { |
9919 | case OSPF_NSSA_ROLE_NEVER: | |
7ef56a73 CS |
9920 | vty_out(vty, |
9921 | " area %s nssa translate-never\n", | |
9922 | buf); | |
d62a17ae | 9923 | break; |
9924 | case OSPF_NSSA_ROLE_ALWAYS: | |
7ef56a73 CS |
9925 | vty_out(vty, |
9926 | " area %s nssa translate-always\n", | |
9927 | buf); | |
d62a17ae | 9928 | break; |
2643b2bc CS |
9929 | case OSPF_NSSA_ROLE_CANDIDATE: |
9930 | vty_out(vty, " area %s nssa \n", buf); | |
9931 | break; | |
d62a17ae | 9932 | } |
7ef56a73 CS |
9933 | if (area->no_summary) |
9934 | vty_out(vty, | |
9935 | " area %s nssa no-summary\n", | |
9936 | buf); | |
d62a17ae | 9937 | } |
718e3744 | 9938 | |
d62a17ae | 9939 | if (area->default_cost != 1) |
9940 | vty_out(vty, " area %s default-cost %d\n", buf, | |
9941 | area->default_cost); | |
9942 | } | |
718e3744 | 9943 | |
d62a17ae | 9944 | for (rn1 = route_top(area->ranges); rn1; rn1 = route_next(rn1)) |
9945 | if (rn1->info) { | |
9946 | struct ospf_area_range *range = rn1->info; | |
718e3744 | 9947 | |
d62a17ae | 9948 | vty_out(vty, " area %s range %s/%d", buf, |
9949 | inet_ntoa(rn1->p.u.prefix4), | |
9950 | rn1->p.prefixlen); | |
718e3744 | 9951 | |
d62a17ae | 9952 | if (range->cost_config |
9953 | != OSPF_AREA_RANGE_COST_UNSPEC) | |
9954 | vty_out(vty, " cost %d", | |
9955 | range->cost_config); | |
718e3744 | 9956 | |
d62a17ae | 9957 | if (!CHECK_FLAG(range->flags, |
9958 | OSPF_AREA_RANGE_ADVERTISE)) | |
9959 | vty_out(vty, " not-advertise"); | |
718e3744 | 9960 | |
d62a17ae | 9961 | if (CHECK_FLAG(range->flags, |
9962 | OSPF_AREA_RANGE_SUBSTITUTE)) | |
9963 | vty_out(vty, " substitute %s/%d", | |
9964 | inet_ntoa(range->subst_addr), | |
9965 | range->subst_masklen); | |
9966 | ||
9967 | vty_out(vty, "\n"); | |
9968 | } | |
9969 | ||
9970 | if (EXPORT_NAME(area)) | |
9971 | vty_out(vty, " area %s export-list %s\n", buf, | |
9972 | EXPORT_NAME(area)); | |
9973 | ||
9974 | if (IMPORT_NAME(area)) | |
9975 | vty_out(vty, " area %s import-list %s\n", buf, | |
9976 | IMPORT_NAME(area)); | |
9977 | ||
9978 | if (PREFIX_NAME_IN(area)) | |
9979 | vty_out(vty, " area %s filter-list prefix %s in\n", buf, | |
9980 | PREFIX_NAME_IN(area)); | |
9981 | ||
9982 | if (PREFIX_NAME_OUT(area)) | |
9983 | vty_out(vty, " area %s filter-list prefix %s out\n", | |
9984 | buf, PREFIX_NAME_OUT(area)); | |
9985 | } | |
9986 | ||
9987 | return 0; | |
718e3744 | 9988 | } |
9989 | ||
d62a17ae | 9990 | static int config_write_ospf_nbr_nbma(struct vty *vty, struct ospf *ospf) |
718e3744 | 9991 | { |
d62a17ae | 9992 | struct ospf_nbr_nbma *nbr_nbma; |
9993 | struct route_node *rn; | |
718e3744 | 9994 | |
d62a17ae | 9995 | /* Static Neighbor configuration print. */ |
9996 | for (rn = route_top(ospf->nbr_nbma); rn; rn = route_next(rn)) | |
9997 | if ((nbr_nbma = rn->info)) { | |
9998 | vty_out(vty, " neighbor %s", inet_ntoa(nbr_nbma->addr)); | |
718e3744 | 9999 | |
d62a17ae | 10000 | if (nbr_nbma->priority |
10001 | != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
10002 | vty_out(vty, " priority %d", | |
10003 | nbr_nbma->priority); | |
718e3744 | 10004 | |
d62a17ae | 10005 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
10006 | vty_out(vty, " poll-interval %d", | |
10007 | nbr_nbma->v_poll); | |
10008 | ||
10009 | vty_out(vty, "\n"); | |
10010 | } | |
10011 | ||
10012 | return 0; | |
10013 | } | |
10014 | ||
10015 | static int config_write_virtual_link(struct vty *vty, struct ospf *ospf) | |
10016 | { | |
10017 | struct listnode *node; | |
10018 | struct ospf_vl_data *vl_data; | |
10019 | char buf[INET_ADDRSTRLEN]; | |
10020 | ||
10021 | /* Virtual-Link print */ | |
10022 | for (ALL_LIST_ELEMENTS_RO(ospf->vlinks, node, vl_data)) { | |
10023 | struct listnode *n2; | |
10024 | struct crypt_key *ck; | |
10025 | struct ospf_interface *oi; | |
10026 | ||
10027 | if (vl_data != NULL) { | |
10028 | memset(buf, 0, INET_ADDRSTRLEN); | |
10029 | ||
10030 | area_id2str(buf, sizeof(buf), &vl_data->vl_area_id, | |
10031 | vl_data->vl_area_id_fmt); | |
10032 | oi = vl_data->vl_oi; | |
10033 | ||
10034 | /* timers */ | |
10035 | if (OSPF_IF_PARAM(oi, v_hello) | |
10036 | != OSPF_HELLO_INTERVAL_DEFAULT | |
10037 | || OSPF_IF_PARAM(oi, v_wait) | |
10038 | != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT | |
10039 | || OSPF_IF_PARAM(oi, retransmit_interval) | |
10040 | != OSPF_RETRANSMIT_INTERVAL_DEFAULT | |
10041 | || OSPF_IF_PARAM(oi, transmit_delay) | |
10042 | != OSPF_TRANSMIT_DELAY_DEFAULT) | |
10043 | vty_out(vty, | |
10044 | " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d\n", | |
10045 | buf, inet_ntoa(vl_data->vl_peer), | |
10046 | OSPF_IF_PARAM(oi, v_hello), | |
10047 | OSPF_IF_PARAM(oi, retransmit_interval), | |
10048 | OSPF_IF_PARAM(oi, transmit_delay), | |
10049 | OSPF_IF_PARAM(oi, v_wait)); | |
10050 | else | |
10051 | vty_out(vty, " area %s virtual-link %s\n", buf, | |
10052 | inet_ntoa(vl_data->vl_peer)); | |
10053 | /* Auth key */ | |
10054 | if (IF_DEF_PARAMS(vl_data->vl_oi->ifp)->auth_simple[0] | |
10055 | != '\0') | |
10056 | vty_out(vty, | |
10057 | " area %s virtual-link %s authentication-key %s\n", | |
10058 | buf, inet_ntoa(vl_data->vl_peer), | |
10059 | IF_DEF_PARAMS(vl_data->vl_oi->ifp) | |
10060 | ->auth_simple); | |
10061 | /* md5 keys */ | |
10062 | for (ALL_LIST_ELEMENTS_RO( | |
10063 | IF_DEF_PARAMS(vl_data->vl_oi->ifp) | |
10064 | ->auth_crypt, | |
10065 | n2, ck)) | |
10066 | vty_out(vty, | |
10067 | " area %s virtual-link %s" | |
10068 | " message-digest-key %d md5 %s\n", | |
10069 | buf, inet_ntoa(vl_data->vl_peer), | |
10070 | ck->key_id, ck->auth_key); | |
10071 | } | |
10072 | } | |
10073 | ||
10074 | return 0; | |
718e3744 | 10075 | } |
10076 | ||
6b0655a2 | 10077 | |
d62a17ae | 10078 | static int config_write_ospf_redistribute(struct vty *vty, struct ospf *ospf) |
718e3744 | 10079 | { |
d62a17ae | 10080 | int type; |
718e3744 | 10081 | |
d62a17ae | 10082 | /* redistribute print. */ |
10083 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { | |
10084 | struct list *red_list; | |
10085 | struct listnode *node; | |
10086 | struct ospf_redist *red; | |
718e3744 | 10087 | |
d62a17ae | 10088 | red_list = ospf->redist[type]; |
10089 | if (!red_list) | |
10090 | continue; | |
7c8ff89e | 10091 | |
d62a17ae | 10092 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
10093 | vty_out(vty, " redistribute %s", | |
10094 | zebra_route_string(type)); | |
10095 | if (red->instance) | |
10096 | vty_out(vty, " %d", red->instance); | |
7c8ff89e | 10097 | |
d62a17ae | 10098 | if (red->dmetric.value >= 0) |
10099 | vty_out(vty, " metric %d", red->dmetric.value); | |
7c8ff89e | 10100 | |
d62a17ae | 10101 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) |
10102 | vty_out(vty, " metric-type 1"); | |
7c8ff89e | 10103 | |
d62a17ae | 10104 | if (ROUTEMAP_NAME(red)) |
10105 | vty_out(vty, " route-map %s", | |
10106 | ROUTEMAP_NAME(red)); | |
7c8ff89e | 10107 | |
d62a17ae | 10108 | vty_out(vty, "\n"); |
10109 | } | |
10110 | } | |
718e3744 | 10111 | |
d62a17ae | 10112 | return 0; |
718e3744 | 10113 | } |
10114 | ||
d62a17ae | 10115 | static int config_write_ospf_default_metric(struct vty *vty, struct ospf *ospf) |
718e3744 | 10116 | { |
d62a17ae | 10117 | if (ospf->default_metric != -1) |
10118 | vty_out(vty, " default-metric %d\n", ospf->default_metric); | |
10119 | return 0; | |
718e3744 | 10120 | } |
10121 | ||
d62a17ae | 10122 | static int config_write_ospf_distribute(struct vty *vty, struct ospf *ospf) |
10123 | { | |
10124 | int type; | |
10125 | struct ospf_redist *red; | |
718e3744 | 10126 | |
d62a17ae | 10127 | if (ospf) { |
10128 | /* distribute-list print. */ | |
10129 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
10130 | if (DISTRIBUTE_NAME(ospf, type)) | |
10131 | vty_out(vty, " distribute-list %s out %s\n", | |
10132 | DISTRIBUTE_NAME(ospf, type), | |
10133 | zebra_route_string(type)); | |
7c8ff89e | 10134 | |
d62a17ae | 10135 | /* default-information print. */ |
10136 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) { | |
10137 | vty_out(vty, " default-information originate"); | |
10138 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
10139 | vty_out(vty, " always"); | |
718e3744 | 10140 | |
d62a17ae | 10141 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
10142 | if (red) { | |
10143 | if (red->dmetric.value >= 0) | |
10144 | vty_out(vty, " metric %d", | |
10145 | red->dmetric.value); | |
951da435 | 10146 | |
d62a17ae | 10147 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) |
10148 | vty_out(vty, " metric-type 1"); | |
718e3744 | 10149 | |
d62a17ae | 10150 | if (ROUTEMAP_NAME(red)) |
10151 | vty_out(vty, " route-map %s", | |
10152 | ROUTEMAP_NAME(red)); | |
10153 | } | |
10154 | ||
10155 | vty_out(vty, "\n"); | |
10156 | } | |
10157 | } | |
10158 | ||
10159 | return 0; | |
718e3744 | 10160 | } |
10161 | ||
d62a17ae | 10162 | static int config_write_ospf_distance(struct vty *vty, struct ospf *ospf) |
10163 | { | |
10164 | struct route_node *rn; | |
10165 | struct ospf_distance *odistance; | |
10166 | ||
10167 | if (ospf->distance_all) | |
10168 | vty_out(vty, " distance %d\n", ospf->distance_all); | |
10169 | ||
10170 | if (ospf->distance_intra || ospf->distance_inter | |
10171 | || ospf->distance_external) { | |
10172 | vty_out(vty, " distance ospf"); | |
10173 | ||
10174 | if (ospf->distance_intra) | |
10175 | vty_out(vty, " intra-area %d", ospf->distance_intra); | |
10176 | if (ospf->distance_inter) | |
10177 | vty_out(vty, " inter-area %d", ospf->distance_inter); | |
10178 | if (ospf->distance_external) | |
10179 | vty_out(vty, " external %d", ospf->distance_external); | |
10180 | ||
10181 | vty_out(vty, "\n"); | |
10182 | } | |
10183 | ||
10184 | for (rn = route_top(ospf->distance_table); rn; rn = route_next(rn)) | |
10185 | if ((odistance = rn->info) != NULL) { | |
10186 | vty_out(vty, " distance %d %s/%d %s\n", | |
10187 | odistance->distance, inet_ntoa(rn->p.u.prefix4), | |
10188 | rn->p.prefixlen, | |
10189 | odistance->access_list ? odistance->access_list | |
10190 | : ""); | |
10191 | } | |
10192 | return 0; | |
718e3744 | 10193 | } |
10194 | ||
43b8d1d8 | 10195 | static int ospf_config_write_one(struct vty *vty, struct ospf *ospf) |
d62a17ae | 10196 | { |
f4e14fdb | 10197 | struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); |
d62a17ae | 10198 | struct interface *ifp; |
10199 | struct ospf_interface *oi; | |
43b8d1d8 | 10200 | struct listnode *node = NULL; |
d62a17ae | 10201 | int write = 0; |
10202 | ||
43b8d1d8 CS |
10203 | /* `router ospf' print. */ |
10204 | if (ospf->instance && ospf->name) { | |
996c9314 LB |
10205 | vty_out(vty, "router ospf %d vrf %s\n", ospf->instance, |
10206 | ospf->name); | |
43b8d1d8 | 10207 | } else if (ospf->instance) { |
996c9314 | 10208 | vty_out(vty, "router ospf %d\n", ospf->instance); |
43b8d1d8 | 10209 | } else if (ospf->name) { |
996c9314 | 10210 | vty_out(vty, "router ospf vrf %s\n", ospf->name); |
43b8d1d8 CS |
10211 | } else |
10212 | vty_out(vty, "router ospf\n"); | |
10213 | ||
10214 | if (!ospf->networks) { | |
10215 | write++; | |
b5a8894d | 10216 | return write; |
43b8d1d8 | 10217 | } |
d62a17ae | 10218 | |
43b8d1d8 CS |
10219 | /* Router ID print. */ |
10220 | if (ospf->router_id_static.s_addr != 0) | |
10221 | vty_out(vty, " ospf router-id %s\n", | |
10222 | inet_ntoa(ospf->router_id_static)); | |
d62a17ae | 10223 | |
43b8d1d8 CS |
10224 | /* ABR type print. */ |
10225 | if (ospf->abr_type != OSPF_ABR_DEFAULT) | |
10226 | vty_out(vty, " ospf abr-type %s\n", | |
10227 | ospf_abr_type_str[ospf->abr_type]); | |
b5a8894d | 10228 | |
43b8d1d8 CS |
10229 | /* log-adjacency-changes flag print. */ |
10230 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) { | |
10231 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
10232 | vty_out(vty, " log-adjacency-changes detail\n"); | |
10233 | else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES) | |
10234 | vty_out(vty, " log-adjacency-changes\n"); | |
10235 | } else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) { | |
10236 | vty_out(vty, " no log-adjacency-changes\n"); | |
10237 | } | |
b5a8894d | 10238 | |
43b8d1d8 CS |
10239 | /* RFC1583 compatibility flag print -- Compatible with CISCO |
10240 | * 12.1. */ | |
10241 | if (CHECK_FLAG(ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
10242 | vty_out(vty, " compatible rfc1583\n"); | |
d62a17ae | 10243 | |
43b8d1d8 CS |
10244 | /* auto-cost reference-bandwidth configuration. */ |
10245 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) { | |
10246 | vty_out(vty, | |
10247 | "! Important: ensure reference bandwidth " | |
10248 | "is consistent across all routers\n"); | |
10249 | vty_out(vty, " auto-cost reference-bandwidth %d\n", | |
10250 | ospf->ref_bandwidth); | |
10251 | } | |
d62a17ae | 10252 | |
43b8d1d8 CS |
10253 | /* SPF timers print. */ |
10254 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT | |
10255 | || ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT | |
10256 | || ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
996c9314 LB |
10257 | vty_out(vty, " timers throttle spf %d %d %d\n", ospf->spf_delay, |
10258 | ospf->spf_holdtime, ospf->spf_max_holdtime); | |
43b8d1d8 CS |
10259 | |
10260 | /* LSA timers print. */ | |
10261 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) | |
10262 | vty_out(vty, " timers throttle lsa all %d\n", | |
10263 | ospf->min_ls_interval); | |
10264 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) | |
10265 | vty_out(vty, " timers lsa min-arrival %d\n", | |
10266 | ospf->min_ls_arrival); | |
10267 | ||
10268 | /* Write multiplier print. */ | |
10269 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) | |
10270 | vty_out(vty, " ospf write-multiplier %d\n", | |
10271 | ospf->write_oi_count); | |
d62a17ae | 10272 | |
43b8d1d8 CS |
10273 | /* Max-metric router-lsa print */ |
10274 | config_write_stub_router(vty, ospf); | |
d62a17ae | 10275 | |
43b8d1d8 | 10276 | /* SPF refresh parameters print. */ |
996c9314 LB |
10277 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
10278 | vty_out(vty, " refresh timer %d\n", ospf->lsa_refresh_interval); | |
d62a17ae | 10279 | |
43b8d1d8 CS |
10280 | /* Redistribute information print. */ |
10281 | config_write_ospf_redistribute(vty, ospf); | |
d62a17ae | 10282 | |
43b8d1d8 CS |
10283 | /* passive-interface print. */ |
10284 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) | |
10285 | vty_out(vty, " passive-interface default\n"); | |
d62a17ae | 10286 | |
451fda4f | 10287 | FOR_ALL_INTERFACES (vrf, ifp) |
43b8d1d8 CS |
10288 | if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), |
10289 | passive_interface) | |
10290 | && IF_DEF_PARAMS(ifp)->passive_interface | |
996c9314 | 10291 | != ospf->passive_interface_default) { |
43b8d1d8 | 10292 | vty_out(vty, " %spassive-interface %s\n", |
996c9314 LB |
10293 | IF_DEF_PARAMS(ifp)->passive_interface ? "" |
10294 | : "no ", | |
43b8d1d8 CS |
10295 | ifp->name); |
10296 | } | |
10297 | for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { | |
996c9314 | 10298 | if (!OSPF_IF_PARAM_CONFIGURED(oi->params, passive_interface)) |
43b8d1d8 CS |
10299 | continue; |
10300 | if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi->ifp), | |
10301 | passive_interface)) { | |
10302 | if (oi->params->passive_interface | |
996c9314 | 10303 | == IF_DEF_PARAMS(oi->ifp)->passive_interface) |
43b8d1d8 CS |
10304 | continue; |
10305 | } else if (oi->params->passive_interface | |
10306 | == ospf->passive_interface_default) | |
10307 | continue; | |
d62a17ae | 10308 | |
43b8d1d8 CS |
10309 | vty_out(vty, " %spassive-interface %s %s\n", |
10310 | oi->params->passive_interface ? "" : "no ", | |
996c9314 | 10311 | oi->ifp->name, inet_ntoa(oi->address->u.prefix4)); |
43b8d1d8 | 10312 | } |
d62a17ae | 10313 | |
43b8d1d8 CS |
10314 | /* Network area print. */ |
10315 | config_write_network_area(vty, ospf); | |
d62a17ae | 10316 | |
43b8d1d8 CS |
10317 | /* Area config print. */ |
10318 | config_write_ospf_area(vty, ospf); | |
d62a17ae | 10319 | |
43b8d1d8 CS |
10320 | /* static neighbor print. */ |
10321 | config_write_ospf_nbr_nbma(vty, ospf); | |
10322 | ||
10323 | /* Virtual-Link print. */ | |
10324 | config_write_virtual_link(vty, ospf); | |
10325 | ||
10326 | /* Default metric configuration. */ | |
10327 | config_write_ospf_default_metric(vty, ospf); | |
10328 | ||
10329 | /* Distribute-list and default-information print. */ | |
10330 | config_write_ospf_distribute(vty, ospf); | |
10331 | ||
10332 | /* Distance configuration. */ | |
10333 | config_write_ospf_distance(vty, ospf); | |
10334 | ||
10335 | ospf_opaque_config_write_router(vty, ospf); | |
10336 | ||
10337 | write++; | |
10338 | return write; | |
10339 | } | |
10340 | ||
10341 | /* OSPF configuration write function. */ | |
10342 | static int ospf_config_write(struct vty *vty) | |
10343 | { | |
10344 | struct ospf *ospf; | |
10345 | struct listnode *ospf_node = NULL; | |
10346 | int write = 0; | |
10347 | ||
10348 | if (listcount(om->ospf) == 0) | |
10349 | return write; | |
10350 | ||
10351 | for (ALL_LIST_ELEMENTS_RO(om->ospf, ospf_node, ospf)) { | |
88d77109 CS |
10352 | /* VRF Default check if it is running. |
10353 | * Upon daemon start, there could be default instance | |
10354 | * in absence of 'router ospf'/oi_running is disabled. */ | |
10355 | if (ospf->vrf_id == VRF_DEFAULT && ospf->oi_running) | |
10356 | write += ospf_config_write_one(vty, ospf); | |
10357 | /* For Non-Default VRF simply display the configuration, | |
10358 | * even if it is not oi_running. */ | |
10359 | else if (ospf->vrf_id != VRF_DEFAULT) | |
43b8d1d8 | 10360 | write += ospf_config_write_one(vty, ospf); |
b5a8894d | 10361 | } |
d62a17ae | 10362 | return write; |
10363 | } | |
10364 | ||
10365 | void ospf_vty_show_init(void) | |
10366 | { | |
10367 | /* "show ip ospf" commands. */ | |
10368 | install_element(VIEW_NODE, &show_ip_ospf_cmd); | |
10369 | ||
10370 | install_element(VIEW_NODE, &show_ip_ospf_instance_cmd); | |
10371 | ||
10372 | /* "show ip ospf database" commands. */ | |
10373 | install_element(VIEW_NODE, &show_ip_ospf_database_max_cmd); | |
10374 | ||
10375 | install_element(VIEW_NODE, | |
10376 | &show_ip_ospf_instance_database_type_adv_router_cmd); | |
10377 | install_element(VIEW_NODE, &show_ip_ospf_instance_database_cmd); | |
10378 | install_element(VIEW_NODE, &show_ip_ospf_instance_database_max_cmd); | |
10379 | ||
10380 | /* "show ip ospf interface" commands. */ | |
10381 | install_element(VIEW_NODE, &show_ip_ospf_interface_cmd); | |
10382 | ||
10383 | install_element(VIEW_NODE, &show_ip_ospf_instance_interface_cmd); | |
c9339663 CS |
10384 | /* "show ip ospf interface traffic */ |
10385 | install_element(VIEW_NODE, &show_ip_ospf_interface_traffic_cmd); | |
d62a17ae | 10386 | |
10387 | /* "show ip ospf neighbor" commands. */ | |
10388 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
10389 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
10390 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
10391 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
10392 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
10393 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
10394 | install_element(VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
10395 | ||
10396 | install_element(VIEW_NODE, | |
10397 | &show_ip_ospf_instance_neighbor_int_detail_cmd); | |
10398 | install_element(VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
10399 | install_element(VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
10400 | install_element(VIEW_NODE, | |
10401 | &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
10402 | install_element(VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
10403 | install_element(VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
10404 | install_element(VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
10405 | ||
10406 | /* "show ip ospf route" commands. */ | |
10407 | install_element(VIEW_NODE, &show_ip_ospf_route_cmd); | |
10408 | install_element(VIEW_NODE, &show_ip_ospf_border_routers_cmd); | |
10409 | ||
10410 | install_element(VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
10411 | install_element(VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); | |
b5a8894d CS |
10412 | |
10413 | /* "show ip ospf vrfs" commands. */ | |
10414 | install_element(VIEW_NODE, &show_ip_ospf_vrfs_cmd); | |
718e3744 | 10415 | } |
10416 | ||
6b0655a2 | 10417 | |
718e3744 | 10418 | /* ospfd's interface node. */ |
d62a17ae | 10419 | static struct cmd_node interface_node = {INTERFACE_NODE, "%s(config-if)# ", 1}; |
718e3744 | 10420 | |
10421 | /* Initialization of OSPF interface. */ | |
d62a17ae | 10422 | static void ospf_vty_if_init(void) |
10423 | { | |
10424 | /* Install interface node. */ | |
10425 | install_node(&interface_node, config_write_interface); | |
10426 | if_cmd_init(); | |
10427 | ||
10428 | /* "ip ospf authentication" commands. */ | |
10429 | install_element(INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
10430 | install_element(INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); | |
10431 | install_element(INTERFACE_NODE, | |
10432 | &no_ip_ospf_authentication_args_addr_cmd); | |
10433 | install_element(INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); | |
10434 | install_element(INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); | |
10435 | install_element(INTERFACE_NODE, | |
10436 | &no_ip_ospf_authentication_key_authkey_addr_cmd); | |
10437 | install_element(INTERFACE_NODE, | |
10438 | &no_ospf_authentication_key_authkey_addr_cmd); | |
10439 | ||
10440 | /* "ip ospf message-digest-key" commands. */ | |
10441 | install_element(INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); | |
10442 | install_element(INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
10443 | ||
10444 | /* "ip ospf cost" commands. */ | |
10445 | install_element(INTERFACE_NODE, &ip_ospf_cost_cmd); | |
10446 | install_element(INTERFACE_NODE, &no_ip_ospf_cost_cmd); | |
10447 | ||
10448 | /* "ip ospf mtu-ignore" commands. */ | |
10449 | install_element(INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
10450 | install_element(INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); | |
10451 | ||
10452 | /* "ip ospf dead-interval" commands. */ | |
10453 | install_element(INTERFACE_NODE, &ip_ospf_dead_interval_cmd); | |
10454 | install_element(INTERFACE_NODE, | |
10455 | &ip_ospf_dead_interval_minimal_addr_cmd); | |
10456 | install_element(INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); | |
10457 | ||
10458 | /* "ip ospf hello-interval" commands. */ | |
10459 | install_element(INTERFACE_NODE, &ip_ospf_hello_interval_cmd); | |
10460 | install_element(INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
10461 | ||
10462 | /* "ip ospf network" commands. */ | |
10463 | install_element(INTERFACE_NODE, &ip_ospf_network_cmd); | |
10464 | install_element(INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
10465 | ||
10466 | /* "ip ospf priority" commands. */ | |
10467 | install_element(INTERFACE_NODE, &ip_ospf_priority_cmd); | |
10468 | install_element(INTERFACE_NODE, &no_ip_ospf_priority_cmd); | |
10469 | ||
10470 | /* "ip ospf retransmit-interval" commands. */ | |
10471 | install_element(INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
10472 | install_element(INTERFACE_NODE, | |
10473 | &no_ip_ospf_retransmit_interval_addr_cmd); | |
10474 | ||
10475 | /* "ip ospf transmit-delay" commands. */ | |
10476 | install_element(INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
10477 | install_element(INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); | |
10478 | ||
10479 | /* "ip ospf area" commands. */ | |
10480 | install_element(INTERFACE_NODE, &ip_ospf_area_cmd); | |
10481 | install_element(INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
10482 | ||
10483 | /* These commands are compatibitliy for previous version. */ | |
10484 | install_element(INTERFACE_NODE, &ospf_authentication_key_cmd); | |
10485 | install_element(INTERFACE_NODE, &ospf_message_digest_key_cmd); | |
10486 | install_element(INTERFACE_NODE, &no_ospf_message_digest_key_cmd); | |
10487 | install_element(INTERFACE_NODE, &ospf_dead_interval_cmd); | |
10488 | install_element(INTERFACE_NODE, &no_ospf_dead_interval_cmd); | |
10489 | install_element(INTERFACE_NODE, &ospf_hello_interval_cmd); | |
10490 | install_element(INTERFACE_NODE, &no_ospf_hello_interval_cmd); | |
10491 | install_element(INTERFACE_NODE, &ospf_cost_cmd); | |
10492 | install_element(INTERFACE_NODE, &no_ospf_cost_cmd); | |
10493 | install_element(INTERFACE_NODE, &ospf_network_cmd); | |
10494 | install_element(INTERFACE_NODE, &no_ospf_network_cmd); | |
10495 | install_element(INTERFACE_NODE, &ospf_priority_cmd); | |
10496 | install_element(INTERFACE_NODE, &no_ospf_priority_cmd); | |
10497 | install_element(INTERFACE_NODE, &ospf_retransmit_interval_cmd); | |
10498 | install_element(INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); | |
10499 | install_element(INTERFACE_NODE, &ospf_transmit_delay_cmd); | |
10500 | install_element(INTERFACE_NODE, &no_ospf_transmit_delay_cmd); | |
10501 | } | |
10502 | ||
10503 | static void ospf_vty_zebra_init(void) | |
10504 | { | |
10505 | install_element(OSPF_NODE, &ospf_redistribute_source_cmd); | |
10506 | install_element(OSPF_NODE, &no_ospf_redistribute_source_cmd); | |
10507 | install_element(OSPF_NODE, &ospf_redistribute_instance_source_cmd); | |
10508 | install_element(OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
10509 | ||
10510 | install_element(OSPF_NODE, &ospf_distribute_list_out_cmd); | |
10511 | install_element(OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
10512 | ||
10513 | install_element(OSPF_NODE, &ospf_default_information_originate_cmd); | |
10514 | install_element(OSPF_NODE, &no_ospf_default_information_originate_cmd); | |
10515 | ||
10516 | install_element(OSPF_NODE, &ospf_default_metric_cmd); | |
10517 | install_element(OSPF_NODE, &no_ospf_default_metric_cmd); | |
10518 | ||
10519 | install_element(OSPF_NODE, &ospf_distance_cmd); | |
10520 | install_element(OSPF_NODE, &no_ospf_distance_cmd); | |
10521 | install_element(OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
10522 | install_element(OSPF_NODE, &ospf_distance_ospf_cmd); | |
718e3744 | 10523 | #if 0 |
10524 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
10525 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
10526 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
10527 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
10528 | #endif /* 0 */ | |
10529 | } | |
10530 | ||
d62a17ae | 10531 | static struct cmd_node ospf_node = {OSPF_NODE, "%s(config-router)# ", 1}; |
718e3744 | 10532 | |
d62a17ae | 10533 | static void ospf_interface_clear(struct interface *ifp) |
09f35f8c | 10534 | { |
d62a17ae | 10535 | if (!if_is_operative(ifp)) |
10536 | return; | |
09f35f8c | 10537 | |
d62a17ae | 10538 | if (IS_DEBUG_OSPF(ism, ISM_EVENTS)) |
10539 | zlog_debug("ISM[%s]: clear by reset", ifp->name); | |
09f35f8c | 10540 | |
d62a17ae | 10541 | ospf_if_reset(ifp); |
09f35f8c DS |
10542 | } |
10543 | ||
10544 | DEFUN (clear_ip_ospf_interface, | |
10545 | clear_ip_ospf_interface_cmd, | |
10546 | "clear ip ospf interface [IFNAME]", | |
10547 | CLEAR_STR | |
10548 | IP_STR | |
10549 | "OSPF information\n" | |
10550 | "Interface information\n" | |
10551 | "Interface name\n") | |
10552 | { | |
d62a17ae | 10553 | int idx_ifname = 4; |
10554 | struct interface *ifp; | |
f4e14fdb | 10555 | struct listnode *node; |
b5a8894d | 10556 | struct ospf *ospf = NULL; |
09f35f8c | 10557 | |
d62a17ae | 10558 | if (argc == 4) /* Clear all the ospfv2 interfaces. */ |
10559 | { | |
f4e14fdb RW |
10560 | for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { |
10561 | struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); | |
451fda4f | 10562 | FOR_ALL_INTERFACES (vrf, ifp) |
b5a8894d CS |
10563 | ospf_interface_clear(ifp); |
10564 | } | |
10565 | } else { | |
10566 | /* Interface name is specified. */ | |
10567 | ifp = if_lookup_by_name_all_vrf(argv[idx_ifname]->arg); | |
10568 | if (ifp == NULL) | |
d62a17ae | 10569 | vty_out(vty, "No such interface name\n"); |
10570 | else | |
10571 | ospf_interface_clear(ifp); | |
10572 | } | |
10573 | ||
10574 | return CMD_SUCCESS; | |
09f35f8c DS |
10575 | } |
10576 | ||
d62a17ae | 10577 | void ospf_vty_clear_init(void) |
09f35f8c | 10578 | { |
d62a17ae | 10579 | install_element(ENABLE_NODE, &clear_ip_ospf_interface_cmd); |
09f35f8c DS |
10580 | } |
10581 | ||
6b0655a2 | 10582 | |
718e3744 | 10583 | /* Install OSPF related vty commands. */ |
d62a17ae | 10584 | void ospf_vty_init(void) |
10585 | { | |
10586 | /* Install ospf top node. */ | |
10587 | install_node(&ospf_node, ospf_config_write); | |
10588 | ||
10589 | /* "router ospf" commands. */ | |
10590 | install_element(CONFIG_NODE, &router_ospf_cmd); | |
10591 | install_element(CONFIG_NODE, &no_router_ospf_cmd); | |
10592 | ||
10593 | ||
10594 | install_default(OSPF_NODE); | |
10595 | ||
10596 | /* "ospf router-id" commands. */ | |
10597 | install_element(OSPF_NODE, &ospf_router_id_cmd); | |
10598 | install_element(OSPF_NODE, &ospf_router_id_old_cmd); | |
10599 | install_element(OSPF_NODE, &no_ospf_router_id_cmd); | |
10600 | ||
10601 | /* "passive-interface" commands. */ | |
10602 | install_element(OSPF_NODE, &ospf_passive_interface_addr_cmd); | |
10603 | install_element(OSPF_NODE, &no_ospf_passive_interface_addr_cmd); | |
10604 | ||
10605 | /* "ospf abr-type" commands. */ | |
10606 | install_element(OSPF_NODE, &ospf_abr_type_cmd); | |
10607 | install_element(OSPF_NODE, &no_ospf_abr_type_cmd); | |
10608 | ||
10609 | /* "ospf log-adjacency-changes" commands. */ | |
10610 | install_element(OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
10611 | install_element(OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
10612 | install_element(OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
10613 | install_element(OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
10614 | ||
10615 | /* "ospf rfc1583-compatible" commands. */ | |
10616 | install_element(OSPF_NODE, &ospf_compatible_rfc1583_cmd); | |
10617 | install_element(OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
10618 | install_element(OSPF_NODE, &ospf_rfc1583_flag_cmd); | |
10619 | install_element(OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
10620 | ||
10621 | /* "network area" commands. */ | |
10622 | install_element(OSPF_NODE, &ospf_network_area_cmd); | |
10623 | install_element(OSPF_NODE, &no_ospf_network_area_cmd); | |
10624 | ||
10625 | /* "area authentication" commands. */ | |
10626 | install_element(OSPF_NODE, | |
10627 | &ospf_area_authentication_message_digest_cmd); | |
10628 | install_element(OSPF_NODE, &ospf_area_authentication_cmd); | |
10629 | install_element(OSPF_NODE, &no_ospf_area_authentication_cmd); | |
10630 | ||
10631 | /* "area range" commands. */ | |
10632 | install_element(OSPF_NODE, &ospf_area_range_cmd); | |
10633 | install_element(OSPF_NODE, &ospf_area_range_cost_cmd); | |
10634 | install_element(OSPF_NODE, &ospf_area_range_not_advertise_cmd); | |
10635 | install_element(OSPF_NODE, &no_ospf_area_range_cmd); | |
10636 | install_element(OSPF_NODE, &ospf_area_range_substitute_cmd); | |
10637 | install_element(OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
10638 | ||
10639 | /* "area virtual-link" commands. */ | |
10640 | install_element(OSPF_NODE, &ospf_area_vlink_cmd); | |
10641 | install_element(OSPF_NODE, &ospf_area_vlink_intervals_cmd); | |
10642 | install_element(OSPF_NODE, &no_ospf_area_vlink_cmd); | |
10643 | install_element(OSPF_NODE, &no_ospf_area_vlink_intervals_cmd); | |
10644 | ||
10645 | ||
10646 | /* "area stub" commands. */ | |
10647 | install_element(OSPF_NODE, &ospf_area_stub_no_summary_cmd); | |
10648 | install_element(OSPF_NODE, &ospf_area_stub_cmd); | |
10649 | install_element(OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
10650 | install_element(OSPF_NODE, &no_ospf_area_stub_cmd); | |
10651 | ||
10652 | /* "area nssa" commands. */ | |
10653 | install_element(OSPF_NODE, &ospf_area_nssa_cmd); | |
d62a17ae | 10654 | install_element(OSPF_NODE, &ospf_area_nssa_translate_cmd); |
10655 | install_element(OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
7ef56a73 | 10656 | install_element(OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
d62a17ae | 10657 | install_element(OSPF_NODE, &no_ospf_area_nssa_cmd); |
10658 | ||
10659 | install_element(OSPF_NODE, &ospf_area_default_cost_cmd); | |
10660 | install_element(OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
10661 | ||
10662 | install_element(OSPF_NODE, &ospf_area_shortcut_cmd); | |
10663 | install_element(OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
10664 | ||
10665 | install_element(OSPF_NODE, &ospf_area_export_list_cmd); | |
10666 | install_element(OSPF_NODE, &no_ospf_area_export_list_cmd); | |
10667 | ||
10668 | install_element(OSPF_NODE, &ospf_area_filter_list_cmd); | |
10669 | install_element(OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
10670 | ||
10671 | install_element(OSPF_NODE, &ospf_area_import_list_cmd); | |
10672 | install_element(OSPF_NODE, &no_ospf_area_import_list_cmd); | |
10673 | ||
10674 | /* SPF timer commands */ | |
10675 | install_element(OSPF_NODE, &ospf_timers_throttle_spf_cmd); | |
10676 | install_element(OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
10677 | ||
10678 | /* LSA timers commands */ | |
10679 | install_element(OSPF_NODE, &ospf_timers_min_ls_interval_cmd); | |
10680 | install_element(OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
0e88de35 QY |
10681 | install_element(OSPF_NODE, &ospf_timers_lsa_min_arrival_cmd); |
10682 | install_element(OSPF_NODE, &no_ospf_timers_lsa_min_arrival_cmd); | |
10683 | install_element(OSPF_NODE, &ospf_timers_lsa_arrival_cmd); | |
10684 | install_element(OSPF_NODE, &no_ospf_timers_lsa_arrival_cmd); | |
d62a17ae | 10685 | |
10686 | /* refresh timer commands */ | |
10687 | install_element(OSPF_NODE, &ospf_refresh_timer_cmd); | |
10688 | install_element(OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
10689 | ||
10690 | /* max-metric commands */ | |
10691 | install_element(OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
10692 | install_element(OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
10693 | install_element(OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
10694 | install_element(OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
10695 | install_element(OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
10696 | install_element(OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
10697 | ||
10698 | /* reference bandwidth commands */ | |
10699 | install_element(OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); | |
10700 | install_element(OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
10701 | ||
10702 | /* "neighbor" commands. */ | |
10703 | install_element(OSPF_NODE, &ospf_neighbor_cmd); | |
10704 | install_element(OSPF_NODE, &ospf_neighbor_poll_interval_cmd); | |
10705 | install_element(OSPF_NODE, &no_ospf_neighbor_cmd); | |
10706 | install_element(OSPF_NODE, &no_ospf_neighbor_poll_cmd); | |
10707 | ||
10708 | /* write multiplier commands */ | |
10709 | install_element(OSPF_NODE, &ospf_write_multiplier_cmd); | |
10710 | install_element(OSPF_NODE, &write_multiplier_cmd); | |
10711 | install_element(OSPF_NODE, &no_ospf_write_multiplier_cmd); | |
10712 | install_element(OSPF_NODE, &no_write_multiplier_cmd); | |
10713 | ||
10714 | /* Init interface related vty commands. */ | |
10715 | ospf_vty_if_init(); | |
10716 | ||
10717 | /* Init zebra related vty commands. */ | |
10718 | ospf_vty_zebra_init(); | |
718e3744 | 10719 | } |