]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPF VTY interface. |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 Toshiaki Takada |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
7ec4159b | 23 | #include <string.h> |
718e3744 | 24 | |
cbf3e3eb | 25 | #include "monotime.h" |
718e3744 | 26 | #include "memory.h" |
27 | #include "thread.h" | |
28 | #include "prefix.h" | |
29 | #include "table.h" | |
30 | #include "vty.h" | |
31 | #include "command.h" | |
32 | #include "plist.h" | |
33 | #include "log.h" | |
34 | #include "zclient.h" | |
bf2bfafd | 35 | #include <lib/json.h> |
8efe88ea | 36 | #include "defaults.h" |
718e3744 | 37 | |
38 | #include "ospfd/ospfd.h" | |
39 | #include "ospfd/ospf_asbr.h" | |
40 | #include "ospfd/ospf_lsa.h" | |
41 | #include "ospfd/ospf_lsdb.h" | |
42 | #include "ospfd/ospf_ism.h" | |
43 | #include "ospfd/ospf_interface.h" | |
44 | #include "ospfd/ospf_nsm.h" | |
45 | #include "ospfd/ospf_neighbor.h" | |
46 | #include "ospfd/ospf_flood.h" | |
47 | #include "ospfd/ospf_abr.h" | |
48 | #include "ospfd/ospf_spf.h" | |
49 | #include "ospfd/ospf_route.h" | |
50 | #include "ospfd/ospf_zebra.h" | |
51 | /*#include "ospfd/ospf_routemap.h" */ | |
52 | #include "ospfd/ospf_vty.h" | |
53 | #include "ospfd/ospf_dump.h" | |
7f342629 | 54 | #include "ospfd/ospf_bfd.h" |
718e3744 | 55 | |
30a2231a | 56 | static const char *ospf_network_type_str[] = |
718e3744 | 57 | { |
58 | "Null", | |
59 | "POINTOPOINT", | |
60 | "BROADCAST", | |
61 | "NBMA", | |
62 | "POINTOMULTIPOINT", | |
63 | "VIRTUALLINK", | |
64 | "LOOPBACK" | |
65 | }; | |
66 | ||
718e3744 | 67 | /* Utility functions. */ |
16f1b9ee | 68 | int |
86573dcb | 69 | str2area_id (const char *str, struct in_addr *area_id, int *area_id_fmt) |
718e3744 | 70 | { |
86573dcb | 71 | char *ep; |
718e3744 | 72 | |
86573dcb QY |
73 | area_id->s_addr = htonl (strtoul (str, &ep, 10)); |
74 | if (*ep && !inet_aton (str, area_id)) | |
75 | return -1; | |
718e3744 | 76 | |
86573dcb | 77 | *area_id_fmt = *ep ? OSPF_AREA_ID_FMT_DOTTEDQUAD : OSPF_AREA_ID_FMT_DECIMAL; |
718e3744 | 78 | |
79 | return 0; | |
80 | } | |
81 | ||
86573dcb QY |
82 | void |
83 | area_id2str (char *buf, int length, struct in_addr *area_id, int area_id_fmt) | |
84 | { | |
85 | memset (buf, 0, length); | |
86 | ||
87 | if (area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) | |
88 | strncpy (buf, inet_ntoa (*area_id), length); | |
89 | else | |
90 | sprintf (buf, "%lu", (unsigned long) ntohl (area_id->s_addr)); | |
91 | } | |
6b0655a2 | 92 | |
4dadc291 | 93 | static int |
6c835671 | 94 | str2metric (const char *str, int *metric) |
718e3744 | 95 | { |
96 | /* Sanity check. */ | |
97 | if (str == NULL) | |
98 | return 0; | |
99 | ||
100 | *metric = strtol (str, NULL, 10); | |
101 | if (*metric < 0 && *metric > 16777214) | |
102 | { | |
1318e7c8 | 103 | /* vty_out (vty, "OSPF metric value is invalid%s", VTYNL); */ |
718e3744 | 104 | return 0; |
105 | } | |
106 | ||
107 | return 1; | |
108 | } | |
109 | ||
4dadc291 | 110 | static int |
6c835671 | 111 | str2metric_type (const char *str, int *metric_type) |
718e3744 | 112 | { |
113 | /* Sanity check. */ | |
114 | if (str == NULL) | |
115 | return 0; | |
116 | ||
117 | if (strncmp (str, "1", 1) == 0) | |
118 | *metric_type = EXTERNAL_METRIC_TYPE_1; | |
119 | else if (strncmp (str, "2", 1) == 0) | |
120 | *metric_type = EXTERNAL_METRIC_TYPE_2; | |
121 | else | |
122 | return 0; | |
123 | ||
124 | return 1; | |
125 | } | |
126 | ||
127 | int | |
128 | ospf_oi_count (struct interface *ifp) | |
129 | { | |
130 | struct route_node *rn; | |
131 | int i = 0; | |
132 | ||
133 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
134 | if (rn->info) | |
135 | i++; | |
136 | ||
137 | return i; | |
138 | } | |
139 | ||
505e5056 | 140 | DEFUN_NOSH (router_ospf, |
718e3744 | 141 | router_ospf_cmd, |
7a7be519 | 142 | "router ospf [(1-65535)]", |
718e3744 | 143 | "Enable a routing process\n" |
7a7be519 | 144 | "Start OSPF configuration\n" |
145 | "Instance ID\n") | |
718e3744 | 146 | { |
7c8ff89e DS |
147 | struct ospf *ospf; |
148 | u_short instance = 0; | |
149 | ||
150 | ospf = ospf_lookup(); | |
151 | if (!ospf) | |
152 | { | |
1318e7c8 | 153 | vty_out (vty, "There isn't active ospf instance %s", VTYNL); |
7c8ff89e DS |
154 | return CMD_WARNING; |
155 | } | |
156 | ||
7a7be519 | 157 | if (argc > 2) |
facfee22 | 158 | instance = strtoul (argv[2]->arg, NULL, 10); |
7c8ff89e | 159 | |
52c6b0e2 | 160 | /* The following logic to set the vty qobj index is in place to be able |
7c8ff89e DS |
161 | to ignore the commands which dont belong to this instance. */ |
162 | if (ospf->instance != instance) | |
cdc2d765 | 163 | VTY_PUSH_CONTEXT_NULL(OSPF_NODE); |
7c8ff89e | 164 | else |
0bad4851 DS |
165 | { |
166 | if (IS_DEBUG_OSPF_EVENT) | |
167 | zlog_debug ("Config command 'router ospf %d' received", instance); | |
168 | ospf->oi_running = 1; | |
52c6b0e2 | 169 | VTY_PUSH_CONTEXT(OSPF_NODE, ospf); |
0bad4851 DS |
170 | ospf_router_id_update (ospf); |
171 | } | |
718e3744 | 172 | |
173 | return CMD_SUCCESS; | |
174 | } | |
175 | ||
176 | DEFUN (no_router_ospf, | |
177 | no_router_ospf_cmd, | |
7a7be519 | 178 | "no router ospf [(1-65535)]", |
718e3744 | 179 | NO_STR |
180 | "Enable a routing process\n" | |
7a7be519 | 181 | "Start OSPF configuration\n" |
182 | "Instance ID\n") | |
718e3744 | 183 | { |
020709f9 | 184 | struct ospf *ospf; |
7c8ff89e | 185 | u_short instance = 0; |
020709f9 | 186 | |
7a7be519 | 187 | if (argc > 3) |
facfee22 | 188 | instance = strtoul(argv[3]->arg, NULL, 10); |
7c8ff89e DS |
189 | |
190 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
191 | return CMD_SUCCESS; | |
718e3744 | 192 | |
020709f9 | 193 | ospf_finish (ospf); |
718e3744 | 194 | |
195 | return CMD_SUCCESS; | |
196 | } | |
197 | ||
7c8ff89e | 198 | |
718e3744 | 199 | DEFUN (ospf_router_id, |
200 | ospf_router_id_cmd, | |
201 | "ospf router-id A.B.C.D", | |
202 | "OSPF specific commands\n" | |
203 | "router-id for the OSPF process\n" | |
204 | "OSPF router-id in IP address format\n") | |
205 | { | |
cdc2d765 | 206 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 207 | int idx_ipv4 = 2; |
2c19a6ec DS |
208 | struct listnode *node; |
209 | struct ospf_area *area; | |
718e3744 | 210 | struct in_addr router_id; |
68980084 | 211 | int ret; |
718e3744 | 212 | |
8d769265 | 213 | ret = inet_aton (argv[idx_ipv4]->arg, &router_id); |
718e3744 | 214 | if (!ret) |
215 | { | |
1318e7c8 | 216 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTYNL); |
718e3744 | 217 | return CMD_WARNING; |
218 | } | |
219 | ||
68980084 | 220 | ospf->router_id_static = router_id; |
2c19a6ec DS |
221 | |
222 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
223 | if (area->full_nbrs) | |
224 | { | |
225 | vty_out (vty, "For this router-id change to take effect," | |
1318e7c8 | 226 | " save config and restart ospfd%s", VTYNL); |
2c19a6ec DS |
227 | return CMD_SUCCESS; |
228 | } | |
229 | ||
b29800a6 | 230 | ospf_router_id_update (ospf); |
231 | ||
718e3744 | 232 | return CMD_SUCCESS; |
233 | } | |
234 | ||
7a7be519 | 235 | DEFUN_HIDDEN (ospf_router_id_old, |
747e489c DW |
236 | ospf_router_id_old_cmd, |
237 | "router-id A.B.C.D", | |
238 | "router-id for the OSPF process\n" | |
239 | "OSPF router-id in IP address format\n") | |
7a7be519 | 240 | { |
cdc2d765 | 241 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 242 | int idx_ipv4 = 1; |
7a7be519 | 243 | struct listnode *node; |
244 | struct ospf_area *area; | |
245 | struct in_addr router_id; | |
246 | int ret; | |
247 | ||
7a7be519 | 248 | ret = inet_aton (argv[idx_ipv4]->arg, &router_id); |
249 | if (!ret) | |
250 | { | |
1318e7c8 | 251 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTYNL); |
7a7be519 | 252 | return CMD_WARNING; |
253 | } | |
254 | ||
255 | ospf->router_id_static = router_id; | |
256 | ||
257 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) | |
258 | if (area->full_nbrs) | |
259 | { | |
260 | vty_out (vty, "For this router-id change to take effect," | |
1318e7c8 | 261 | " save config and restart ospfd%s", VTYNL); |
7a7be519 | 262 | return CMD_SUCCESS; |
263 | } | |
264 | ||
265 | ospf_router_id_update (ospf); | |
266 | ||
267 | return CMD_SUCCESS; | |
268 | } | |
747e489c | 269 | |
718e3744 | 270 | DEFUN (no_ospf_router_id, |
271 | no_ospf_router_id_cmd, | |
7a7be519 | 272 | "no ospf router-id [A.B.C.D]", |
718e3744 | 273 | NO_STR |
274 | "OSPF specific commands\n" | |
7a7be519 | 275 | "router-id for the OSPF process\n" |
276 | "OSPF router-id in IP address format\n") | |
718e3744 | 277 | { |
cdc2d765 | 278 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
2c19a6ec DS |
279 | struct listnode *node; |
280 | struct ospf_area *area; | |
68980084 | 281 | |
282 | ospf->router_id_static.s_addr = 0; | |
718e3744 | 283 | |
2c19a6ec DS |
284 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
285 | if (area->full_nbrs) | |
286 | { | |
287 | vty_out (vty, "For this router-id change to take effect," | |
1318e7c8 | 288 | " save config and restart ospfd%s", VTYNL); |
2c19a6ec DS |
289 | return CMD_SUCCESS; |
290 | } | |
291 | ||
68980084 | 292 | ospf_router_id_update (ospf); |
718e3744 | 293 | |
294 | return CMD_SUCCESS; | |
295 | } | |
296 | ||
718e3744 | 297 | |
7ffa8fa2 | 298 | static void |
43540886 | 299 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
7ffa8fa2 PJ |
300 | { |
301 | struct listnode *ln; | |
302 | struct interface *ifp; | |
303 | struct ospf_interface *oi; | |
304 | ||
43540886 AS |
305 | ospf->passive_interface_default = newval; |
306 | ||
7ffa8fa2 PJ |
307 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
308 | { | |
309 | if (ifp && | |
310 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
311 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); | |
312 | } | |
313 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) | |
314 | { | |
315 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
316 | UNSET_IF_PARAM (oi->params, passive_interface); | |
43540886 AS |
317 | /* update multicast memberships */ |
318 | ospf_if_set_multicast(oi); | |
7ffa8fa2 PJ |
319 | } |
320 | } | |
321 | ||
322 | static void | |
f842f166 PJ |
323 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
324 | struct ospf_if_params *params, u_char value, | |
325 | struct in_addr addr) | |
7ffa8fa2 PJ |
326 | { |
327 | u_char dflt; | |
328 | ||
329 | params->passive_interface = value; | |
330 | if (params != IF_DEF_PARAMS (ifp)) | |
331 | { | |
332 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) | |
333 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; | |
334 | else | |
335 | dflt = ospf->passive_interface_default; | |
336 | ||
337 | if (value != dflt) | |
338 | SET_IF_PARAM (params, passive_interface); | |
339 | else | |
340 | UNSET_IF_PARAM (params, passive_interface); | |
341 | ||
342 | ospf_free_if_params (ifp, addr); | |
343 | ospf_if_update_params (ifp, addr); | |
344 | } | |
f842f166 PJ |
345 | } |
346 | ||
347 | static void | |
348 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, | |
349 | struct ospf_if_params *params, u_char value) | |
350 | { | |
351 | params->passive_interface = value; | |
352 | if (params == IF_DEF_PARAMS (ifp)) | |
7ffa8fa2 PJ |
353 | { |
354 | if (value != ospf->passive_interface_default) | |
355 | SET_IF_PARAM (params, passive_interface); | |
356 | else | |
357 | UNSET_IF_PARAM (params, passive_interface); | |
358 | } | |
359 | } | |
360 | ||
a2c62831 | 361 | DEFUN (ospf_passive_interface, |
362 | ospf_passive_interface_addr_cmd, | |
7a7be519 | 363 | "passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 364 | "Suppress routing updates on an interface\n" |
7a7be519 | 365 | "Interface's name\n" |
3a2d747c | 366 | "IPv4 address\n" |
7a7be519 | 367 | "Suppress routing updates on interfaces by default\n") |
718e3744 | 368 | { |
cdc2d765 | 369 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 370 | int idx_ipv4 = 2; |
7ffa8fa2 | 371 | struct interface *ifp; |
cb2af5d0 | 372 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
7ffa8fa2 PJ |
373 | int ret; |
374 | struct ospf_if_params *params; | |
375 | struct route_node *rn; | |
718e3744 | 376 | |
7e045c3d | 377 | if (strmatch(argv[1]->text, "default")) |
43540886 AS |
378 | { |
379 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); | |
380 | return CMD_SUCCESS; | |
381 | } | |
382 | ||
92a57eb2 | 383 | ifp = if_get_by_name (argv[1]->arg, VRF_DEFAULT); |
718e3744 | 384 | |
385 | params = IF_DEF_PARAMS (ifp); | |
386 | ||
7a7be519 | 387 | if (argc == 3) |
718e3744 | 388 | { |
7a7be519 | 389 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
43540886 AS |
390 | if (!ret) |
391 | { | |
392 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 393 | VTYNL); |
43540886 AS |
394 | return CMD_WARNING; |
395 | } | |
396 | ||
397 | params = ospf_get_if_params (ifp, addr); | |
398 | ospf_if_update_params (ifp, addr); | |
f842f166 PJ |
399 | ospf_passive_interface_update_addr (ospf, ifp, params, |
400 | OSPF_IF_PASSIVE, addr); | |
7ffa8fa2 | 401 | } |
f842f166 PJ |
402 | |
403 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); | |
43540886 | 404 | |
ba6454ec | 405 | /* XXX We should call ospf_if_set_multicast on exactly those |
406 | * interfaces for which the passive property changed. It is too much | |
407 | * work to determine this set, so we do this for every interface. | |
408 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
409 | * record of joined groups to avoid systems calls if the desired | |
410 | * memberships match the current memership. | |
411 | */ | |
7ffa8fa2 | 412 | |
ba6454ec | 413 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
414 | { | |
415 | struct ospf_interface *oi = rn->info; | |
416 | ||
417 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) | |
43540886 | 418 | ospf_if_set_multicast(oi); |
ba6454ec | 419 | } |
420 | /* | |
421 | * XXX It is not clear what state transitions the interface needs to | |
422 | * undergo when going from active to passive. Fixing this will | |
423 | * require precise identification of interfaces having such a | |
424 | * transition. | |
425 | */ | |
426 | ||
718e3744 | 427 | return CMD_SUCCESS; |
428 | } | |
429 | ||
a2c62831 | 430 | DEFUN (no_ospf_passive_interface, |
431 | no_ospf_passive_interface_addr_cmd, | |
7a7be519 | 432 | "no passive-interface <IFNAME [A.B.C.D]|default>", |
718e3744 | 433 | NO_STR |
434 | "Allow routing updates on an interface\n" | |
7a7be519 | 435 | "Interface's name\n" |
3a2d747c | 436 | "IPv4 address\n" |
7a7be519 | 437 | "Allow routing updates on interfaces by default\n") |
718e3744 | 438 | { |
cdc2d765 | 439 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 440 | int idx_ipv4 = 3; |
718e3744 | 441 | struct interface *ifp; |
cb2af5d0 | 442 | struct in_addr addr = { .s_addr = INADDR_ANY }; |
718e3744 | 443 | struct ospf_if_params *params; |
444 | int ret; | |
ba6454ec | 445 | struct route_node *rn; |
43540886 | 446 | |
7e045c3d | 447 | if (strmatch(argv[2]->text, "default")) |
43540886 AS |
448 | { |
449 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); | |
450 | return CMD_SUCCESS; | |
451 | } | |
718e3744 | 452 | |
92a57eb2 | 453 | ifp = if_get_by_name (argv[2]->arg, VRF_DEFAULT); |
718e3744 | 454 | |
455 | params = IF_DEF_PARAMS (ifp); | |
456 | ||
7a7be519 | 457 | if (argc == 4) |
718e3744 | 458 | { |
7a7be519 | 459 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
43540886 AS |
460 | if (!ret) |
461 | { | |
462 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 463 | VTYNL); |
43540886 AS |
464 | return CMD_WARNING; |
465 | } | |
466 | ||
467 | params = ospf_lookup_if_params (ifp, addr); | |
468 | if (params == NULL) | |
469 | return CMD_SUCCESS; | |
f842f166 PJ |
470 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
471 | addr); | |
718e3744 | 472 | } |
f842f166 PJ |
473 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
474 | ||
ba6454ec | 475 | /* XXX We should call ospf_if_set_multicast on exactly those |
476 | * interfaces for which the passive property changed. It is too much | |
477 | * work to determine this set, so we do this for every interface. | |
478 | * This is safe and reasonable because ospf_if_set_multicast uses a | |
479 | * record of joined groups to avoid systems calls if the desired | |
480 | * memberships match the current memership. | |
481 | */ | |
482 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) | |
483 | { | |
484 | struct ospf_interface *oi = rn->info; | |
485 | ||
486 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) | |
487 | ospf_if_set_multicast(oi); | |
488 | } | |
489 | ||
718e3744 | 490 | return CMD_SUCCESS; |
491 | } | |
492 | ||
718e3744 | 493 | |
7ffa8fa2 | 494 | |
a2c62831 | 495 | DEFUN (ospf_network_area, |
496 | ospf_network_area_cmd, | |
6147e2c6 | 497 | "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 498 | "Enable routing on an IP network\n" |
499 | "OSPF network prefix\n" | |
500 | "Set the OSPF area ID\n" | |
501 | "OSPF area ID in IP address format\n" | |
502 | "OSPF area ID as a decimal value\n") | |
503 | { | |
cdc2d765 | 504 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
505 | int idx_ipv4_prefixlen = 1; |
506 | int idx_ipv4_number = 3; | |
718e3744 | 507 | struct prefix_ipv4 p; |
508 | struct in_addr area_id; | |
509 | int ret, format; | |
510 | ||
7c8ff89e DS |
511 | if (ospf->instance) |
512 | { | |
513 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
1318e7c8 | 514 | VTYNL); |
7c8ff89e DS |
515 | return CMD_WARNING; |
516 | } | |
517 | ||
953cde65 JT |
518 | if (ospf->if_ospf_cli_count > 0) |
519 | { | |
520 | vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s", | |
1318e7c8 | 521 | VTYNL); |
953cde65 JT |
522 | return CMD_WARNING; |
523 | } | |
524 | ||
718e3744 | 525 | /* Get network prefix and Area ID. */ |
facfee22 | 526 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
8d769265 | 527 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 528 | |
86573dcb | 529 | ret = ospf_network_set (ospf, &p, area_id, format); |
718e3744 | 530 | if (ret == 0) |
531 | { | |
1318e7c8 | 532 | vty_out (vty, "There is already same network statement.%s", VTYNL); |
718e3744 | 533 | return CMD_WARNING; |
534 | } | |
535 | ||
536 | return CMD_SUCCESS; | |
537 | } | |
538 | ||
a2c62831 | 539 | DEFUN (no_ospf_network_area, |
540 | no_ospf_network_area_cmd, | |
6147e2c6 | 541 | "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>", |
718e3744 | 542 | NO_STR |
543 | "Enable routing on an IP network\n" | |
544 | "OSPF network prefix\n" | |
545 | "Set the OSPF area ID\n" | |
546 | "OSPF area ID in IP address format\n" | |
547 | "OSPF area ID as a decimal value\n") | |
548 | { | |
cdc2d765 | 549 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
550 | int idx_ipv4_prefixlen = 2; |
551 | int idx_ipv4_number = 4; | |
718e3744 | 552 | struct prefix_ipv4 p; |
553 | struct in_addr area_id; | |
554 | int ret, format; | |
555 | ||
7c8ff89e DS |
556 | if (ospf->instance) |
557 | { | |
558 | vty_out (vty, "The network command is not supported in multi-instance ospf%s", | |
1318e7c8 | 559 | VTYNL); |
7c8ff89e DS |
560 | return CMD_WARNING; |
561 | } | |
562 | ||
718e3744 | 563 | /* Get network prefix and Area ID. */ |
facfee22 | 564 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
8d769265 | 565 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 566 | |
567 | ret = ospf_network_unset (ospf, &p, area_id); | |
568 | if (ret == 0) | |
569 | { | |
570 | vty_out (vty, "Can't find specified network area configuration.%s", | |
1318e7c8 | 571 | VTYNL); |
718e3744 | 572 | return CMD_WARNING; |
573 | } | |
574 | ||
575 | return CMD_SUCCESS; | |
576 | } | |
577 | ||
a2c62831 | 578 | DEFUN (ospf_area_range, |
579 | ospf_area_range_cmd, | |
7a7be519 | 580 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]", |
718e3744 | 581 | "OSPF area parameters\n" |
582 | "OSPF area ID in IP address format\n" | |
583 | "OSPF area ID as a decimal value\n" | |
584 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 585 | "Area range prefix\n" |
586 | "Advertise this range (default)\n" | |
587 | "User specified metric for this range\n" | |
588 | "Advertised metric for this range\n") | |
718e3744 | 589 | { |
cdc2d765 | 590 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
591 | int idx_ipv4_number = 1; |
592 | int idx_ipv4_prefixlen = 3; | |
7a7be519 | 593 | int idx_cost = 6; |
718e3744 | 594 | struct prefix_ipv4 p; |
595 | struct in_addr area_id; | |
596 | int format; | |
597 | u_int32_t cost; | |
598 | ||
8d769265 | 599 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 | 600 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
718e3744 | 601 | |
602 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
7a7be519 | 603 | if (argc > 5) |
718e3744 | 604 | { |
facfee22 | 605 | cost = strtoul(argv[idx_cost]->arg, NULL, 10); |
718e3744 | 606 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
607 | } | |
608 | ||
609 | return CMD_SUCCESS; | |
610 | } | |
611 | ||
7a7be519 | 612 | DEFUN (ospf_area_range_cost, |
613 | ospf_area_range_cost_cmd, | |
614 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)", | |
615 | "OSPF area parameters\n" | |
616 | "OSPF area ID in IP address format\n" | |
617 | "OSPF area ID as a decimal value\n" | |
618 | "Summarize routes matching address/mask (border routers only)\n" | |
619 | "Area range prefix\n" | |
620 | "User specified metric for this range\n" | |
621 | "Advertised metric for this range\n") | |
622 | { | |
cdc2d765 | 623 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 624 | int idx_ipv4_number = 1; |
625 | int idx_ipv4_prefixlen = 3; | |
626 | int idx_cost = 5; | |
7a7be519 | 627 | struct prefix_ipv4 p; |
628 | struct in_addr area_id; | |
629 | int format; | |
630 | u_int32_t cost; | |
631 | ||
7a7be519 | 632 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 | 633 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
7a7be519 | 634 | |
635 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); | |
86573dcb | 636 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 637 | |
facfee22 | 638 | cost = strtoul(argv[idx_cost]->arg, NULL, 10); |
7a7be519 | 639 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
718e3744 | 640 | |
7a7be519 | 641 | return CMD_SUCCESS; |
642 | } | |
718e3744 | 643 | |
a2c62831 | 644 | DEFUN (ospf_area_range_not_advertise, |
645 | ospf_area_range_not_advertise_cmd, | |
6147e2c6 | 646 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise", |
718e3744 | 647 | "OSPF area parameters\n" |
648 | "OSPF area ID in IP address format\n" | |
649 | "OSPF area ID as a decimal value\n" | |
650 | "Summarize routes matching address/mask (border routers only)\n" | |
651 | "Area range prefix\n" | |
652 | "DoNotAdvertise this range\n") | |
653 | { | |
cdc2d765 | 654 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
655 | int idx_ipv4_number = 1; |
656 | int idx_ipv4_prefixlen = 3; | |
718e3744 | 657 | struct prefix_ipv4 p; |
658 | struct in_addr area_id; | |
659 | int format; | |
660 | ||
8d769265 | 661 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 | 662 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
718e3744 | 663 | |
664 | ospf_area_range_set (ospf, area_id, &p, 0); | |
86573dcb | 665 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 666 | |
667 | return CMD_SUCCESS; | |
668 | } | |
669 | ||
a2c62831 | 670 | DEFUN (no_ospf_area_range, |
671 | no_ospf_area_range_cmd, | |
3a2d747c | 672 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]", |
718e3744 | 673 | NO_STR |
674 | "OSPF area parameters\n" | |
675 | "OSPF area ID in IP address format\n" | |
676 | "OSPF area ID as a decimal value\n" | |
677 | "Summarize routes matching address/mask (border routers only)\n" | |
7a7be519 | 678 | "Area range prefix\n" |
3a2d747c QY |
679 | "User specified metric for this range\n" |
680 | "Advertised metric for this range\n" | |
7a7be519 | 681 | "Advertise this range (default)\n" |
3a2d747c QY |
682 | "User specified metric for this range\n" |
683 | "Advertised metric for this range\n" | |
7a7be519 | 684 | "DoNotAdvertise this range\n") |
718e3744 | 685 | { |
cdc2d765 | 686 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
687 | int idx_ipv4_number = 2; |
688 | int idx_ipv4_prefixlen = 4; | |
718e3744 | 689 | struct prefix_ipv4 p; |
690 | struct in_addr area_id; | |
691 | int format; | |
692 | ||
8d769265 | 693 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 | 694 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
718e3744 | 695 | |
696 | ospf_area_range_unset (ospf, area_id, &p); | |
697 | ||
698 | return CMD_SUCCESS; | |
699 | } | |
700 | ||
a2c62831 | 701 | DEFUN (ospf_area_range_substitute, |
702 | ospf_area_range_substitute_cmd, | |
6147e2c6 | 703 | "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 704 | "OSPF area parameters\n" |
705 | "OSPF area ID in IP address format\n" | |
706 | "OSPF area ID as a decimal value\n" | |
707 | "Summarize routes matching address/mask (border routers only)\n" | |
708 | "Area range prefix\n" | |
709 | "Announce area range as another prefix\n" | |
710 | "Network prefix to be announced instead of range\n") | |
711 | { | |
cdc2d765 | 712 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
713 | int idx_ipv4_number = 1; |
714 | int idx_ipv4_prefixlen = 3; | |
715 | int idx_ipv4_prefixlen_2 = 5; | |
718e3744 | 716 | struct prefix_ipv4 p, s; |
717 | struct in_addr area_id; | |
718 | int format; | |
719 | ||
8d769265 | 720 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 QY |
721 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
722 | str2prefix_ipv4(argv[idx_ipv4_prefixlen_2]->arg, &s); | |
718e3744 | 723 | |
724 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); | |
86573dcb | 725 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 726 | |
727 | return CMD_SUCCESS; | |
728 | } | |
729 | ||
a2c62831 | 730 | DEFUN (no_ospf_area_range_substitute, |
731 | no_ospf_area_range_substitute_cmd, | |
6147e2c6 | 732 | "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M", |
718e3744 | 733 | NO_STR |
734 | "OSPF area parameters\n" | |
735 | "OSPF area ID in IP address format\n" | |
736 | "OSPF area ID as a decimal value\n" | |
737 | "Summarize routes matching address/mask (border routers only)\n" | |
738 | "Area range prefix\n" | |
739 | "Announce area range as another prefix\n" | |
740 | "Network prefix to be announced instead of range\n") | |
741 | { | |
cdc2d765 | 742 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
743 | int idx_ipv4_number = 2; |
744 | int idx_ipv4_prefixlen = 4; | |
745 | int idx_ipv4_prefixlen_2 = 6; | |
718e3744 | 746 | struct prefix_ipv4 p, s; |
747 | struct in_addr area_id; | |
748 | int format; | |
749 | ||
8d769265 | 750 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 QY |
751 | str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p); |
752 | str2prefix_ipv4(argv[idx_ipv4_prefixlen_2]->arg, &s); | |
718e3744 | 753 | |
754 | ospf_area_range_substitute_unset (ospf, area_id, &p); | |
755 | ||
756 | return CMD_SUCCESS; | |
757 | } | |
758 | ||
6b0655a2 | 759 | |
718e3744 | 760 | /* Command Handler Logic in VLink stuff is delicate!! |
761 | ||
762 | ALTER AT YOUR OWN RISK!!!! | |
763 | ||
764 | Various dummy values are used to represent 'NoChange' state for | |
765 | VLink configuration NOT being changed by a VLink command, and | |
766 | special syntax is used within the command strings so that the | |
767 | typed in command verbs can be seen in the configuration command | |
768 | bacckend handler. This is to drastically reduce the verbeage | |
769 | required to coe up with a reasonably compatible Cisco VLink command | |
770 | ||
771 | - Matthew Grant <grantma@anathoth.gen.nz> | |
772 | Wed, 21 Feb 2001 15:13:52 +1300 | |
773 | */ | |
774 | ||
718e3744 | 775 | /* Configuration data for virtual links |
776 | */ | |
777 | struct ospf_vl_config_data { | |
778 | struct vty *vty; /* vty stuff */ | |
779 | struct in_addr area_id; /* area ID from command line */ | |
86573dcb | 780 | int area_id_fmt; /* command line area ID format */ |
718e3744 | 781 | struct in_addr vl_peer; /* command line vl_peer */ |
782 | int auth_type; /* Authehntication type, if given */ | |
783 | char *auth_key; /* simple password if present */ | |
784 | int crypto_key_id; /* Cryptographic key ID */ | |
785 | char *md5_key; /* MD5 authentication key */ | |
786 | int hello_interval; /* Obvious what these are... */ | |
787 | int retransmit_interval; | |
788 | int transmit_delay; | |
789 | int dead_interval; | |
790 | }; | |
791 | ||
4dadc291 | 792 | static void |
718e3744 | 793 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
794 | struct vty *vty) | |
795 | { | |
796 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); | |
797 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; | |
798 | vl_config->vty = vty; | |
799 | } | |
800 | ||
4dadc291 | 801 | static struct ospf_vl_data * |
68980084 | 802 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 803 | { |
804 | struct ospf_area *area; | |
805 | struct ospf_vl_data *vl_data; | |
806 | struct vty *vty; | |
807 | struct in_addr area_id; | |
808 | ||
809 | vty = vl_config->vty; | |
810 | area_id = vl_config->area_id; | |
811 | ||
812 | if (area_id.s_addr == OSPF_AREA_BACKBONE) | |
813 | { | |
814 | vty_out (vty, | |
815 | "Configuring VLs over the backbone is not allowed%s", | |
1318e7c8 | 816 | VTYNL); |
718e3744 | 817 | return NULL; |
818 | } | |
86573dcb QY |
819 | area = ospf_area_get (ospf, area_id); |
820 | ospf_area_display_format_set (ospf, area, vl_config->area_id_fmt); | |
718e3744 | 821 | |
822 | if (area->external_routing != OSPF_AREA_DEFAULT) | |
823 | { | |
86573dcb | 824 | if (vl_config->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) |
718e3744 | 825 | vty_out (vty, "Area %s is %s%s", |
826 | inet_ntoa (area_id), | |
718e3744 | 827 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
1318e7c8 | 828 | VTYNL); |
718e3744 | 829 | else |
830 | vty_out (vty, "Area %ld is %s%s", | |
831 | (u_long)ntohl (area_id.s_addr), | |
718e3744 | 832 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
1318e7c8 | 833 | VTYNL); |
718e3744 | 834 | return NULL; |
835 | } | |
836 | ||
9c27ef9b | 837 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
718e3744 | 838 | { |
839 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); | |
840 | if (vl_data->vl_oi == NULL) | |
841 | { | |
68980084 | 842 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
843 | ospf_vl_add (ospf, vl_data); | |
d3a9c768 | 844 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 845 | } |
846 | } | |
847 | return vl_data; | |
848 | } | |
849 | ||
850 | ||
4dadc291 | 851 | static int |
718e3744 | 852 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
853 | struct ospf_vl_config_data *vl_config) | |
854 | { | |
855 | struct crypt_key *ck; | |
856 | struct vty *vty; | |
857 | struct interface *ifp = vl_data->vl_oi->ifp; | |
858 | ||
859 | vty = vl_config->vty; | |
860 | ||
861 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) | |
862 | { | |
863 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); | |
864 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; | |
865 | } | |
866 | ||
867 | if (vl_config->auth_key) | |
868 | { | |
869 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); | |
c9e52be3 | 870 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
718e3744 | 871 | OSPF_AUTH_SIMPLE_SIZE); |
872 | } | |
873 | else if (vl_config->md5_key) | |
874 | { | |
875 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) | |
876 | != NULL) | |
877 | { | |
878 | vty_out (vty, "OSPF: Key %d already exists%s", | |
1318e7c8 | 879 | vl_config->crypto_key_id, VTYNL); |
718e3744 | 880 | return CMD_WARNING; |
881 | } | |
882 | ck = ospf_crypt_key_new (); | |
883 | ck->key_id = vl_config->crypto_key_id; | |
884 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
c9e52be3 | 885 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
718e3744 | 886 | |
887 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); | |
888 | } | |
889 | else if (vl_config->crypto_key_id != 0) | |
890 | { | |
891 | /* Delete a key */ | |
892 | ||
893 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, | |
894 | vl_config->crypto_key_id) == NULL) | |
895 | { | |
896 | vty_out (vty, "OSPF: Key %d does not exist%s", | |
1318e7c8 | 897 | vl_config->crypto_key_id, VTYNL); |
718e3744 | 898 | return CMD_WARNING; |
899 | } | |
900 | ||
901 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); | |
902 | ||
903 | } | |
904 | ||
905 | return CMD_SUCCESS; | |
906 | } | |
907 | ||
4dadc291 | 908 | static int |
718e3744 | 909 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
910 | struct ospf_vl_config_data *vl_config) | |
911 | { | |
c8cdf5c7 | 912 | struct interface *ifp = vl_data->vl_oi->ifp; |
718e3744 | 913 | /* Virtual Link data initialised to defaults, so only set |
914 | if a value given */ | |
915 | if (vl_config->hello_interval) | |
916 | { | |
917 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); | |
918 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; | |
919 | } | |
920 | ||
921 | if (vl_config->dead_interval) | |
922 | { | |
923 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); | |
924 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; | |
925 | } | |
926 | ||
927 | if (vl_config->retransmit_interval) | |
928 | { | |
929 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); | |
930 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; | |
931 | } | |
932 | ||
933 | if (vl_config->transmit_delay) | |
934 | { | |
935 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); | |
936 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; | |
937 | } | |
938 | ||
939 | return CMD_SUCCESS; | |
940 | } | |
941 | ||
942 | ||
718e3744 | 943 | /* The business end of all of the above */ |
4dadc291 | 944 | static int |
68980084 | 945 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
718e3744 | 946 | { |
947 | struct ospf_vl_data *vl_data; | |
948 | int ret; | |
949 | ||
68980084 | 950 | vl_data = ospf_find_vl_data (ospf, vl_config); |
718e3744 | 951 | if (!vl_data) |
952 | return CMD_WARNING; | |
953 | ||
954 | /* Process this one first as it can have a fatal result, which can | |
955 | only logically occur if the virtual link exists already | |
956 | Thus a command error does not result in a change to the | |
957 | running configuration such as unexpectedly altered timer | |
958 | values etc.*/ | |
959 | ret = ospf_vl_set_security (vl_data, vl_config); | |
960 | if (ret != CMD_SUCCESS) | |
961 | return ret; | |
962 | ||
963 | /* Set any time based parameters, these area already range checked */ | |
964 | ||
965 | ret = ospf_vl_set_timers (vl_data, vl_config); | |
966 | if (ret != CMD_SUCCESS) | |
967 | return ret; | |
968 | ||
969 | return CMD_SUCCESS; | |
970 | ||
971 | } | |
972 | ||
973 | /* This stuff exists to make specifying all the alias commands A LOT simpler | |
974 | */ | |
975 | #define VLINK_HELPSTR_IPADDR \ | |
976 | "OSPF area parameters\n" \ | |
977 | "OSPF area ID in IP address format\n" \ | |
978 | "OSPF area ID as a decimal value\n" \ | |
979 | "Configure a virtual link\n" \ | |
980 | "Router ID of the remote ABR\n" | |
981 | ||
982 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
983 | "Enable authentication on this virtual link\n" \ | |
984 | "dummy string \n" | |
985 | ||
986 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ | |
987 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ | |
988 | "Use null authentication\n" \ | |
989 | "Use message-digest authentication\n" | |
990 | ||
a663a38e | 991 | #define VLINK_HELPSTR_TIME_PARAM \ |
718e3744 | 992 | "Time between HELLO packets\n" \ |
a663a38e | 993 | "Seconds\n" \ |
718e3744 | 994 | "Time between retransmitting lost link state advertisements\n" \ |
a663a38e | 995 | "Seconds\n" \ |
718e3744 | 996 | "Link state transmit delay\n" \ |
a663a38e QY |
997 | "Seconds\n" \ |
998 | "Interval time after which a neighbor is declared down\n" \ | |
999 | "Seconds\n" \ | |
718e3744 | 1000 | |
1001 | #define VLINK_HELPSTR_AUTH_SIMPLE \ | |
1002 | "Authentication password (key)\n" \ | |
1003 | "The OSPF password (key)" | |
1004 | ||
1005 | #define VLINK_HELPSTR_AUTH_MD5 \ | |
1006 | "Message digest authentication password (key)\n" \ | |
1007 | "dummy string \n" \ | |
1008 | "Key ID\n" \ | |
1009 | "Use MD5 algorithm\n" \ | |
1010 | "The OSPF password (key)" | |
1011 | ||
a2c62831 | 1012 | DEFUN (ospf_area_vlink, |
1013 | ospf_area_vlink_cmd, | |
22b27e95 | 1014 | "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]", |
7a7be519 | 1015 | VLINK_HELPSTR_IPADDR |
1016 | "Enable authentication on this virtual link\n" \ | |
1017 | "Use null authentication\n" \ | |
1018 | "Use message-digest authentication\n" | |
1019 | "Message digest authentication password (key)\n" \ | |
1020 | "Key ID\n" \ | |
1021 | "Use MD5 algorithm\n" \ | |
1022 | "The OSPF password (key)") | |
718e3744 | 1023 | { |
cdc2d765 | 1024 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1025 | int idx_ipv4_number = 1; |
1026 | int idx_ipv4 = 3; | |
718e3744 | 1027 | struct ospf_vl_config_data vl_config; |
1028 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1029 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; | |
1030 | int i; | |
1031 | int ret; | |
7c8ff89e | 1032 | |
718e3744 | 1033 | ospf_vl_config_data_init(&vl_config, vty); |
1034 | ||
1035 | /* Read off first 2 parameters and check them */ | |
86573dcb QY |
1036 | ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, |
1037 | &vl_config.area_id_fmt); | |
718e3744 | 1038 | if (ret < 0) |
1039 | { | |
1318e7c8 | 1040 | vty_out (vty, "OSPF area ID is invalid%s", VTYNL); |
718e3744 | 1041 | return CMD_WARNING; |
1042 | } | |
1043 | ||
8d769265 | 1044 | ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); |
718e3744 | 1045 | if (! ret) |
1046 | { | |
1047 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1318e7c8 | 1048 | VTYNL); |
718e3744 | 1049 | return CMD_WARNING; |
1050 | } | |
1051 | ||
7a7be519 | 1052 | if (argc <=4) |
718e3744 | 1053 | { |
1054 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
1055 | ||
68980084 | 1056 | return ospf_vl_set (ospf, &vl_config); |
718e3744 | 1057 | } |
1058 | ||
1059 | /* Deal with other parameters */ | |
7a7be519 | 1060 | for (i=5; i < argc; i++) |
718e3744 | 1061 | { |
1062 | ||
1318e7c8 | 1063 | /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTYNL); */ |
718e3744 | 1064 | |
7a7be519 | 1065 | switch (argv[i]->arg[0]) |
718e3744 | 1066 | { |
1067 | ||
1068 | case 'a': | |
7a7be519 | 1069 | if (i >5 || strncmp (argv[i]->arg, "authentication-", 15) == 0) |
718e3744 | 1070 | { |
1071 | /* authentication-key - this option can occur anywhere on | |
1072 | command line. At start of command line | |
1073 | must check for authentication option. */ | |
1074 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
7a7be519 | 1075 | strncpy (auth_key, argv[i+1]->text, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 1076 | vl_config.auth_key = auth_key; |
1077 | i++; | |
1078 | } | |
7a7be519 | 1079 | else if (strncmp (argv[i]->arg, "authentication", 14) == 0) |
718e3744 | 1080 | { |
1081 | /* authentication - this option can only occur at start | |
1082 | of command line */ | |
1083 | vl_config.auth_type = OSPF_AUTH_SIMPLE; | |
1084 | if ((i+1) < argc) | |
1085 | { | |
7a7be519 | 1086 | if (strncmp (argv[i+1]->arg, "n", 1) == 0) |
718e3744 | 1087 | { |
1088 | /* "authentication null" */ | |
1089 | vl_config.auth_type = OSPF_AUTH_NULL; | |
1090 | i++; | |
1091 | } | |
7a7be519 | 1092 | else if (strncmp (argv[i+1]->arg, "m", 1) == 0 |
7e045c3d | 1093 | && !strmatch(argv[i + 1]->text, "message-digest-")) |
718e3744 | 1094 | { |
1095 | /* "authentication message-digest" */ | |
1096 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
1097 | i++; | |
1098 | } | |
1099 | } | |
1100 | } | |
1101 | break; | |
1102 | ||
1103 | case 'm': | |
1104 | /* message-digest-key */ | |
1105 | i++; | |
effe821e DS |
1106 | if (i < argc) |
1107 | { | |
1108 | vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); | |
1109 | if (vl_config.crypto_key_id < 0) | |
1110 | return CMD_WARNING; | |
1111 | i++; | |
1112 | if (i < argc) | |
1113 | { | |
1114 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
1115 | strncpy (md5_key, argv[i]->arg, OSPF_AUTH_MD5_SIZE); | |
1116 | vl_config.md5_key = md5_key; | |
1117 | } | |
1118 | } | |
1119 | else | |
1120 | vl_config.md5_key = NULL; | |
718e3744 | 1121 | break; |
7a7be519 | 1122 | } |
1123 | } | |
1124 | ||
1125 | ||
1126 | /* Action configuration */ | |
1127 | ||
1128 | return ospf_vl_set (ospf, &vl_config); | |
1129 | ||
1130 | } | |
1131 | ||
a2c62831 | 1132 | DEFUN (no_ospf_area_vlink, |
1133 | no_ospf_area_vlink_cmd, | |
bc7d452f | 1134 | "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 | 1135 | NO_STR |
7a7be519 | 1136 | VLINK_HELPSTR_IPADDR |
1137 | "Enable authentication on this virtual link\n" \ | |
1138 | "Use null authentication\n" \ | |
1139 | "Use message-digest authentication\n" | |
1140 | "Message digest authentication password (key)\n" \ | |
1141 | "Key ID\n" \ | |
1142 | "Use MD5 algorithm\n" \ | |
1143 | "The OSPF password (key)") | |
718e3744 | 1144 | { |
cdc2d765 | 1145 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1146 | int idx_ipv4_number = 2; |
1147 | int idx_ipv4 = 4; | |
718e3744 | 1148 | struct ospf_area *area; |
1149 | struct ospf_vl_config_data vl_config; | |
1150 | struct ospf_vl_data *vl_data = NULL; | |
1151 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; | |
1152 | int i; | |
1153 | int ret, format; | |
1154 | ||
1155 | ospf_vl_config_data_init(&vl_config, vty); | |
1156 | ||
86573dcb | 1157 | ret = str2area_id (argv[idx_ipv4_number]->arg, &vl_config.area_id, &format); |
718e3744 | 1158 | if (ret < 0) |
1159 | { | |
1318e7c8 | 1160 | vty_out (vty, "OSPF area ID is invalid%s", VTYNL); |
718e3744 | 1161 | return CMD_WARNING; |
1162 | } | |
1163 | ||
68980084 | 1164 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
718e3744 | 1165 | if (!area) |
1166 | { | |
1318e7c8 | 1167 | vty_out (vty, "Area does not exist%s", VTYNL); |
718e3744 | 1168 | return CMD_WARNING; |
1169 | } | |
1170 | ||
8d769265 | 1171 | ret = inet_aton (argv[idx_ipv4]->arg, &vl_config.vl_peer); |
718e3744 | 1172 | if (! ret) |
1173 | { | |
1174 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", | |
1318e7c8 | 1175 | VTYNL); |
718e3744 | 1176 | return CMD_WARNING; |
1177 | } | |
1178 | ||
7a7be519 | 1179 | if (argc <=5) |
718e3744 | 1180 | { |
1181 | /* Basic VLink no command */ | |
1182 | /* Thats all folks! - BUGS B. strikes again!!!*/ | |
9c27ef9b | 1183 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
68980084 | 1184 | ospf_vl_delete (ospf, vl_data); |
718e3744 | 1185 | |
68980084 | 1186 | ospf_area_check_free (ospf, vl_config.area_id); |
7a7be519 | 1187 | |
718e3744 | 1188 | return CMD_SUCCESS; |
1189 | } | |
1190 | ||
1191 | /* If we are down here, we are reseting parameters */ | |
1192 | ||
1193 | /* Deal with other parameters */ | |
effe821e | 1194 | for (i=6; i < argc; i++) |
718e3744 | 1195 | { |
1318e7c8 | 1196 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTYNL); */ |
718e3744 | 1197 | |
7a7be519 | 1198 | switch (argv[i]->arg[0]) |
718e3744 | 1199 | { |
1200 | ||
1201 | case 'a': | |
7a7be519 | 1202 | if (i > 2 || strncmp (argv[i]->text, "authentication-", 15) == 0) |
718e3744 | 1203 | { |
1204 | /* authentication-key - this option can occur anywhere on | |
1205 | command line. At start of command line | |
1206 | must check for authentication option. */ | |
1207 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); | |
1208 | vl_config.auth_key = auth_key; | |
1209 | } | |
7a7be519 | 1210 | else if (strncmp (argv[i]->text, "authentication", 14) == 0) |
718e3744 | 1211 | { |
1212 | /* authentication - this option can only occur at start | |
1213 | of command line */ | |
1214 | vl_config.auth_type = OSPF_AUTH_NOTSET; | |
1215 | } | |
1216 | break; | |
1217 | ||
1218 | case 'm': | |
1219 | /* message-digest-key */ | |
1220 | /* Delete one key */ | |
1221 | i++; | |
36da0665 DS |
1222 | if (i < argc) |
1223 | { | |
b6f1faf0 | 1224 | vl_config.crypto_key_id = strtol (argv[i]->arg, NULL, 10); |
36da0665 DS |
1225 | if (vl_config.crypto_key_id < 0) |
1226 | return CMD_WARNING; | |
1227 | vl_config.md5_key = NULL; | |
1228 | } | |
1229 | else | |
718e3744 | 1230 | return CMD_WARNING; |
718e3744 | 1231 | break; |
1232 | ||
7a7be519 | 1233 | } |
1234 | } | |
1235 | ||
1236 | ||
1237 | /* Action configuration */ | |
1238 | ||
1239 | return ospf_vl_set (ospf, &vl_config); | |
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 | { | |
1248 | VTY_DECLVAR_CONTEXT(ospf, ospf); | |
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 | { | |
1318e7c8 | 1260 | vty_out (vty, "OSPF area ID is invalid%s", VTYNL); |
b1c02cec QY |
1261 | return CMD_WARNING; |
1262 | } | |
1263 | ||
1264 | ret = inet_aton (router_id, &vl_config.vl_peer); | |
1265 | if (! ret) | |
1266 | { | |
1318e7c8 | 1267 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTYNL); |
b1c02cec QY |
1268 | return CMD_WARNING; |
1269 | } | |
1270 | ||
1271 | for (int idx = 4; idx < argc; idx++) | |
1272 | { | |
1273 | if (strmatch (argv[idx]->text, "hello-interval")) | |
1274 | vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); | |
1275 | else if (strmatch (argv[idx]->text, "retransmit-interval")) | |
1276 | vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); | |
1277 | else if (strmatch (argv[idx]->text, "transmit-delay")) | |
1278 | vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); | |
1279 | else if (strmatch (argv[idx]->text, "dead-interval")) | |
1280 | vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); | |
1281 | } | |
1282 | ||
1283 | /* Action configuration */ | |
1284 | return ospf_vl_set (ospf, &vl_config); | |
1285 | } | |
1286 | ||
7a7be519 | 1287 | DEFUN (no_ospf_area_vlink_intervals, |
1288 | no_ospf_area_vlink_intervals_cmd, | |
a663a38e | 1289 | "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 | 1290 | NO_STR |
7a7be519 | 1291 | VLINK_HELPSTR_IPADDR |
7a7be519 | 1292 | VLINK_HELPSTR_TIME_PARAM) |
1293 | { | |
cdc2d765 | 1294 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 1295 | struct ospf_vl_config_data vl_config; |
bc7d452f | 1296 | int ret = 0; |
7a7be519 | 1297 | |
7a7be519 | 1298 | ospf_vl_config_data_init(&vl_config, vty); |
1299 | ||
bc7d452f QY |
1300 | char *area_id = argv[2]->arg; |
1301 | char *router_id = argv[4]->arg; | |
1302 | ||
86573dcb | 1303 | ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); |
7a7be519 | 1304 | if (ret < 0) |
1305 | { | |
1318e7c8 | 1306 | vty_out (vty, "OSPF area ID is invalid%s", VTYNL); |
7a7be519 | 1307 | return CMD_WARNING; |
1308 | } | |
1309 | ||
bc7d452f | 1310 | ret = inet_aton (router_id, &vl_config.vl_peer); |
7a7be519 | 1311 | if (! ret) |
1312 | { | |
1318e7c8 | 1313 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTYNL); |
7a7be519 | 1314 | return CMD_WARNING; |
1315 | } | |
1316 | ||
a663a38e | 1317 | for (int idx = 5; idx < argc; idx++) |
7a7be519 | 1318 | { |
a663a38e | 1319 | if (strmatch (argv[idx]->text, "hello-interval")) |
bc7d452f | 1320 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
a663a38e | 1321 | else if (strmatch (argv[idx]->text, "retransmit-interval")) |
bc7d452f | 1322 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
a663a38e | 1323 | else if (strmatch (argv[idx]->text, "transmit-delay")) |
bc7d452f | 1324 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
a663a38e | 1325 | else if (strmatch (argv[idx]->text, "dead-interval")) |
bc7d452f | 1326 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
718e3744 | 1327 | } |
1328 | ||
718e3744 | 1329 | /* Action configuration */ |
68980084 | 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 | { | |
cdc2d765 | 1344 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1345 | int idx_ipv4_number = 1; |
1346 | int idx_enable_disable = 3; | |
718e3744 | 1347 | struct ospf_area *area; |
1348 | struct in_addr area_id; | |
1349 | int mode; | |
1350 | int format; | |
1351 | ||
8d769265 | 1352 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1353 | |
86573dcb QY |
1354 | area = ospf_area_get (ospf, area_id); |
1355 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1356 | |
8d769265 | 1357 | if (strncmp (argv[idx_enable_disable]->arg, "de", 2) == 0) |
718e3744 | 1358 | mode = OSPF_SHORTCUT_DEFAULT; |
8d769265 | 1359 | else if (strncmp (argv[idx_enable_disable]->arg, "di", 2) == 0) |
718e3744 | 1360 | mode = OSPF_SHORTCUT_DISABLE; |
8d769265 | 1361 | else if (strncmp (argv[idx_enable_disable]->arg, "e", 1) == 0) |
718e3744 | 1362 | mode = OSPF_SHORTCUT_ENABLE; |
1363 | else | |
1364 | return CMD_WARNING; | |
1365 | ||
68980084 | 1366 | ospf_area_shortcut_set (ospf, area, mode); |
718e3744 | 1367 | |
68980084 | 1368 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
718e3744 | 1369 | vty_out (vty, "Shortcut area setting will take effect " |
1370 | "only when the router is configured as Shortcut ABR%s", | |
1318e7c8 | 1371 | VTYNL); |
718e3744 | 1372 | |
1373 | return CMD_SUCCESS; | |
1374 | } | |
1375 | ||
a2c62831 | 1376 | DEFUN (no_ospf_area_shortcut, |
1377 | no_ospf_area_shortcut_cmd, | |
6147e2c6 | 1378 | "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>", |
718e3744 | 1379 | NO_STR |
1380 | "OSPF area parameters\n" | |
1381 | "OSPF area ID in IP address format\n" | |
1382 | "OSPF area ID as a decimal value\n" | |
1383 | "Deconfigure the area's shortcutting mode\n" | |
1384 | "Deconfigure enabled shortcutting through the area\n" | |
1385 | "Deconfigure disabled shortcutting through the area\n") | |
1386 | { | |
cdc2d765 | 1387 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1388 | int idx_ipv4_number = 2; |
718e3744 | 1389 | struct ospf_area *area; |
1390 | struct in_addr area_id; | |
1391 | int format; | |
1392 | ||
8d769265 | 1393 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1394 | |
68980084 | 1395 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1396 | if (!area) |
1397 | return CMD_SUCCESS; | |
1398 | ||
68980084 | 1399 | ospf_area_shortcut_unset (ospf, area); |
718e3744 | 1400 | |
1401 | return CMD_SUCCESS; | |
1402 | } | |
1403 | ||
6b0655a2 | 1404 | |
a2c62831 | 1405 | DEFUN (ospf_area_stub, |
1406 | ospf_area_stub_cmd, | |
6147e2c6 | 1407 | "area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1408 | "OSPF area parameters\n" |
1409 | "OSPF area ID in IP address format\n" | |
1410 | "OSPF area ID as a decimal value\n" | |
1411 | "Configure OSPF area as stub\n") | |
1412 | { | |
cdc2d765 | 1413 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1414 | int idx_ipv4_number = 1; |
718e3744 | 1415 | struct in_addr area_id; |
1416 | int ret, format; | |
1417 | ||
8d769265 | 1418 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1419 | |
1420 | ret = ospf_area_stub_set (ospf, area_id); | |
86573dcb | 1421 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 1422 | if (ret == 0) |
1423 | { | |
1424 | vty_out (vty, "First deconfigure all virtual link through this area%s", | |
1318e7c8 | 1425 | VTYNL); |
718e3744 | 1426 | return CMD_WARNING; |
1427 | } | |
1428 | ||
1429 | ospf_area_no_summary_unset (ospf, area_id); | |
1430 | ||
1431 | return CMD_SUCCESS; | |
1432 | } | |
1433 | ||
a2c62831 | 1434 | DEFUN (ospf_area_stub_no_summary, |
1435 | ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1436 | "area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1437 | "OSPF stub parameters\n" |
1438 | "OSPF area ID in IP address format\n" | |
1439 | "OSPF area ID as a decimal value\n" | |
1440 | "Configure OSPF area as stub\n" | |
1441 | "Do not inject inter-area routes into stub\n") | |
1442 | { | |
cdc2d765 | 1443 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1444 | int idx_ipv4_number = 1; |
718e3744 | 1445 | struct in_addr area_id; |
1446 | int ret, format; | |
1447 | ||
8d769265 | 1448 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1449 | |
1450 | ret = ospf_area_stub_set (ospf, area_id); | |
86573dcb | 1451 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 1452 | if (ret == 0) |
1453 | { | |
b0a053be | 1454 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
1318e7c8 | 1455 | VTYNL); |
718e3744 | 1456 | return CMD_WARNING; |
1457 | } | |
1458 | ||
1459 | ospf_area_no_summary_set (ospf, area_id); | |
1460 | ||
1461 | return CMD_SUCCESS; | |
1462 | } | |
1463 | ||
a2c62831 | 1464 | DEFUN (no_ospf_area_stub, |
1465 | no_ospf_area_stub_cmd, | |
6147e2c6 | 1466 | "no area <A.B.C.D|(0-4294967295)> stub", |
718e3744 | 1467 | NO_STR |
1468 | "OSPF area parameters\n" | |
1469 | "OSPF area ID in IP address format\n" | |
1470 | "OSPF area ID as a decimal value\n" | |
1471 | "Configure OSPF area as stub\n") | |
1472 | { | |
cdc2d765 | 1473 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1474 | int idx_ipv4_number = 2; |
718e3744 | 1475 | struct in_addr area_id; |
1476 | int format; | |
1477 | ||
8d769265 | 1478 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1479 | |
1480 | ospf_area_stub_unset (ospf, area_id); | |
1481 | ospf_area_no_summary_unset (ospf, area_id); | |
1482 | ||
1483 | return CMD_SUCCESS; | |
1484 | } | |
1485 | ||
a2c62831 | 1486 | DEFUN (no_ospf_area_stub_no_summary, |
1487 | no_ospf_area_stub_no_summary_cmd, | |
6147e2c6 | 1488 | "no area <A.B.C.D|(0-4294967295)> stub no-summary", |
718e3744 | 1489 | NO_STR |
1490 | "OSPF area parameters\n" | |
1491 | "OSPF area ID in IP address format\n" | |
1492 | "OSPF area ID as a decimal value\n" | |
1493 | "Configure OSPF area as stub\n" | |
1494 | "Do not inject inter-area routes into area\n") | |
1495 | { | |
cdc2d765 | 1496 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1497 | int idx_ipv4_number = 2; |
718e3744 | 1498 | struct in_addr area_id; |
1499 | int format; | |
1500 | ||
8d769265 | 1501 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1502 | ospf_area_no_summary_unset (ospf, area_id); |
1503 | ||
1504 | return CMD_SUCCESS; | |
1505 | } | |
1506 | ||
4dadc291 | 1507 | static int |
7a7be519 | 1508 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, struct cmd_token **argv, |
6c835671 | 1509 | int nosum) |
718e3744 | 1510 | { |
cdc2d765 | 1511 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 1512 | struct in_addr area_id; |
1513 | int ret, format; | |
1514 | ||
7a7be519 | 1515 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[1]->arg); |
718e3744 | 1516 | |
1517 | ret = ospf_area_nssa_set (ospf, area_id); | |
86573dcb | 1518 | ospf_area_display_format_set (ospf, ospf_area_get (ospf, area_id), format); |
718e3744 | 1519 | if (ret == 0) |
1520 | { | |
1521 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", | |
1318e7c8 | 1522 | VTYNL); |
718e3744 | 1523 | return CMD_WARNING; |
1524 | } | |
1525 | ||
313605cb | 1526 | if (argc > 3) |
718e3744 | 1527 | { |
7a7be519 | 1528 | if (strncmp (argv[3]->text, "translate-c", 11) == 0) |
b0a053be | 1529 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1530 | OSPF_NSSA_ROLE_CANDIDATE); |
7a7be519 | 1531 | else if (strncmp (argv[3]->text, "translate-n", 11) == 0) |
b0a053be | 1532 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1533 | OSPF_NSSA_ROLE_NEVER); |
7a7be519 | 1534 | else if (strncmp (argv[3]->text, "translate-a", 11) == 0) |
b0a053be | 1535 | ospf_area_nssa_translator_role_set (ospf, area_id, |
718e3744 | 1536 | OSPF_NSSA_ROLE_ALWAYS); |
1537 | } | |
b0a053be | 1538 | else |
1539 | { | |
1540 | ospf_area_nssa_translator_role_set (ospf, area_id, | |
1541 | OSPF_NSSA_ROLE_CANDIDATE); | |
1542 | } | |
718e3744 | 1543 | |
b0a053be | 1544 | if (nosum) |
718e3744 | 1545 | ospf_area_no_summary_set (ospf, area_id); |
b0a053be | 1546 | else |
1547 | ospf_area_no_summary_unset (ospf, area_id); | |
718e3744 | 1548 | |
b0a053be | 1549 | ospf_schedule_abr_task (ospf); |
1550 | ||
718e3744 | 1551 | return CMD_SUCCESS; |
1552 | } | |
1553 | ||
b0a053be | 1554 | DEFUN (ospf_area_nssa_translate_no_summary, |
a2c62831 | 1555 | ospf_area_nssa_translate_no_summary_cmd, |
6147e2c6 | 1556 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary", |
718e3744 | 1557 | "OSPF area parameters\n" |
1558 | "OSPF area ID in IP address format\n" | |
1559 | "OSPF area ID as a decimal value\n" | |
1560 | "Configure OSPF area as nssa\n" | |
1561 | "Configure NSSA-ABR for translate election (default)\n" | |
1562 | "Configure NSSA-ABR to never translate\n" | |
1563 | "Configure NSSA-ABR to always translate\n" | |
b0a053be | 1564 | "Do not inject inter-area routes into nssa\n") |
1565 | { | |
1566 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); | |
1567 | } | |
718e3744 | 1568 | |
b0a053be | 1569 | DEFUN (ospf_area_nssa_translate, |
a2c62831 | 1570 | ospf_area_nssa_translate_cmd, |
6147e2c6 | 1571 | "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>", |
718e3744 | 1572 | "OSPF area parameters\n" |
1573 | "OSPF area ID in IP address format\n" | |
1574 | "OSPF area ID as a decimal value\n" | |
1575 | "Configure OSPF area as nssa\n" | |
1576 | "Configure NSSA-ABR for translate election (default)\n" | |
1577 | "Configure NSSA-ABR to never translate\n" | |
1578 | "Configure NSSA-ABR to always translate\n") | |
b0a053be | 1579 | { |
1580 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1581 | } | |
1582 | ||
1583 | DEFUN (ospf_area_nssa, | |
1584 | ospf_area_nssa_cmd, | |
6147e2c6 | 1585 | "area <A.B.C.D|(0-4294967295)> nssa", |
b0a053be | 1586 | "OSPF area parameters\n" |
1587 | "OSPF area ID in IP address format\n" | |
1588 | "OSPF area ID as a decimal value\n" | |
1589 | "Configure OSPF area as nssa\n") | |
1590 | { | |
1591 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); | |
1592 | } | |
718e3744 | 1593 | |
a2c62831 | 1594 | DEFUN (ospf_area_nssa_no_summary, |
1595 | ospf_area_nssa_no_summary_cmd, | |
6147e2c6 | 1596 | "area <A.B.C.D|(0-4294967295)> nssa no-summary", |
718e3744 | 1597 | "OSPF area parameters\n" |
1598 | "OSPF area ID in IP address format\n" | |
1599 | "OSPF area ID as a decimal value\n" | |
1600 | "Configure OSPF area as nssa\n" | |
1601 | "Do not inject inter-area routes into nssa\n") | |
1602 | { | |
b0a053be | 1603 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
718e3744 | 1604 | } |
1605 | ||
a2c62831 | 1606 | DEFUN (no_ospf_area_nssa, |
1607 | no_ospf_area_nssa_cmd, | |
7a7be519 | 1608 | "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]", |
718e3744 | 1609 | NO_STR |
1610 | "OSPF area parameters\n" | |
1611 | "OSPF area ID in IP address format\n" | |
1612 | "OSPF area ID as a decimal value\n" | |
7a7be519 | 1613 | "Configure OSPF area as nssa\n" |
1614 | "Configure NSSA-ABR for translate election (default)\n" | |
1615 | "Configure NSSA-ABR to never translate\n" | |
1616 | "Configure NSSA-ABR to always translate\n" | |
1617 | "Do not inject inter-area routes into nssa\n") | |
22b27e95 | 1618 | { |
cdc2d765 | 1619 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1620 | int idx_ipv4_number = 2; |
718e3744 | 1621 | struct in_addr area_id; |
1622 | int format; | |
1623 | ||
8d769265 | 1624 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1625 | |
1626 | ospf_area_nssa_unset (ospf, area_id); | |
1627 | ospf_area_no_summary_unset (ospf, area_id); | |
1628 | ||
b0a053be | 1629 | ospf_schedule_abr_task (ospf); |
1630 | ||
718e3744 | 1631 | return CMD_SUCCESS; |
1632 | } | |
1633 | ||
718e3744 | 1634 | |
a2c62831 | 1635 | DEFUN (ospf_area_default_cost, |
1636 | ospf_area_default_cost_cmd, | |
6147e2c6 | 1637 | "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1638 | "OSPF area parameters\n" |
1639 | "OSPF area ID in IP address format\n" | |
1640 | "OSPF area ID as a decimal value\n" | |
1641 | "Set the summary-default cost of a NSSA or stub area\n" | |
1642 | "Stub's advertised default summary cost\n") | |
1643 | { | |
cdc2d765 | 1644 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1645 | int idx_ipv4_number = 1; |
1646 | int idx_number = 3; | |
718e3744 | 1647 | struct ospf_area *area; |
1648 | struct in_addr area_id; | |
1649 | u_int32_t cost; | |
1650 | int format; | |
ba682537 | 1651 | struct prefix_ipv4 p; |
718e3744 | 1652 | |
8d769265 | 1653 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); |
facfee22 | 1654 | cost = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1655 | |
86573dcb QY |
1656 | area = ospf_area_get (ospf, area_id); |
1657 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1658 | |
1659 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1660 | { | |
1318e7c8 | 1661 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTYNL); |
718e3744 | 1662 | return CMD_WARNING; |
1663 | } | |
1664 | ||
1665 | area->default_cost = cost; | |
1666 | ||
ba682537 | 1667 | p.family = AF_INET; |
1668 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1669 | p.prefixlen = 0; | |
1670 | if (IS_DEBUG_OSPF_EVENT) | |
1671 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1672 | "announcing 0.0.0.0/0 to area %s", | |
1673 | inet_ntoa (area->area_id)); | |
1674 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1675 | ||
718e3744 | 1676 | return CMD_SUCCESS; |
1677 | } | |
1678 | ||
a2c62831 | 1679 | DEFUN (no_ospf_area_default_cost, |
1680 | no_ospf_area_default_cost_cmd, | |
6147e2c6 | 1681 | "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)", |
718e3744 | 1682 | NO_STR |
1683 | "OSPF area parameters\n" | |
1684 | "OSPF area ID in IP address format\n" | |
1685 | "OSPF area ID as a decimal value\n" | |
1686 | "Set the summary-default cost of a NSSA or stub area\n" | |
1687 | "Stub's advertised default summary cost\n") | |
1688 | { | |
cdc2d765 | 1689 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1690 | int idx_ipv4_number = 2; |
718e3744 | 1691 | struct ospf_area *area; |
1692 | struct in_addr area_id; | |
718e3744 | 1693 | int format; |
ba682537 | 1694 | struct prefix_ipv4 p; |
718e3744 | 1695 | |
8d769265 | 1696 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1697 | |
68980084 | 1698 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1699 | if (area == NULL) |
1700 | return CMD_SUCCESS; | |
1701 | ||
1702 | if (area->external_routing == OSPF_AREA_DEFAULT) | |
1703 | { | |
1318e7c8 | 1704 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTYNL); |
718e3744 | 1705 | return CMD_WARNING; |
1706 | } | |
1707 | ||
1708 | area->default_cost = 1; | |
1709 | ||
ba682537 | 1710 | p.family = AF_INET; |
1711 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; | |
1712 | p.prefixlen = 0; | |
1713 | if (IS_DEBUG_OSPF_EVENT) | |
1714 | zlog_debug ("ospf_abr_announce_stub_defaults(): " | |
1715 | "announcing 0.0.0.0/0 to area %s", | |
1716 | inet_ntoa (area->area_id)); | |
1717 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); | |
1718 | ||
1719 | ||
68980084 | 1720 | ospf_area_check_free (ospf, area_id); |
718e3744 | 1721 | |
1722 | return CMD_SUCCESS; | |
1723 | } | |
1724 | ||
a2c62831 | 1725 | DEFUN (ospf_area_export_list, |
1726 | ospf_area_export_list_cmd, | |
6147e2c6 | 1727 | "area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1728 | "OSPF area parameters\n" |
1729 | "OSPF area ID in IP address format\n" | |
1730 | "OSPF area ID as a decimal value\n" | |
1731 | "Set the filter for networks announced to other areas\n" | |
1732 | "Name of the access-list\n") | |
1733 | { | |
cdc2d765 | 1734 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1735 | int idx_ipv4_number = 1; |
718e3744 | 1736 | struct ospf_area *area; |
1737 | struct in_addr area_id; | |
1738 | int format; | |
1739 | ||
8d769265 | 1740 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1741 | |
86573dcb QY |
1742 | area = ospf_area_get (ospf, area_id); |
1743 | ospf_area_display_format_set (ospf, area, format); | |
7a7be519 | 1744 | ospf_area_export_list_set (ospf, area, argv[3]->arg); |
718e3744 | 1745 | |
1746 | return CMD_SUCCESS; | |
1747 | } | |
1748 | ||
a2c62831 | 1749 | DEFUN (no_ospf_area_export_list, |
1750 | no_ospf_area_export_list_cmd, | |
6147e2c6 | 1751 | "no area <A.B.C.D|(0-4294967295)> export-list NAME", |
718e3744 | 1752 | NO_STR |
1753 | "OSPF area parameters\n" | |
1754 | "OSPF area ID in IP address format\n" | |
1755 | "OSPF area ID as a decimal value\n" | |
1756 | "Unset the filter for networks announced to other areas\n" | |
1757 | "Name of the access-list\n") | |
1758 | { | |
cdc2d765 | 1759 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1760 | int idx_ipv4_number = 2; |
718e3744 | 1761 | struct ospf_area *area; |
1762 | struct in_addr area_id; | |
1763 | int format; | |
1764 | ||
8d769265 | 1765 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1766 | |
68980084 | 1767 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1768 | if (area == NULL) |
1769 | return CMD_SUCCESS; | |
1770 | ||
68980084 | 1771 | ospf_area_export_list_unset (ospf, area); |
718e3744 | 1772 | |
1773 | return CMD_SUCCESS; | |
1774 | } | |
1775 | ||
1776 | ||
a2c62831 | 1777 | DEFUN (ospf_area_import_list, |
1778 | ospf_area_import_list_cmd, | |
6147e2c6 | 1779 | "area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1780 | "OSPF area parameters\n" |
1781 | "OSPF area ID in IP address format\n" | |
1782 | "OSPF area ID as a decimal value\n" | |
1783 | "Set the filter for networks from other areas announced to the specified one\n" | |
1784 | "Name of the access-list\n") | |
1785 | { | |
cdc2d765 | 1786 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1787 | int idx_ipv4_number = 1; |
718e3744 | 1788 | struct ospf_area *area; |
1789 | struct in_addr area_id; | |
1790 | int format; | |
1791 | ||
8d769265 | 1792 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1793 | |
86573dcb QY |
1794 | area = ospf_area_get (ospf, area_id); |
1795 | ospf_area_display_format_set (ospf, area, format); | |
7a7be519 | 1796 | ospf_area_import_list_set (ospf, area, argv[3]->arg); |
718e3744 | 1797 | |
1798 | return CMD_SUCCESS; | |
1799 | } | |
1800 | ||
a2c62831 | 1801 | DEFUN (no_ospf_area_import_list, |
1802 | no_ospf_area_import_list_cmd, | |
6147e2c6 | 1803 | "no area <A.B.C.D|(0-4294967295)> import-list NAME", |
718e3744 | 1804 | NO_STR |
1805 | "OSPF area parameters\n" | |
1806 | "OSPF area ID in IP address format\n" | |
1807 | "OSPF area ID as a decimal value\n" | |
1808 | "Unset the filter for networks announced to other areas\n" | |
1809 | "Name of the access-list\n") | |
1810 | { | |
cdc2d765 | 1811 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1812 | int idx_ipv4_number = 2; |
718e3744 | 1813 | struct ospf_area *area; |
1814 | struct in_addr area_id; | |
1815 | int format; | |
1816 | ||
8d769265 | 1817 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
52930766 | 1818 | |
68980084 | 1819 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 1820 | if (area == NULL) |
1821 | return CMD_SUCCESS; | |
1822 | ||
68980084 | 1823 | ospf_area_import_list_unset (ospf, area); |
718e3744 | 1824 | |
1825 | return CMD_SUCCESS; | |
1826 | } | |
1827 | ||
a2c62831 | 1828 | DEFUN (ospf_area_filter_list, |
1829 | ospf_area_filter_list_cmd, | |
6147e2c6 | 1830 | "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1831 | "OSPF area parameters\n" |
1832 | "OSPF area ID in IP address format\n" | |
1833 | "OSPF area ID as a decimal value\n" | |
1834 | "Filter networks between OSPF areas\n" | |
1835 | "Filter prefixes between OSPF areas\n" | |
1836 | "Name of an IP prefix-list\n" | |
1837 | "Filter networks sent to this area\n" | |
1838 | "Filter networks sent from this area\n") | |
1839 | { | |
cdc2d765 | 1840 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1841 | int idx_ipv4_number = 1; |
1842 | int idx_word = 4; | |
1843 | int idx_in_out = 5; | |
718e3744 | 1844 | struct ospf_area *area; |
1845 | struct in_addr area_id; | |
1846 | struct prefix_list *plist; | |
1847 | int format; | |
1848 | ||
8d769265 | 1849 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1850 | |
86573dcb QY |
1851 | area = ospf_area_get (ospf, area_id); |
1852 | ospf_area_display_format_set (ospf, area, format); | |
8d769265 DW |
1853 | plist = prefix_list_lookup (AFI_IP, argv[idx_word]->arg); |
1854 | if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) | |
718e3744 | 1855 | { |
1856 | PREFIX_LIST_IN (area) = plist; | |
1857 | if (PREFIX_NAME_IN (area)) | |
1858 | free (PREFIX_NAME_IN (area)); | |
1859 | ||
8d769265 | 1860 | PREFIX_NAME_IN (area) = strdup (argv[idx_word]->arg); |
68980084 | 1861 | ospf_schedule_abr_task (ospf); |
718e3744 | 1862 | } |
1863 | else | |
1864 | { | |
1865 | PREFIX_LIST_OUT (area) = plist; | |
1866 | if (PREFIX_NAME_OUT (area)) | |
1867 | free (PREFIX_NAME_OUT (area)); | |
1868 | ||
8d769265 | 1869 | PREFIX_NAME_OUT (area) = strdup (argv[idx_word]->arg); |
68980084 | 1870 | ospf_schedule_abr_task (ospf); |
718e3744 | 1871 | } |
1872 | ||
1873 | return CMD_SUCCESS; | |
1874 | } | |
1875 | ||
a2c62831 | 1876 | DEFUN (no_ospf_area_filter_list, |
1877 | no_ospf_area_filter_list_cmd, | |
6147e2c6 | 1878 | "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>", |
718e3744 | 1879 | NO_STR |
1880 | "OSPF area parameters\n" | |
1881 | "OSPF area ID in IP address format\n" | |
1882 | "OSPF area ID as a decimal value\n" | |
1883 | "Filter networks between OSPF areas\n" | |
1884 | "Filter prefixes between OSPF areas\n" | |
1885 | "Name of an IP prefix-list\n" | |
1886 | "Filter networks sent to this area\n" | |
1887 | "Filter networks sent from this area\n") | |
1888 | { | |
cdc2d765 | 1889 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
1890 | int idx_ipv4_number = 2; |
1891 | int idx_word = 5; | |
1892 | int idx_in_out = 6; | |
718e3744 | 1893 | struct ospf_area *area; |
1894 | struct in_addr area_id; | |
718e3744 | 1895 | int format; |
1896 | ||
8d769265 | 1897 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1898 | |
1a8ec2b9 PJ |
1899 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
1900 | return CMD_SUCCESS; | |
1901 | ||
8d769265 | 1902 | if (strncmp (argv[idx_in_out]->arg, "in", 2) == 0) |
718e3744 | 1903 | { |
1904 | if (PREFIX_NAME_IN (area)) | |
8d769265 | 1905 | if (strcmp (PREFIX_NAME_IN (area), argv[idx_word]->arg) != 0) |
718e3744 | 1906 | return CMD_SUCCESS; |
1907 | ||
1908 | PREFIX_LIST_IN (area) = NULL; | |
1909 | if (PREFIX_NAME_IN (area)) | |
1910 | free (PREFIX_NAME_IN (area)); | |
1911 | ||
1912 | PREFIX_NAME_IN (area) = NULL; | |
1913 | ||
68980084 | 1914 | ospf_schedule_abr_task (ospf); |
718e3744 | 1915 | } |
1916 | else | |
1917 | { | |
1918 | if (PREFIX_NAME_OUT (area)) | |
8d769265 | 1919 | if (strcmp (PREFIX_NAME_OUT (area), argv[idx_word]->arg) != 0) |
718e3744 | 1920 | return CMD_SUCCESS; |
1921 | ||
1922 | PREFIX_LIST_OUT (area) = NULL; | |
1923 | if (PREFIX_NAME_OUT (area)) | |
1924 | free (PREFIX_NAME_OUT (area)); | |
1925 | ||
1926 | PREFIX_NAME_OUT (area) = NULL; | |
1927 | ||
68980084 | 1928 | ospf_schedule_abr_task (ospf); |
718e3744 | 1929 | } |
1930 | ||
1931 | return CMD_SUCCESS; | |
1932 | } | |
1933 | ||
6b0655a2 | 1934 | |
a2c62831 | 1935 | DEFUN (ospf_area_authentication_message_digest, |
1936 | ospf_area_authentication_message_digest_cmd, | |
6147e2c6 | 1937 | "area <A.B.C.D|(0-4294967295)> authentication message-digest", |
718e3744 | 1938 | "OSPF area parameters\n" |
2b00515a CF |
1939 | "OSPF area ID in IP address format\n" |
1940 | "OSPF area ID as a decimal value\n" | |
718e3744 | 1941 | "Enable authentication\n" |
1942 | "Use message-digest authentication\n") | |
1943 | { | |
cdc2d765 | 1944 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1945 | int idx_ipv4_number = 1; |
718e3744 | 1946 | struct ospf_area *area; |
1947 | struct in_addr area_id; | |
1948 | int format; | |
1949 | ||
8d769265 | 1950 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1951 | |
86573dcb QY |
1952 | area = ospf_area_get (ospf, area_id); |
1953 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1954 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
1955 | ||
1956 | return CMD_SUCCESS; | |
1957 | } | |
1958 | ||
a2c62831 | 1959 | DEFUN (ospf_area_authentication, |
1960 | ospf_area_authentication_cmd, | |
6147e2c6 | 1961 | "area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 1962 | "OSPF area parameters\n" |
1963 | "OSPF area ID in IP address format\n" | |
1964 | "OSPF area ID as a decimal value\n" | |
1965 | "Enable authentication\n") | |
1966 | { | |
cdc2d765 | 1967 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1968 | int idx_ipv4_number = 1; |
718e3744 | 1969 | struct ospf_area *area; |
1970 | struct in_addr area_id; | |
1971 | int format; | |
1972 | ||
8d769265 | 1973 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1974 | |
86573dcb QY |
1975 | area = ospf_area_get (ospf, area_id); |
1976 | ospf_area_display_format_set (ospf, area, format); | |
718e3744 | 1977 | area->auth_type = OSPF_AUTH_SIMPLE; |
1978 | ||
1979 | return CMD_SUCCESS; | |
1980 | } | |
1981 | ||
a2c62831 | 1982 | DEFUN (no_ospf_area_authentication, |
1983 | no_ospf_area_authentication_cmd, | |
6147e2c6 | 1984 | "no area <A.B.C.D|(0-4294967295)> authentication", |
718e3744 | 1985 | NO_STR |
1986 | "OSPF area parameters\n" | |
1987 | "OSPF area ID in IP address format\n" | |
1988 | "OSPF area ID as a decimal value\n" | |
1989 | "Enable authentication\n") | |
1990 | { | |
cdc2d765 | 1991 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 1992 | int idx_ipv4_number = 2; |
718e3744 | 1993 | struct ospf_area *area; |
1994 | struct in_addr area_id; | |
1995 | int format; | |
1996 | ||
8d769265 | 1997 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[idx_ipv4_number]->arg); |
718e3744 | 1998 | |
68980084 | 1999 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
718e3744 | 2000 | if (area == NULL) |
2001 | return CMD_SUCCESS; | |
2002 | ||
2003 | area->auth_type = OSPF_AUTH_NULL; | |
2004 | ||
68980084 | 2005 | ospf_area_check_free (ospf, area_id); |
718e3744 | 2006 | |
2007 | return CMD_SUCCESS; | |
2008 | } | |
2009 | ||
6b0655a2 | 2010 | |
718e3744 | 2011 | DEFUN (ospf_abr_type, |
2012 | ospf_abr_type_cmd, | |
6147e2c6 | 2013 | "ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2014 | "OSPF specific commands\n" |
2015 | "Set OSPF ABR type\n" | |
2016 | "Alternative ABR, cisco implementation\n" | |
2017 | "Alternative ABR, IBM implementation\n" | |
2018 | "Shortcut ABR\n" | |
2019 | "Standard behavior (RFC2328)\n") | |
2020 | { | |
cdc2d765 | 2021 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2022 | int idx_vendor = 2; |
718e3744 | 2023 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2024 | ||
8d769265 | 2025 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) |
718e3744 | 2026 | abr_type = OSPF_ABR_CISCO; |
8d769265 | 2027 | else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) |
718e3744 | 2028 | abr_type = OSPF_ABR_IBM; |
8d769265 | 2029 | else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) |
718e3744 | 2030 | abr_type = OSPF_ABR_SHORTCUT; |
8d769265 | 2031 | else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) |
718e3744 | 2032 | abr_type = OSPF_ABR_STAND; |
2033 | else | |
2034 | return CMD_WARNING; | |
2035 | ||
2036 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2037 | if (ospf->abr_type != abr_type) |
718e3744 | 2038 | { |
68980084 | 2039 | ospf->abr_type = abr_type; |
2040 | ospf_schedule_abr_task (ospf); | |
718e3744 | 2041 | } |
2042 | ||
2043 | return CMD_SUCCESS; | |
2044 | } | |
2045 | ||
2046 | DEFUN (no_ospf_abr_type, | |
2047 | no_ospf_abr_type_cmd, | |
6147e2c6 | 2048 | "no ospf abr-type <cisco|ibm|shortcut|standard>", |
718e3744 | 2049 | NO_STR |
2050 | "OSPF specific commands\n" | |
2051 | "Set OSPF ABR type\n" | |
2052 | "Alternative ABR, cisco implementation\n" | |
2053 | "Alternative ABR, IBM implementation\n" | |
3a2d747c QY |
2054 | "Shortcut ABR\n" |
2055 | "Standard ABR\n") | |
718e3744 | 2056 | { |
cdc2d765 | 2057 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2058 | int idx_vendor = 3; |
718e3744 | 2059 | u_char abr_type = OSPF_ABR_UNKNOWN; |
2060 | ||
8d769265 | 2061 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) |
718e3744 | 2062 | abr_type = OSPF_ABR_CISCO; |
8d769265 | 2063 | else if (strncmp (argv[idx_vendor]->arg, "i", 1) == 0) |
718e3744 | 2064 | abr_type = OSPF_ABR_IBM; |
8d769265 | 2065 | else if (strncmp (argv[idx_vendor]->arg, "sh", 2) == 0) |
718e3744 | 2066 | abr_type = OSPF_ABR_SHORTCUT; |
8d769265 | 2067 | else if (strncmp (argv[idx_vendor]->arg, "st", 2) == 0) |
04d23314 | 2068 | abr_type = OSPF_ABR_STAND; |
718e3744 | 2069 | else |
2070 | return CMD_WARNING; | |
2071 | ||
2072 | /* If ABR type value is changed, schedule ABR task. */ | |
68980084 | 2073 | if (ospf->abr_type == abr_type) |
718e3744 | 2074 | { |
d57834f6 | 2075 | ospf->abr_type = OSPF_ABR_DEFAULT; |
68980084 | 2076 | ospf_schedule_abr_task (ospf); |
718e3744 | 2077 | } |
2078 | ||
2079 | return CMD_SUCCESS; | |
2080 | } | |
2081 | ||
d7e60dd7 AS |
2082 | DEFUN (ospf_log_adjacency_changes, |
2083 | ospf_log_adjacency_changes_cmd, | |
2084 | "log-adjacency-changes", | |
2085 | "Log changes in adjacency state\n") | |
2086 | { | |
cdc2d765 | 2087 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2088 | |
2089 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
692c7954 | 2090 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
d7e60dd7 AS |
2091 | return CMD_SUCCESS; |
2092 | } | |
2093 | ||
2094 | DEFUN (ospf_log_adjacency_changes_detail, | |
2095 | ospf_log_adjacency_changes_detail_cmd, | |
2096 | "log-adjacency-changes detail", | |
2097 | "Log changes in adjacency state\n" | |
2098 | "Log all state changes\n") | |
2099 | { | |
cdc2d765 | 2100 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2101 | |
2102 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2103 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2104 | return CMD_SUCCESS; | |
2105 | } | |
2106 | ||
2107 | DEFUN (no_ospf_log_adjacency_changes, | |
2108 | no_ospf_log_adjacency_changes_cmd, | |
2109 | "no log-adjacency-changes", | |
2110 | NO_STR | |
2111 | "Log changes in adjacency state\n") | |
2112 | { | |
cdc2d765 | 2113 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2114 | |
2115 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2116 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); | |
2117 | return CMD_SUCCESS; | |
2118 | } | |
2119 | ||
2120 | DEFUN (no_ospf_log_adjacency_changes_detail, | |
2121 | no_ospf_log_adjacency_changes_detail_cmd, | |
2122 | "no log-adjacency-changes detail", | |
2123 | NO_STR | |
2124 | "Log changes in adjacency state\n" | |
2125 | "Log all state changes\n") | |
2126 | { | |
cdc2d765 | 2127 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d7e60dd7 AS |
2128 | |
2129 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); | |
2130 | return CMD_SUCCESS; | |
2131 | } | |
2132 | ||
718e3744 | 2133 | DEFUN (ospf_compatible_rfc1583, |
2134 | ospf_compatible_rfc1583_cmd, | |
2135 | "compatible rfc1583", | |
2136 | "OSPF compatibility list\n" | |
2137 | "compatible with RFC 1583\n") | |
2138 | { | |
cdc2d765 | 2139 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 2140 | |
2141 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
2142 | { | |
2143 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2144 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2145 | } |
2146 | return CMD_SUCCESS; | |
2147 | } | |
2148 | ||
2149 | DEFUN (no_ospf_compatible_rfc1583, | |
2150 | no_ospf_compatible_rfc1583_cmd, | |
2151 | "no compatible rfc1583", | |
2152 | NO_STR | |
2153 | "OSPF compatibility list\n" | |
2154 | "compatible with RFC 1583\n") | |
2155 | { | |
cdc2d765 | 2156 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 2157 | |
2158 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
2159 | { | |
2160 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); | |
d3a9c768 | 2161 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
718e3744 | 2162 | } |
2163 | return CMD_SUCCESS; | |
2164 | } | |
2165 | ||
7a7be519 | 2166 | ALIAS (ospf_compatible_rfc1583, |
2167 | ospf_rfc1583_flag_cmd, | |
2168 | "ospf rfc1583compatibility", | |
2169 | "OSPF specific commands\n" | |
2170 | "Enable the RFC1583Compatibility flag\n") | |
718e3744 | 2171 | |
7a7be519 | 2172 | ALIAS (no_ospf_compatible_rfc1583, |
2173 | no_ospf_rfc1583_flag_cmd, | |
2174 | "no ospf rfc1583compatibility", | |
2175 | NO_STR | |
2176 | "OSPF specific commands\n" | |
2177 | "Disable the RFC1583Compatibility flag\n") | |
6b0655a2 | 2178 | |
d24f6e2a | 2179 | static int |
2180 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, | |
2181 | unsigned int hold, | |
2182 | unsigned int max) | |
2183 | { | |
cdc2d765 | 2184 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7c8ff89e | 2185 | |
d24f6e2a | 2186 | ospf->spf_delay = delay; |
2187 | ospf->spf_holdtime = hold; | |
2188 | ospf->spf_max_holdtime = max; | |
2189 | ||
2190 | return CMD_SUCCESS; | |
2191 | } | |
718e3744 | 2192 | |
ac7424f9 MR |
2193 | DEFUN (ospf_timers_min_ls_interval, |
2194 | ospf_timers_min_ls_interval_cmd, | |
6147e2c6 | 2195 | "timers throttle lsa all (0-5000)", |
ac7424f9 MR |
2196 | "Adjust routing timers\n" |
2197 | "Throttling adaptive timer\n" | |
2198 | "LSA delay between transmissions\n" | |
813d4307 | 2199 | "All LSA types\n" |
ac7424f9 MR |
2200 | "Delay (msec) between sending LSAs\n") |
2201 | { | |
cdc2d765 | 2202 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2203 | int idx_number = 4; |
ac7424f9 MR |
2204 | unsigned int interval; |
2205 | ||
3ba26039 | 2206 | if (argc < 5) |
ac7424f9 | 2207 | { |
1318e7c8 | 2208 | vty_out (vty, "Insufficient arguments%s", VTYNL); |
ac7424f9 MR |
2209 | return CMD_WARNING; |
2210 | } | |
2211 | ||
facfee22 | 2212 | interval = strtoul(argv[idx_number]->arg, NULL, 10); |
ac7424f9 MR |
2213 | |
2214 | ospf->min_ls_interval = interval; | |
2215 | ||
2216 | return CMD_SUCCESS; | |
2217 | } | |
2218 | ||
2219 | DEFUN (no_ospf_timers_min_ls_interval, | |
2220 | no_ospf_timers_min_ls_interval_cmd, | |
7a7be519 | 2221 | "no timers throttle lsa all [(0-5000)]", |
ac7424f9 MR |
2222 | NO_STR |
2223 | "Adjust routing timers\n" | |
2224 | "Throttling adaptive timer\n" | |
813d4307 | 2225 | "LSA delay between transmissions\n" |
7a7be519 | 2226 | "All LSA types\n" |
2227 | "Delay (msec) between sending LSAs\n") | |
ac7424f9 | 2228 | { |
cdc2d765 | 2229 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
ac7424f9 MR |
2230 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; |
2231 | ||
2232 | return CMD_SUCCESS; | |
2233 | } | |
2234 | ||
813d4307 | 2235 | |
ac7424f9 MR |
2236 | DEFUN (ospf_timers_min_ls_arrival, |
2237 | ospf_timers_min_ls_arrival_cmd, | |
6147e2c6 | 2238 | "timers lsa arrival (0-1000)", |
ac7424f9 MR |
2239 | "Adjust routing timers\n" |
2240 | "Throttling link state advertisement delays\n" | |
2241 | "OSPF minimum arrival interval delay\n" | |
2242 | "Delay (msec) between accepted LSAs\n") | |
2243 | { | |
cdc2d765 | 2244 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2245 | int idx_number = 3; |
ac7424f9 MR |
2246 | unsigned int arrival; |
2247 | ||
3ba26039 | 2248 | if (argc < 4) |
ac7424f9 | 2249 | { |
1318e7c8 | 2250 | vty_out (vty, "Insufficient arguments%s", VTYNL); |
ac7424f9 MR |
2251 | return CMD_WARNING; |
2252 | } | |
2253 | ||
facfee22 | 2254 | arrival = strtoul(argv[idx_number]->arg, NULL, 10); |
ac7424f9 MR |
2255 | |
2256 | ospf->min_ls_arrival = arrival; | |
2257 | ||
2258 | return CMD_SUCCESS; | |
2259 | } | |
2260 | ||
2261 | DEFUN (no_ospf_timers_min_ls_arrival, | |
2262 | no_ospf_timers_min_ls_arrival_cmd, | |
7a7be519 | 2263 | "no timers lsa arrival [(0-1000)]", |
ac7424f9 MR |
2264 | NO_STR |
2265 | "Adjust routing timers\n" | |
2266 | "Throttling link state advertisement delays\n" | |
7a7be519 | 2267 | "OSPF minimum arrival interval delay\n" |
2268 | "Delay (msec) between accepted LSAs\n") | |
ac7424f9 | 2269 | { |
cdc2d765 | 2270 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
d8f70b86 | 2271 | |
ac7424f9 MR |
2272 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
2273 | ||
2274 | return CMD_SUCCESS; | |
2275 | } | |
2276 | ||
813d4307 | 2277 | |
d24f6e2a | 2278 | DEFUN (ospf_timers_throttle_spf, |
2279 | ospf_timers_throttle_spf_cmd, | |
6147e2c6 | 2280 | "timers throttle spf (0-600000) (0-600000) (0-600000)", |
d24f6e2a | 2281 | "Adjust routing timers\n" |
2282 | "Throttling adaptive timer\n" | |
2283 | "OSPF SPF timers\n" | |
2284 | "Delay (msec) from first change received till SPF calculation\n" | |
2285 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2286 | "Maximum hold time (msec)\n") | |
2287 | { | |
8d769265 DW |
2288 | int idx_number = 3; |
2289 | int idx_number_2 = 4; | |
2290 | int idx_number_3 = 5; | |
d24f6e2a | 2291 | unsigned int delay, hold, max; |
2292 | ||
3ba26039 | 2293 | if (argc < 6) |
d24f6e2a | 2294 | { |
1318e7c8 | 2295 | vty_out (vty, "Insufficient arguments%s", VTYNL); |
d24f6e2a | 2296 | return CMD_WARNING; |
2297 | } | |
2298 | ||
facfee22 QY |
2299 | delay = strtoul(argv[idx_number]->arg, NULL, 10); |
2300 | hold = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
2301 | max = strtoul(argv[idx_number_3]->arg, NULL, 10); | |
d24f6e2a | 2302 | |
2303 | return ospf_timers_spf_set (vty, delay, hold, max); | |
2304 | } | |
2305 | ||
d24f6e2a | 2306 | DEFUN (no_ospf_timers_throttle_spf, |
2307 | no_ospf_timers_throttle_spf_cmd, | |
7a7be519 | 2308 | "no timers throttle spf [(0-600000)(0-600000)(0-600000)]", |
718e3744 | 2309 | NO_STR |
2310 | "Adjust routing timers\n" | |
d24f6e2a | 2311 | "Throttling adaptive timer\n" |
7a7be519 | 2312 | "OSPF SPF timers\n" |
2313 | "Delay (msec) from first change received till SPF calculation\n" | |
2314 | "Initial hold time (msec) between consecutive SPF calculations\n" | |
2315 | "Maximum hold time (msec)\n") | |
22b27e95 | 2316 | { |
d24f6e2a | 2317 | return ospf_timers_spf_set (vty, |
2318 | OSPF_SPF_DELAY_DEFAULT, | |
2319 | OSPF_SPF_HOLDTIME_DEFAULT, | |
2320 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); | |
718e3744 | 2321 | } |
2322 | ||
b4a039bf | 2323 | |
b6927875 DS |
2324 | DEFUN (ospf_timers_lsa, |
2325 | ospf_timers_lsa_cmd, | |
6147e2c6 | 2326 | "timers lsa min-arrival (0-600000)", |
b6927875 DS |
2327 | "Adjust routing timers\n" |
2328 | "OSPF LSA timers\n" | |
2329 | "Minimum delay in receiving new version of a LSA\n" | |
2330 | "Delay in milliseconds\n") | |
2331 | { | |
cdc2d765 | 2332 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2333 | int idx_number = 3; |
b6927875 | 2334 | unsigned int minarrival; |
b6927875 | 2335 | |
3ba26039 | 2336 | if (argc < 4) |
b6927875 | 2337 | { |
1318e7c8 | 2338 | vty_out (vty, "Insufficient number of arguments%s", VTYNL); |
b6927875 DS |
2339 | return CMD_WARNING; |
2340 | } | |
2341 | ||
facfee22 | 2342 | minarrival = strtoul(argv[idx_number]->arg, NULL, 10); |
b6927875 | 2343 | |
ac7424f9 | 2344 | ospf->min_ls_arrival = minarrival; |
b6927875 DS |
2345 | |
2346 | return CMD_SUCCESS; | |
2347 | } | |
2348 | ||
2349 | DEFUN (no_ospf_timers_lsa, | |
2350 | no_ospf_timers_lsa_cmd, | |
7a7be519 | 2351 | "no timers lsa min-arrival [(0-600000)]", |
b6927875 DS |
2352 | NO_STR |
2353 | "Adjust routing timers\n" | |
2354 | "OSPF LSA timers\n" | |
7a7be519 | 2355 | "Minimum delay in receiving new version of a LSA\n" |
2356 | "Delay in milliseconds\n") | |
b6927875 | 2357 | { |
cdc2d765 | 2358 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
b6927875 | 2359 | unsigned int minarrival; |
b6927875 | 2360 | |
7a7be519 | 2361 | if (argc > 4) |
b6927875 | 2362 | { |
facfee22 | 2363 | minarrival = strtoul(argv[4]->arg, NULL, 10); |
b6927875 | 2364 | |
ac7424f9 | 2365 | if (ospf->min_ls_arrival != minarrival || |
b6927875 DS |
2366 | minarrival == OSPF_MIN_LS_ARRIVAL) |
2367 | return CMD_SUCCESS; | |
2368 | } | |
2369 | ||
ac7424f9 | 2370 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
b6927875 DS |
2371 | |
2372 | return CMD_SUCCESS; | |
2373 | } | |
2374 | ||
a2c62831 | 2375 | DEFUN (ospf_neighbor, |
2376 | ospf_neighbor_cmd, | |
7a7be519 | 2377 | "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]", |
718e3744 | 2378 | NEIGHBOR_STR |
7a7be519 | 2379 | "Neighbor IP address\n" |
2380 | "Neighbor Priority\n" | |
2381 | "Priority\n" | |
2382 | "Dead Neighbor Polling interval\n" | |
2383 | "Seconds\n") | |
718e3744 | 2384 | { |
cdc2d765 | 2385 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2386 | int idx_ipv4 = 1; |
7a7be519 | 2387 | int idx_pri = 3; |
2388 | int idx_poll = 5; | |
718e3744 | 2389 | struct in_addr nbr_addr; |
eb1ce605 | 2390 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2391 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2392 | |
facfee22 | 2393 | inet_aton(argv[idx_ipv4]->arg, &nbr_addr); |
718e3744 | 2394 | |
718e3744 | 2395 | if (argc > 2) |
facfee22 | 2396 | priority = strtoul(argv[idx_pri]->arg, NULL, 10); |
7a7be519 | 2397 | |
2398 | if (argc > 4) | |
facfee22 | 2399 | interval = strtoul(argv[idx_poll]->arg, NULL, 10); |
718e3744 | 2400 | |
2401 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
7a7be519 | 2402 | |
718e3744 | 2403 | if (argc > 2) |
7a7be519 | 2404 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
2405 | ||
2406 | if (argc > 4) | |
1a61ad10 | 2407 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
718e3744 | 2408 | |
2409 | return CMD_SUCCESS; | |
2410 | } | |
2411 | ||
a2c62831 | 2412 | DEFUN (ospf_neighbor_poll_interval, |
2413 | ospf_neighbor_poll_interval_cmd, | |
7a7be519 | 2414 | "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", |
718e3744 | 2415 | NEIGHBOR_STR |
2416 | "Neighbor IP address\n" | |
2417 | "Dead Neighbor Polling interval\n" | |
7a7be519 | 2418 | "Seconds\n" |
2419 | "OSPF priority of non-broadcast neighbor\n" | |
2420 | "Priority\n") | |
22b27e95 | 2421 | { |
cdc2d765 | 2422 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2423 | int idx_ipv4 = 1; |
7a7be519 | 2424 | int idx_poll = 3; |
2425 | int idx_pri = 5; | |
718e3744 | 2426 | struct in_addr nbr_addr; |
eb1ce605 | 2427 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
2428 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; | |
718e3744 | 2429 | |
facfee22 | 2430 | inet_aton(argv[idx_ipv4]->arg, &nbr_addr); |
718e3744 | 2431 | |
facfee22 | 2432 | interval = strtoul(argv[idx_poll]->arg, NULL, 10); |
718e3744 | 2433 | |
7a7be519 | 2434 | if (argc > 4) |
facfee22 | 2435 | priority = strtoul(argv[idx_pri]->arg, NULL, 10); |
718e3744 | 2436 | |
2437 | ospf_nbr_nbma_set (ospf, nbr_addr); | |
7a7be519 | 2438 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
2439 | ||
2440 | if (argc > 4) | |
718e3744 | 2441 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
2442 | ||
2443 | return CMD_SUCCESS; | |
2444 | } | |
2445 | ||
a2c62831 | 2446 | DEFUN (no_ospf_neighbor, |
2447 | no_ospf_neighbor_cmd, | |
7a7be519 | 2448 | "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]", |
718e3744 | 2449 | NO_STR |
2450 | NEIGHBOR_STR | |
7a7be519 | 2451 | "Neighbor IP address\n" |
2452 | "Neighbor Priority\n" | |
2453 | "Priority\n" | |
2454 | "Dead Neighbor Polling interval\n" | |
2455 | "Seconds\n") | |
718e3744 | 2456 | { |
cdc2d765 | 2457 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2458 | int idx_ipv4 = 2; |
718e3744 | 2459 | struct in_addr nbr_addr; |
718e3744 | 2460 | |
facfee22 | 2461 | inet_aton(argv[idx_ipv4]->arg, &nbr_addr); |
718e3744 | 2462 | |
0798cee3 | 2463 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
718e3744 | 2464 | |
2465 | return CMD_SUCCESS; | |
2466 | } | |
2467 | ||
7a7be519 | 2468 | DEFUN (no_ospf_neighbor_poll, |
2469 | no_ospf_neighbor_poll_cmd, | |
2470 | "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]", | |
2471 | NO_STR | |
2472 | NEIGHBOR_STR | |
2473 | "Neighbor IP address\n" | |
2474 | "Dead Neighbor Polling interval\n" | |
2475 | "Seconds\n" | |
2476 | "Neighbor Priority\n" | |
2477 | "Priority\n") | |
2478 | { | |
cdc2d765 | 2479 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 2480 | int idx_ipv4 = 2; |
7a7be519 | 2481 | struct in_addr nbr_addr; |
2482 | ||
facfee22 | 2483 | inet_aton(argv[idx_ipv4]->arg, &nbr_addr); |
718e3744 | 2484 | |
7a7be519 | 2485 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
813d4307 | 2486 | |
7a7be519 | 2487 | return CMD_SUCCESS; |
2488 | } | |
718e3744 | 2489 | |
bf2bfafd DW |
2490 | DEFUN (ospf_refresh_timer, |
2491 | ospf_refresh_timer_cmd, | |
6147e2c6 | 2492 | "refresh timer (10-1800)", |
718e3744 | 2493 | "Adjust refresh parameters\n" |
2494 | "Set refresh timer\n" | |
2495 | "Timer value in seconds\n") | |
2496 | { | |
cdc2d765 | 2497 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2498 | int idx_number = 2; |
eb1ce605 | 2499 | unsigned int interval; |
7c8ff89e | 2500 | |
facfee22 | 2501 | interval = strtoul(argv[idx_number]->arg, NULL, 10); |
535c84b1 | 2502 | interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY; |
718e3744 | 2503 | |
2504 | ospf_timers_refresh_set (ospf, interval); | |
2505 | ||
2506 | return CMD_SUCCESS; | |
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 | { | |
cdc2d765 | 2517 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2518 | int idx_number = 3; |
eb1ce605 | 2519 | unsigned int interval; |
718e3744 | 2520 | |
2521 | if (argc == 1) | |
2522 | { | |
facfee22 | 2523 | interval = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2524 | |
2525 | if (ospf->lsa_refresh_interval != interval || | |
2526 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) | |
2527 | return CMD_SUCCESS; | |
2528 | } | |
2529 | ||
2530 | ospf_timers_refresh_unset (ospf); | |
2531 | ||
2532 | return CMD_SUCCESS; | |
2533 | } | |
2534 | ||
718e3744 | 2535 | |
a2c62831 | 2536 | DEFUN (ospf_auto_cost_reference_bandwidth, |
2537 | ospf_auto_cost_reference_bandwidth_cmd, | |
6147e2c6 | 2538 | "auto-cost reference-bandwidth (1-4294967)", |
718e3744 | 2539 | "Calculate OSPF interface cost according to bandwidth\n" |
2540 | "Use reference bandwidth method to assign OSPF cost\n" | |
2541 | "The reference bandwidth in terms of Mbits per second\n") | |
2542 | { | |
cdc2d765 | 2543 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 2544 | int idx_number = 2; |
718e3744 | 2545 | u_int32_t refbw; |
52dc7ee6 | 2546 | struct listnode *node; |
1eb8ef25 | 2547 | struct interface *ifp; |
718e3744 | 2548 | |
8d769265 | 2549 | refbw = strtol (argv[idx_number]->arg, NULL, 10); |
718e3744 | 2550 | if (refbw < 1 || refbw > 4294967) |
2551 | { | |
1318e7c8 | 2552 | vty_out (vty, "reference-bandwidth value is invalid%s", VTYNL); |
718e3744 | 2553 | return CMD_WARNING; |
2554 | } | |
2555 | ||
2556 | /* If reference bandwidth is changed. */ | |
70bd3c43 | 2557 | if ((refbw) == ospf->ref_bandwidth) |
718e3744 | 2558 | return CMD_SUCCESS; |
2559 | ||
70bd3c43 | 2560 | ospf->ref_bandwidth = refbw; |
1eb8ef25 | 2561 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
2562 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2563 | |
2564 | return CMD_SUCCESS; | |
2565 | } | |
2566 | ||
a2c62831 | 2567 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
2568 | no_ospf_auto_cost_reference_bandwidth_cmd, | |
7a7be519 | 2569 | "no auto-cost reference-bandwidth [(1-4294967)]", |
718e3744 | 2570 | NO_STR |
2571 | "Calculate OSPF interface cost according to bandwidth\n" | |
7a7be519 | 2572 | "Use reference bandwidth method to assign OSPF cost\n" |
2573 | "The reference bandwidth in terms of Mbits per second\n") | |
718e3744 | 2574 | { |
cdc2d765 | 2575 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
1eb8ef25 | 2576 | struct listnode *node, *nnode; |
2577 | struct interface *ifp; | |
718e3744 | 2578 | |
68980084 | 2579 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
718e3744 | 2580 | return CMD_SUCCESS; |
2581 | ||
68980084 | 2582 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
1318e7c8 QY |
2583 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTYNL); |
2584 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTYNL); | |
718e3744 | 2585 | |
1eb8ef25 | 2586 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
2587 | ospf_if_recalculate_output_cost (ifp); | |
718e3744 | 2588 | |
2589 | return CMD_SUCCESS; | |
2590 | } | |
2591 | ||
2f8f370e DS |
2592 | DEFUN (ospf_write_multiplier, |
2593 | ospf_write_multiplier_cmd, | |
6147e2c6 | 2594 | "ospf write-multiplier (1-100)", |
e8f45e82 DS |
2595 | "OSPF specific commands\n" |
2596 | "Write multiplier\n" | |
2597 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2598 | { |
cdc2d765 | 2599 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7a7be519 | 2600 | int idx_number; |
e8f45e82 | 2601 | u_int32_t write_oi_count; |
2f8f370e | 2602 | |
7a7be519 | 2603 | if (argc == 3) |
2604 | idx_number = 2; | |
2605 | else | |
2606 | idx_number = 1; | |
2607 | ||
8d769265 | 2608 | write_oi_count = strtol (argv[idx_number]->arg, NULL, 10); |
e8f45e82 | 2609 | if (write_oi_count < 1 || write_oi_count > 100) |
2f8f370e | 2610 | { |
1318e7c8 | 2611 | vty_out (vty, "write-multiplier value is invalid%s", VTYNL); |
2f8f370e DS |
2612 | return CMD_WARNING; |
2613 | } | |
2614 | ||
e8f45e82 | 2615 | ospf->write_oi_count = write_oi_count; |
2f8f370e DS |
2616 | return CMD_SUCCESS; |
2617 | } | |
2618 | ||
7a7be519 | 2619 | ALIAS (ospf_write_multiplier, |
2620 | write_multiplier_cmd, | |
2621 | "write-multiplier (1-100)", | |
2622 | "Write multiplier\n" | |
2623 | "Maximum number of interface serviced per write\n") | |
e8f45e82 | 2624 | |
2f8f370e DS |
2625 | DEFUN (no_ospf_write_multiplier, |
2626 | no_ospf_write_multiplier_cmd, | |
6147e2c6 | 2627 | "no ospf write-multiplier (1-100)", |
2f8f370e | 2628 | NO_STR |
e8f45e82 | 2629 | "OSPF specific commands\n" |
813d4307 DW |
2630 | "Write multiplier\n" |
2631 | "Maximum number of interface serviced per write\n") | |
2f8f370e | 2632 | { |
cdc2d765 | 2633 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
2f8f370e | 2634 | |
e8f45e82 | 2635 | ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT; |
2f8f370e DS |
2636 | return CMD_SUCCESS; |
2637 | } | |
2638 | ||
7a7be519 | 2639 | ALIAS (no_ospf_write_multiplier, |
2640 | no_write_multiplier_cmd, | |
2641 | "no write-multiplier (1-100)", | |
2642 | NO_STR | |
2643 | "Write multiplier\n" | |
2644 | "Maximum number of interface serviced per write\n") | |
813d4307 | 2645 | |
eb1ce605 | 2646 | const char *ospf_abr_type_descr_str[] = |
718e3744 | 2647 | { |
2648 | "Unknown", | |
2649 | "Standard (RFC2328)", | |
2650 | "Alternative IBM", | |
2651 | "Alternative Cisco", | |
2652 | "Alternative Shortcut" | |
2653 | }; | |
2654 | ||
eb1ce605 | 2655 | const char *ospf_shortcut_mode_descr_str[] = |
718e3744 | 2656 | { |
2657 | "Default", | |
2658 | "Enabled", | |
2659 | "Disabled" | |
2660 | }; | |
2661 | ||
4dadc291 | 2662 | static void |
ca08c43d | 2663 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json) |
718e3744 | 2664 | { |
ca08c43d DS |
2665 | json_object *json_area = NULL; |
2666 | ||
2667 | if (use_json) | |
2668 | json_area = json_object_new_object(); | |
2669 | ||
718e3744 | 2670 | /* Show Area ID. */ |
ca08c43d DS |
2671 | if (!use_json) |
2672 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); | |
718e3744 | 2673 | |
2674 | /* Show Area type/mode. */ | |
2675 | if (OSPF_IS_AREA_BACKBONE (area)) | |
ca08c43d DS |
2676 | { |
2677 | if (use_json) | |
2678 | json_object_boolean_true_add(json_area, "backbone"); | |
2679 | else | |
1318e7c8 | 2680 | vty_out (vty, " (Backbone)%s", VTYNL); |
ca08c43d | 2681 | } |
718e3744 | 2682 | else |
2683 | { | |
ca08c43d DS |
2684 | if (use_json) |
2685 | { | |
2686 | if (area->external_routing == OSPF_AREA_STUB) | |
2687 | { | |
2688 | if (area->no_summary) | |
2689 | json_object_boolean_true_add(json_area, "stubNoSummary"); | |
2690 | if (area->shortcut_configured) | |
2691 | json_object_boolean_true_add(json_area, "stubShortcut"); | |
2692 | } | |
2693 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2694 | { | |
2695 | if (area->no_summary) | |
2696 | json_object_boolean_true_add(json_area, "nssaNoSummary"); | |
2697 | if (area->shortcut_configured) | |
2698 | json_object_boolean_true_add(json_area, "nssaShortcut"); | |
2699 | } | |
2700 | ||
2701 | json_object_string_add(json_area,"shortcuttingMode", | |
2702 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
2703 | if (area->shortcut_capability) | |
2704 | json_object_boolean_true_add(json_area,"sBitConcensus"); | |
2705 | } | |
2706 | else | |
2707 | { | |
2708 | if (area->external_routing == OSPF_AREA_STUB) | |
2709 | vty_out (vty, " (Stub%s%s)", | |
2710 | area->no_summary ? ", no summary" : "", | |
2711 | area->shortcut_configured ? "; " : ""); | |
2712 | else if (area->external_routing == OSPF_AREA_NSSA) | |
2713 | vty_out (vty, " (NSSA%s%s)", | |
2714 | area->no_summary ? ", no summary" : "", | |
2715 | area->shortcut_configured ? "; " : ""); | |
2716 | ||
1318e7c8 | 2717 | vty_out (vty, "%s", VTYNL); |
ca08c43d DS |
2718 | vty_out (vty, " Shortcutting mode: %s", |
2719 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); | |
2720 | vty_out (vty, ", S-bit consensus: %s%s", | |
1318e7c8 | 2721 | area->shortcut_capability ? "ok" : "no", VTYNL); |
ca08c43d DS |
2722 | } |
2723 | } | |
2724 | ||
2725 | /* Show number of interfaces */ | |
2726 | if (use_json) | |
2727 | { | |
3ac237f8 MS |
2728 | json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist)); |
2729 | json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints); | |
718e3744 | 2730 | } |
ca08c43d DS |
2731 | else |
2732 | vty_out (vty, " Number of interfaces in this area: Total: %d, " | |
2733 | "Active: %d%s", listcount (area->oiflist), | |
1318e7c8 | 2734 | area->act_ints, VTYNL); |
718e3744 | 2735 | |
718e3744 | 2736 | if (area->external_routing == OSPF_AREA_NSSA) |
2737 | { | |
ca08c43d DS |
2738 | if (use_json) |
2739 | { | |
2740 | json_object_boolean_true_add(json_area, "nssa"); | |
2741 | if (! IS_OSPF_ABR (area->ospf)) | |
2742 | json_object_boolean_false_add(json_area, "abr"); | |
2743 | else if (area->NSSATranslatorState) | |
2744 | { | |
2745 | json_object_boolean_true_add(json_area, "abr"); | |
2746 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2747 | json_object_boolean_true_add(json_area, "nssaTranslatorElected"); | |
2748 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) | |
2749 | json_object_boolean_true_add(json_area, "nssaTranslatorAlways"); | |
2750 | } | |
2751 | else | |
2752 | { | |
2753 | json_object_boolean_true_add(json_area, "abr"); | |
2754 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2755 | json_object_boolean_false_add(json_area, "nssaTranslatorElected"); | |
2756 | else | |
2757 | json_object_boolean_true_add(json_area, "nssaTranslatorNever"); | |
2758 | } | |
2759 | } | |
718e3744 | 2760 | else |
ca08c43d | 2761 | { |
1318e7c8 | 2762 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTYNL, VTYNL); |
ca08c43d DS |
2763 | if (! IS_OSPF_ABR (area->ospf)) |
2764 | vty_out (vty, " It is not ABR, therefore not Translator. %s", | |
1318e7c8 | 2765 | VTYNL); |
ca08c43d DS |
2766 | else if (area->NSSATranslatorState) |
2767 | { | |
2768 | vty_out (vty, " We are an ABR and "); | |
2769 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2770 | vty_out (vty, "the NSSA Elected Translator. %s", | |
1318e7c8 | 2771 | VTYNL); |
ca08c43d DS |
2772 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
2773 | vty_out (vty, "always an NSSA Translator. %s", | |
1318e7c8 | 2774 | VTYNL); |
ca08c43d DS |
2775 | } |
2776 | else | |
2777 | { | |
2778 | vty_out (vty, " We are an ABR, but "); | |
2779 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) | |
2780 | vty_out (vty, "not the NSSA Elected Translator. %s", | |
1318e7c8 | 2781 | VTYNL); |
ca08c43d DS |
2782 | else |
2783 | vty_out (vty, "never an NSSA Translator. %s", | |
1318e7c8 | 2784 | VTYNL); |
ca08c43d DS |
2785 | } |
2786 | } | |
718e3744 | 2787 | } |
ca08c43d | 2788 | |
88d6cf37 | 2789 | /* Stub-router state for this area */ |
2790 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
2791 | { | |
649654ab | 2792 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
2793 | |
2794 | if (use_json) | |
2795 | { | |
2796 | json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa"); | |
2797 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
2798 | json_object_boolean_true_add(json_area, "indefiniteActiveAdmin"); | |
2799 | if (area->t_stub_router) | |
2800 | { | |
cbf3e3eb DL |
2801 | long time_store; |
2802 | time_store = monotime_until(&area->t_stub_router->u.sands, NULL) / 1000LL; | |
ca08c43d DS |
2803 | json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store); |
2804 | } | |
2805 | } | |
2806 | else | |
2807 | { | |
2808 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", | |
1318e7c8 | 2809 | VTYNL); |
ca08c43d DS |
2810 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
2811 | vty_out (vty, " Administratively activated (indefinitely)%s", | |
1318e7c8 | 2812 | VTYNL); |
ca08c43d DS |
2813 | if (area->t_stub_router) |
2814 | vty_out (vty, " Active from startup, %s remaining%s", | |
2815 | ospf_timer_dump (area->t_stub_router, timebuf, | |
1318e7c8 | 2816 | sizeof(timebuf)), VTYNL); |
ca08c43d DS |
2817 | } |
2818 | } | |
2819 | ||
2820 | if (use_json) | |
2821 | { | |
2822 | /* Show number of fully adjacent neighbors. */ | |
3ac237f8 | 2823 | json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs); |
ca08c43d DS |
2824 | |
2825 | /* Show authentication type. */ | |
2826 | if (area->auth_type == OSPF_AUTH_NULL) | |
2827 | json_object_string_add(json_area, "authentication", "authenticationNone"); | |
2828 | else if (area->auth_type == OSPF_AUTH_SIMPLE) | |
2829 | json_object_string_add(json_area, "authentication", "authenticationSimplePassword"); | |
2830 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) | |
2831 | json_object_string_add(json_area, "authentication", "authenticationMessageDigest"); | |
2832 | ||
2833 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
3ac237f8 | 2834 | json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls); |
ca08c43d DS |
2835 | |
2836 | /* Show SPF calculation times. */ | |
3ac237f8 | 2837 | json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation); |
ca08c43d DS |
2838 | json_object_int_add(json_area, "lsaNumber", area->lsdb->total); |
2839 | json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA)); | |
2840 | json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA)); | |
2841 | json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA)); | |
2842 | json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA)); | |
2843 | json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA)); | |
2844 | json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA)); | |
2845 | json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2846 | json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA)); | |
2847 | json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA)); | |
2848 | json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA)); | |
88d6cf37 | 2849 | } |
ca08c43d DS |
2850 | else |
2851 | { | |
2852 | /* Show number of fully adjacent neighbors. */ | |
2853 | vty_out (vty, " Number of fully adjacent neighbors in this area:" | |
1318e7c8 | 2854 | " %d%s", area->full_nbrs, VTYNL); |
ca08c43d DS |
2855 | |
2856 | /* Show authentication type. */ | |
2857 | vty_out (vty, " Area has "); | |
2858 | if (area->auth_type == OSPF_AUTH_NULL) | |
1318e7c8 | 2859 | vty_out (vty, "no authentication%s", VTYNL); |
ca08c43d | 2860 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
1318e7c8 | 2861 | vty_out (vty, "simple password authentication%s", VTYNL); |
ca08c43d | 2862 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
1318e7c8 | 2863 | vty_out (vty, "message digest authentication%s", VTYNL); |
ca08c43d DS |
2864 | |
2865 | if (!OSPF_IS_AREA_BACKBONE (area)) | |
2866 | vty_out (vty, " Number of full virtual adjacencies going through" | |
1318e7c8 | 2867 | " this area: %d%s", area->full_vls, VTYNL); |
ca08c43d DS |
2868 | |
2869 | /* Show SPF calculation times. */ | |
2870 | vty_out (vty, " SPF algorithm executed %d times%s", | |
1318e7c8 | 2871 | area->spf_calculation, VTYNL); |
ca08c43d DS |
2872 | |
2873 | /* Show number of LSA. */ | |
1318e7c8 | 2874 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTYNL); |
ca08c43d DS |
2875 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
2876 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), | |
1318e7c8 | 2877 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTYNL); |
ca08c43d DS |
2878 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
2879 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), | |
1318e7c8 | 2880 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTYNL); |
ca08c43d DS |
2881 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
2882 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), | |
1318e7c8 | 2883 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTYNL); |
ca08c43d DS |
2884 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
2885 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), | |
1318e7c8 | 2886 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTYNL); |
ca08c43d DS |
2887 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
2888 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), | |
1318e7c8 | 2889 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTYNL); |
ca08c43d DS |
2890 | } |
2891 | ||
ca08c43d DS |
2892 | if (use_json) |
2893 | { | |
2894 | json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2895 | json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA)); | |
2896 | json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2897 | json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA)); | |
2898 | } | |
2899 | else | |
2900 | { | |
2901 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", | |
2902 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), | |
1318e7c8 | 2903 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTYNL); |
ca08c43d DS |
2904 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
2905 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), | |
1318e7c8 | 2906 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTYNL); |
ca08c43d | 2907 | } |
ca08c43d DS |
2908 | |
2909 | if (use_json) | |
2910 | json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area); | |
2911 | else | |
1318e7c8 | 2912 | vty_out (vty, "%s", VTYNL); |
718e3744 | 2913 | } |
2914 | ||
7c8ff89e | 2915 | static int |
ca08c43d | 2916 | show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 2917 | { |
1eb8ef25 | 2918 | struct listnode *node, *nnode; |
718e3744 | 2919 | struct ospf_area * area; |
d24f6e2a | 2920 | struct timeval result; |
649654ab | 2921 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
ca08c43d DS |
2922 | json_object *json = NULL; |
2923 | json_object *json_areas = NULL; | |
2924 | ||
2925 | if (use_json) | |
0cad6e26 DS |
2926 | { |
2927 | json = json_object_new_object(); | |
2928 | json_areas = json_object_new_object(); | |
2929 | } | |
718e3744 | 2930 | |
7c8ff89e | 2931 | if (ospf->instance) |
ca08c43d DS |
2932 | { |
2933 | if (use_json) | |
2934 | { | |
2935 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
2936 | } | |
2937 | else | |
2938 | { | |
1318e7c8 QY |
2939 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
2940 | VTYNL, VTYNL); | |
ca08c43d DS |
2941 | } |
2942 | } | |
718e3744 | 2943 | |
2944 | /* Show Router ID. */ | |
ca08c43d DS |
2945 | if (use_json) |
2946 | { | |
2947 | json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id)); | |
2948 | } | |
2949 | else | |
2950 | { | |
2951 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", | |
2952 | inet_ntoa (ospf->router_id), | |
1318e7c8 | 2953 | VTYNL); |
ca08c43d | 2954 | } |
7c8ff89e | 2955 | |
88d6cf37 | 2956 | /* Graceful shutdown */ |
c9c93d50 | 2957 | if (ospf->t_deferred_shutdown) |
ca08c43d DS |
2958 | { |
2959 | if (use_json) | |
2960 | { | |
cbf3e3eb DL |
2961 | long time_store; |
2962 | time_store = monotime_until(&ospf->t_deferred_shutdown->u.sands, NULL) / 1000LL; | |
ca08c43d DS |
2963 | json_object_int_add(json, "deferredShutdownMsecs", time_store); |
2964 | } | |
2965 | else | |
2966 | { | |
2967 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", | |
2968 | ospf_timer_dump (ospf->t_deferred_shutdown, | |
1318e7c8 | 2969 | timebuf, sizeof (timebuf)), VTYNL); |
ca08c43d DS |
2970 | } |
2971 | } | |
2972 | ||
718e3744 | 2973 | /* Show capability. */ |
ca08c43d DS |
2974 | if (use_json) |
2975 | { | |
2976 | json_object_boolean_true_add(json, "tosRoutesOnly"); | |
2977 | json_object_boolean_true_add(json, "rfc2328Conform"); | |
2978 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) | |
2979 | { | |
2980 | json_object_boolean_true_add(json, "rfc1583Compatibility"); | |
2981 | } | |
2982 | } | |
2983 | else | |
2984 | { | |
1318e7c8 QY |
2985 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTYNL); |
2986 | vty_out (vty, " This implementation conforms to RFC2328%s", VTYNL); | |
ca08c43d DS |
2987 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
2988 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? | |
1318e7c8 | 2989 | "enabled" : "disabled", VTYNL); |
ca08c43d DS |
2990 | } |
2991 | ||
ca08c43d DS |
2992 | if (use_json) |
2993 | { | |
2994 | if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE)) | |
2995 | { | |
2996 | json_object_boolean_true_add(json, "opaqueCapable"); | |
2997 | } | |
ca08c43d DS |
2998 | } |
2999 | else | |
3000 | { | |
801e0e14 | 3001 | vty_out (vty, " OpaqueCapability flag is %s%s", |
ca08c43d | 3002 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled", |
1318e7c8 | 3003 | VTYNL); |
ca08c43d | 3004 | } |
ca08c43d | 3005 | |
88d6cf37 | 3006 | /* Show stub-router configuration */ |
3007 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED | |
3008 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3009 | { | |
ca08c43d DS |
3010 | if (use_json) |
3011 | { | |
3012 | json_object_boolean_true_add(json, "stubAdvertisement"); | |
3013 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3014 | json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000); | |
3015 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
3016 | json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000); | |
3017 | } | |
3018 | else | |
3019 | { | |
3020 | vty_out (vty, " Stub router advertisement is configured%s", | |
1318e7c8 | 3021 | VTYNL); |
ca08c43d DS |
3022 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
3023 | vty_out (vty, " Enabled for %us after start-up%s", | |
1318e7c8 | 3024 | ospf->stub_router_startup_time, VTYNL); |
ca08c43d DS |
3025 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
3026 | vty_out (vty, " Enabled for %us prior to full shutdown%s", | |
1318e7c8 | 3027 | ospf->stub_router_shutdown_time, VTYNL); |
ca08c43d | 3028 | } |
88d6cf37 | 3029 | } |
ca08c43d | 3030 | |
718e3744 | 3031 | /* Show SPF timers. */ |
ca08c43d DS |
3032 | if (use_json) |
3033 | { | |
3034 | json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay); | |
3035 | json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime); | |
3036 | json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime); | |
3037 | json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier); | |
b8ad39d4 | 3038 | } |
3039 | else | |
ca08c43d DS |
3040 | { |
3041 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" | |
3042 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" | |
3043 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" | |
3044 | " Hold time multiplier is currently %d%s", | |
1318e7c8 QY |
3045 | ospf->spf_delay, VTYNL, |
3046 | ospf->spf_holdtime, VTYNL, | |
3047 | ospf->spf_max_holdtime, VTYNL, | |
3048 | ospf->spf_hold_multiplier, VTYNL); | |
ca08c43d | 3049 | } |
b6927875 | 3050 | |
ca08c43d DS |
3051 | if (use_json) |
3052 | { | |
3053 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3054 | { | |
cbf3e3eb | 3055 | long time_store = 0; |
ca08c43d | 3056 | |
cbf3e3eb | 3057 | time_store = monotime_since(&ospf->ts_spf, NULL) / 1000LL; |
ca08c43d DS |
3058 | json_object_int_add(json, "spfLastExecutedMsecs", time_store); |
3059 | ||
3060 | time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000); | |
3061 | json_object_int_add(json, "spfLastDurationMsecs", time_store); | |
3062 | } | |
3063 | else | |
3064 | json_object_boolean_true_add(json, "spfHasNotRun"); | |
3065 | } | |
3066 | else | |
3067 | { | |
3068 | vty_out (vty, " SPF algorithm "); | |
3069 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) | |
3070 | { | |
cbf3e3eb | 3071 | monotime_since(&ospf->ts_spf, &result); |
ca08c43d DS |
3072 | vty_out (vty, "last executed %s ago%s", |
3073 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), | |
1318e7c8 | 3074 | VTYNL); |
ca08c43d DS |
3075 | vty_out (vty, " Last SPF duration %s%s", |
3076 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), | |
1318e7c8 | 3077 | VTYNL); |
ca08c43d DS |
3078 | } |
3079 | else | |
1318e7c8 | 3080 | vty_out (vty, "has not been run%s", VTYNL); |
ca08c43d DS |
3081 | } |
3082 | ||
3083 | if (use_json) | |
3084 | { | |
ca08c43d DS |
3085 | if (ospf->t_spf_calc) |
3086 | { | |
cbf3e3eb DL |
3087 | long time_store; |
3088 | time_store = monotime_until(&ospf->t_spf_calc->u.sands, NULL) / 1000LL; | |
ca08c43d DS |
3089 | json_object_int_add(json, "spfTimerDueInMsecs", time_store); |
3090 | } | |
3091 | ||
ac7424f9 MR |
3092 | json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval); |
3093 | json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival); | |
ca08c43d DS |
3094 | /* Show write multiplier values */ |
3095 | json_object_int_add(json, "writeMultiplier", ospf->write_oi_count); | |
3096 | /* Show refresh parameters. */ | |
54b7214f | 3097 | json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000); |
ca08c43d DS |
3098 | } |
3099 | else | |
3100 | { | |
3101 | vty_out (vty, " SPF timer %s%s%s", | |
3102 | (ospf->t_spf_calc ? "due in " : "is "), | |
3103 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), | |
1318e7c8 | 3104 | VTYNL); |
ca08c43d | 3105 | |
ac7424f9 | 3106 | vty_out (vty, " LSA minimum interval %d msecs%s", |
1318e7c8 | 3107 | ospf->min_ls_interval, VTYNL); |
ca08c43d | 3108 | vty_out (vty, " LSA minimum arrival %d msecs%s", |
1318e7c8 | 3109 | ospf->min_ls_arrival, VTYNL); |
ca08c43d DS |
3110 | |
3111 | /* Show write multiplier values */ | |
3112 | vty_out (vty, " Write Multiplier set to %d %s", | |
1318e7c8 | 3113 | ospf->write_oi_count, VTYNL); |
ca08c43d DS |
3114 | |
3115 | /* Show refresh parameters. */ | |
3116 | vty_out (vty, " Refresh timer %d secs%s", | |
1318e7c8 | 3117 | ospf->lsa_refresh_interval, VTYNL); |
ca08c43d | 3118 | } |
2f8f370e | 3119 | |
718e3744 | 3120 | /* Show ABR/ASBR flags. */ |
68980084 | 3121 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
ca08c43d DS |
3122 | { |
3123 | if (use_json) | |
3124 | json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]); | |
3125 | else | |
3126 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", | |
1318e7c8 | 3127 | ospf_abr_type_descr_str[ospf->abr_type], VTYNL); |
ca08c43d | 3128 | } |
68980084 | 3129 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
ca08c43d DS |
3130 | { |
3131 | if (use_json) | |
3132 | json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation"); | |
3133 | else | |
3134 | vty_out (vty, " This router is an ASBR " | |
1318e7c8 | 3135 | "(injecting external routing information)%s", VTYNL); |
ca08c43d | 3136 | } |
718e3744 | 3137 | |
3138 | /* Show Number of AS-external-LSAs. */ | |
ca08c43d DS |
3139 | if (use_json) |
3140 | { | |
3ac237f8 | 3141 | json_object_int_add(json, "lsaExternalCounter", |
ca08c43d DS |
3142 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); |
3143 | json_object_int_add(json, "lsaExternalChecksum", | |
3144 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA)); | |
3145 | } | |
3146 | else | |
3147 | { | |
3148 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", | |
3149 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), | |
1318e7c8 | 3150 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTYNL); |
ca08c43d DS |
3151 | } |
3152 | ||
ca08c43d DS |
3153 | if (use_json) |
3154 | { | |
3ac237f8 | 3155 | json_object_int_add(json, "lsaAsopaqueCounter", |
ca08c43d DS |
3156 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); |
3157 | json_object_int_add(json, "lsaAsOpaqueChecksum", | |
3158 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA)); | |
3159 | } | |
3160 | else | |
3161 | { | |
3162 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", | |
3163 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), | |
1318e7c8 | 3164 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTYNL); |
ca08c43d | 3165 | } |
ca08c43d | 3166 | |
718e3744 | 3167 | /* Show number of areas attached. */ |
ca08c43d | 3168 | if (use_json) |
3ac237f8 | 3169 | json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas)); |
ca08c43d DS |
3170 | else |
3171 | vty_out (vty, " Number of areas attached to this router: %d%s", | |
1318e7c8 | 3172 | listcount (ospf->areas), VTYNL); |
d7e60dd7 AS |
3173 | |
3174 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
3175 | { | |
3176 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) | |
ca08c43d DS |
3177 | { |
3178 | if (use_json) | |
3179 | json_object_boolean_true_add(json, "adjacencyChangesLoggedAll"); | |
3180 | else | |
1318e7c8 | 3181 | vty_out(vty, " All adjacency changes are logged%s",VTYNL); |
ca08c43d | 3182 | } |
d7e60dd7 | 3183 | else |
ca08c43d DS |
3184 | { |
3185 | if (use_json) | |
3186 | json_object_boolean_true_add(json, "adjacencyChangesLogged"); | |
3187 | else | |
1318e7c8 | 3188 | vty_out(vty, " Adjacency changes are logged%s",VTYNL); |
ca08c43d | 3189 | } |
d7e60dd7 | 3190 | } |
718e3744 | 3191 | /* Show each area status. */ |
1eb8ef25 | 3192 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
ca08c43d DS |
3193 | show_ip_ospf_area (vty, area, json_areas, use_json); |
3194 | ||
3195 | if (use_json) | |
3196 | { | |
3197 | json_object_object_add(json, "areas", json_areas); | |
1318e7c8 | 3198 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
ca08c43d DS |
3199 | json_object_free(json); |
3200 | } | |
3201 | else | |
1318e7c8 | 3202 | vty_out (vty, "%s",VTYNL); |
718e3744 | 3203 | |
3204 | return CMD_SUCCESS; | |
3205 | } | |
3206 | ||
7c8ff89e DS |
3207 | DEFUN (show_ip_ospf, |
3208 | show_ip_ospf_cmd, | |
b162fa78 | 3209 | "show ip ospf [json]", |
7c8ff89e DS |
3210 | SHOW_STR |
3211 | IP_STR | |
ca08c43d | 3212 | "OSPF information\n" |
9973d184 | 3213 | JSON_STR) |
7c8ff89e DS |
3214 | { |
3215 | struct ospf *ospf; | |
db7c8528 | 3216 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3217 | |
0bad4851 | 3218 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3219 | return CMD_SUCCESS; |
3220 | ||
db7c8528 | 3221 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3222 | } |
3223 | ||
3224 | DEFUN (show_ip_ospf_instance, | |
3225 | show_ip_ospf_instance_cmd, | |
6147e2c6 | 3226 | "show ip ospf (1-65535) [json]", |
7c8ff89e DS |
3227 | SHOW_STR |
3228 | IP_STR | |
3229 | "OSPF information\n" | |
ca08c43d | 3230 | "Instance ID\n" |
9973d184 | 3231 | JSON_STR) |
7c8ff89e | 3232 | { |
8d769265 | 3233 | int idx_number = 3; |
7c8ff89e DS |
3234 | struct ospf *ospf; |
3235 | u_short instance = 0; | |
db7c8528 | 3236 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3237 | |
facfee22 | 3238 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 3239 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3240 | return CMD_SUCCESS; |
3241 | ||
db7c8528 | 3242 | return (show_ip_ospf_common(vty, ospf, uj)); |
7c8ff89e DS |
3243 | } |
3244 | ||
fd651fa6 | 3245 | static void |
7ec4159b DS |
3246 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp, |
3247 | json_object *json_interface_sub, u_char use_json) | |
718e3744 | 3248 | { |
fd651fa6 | 3249 | int is_up; |
718e3744 | 3250 | struct ospf_neighbor *nbr; |
718e3744 | 3251 | struct route_node *rn; |
05b15adc | 3252 | uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed; |
718e3744 | 3253 | |
718e3744 | 3254 | /* Is interface up? */ |
7ec4159b DS |
3255 | if (use_json) |
3256 | { | |
3257 | is_up = if_is_operative(ifp); | |
3258 | if (is_up) | |
3259 | json_object_boolean_true_add(json_interface_sub, "ifUp"); | |
3260 | else | |
3261 | json_object_boolean_false_add(json_interface_sub, "ifDown"); | |
3262 | ||
3263 | json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); | |
3264 | json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); | |
05b15adc | 3265 | json_object_int_add(json_interface_sub, "bandwidthMbit", bandwidth); |
7ec4159b DS |
3266 | json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); |
3267 | } | |
3268 | else | |
3269 | { | |
1318e7c8 QY |
3270 | vty_outln (vty, "%s is %s", ifp->name, |
3271 | ((is_up = if_is_operative(ifp)) ? "up" : "down")); | |
3272 | vty_outln (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s", | |
8e25c8ce | 3273 | ifp->ifindex, ifp->mtu, bandwidth, if_flag_dump(ifp->flags)); |
7ec4159b | 3274 | } |
718e3744 | 3275 | |
3276 | /* Is interface OSPF enabled? */ | |
7ec4159b | 3277 | if (use_json) |
718e3744 | 3278 | { |
7ec4159b DS |
3279 | if (ospf_oi_count(ifp) == 0) |
3280 | { | |
3281 | json_object_boolean_false_add(json_interface_sub, "ospfEnabled"); | |
3282 | return; | |
3283 | } | |
3284 | else if (!is_up) | |
3285 | { | |
3286 | json_object_boolean_false_add(json_interface_sub, "ospfRunning"); | |
3287 | return; | |
3288 | } | |
3289 | else | |
3290 | json_object_boolean_true_add(json_interface_sub, "ospfEnabled"); | |
718e3744 | 3291 | } |
7ec4159b | 3292 | else |
fd651fa6 | 3293 | { |
7ec4159b DS |
3294 | if (ospf_oi_count(ifp) == 0) |
3295 | { | |
1318e7c8 | 3296 | vty_out (vty, " OSPF not enabled on this interface%s", VTYNL); |
7ec4159b DS |
3297 | return; |
3298 | } | |
3299 | else if (!is_up) | |
3300 | { | |
3301 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", | |
1318e7c8 | 3302 | VTYNL); |
7ec4159b DS |
3303 | return; |
3304 | } | |
fd651fa6 | 3305 | } |
3306 | ||
718e3744 | 3307 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3308 | { | |
3309 | struct ospf_interface *oi = rn->info; | |
7ec4159b | 3310 | |
718e3744 | 3311 | if (oi == NULL) |
7ec4159b DS |
3312 | continue; |
3313 | ||
525c1839 DS |
3314 | if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) |
3315 | { | |
7ec4159b DS |
3316 | if (use_json) |
3317 | json_object_boolean_true_add(json_interface_sub, "ifUnnumbered"); | |
3318 | else | |
3319 | vty_out (vty, " This interface is UNNUMBERED,"); | |
525c1839 DS |
3320 | } |
3321 | else | |
9c27ef9b | 3322 | { |
525c1839 | 3323 | /* Show OSPF interface information. */ |
7ec4159b DS |
3324 | if (use_json) |
3325 | { | |
3326 | json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4)); | |
3327 | json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen); | |
3328 | } | |
3329 | else | |
3330 | vty_out (vty, " Internet Address %s/%d,", | |
3331 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); | |
525c1839 DS |
3332 | |
3333 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3334 | { | |
3335 | struct in_addr *dest; | |
3336 | const char *dstr; | |
3337 | ||
3338 | if (CONNECTED_PEER(oi->connected) | |
3339 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3340 | dstr = "Peer"; | |
3341 | else | |
3342 | dstr = "Broadcast"; | |
3343 | ||
3344 | /* For Vlinks, showing the peer address is probably more | |
7ec4159b DS |
3345 | * * * * * informative than the local interface that is being used |
3346 | * * * * */ | |
525c1839 DS |
3347 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
3348 | dest = &oi->vl_data->peer_addr; | |
3349 | else | |
3350 | dest = &oi->connected->destination->u.prefix4; | |
3351 | ||
7ec4159b DS |
3352 | if (use_json) |
3353 | { | |
3354 | json_object_string_add(json_interface_sub, "ospfIfType", dstr); | |
3355 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) | |
3356 | json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest)); | |
3357 | else | |
3358 | json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest)); | |
3359 | } | |
3360 | else | |
3361 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); | |
525c1839 | 3362 | } |
9c27ef9b | 3363 | } |
7ec4159b DS |
3364 | if (use_json) |
3365 | { | |
3366 | json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area)); | |
3367 | if (OSPF_IF_PARAM(oi, mtu_ignore)) | |
3368 | json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect"); | |
3369 | json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id)); | |
3370 | json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]); | |
3371 | json_object_int_add(json_interface_sub, "cost", oi->output_cost); | |
3372 | json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay)); | |
56b40679 | 3373 | json_object_string_add(json_interface_sub, "state", lookup_msg(ospf_ism_state_msg, oi->state, NULL)); |
7ec4159b DS |
3374 | json_object_int_add(json_interface_sub, "priority", PRIORITY (oi)); |
3375 | } | |
3376 | else | |
3377 | { | |
1318e7c8 | 3378 | vty_outln (vty, " Area %s", ospf_area_desc_string (oi->area)); |
3fb9cd6e | 3379 | |
1318e7c8 QY |
3380 | vty_outln (vty, " MTU mismatch detection: %s", |
3381 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled"); | |
ba682537 | 3382 | |
1318e7c8 QY |
3383 | vty_outln (vty, " Router ID %s, Network Type %s, Cost: %d", |
3384 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], | |
3385 | oi->output_cost); | |
718e3744 | 3386 | |
1318e7c8 QY |
3387 | vty_outln (vty, " Transmit Delay is %d sec, State %s, Priority %d", |
3388 | OSPF_IF_PARAM (oi,transmit_delay), lookup_msg(ospf_ism_state_msg, oi->state, NULL), | |
3389 | PRIORITY (oi)); | |
7ec4159b | 3390 | } |
718e3744 | 3391 | |
3392 | /* Show DR information. */ | |
3393 | if (DR (oi).s_addr == 0) | |
7ec4159b DS |
3394 | { |
3395 | if (!use_json) | |
1318e7c8 | 3396 | vty_outln (vty, " No backup designated router on this network"); |
7ec4159b | 3397 | } |
718e3744 | 3398 | else |
7ec4159b DS |
3399 | { |
3400 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); | |
3401 | if (nbr == NULL) | |
3402 | { | |
3403 | if (!use_json) | |
96ade3ed | 3404 | vty_outln (vty, " No backup designated router on this network"); |
7ec4159b DS |
3405 | } |
3406 | else | |
3407 | { | |
3408 | if (use_json) | |
3409 | { | |
3410 | json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id)); | |
3411 | json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4)); | |
3412 | } | |
3413 | else | |
3414 | { | |
3415 | vty_out (vty, " Backup Designated Router (ID) %s,", | |
3416 | inet_ntoa (nbr->router_id)); | |
1318e7c8 QY |
3417 | vty_outln (vty, " Interface Address %s", |
3418 | inet_ntoa (nbr->address.u.prefix4)); | |
7ec4159b DS |
3419 | } |
3420 | } | |
3421 | } | |
525c1839 | 3422 | |
7eb5b47e | 3423 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
7ec4159b | 3424 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER) |
429ac78c | 3425 | { |
7ec4159b DS |
3426 | if (use_json) |
3427 | json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum)); | |
3428 | else | |
3429 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", | |
1318e7c8 | 3430 | ntohl (oi->params->network_lsa_seqnum), VTYNL); |
7ec4159b DS |
3431 | } |
3432 | ||
3433 | if (use_json) | |
3434 | { | |
3435 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3436 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3437 | { | |
3438 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3439 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters"); | |
3440 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3441 | json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters"); | |
3442 | } | |
429ac78c PJ |
3443 | } |
3444 | else | |
7ec4159b DS |
3445 | { |
3446 | vty_out (vty, " Multicast group memberships:"); | |
3447 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) | |
3448 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3449 | { | |
3450 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) | |
3451 | vty_out (vty, " OSPFAllRouters"); | |
3452 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) | |
3453 | vty_out (vty, " OSPFDesignatedRouters"); | |
3454 | } | |
3455 | else | |
3456 | vty_out (vty, " <None>"); | |
1318e7c8 | 3457 | vty_out (vty, "%s", VTYNL); |
7ec4159b | 3458 | } |
ba6454ec | 3459 | |
7ec4159b DS |
3460 | if (use_json) |
3461 | { | |
3462 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3463 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello)); | |
3464 | else | |
3465 | json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3466 | json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3467 | json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait)); | |
3468 | json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval)); | |
3469 | } | |
f9ad937f | 3470 | else |
7ec4159b DS |
3471 | { |
3472 | vty_out (vty, " Timer intervals configured,"); | |
3473 | vty_out (vty, " Hello "); | |
3474 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) | |
3475 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); | |
3476 | else | |
3477 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); | |
3478 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", | |
3479 | OSPF_IF_PARAM (oi, v_wait), | |
3480 | OSPF_IF_PARAM (oi, v_wait), | |
3481 | OSPF_IF_PARAM (oi, retransmit_interval), | |
1318e7c8 | 3482 | VTYNL); |
7ec4159b DS |
3483 | } |
3484 | ||
7ffa8fa2 | 3485 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
f9ad937f | 3486 | { |
7ec4159b DS |
3487 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3488 | if (use_json) | |
3489 | { | |
cbf3e3eb DL |
3490 | long time_store = 0; |
3491 | if (oi->t_hello) | |
3492 | time_store = monotime_until(&oi->t_hello->u.sands, NULL) / 1000LL; | |
7ec4159b DS |
3493 | json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store); |
3494 | } | |
3495 | else | |
3496 | vty_out (vty, " Hello due in %s%s", | |
3497 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), | |
1318e7c8 | 3498 | VTYNL); |
f9ad937f | 3499 | } |
7ffa8fa2 | 3500 | else /* passive-interface is set */ |
7ec4159b DS |
3501 | { |
3502 | if (use_json) | |
3503 | json_object_boolean_true_add(json_interface_sub, "timerPassiveIface"); | |
3504 | else | |
1318e7c8 | 3505 | vty_out (vty, " No Hellos (Passive interface)%s", VTYNL); |
7ec4159b DS |
3506 | } |
3507 | ||
3508 | if (use_json) | |
3509 | { | |
3510 | json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0)); | |
3511 | json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full)); | |
3512 | } | |
3513 | else | |
3514 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", | |
3515 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), | |
1318e7c8 | 3516 | VTYNL); |
68fe91d6 | 3517 | ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json); |
718e3744 | 3518 | } |
3519 | } | |
3520 | ||
7c8ff89e | 3521 | static int |
7ec4159b | 3522 | show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, |
7a7be519 | 3523 | struct cmd_token **argv, int iface_argv, u_char use_json) |
718e3744 | 3524 | { |
3525 | struct interface *ifp; | |
52dc7ee6 | 3526 | struct listnode *node; |
7ec4159b DS |
3527 | json_object *json = NULL; |
3528 | json_object *json_interface_sub = NULL; | |
3529 | ||
3530 | if (use_json) | |
3531 | { | |
3532 | json = json_object_new_object(); | |
7ec4159b | 3533 | } |
718e3744 | 3534 | |
7c8ff89e | 3535 | if (ospf->instance) |
7ec4159b DS |
3536 | { |
3537 | if (use_json) | |
3538 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3539 | else | |
1318e7c8 QY |
3540 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
3541 | VTYNL, VTYNL); | |
7ec4159b | 3542 | } |
7c8ff89e | 3543 | |
6be4da3d | 3544 | if (argc == iface_argv) |
7ec4159b DS |
3545 | { |
3546 | /* Show All Interfaces.*/ | |
b2d7c082 | 3547 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
7ec4159b DS |
3548 | { |
3549 | if (ospf_oi_count(ifp)) | |
3550 | { | |
7d6e13e1 QY |
3551 | if (use_json) |
3552 | json_interface_sub = json_object_new_object(); | |
3553 | ||
7ec4159b | 3554 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); |
7d6e13e1 | 3555 | |
b8dfa544 DS |
3556 | if (use_json) |
3557 | json_object_object_add (json, ifp->name, json_interface_sub); | |
7ec4159b DS |
3558 | } |
3559 | } | |
3560 | } | |
718e3744 | 3561 | else |
3562 | { | |
7c8ff89e | 3563 | /* Interface name is specified. */ |
1306c09a | 3564 | if ((ifp = if_lookup_by_name (argv[iface_argv]->arg, VRF_DEFAULT)) == NULL) |
7ec4159b DS |
3565 | { |
3566 | if (use_json) | |
3567 | json_object_boolean_true_add(json, "noSuchIface"); | |
3568 | else | |
1318e7c8 | 3569 | vty_out (vty, "No such interface name%s", VTYNL); |
7ec4159b | 3570 | } |
718e3744 | 3571 | else |
7ec4159b | 3572 | { |
7d6e13e1 QY |
3573 | if (use_json) |
3574 | json_interface_sub = json_object_new_object(); | |
3575 | ||
7ec4159b | 3576 | show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); |
7d6e13e1 | 3577 | |
7ec4159b DS |
3578 | if (use_json) |
3579 | json_object_object_add(json, ifp->name, json_interface_sub); | |
3580 | } | |
718e3744 | 3581 | } |
3582 | ||
7ec4159b DS |
3583 | if (use_json) |
3584 | { | |
1318e7c8 | 3585 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
7ec4159b DS |
3586 | json_object_free(json); |
3587 | } | |
3588 | else | |
1318e7c8 | 3589 | vty_out (vty, "%s", VTYNL); |
7c8ff89e | 3590 | |
718e3744 | 3591 | return CMD_SUCCESS; |
3592 | } | |
3593 | ||
7c8ff89e DS |
3594 | DEFUN (show_ip_ospf_interface, |
3595 | show_ip_ospf_interface_cmd, | |
b162fa78 | 3596 | "show ip ospf interface [INTERFACE] [json]", |
7c8ff89e DS |
3597 | SHOW_STR |
3598 | IP_STR | |
3599 | "OSPF information\n" | |
3600 | "Interface information\n" | |
7ec4159b | 3601 | "Interface name\n" |
9973d184 | 3602 | JSON_STR) |
7c8ff89e DS |
3603 | { |
3604 | struct ospf *ospf; | |
db7c8528 | 3605 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3606 | |
0bad4851 | 3607 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3608 | return CMD_SUCCESS; |
3609 | ||
6be4da3d DS |
3610 | if (uj) |
3611 | argc--; | |
3612 | ||
3613 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 4, uj); | |
7c8ff89e DS |
3614 | } |
3615 | ||
3616 | DEFUN (show_ip_ospf_instance_interface, | |
3617 | show_ip_ospf_instance_interface_cmd, | |
6147e2c6 | 3618 | "show ip ospf (1-65535) interface [INTERFACE] [json]", |
7c8ff89e DS |
3619 | SHOW_STR |
3620 | IP_STR | |
3621 | "OSPF information\n" | |
3622 | "Instance ID\n" | |
3623 | "Interface information\n" | |
7ec4159b | 3624 | "Interface name\n" |
9973d184 | 3625 | JSON_STR) |
7c8ff89e | 3626 | { |
8d769265 | 3627 | int idx_number = 3; |
7c8ff89e DS |
3628 | struct ospf *ospf; |
3629 | u_short instance = 0; | |
db7c8528 | 3630 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3631 | |
facfee22 | 3632 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 3633 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3634 | return CMD_SUCCESS; |
3635 | ||
6be4da3d DS |
3636 | if (uj) |
3637 | argc--; | |
3638 | ||
3639 | return show_ip_ospf_interface_common(vty, ospf, argc, argv, 5, uj); | |
7c8ff89e DS |
3640 | } |
3641 | ||
d24f6e2a | 3642 | static void |
3643 | show_ip_ospf_neighbour_header (struct vty *vty) | |
3644 | { | |
490578f3 | 3645 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
1318e7c8 | 3646 | VTYNL, |
d24f6e2a | 3647 | "Neighbor ID", "Pri", "State", "Dead Time", |
3648 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", | |
1318e7c8 | 3649 | VTYNL); |
d24f6e2a | 3650 | } |
3651 | ||
4dadc291 | 3652 | static void |
91756b38 | 3653 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json) |
718e3744 | 3654 | { |
3655 | struct route_node *rn; | |
3656 | struct ospf_neighbor *nbr; | |
3657 | char msgbuf[16]; | |
649654ab | 3658 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
91756b38 | 3659 | json_object *json_neighbor = NULL; |
718e3744 | 3660 | |
3661 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
91756b38 DS |
3662 | { |
3663 | if ((nbr = rn->info)) | |
3664 | { | |
3665 | /* Do not show myself. */ | |
3666 | if (nbr != oi->nbr_self) | |
3667 | { | |
3668 | /* Down state is not shown. */ | |
3669 | if (nbr->state != NSM_Down) | |
3670 | { | |
3671 | if (use_json) | |
3672 | { | |
3673 | json_neighbor = json_object_new_object(); | |
3674 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3675 | ||
cbf3e3eb | 3676 | long time_store; |
91756b38 | 3677 | |
cbf3e3eb | 3678 | time_store = monotime_until(&nbr->t_inactivity->u.sands, NULL) / 1000LL; |
91756b38 DS |
3679 | |
3680 | json_object_int_add (json_neighbor, "priority", nbr->priority); | |
3681 | json_object_string_add (json_neighbor, "state", msgbuf); | |
3682 | json_object_int_add (json_neighbor, "deadTimeMsecs", time_store); | |
3683 | json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src)); | |
3684 | json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi)); | |
3ac237f8 MS |
3685 | json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr)); |
3686 | json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr)); | |
3687 | json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr)); | |
91756b38 DS |
3688 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
3689 | json_object_object_add(json, "neighbor", json_neighbor); | |
3690 | else | |
3691 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor); | |
3692 | } | |
3693 | else | |
3694 | { | |
3695 | ospf_nbr_state_message (nbr, msgbuf, 16); | |
3696 | ||
3697 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
3698 | vty_out (vty, "%-15s %3d %-15s ", | |
3699 | "-", nbr->priority, | |
3700 | msgbuf); | |
3701 | else | |
3702 | vty_out (vty, "%-15s %3d %-15s ", | |
3703 | inet_ntoa (nbr->router_id), nbr->priority, | |
3704 | msgbuf); | |
3705 | ||
3706 | vty_out (vty, "%9s ", | |
3707 | ospf_timer_dump (nbr->t_inactivity, timebuf, | |
3708 | sizeof(timebuf))); | |
3709 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); | |
3710 | vty_out (vty, "%-20s %5ld %5ld %5d%s", | |
3711 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), | |
3712 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), | |
1318e7c8 | 3713 | VTYNL); |
91756b38 DS |
3714 | } |
3715 | } | |
3716 | } | |
3717 | } | |
3718 | } | |
718e3744 | 3719 | } |
3720 | ||
7c8ff89e | 3721 | static int |
91756b38 | 3722 | show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
718e3744 | 3723 | { |
1eb8ef25 | 3724 | struct ospf_interface *oi; |
52dc7ee6 | 3725 | struct listnode *node; |
91756b38 | 3726 | json_object *json = NULL; |
718e3744 | 3727 | |
91756b38 DS |
3728 | if (use_json) |
3729 | json = json_object_new_object(); | |
3730 | else | |
3731 | show_ip_ospf_neighbour_header (vty); | |
718e3744 | 3732 | |
91756b38 DS |
3733 | if (ospf->instance) |
3734 | { | |
3735 | if (use_json) | |
3736 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3737 | else | |
1318e7c8 QY |
3738 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
3739 | VTYNL, VTYNL); | |
91756b38 | 3740 | } |
718e3744 | 3741 | |
1eb8ef25 | 3742 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
91756b38 | 3743 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3744 | |
91756b38 DS |
3745 | if (use_json) |
3746 | { | |
1318e7c8 | 3747 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
91756b38 DS |
3748 | json_object_free(json); |
3749 | } | |
3750 | else | |
1318e7c8 | 3751 | vty_out (vty, "%s", VTYNL); |
7c8ff89e | 3752 | |
718e3744 | 3753 | return CMD_SUCCESS; |
3754 | } | |
3755 | ||
7c8ff89e DS |
3756 | DEFUN (show_ip_ospf_neighbor, |
3757 | show_ip_ospf_neighbor_cmd, | |
b162fa78 | 3758 | "show ip ospf neighbor [json]", |
718e3744 | 3759 | SHOW_STR |
3760 | IP_STR | |
3761 | "OSPF information\n" | |
91756b38 | 3762 | "Neighbor list\n" |
9973d184 | 3763 | JSON_STR) |
718e3744 | 3764 | { |
7c8ff89e | 3765 | struct ospf *ospf; |
db7c8528 | 3766 | u_char uj = use_json(argc, argv); |
718e3744 | 3767 | |
0bad4851 | 3768 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3769 | return CMD_SUCCESS; |
3770 | ||
db7c8528 | 3771 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
3772 | } |
3773 | ||
3774 | ||
3775 | DEFUN (show_ip_ospf_instance_neighbor, | |
3776 | show_ip_ospf_instance_neighbor_cmd, | |
6147e2c6 | 3777 | "show ip ospf (1-65535) neighbor [json]", |
7c8ff89e DS |
3778 | SHOW_STR |
3779 | IP_STR | |
3780 | "OSPF information\n" | |
3781 | "Instance ID\n" | |
91756b38 | 3782 | "Neighbor list\n" |
9973d184 | 3783 | JSON_STR) |
7c8ff89e | 3784 | { |
8d769265 | 3785 | int idx_number = 3; |
7c8ff89e DS |
3786 | struct ospf *ospf; |
3787 | u_short instance = 0; | |
db7c8528 | 3788 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3789 | |
facfee22 | 3790 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 3791 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3792 | return CMD_SUCCESS; |
3793 | ||
db7c8528 | 3794 | return show_ip_ospf_neighbor_common(vty, ospf, uj); |
7c8ff89e DS |
3795 | } |
3796 | ||
3797 | static int | |
91756b38 | 3798 | show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e DS |
3799 | { |
3800 | struct listnode *node; | |
3801 | struct ospf_interface *oi; | |
91756b38 DS |
3802 | json_object *json = NULL; |
3803 | json_object *json_neighbor_sub = NULL; | |
7c8ff89e | 3804 | |
91756b38 DS |
3805 | if (use_json) |
3806 | { | |
3807 | json = json_object_new_object(); | |
3808 | json_neighbor_sub = json_object_new_object(); | |
3809 | } | |
3810 | else | |
3811 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e | 3812 | |
91756b38 DS |
3813 | if (ospf->instance) |
3814 | { | |
3815 | if (use_json) | |
3816 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3817 | else | |
1318e7c8 QY |
3818 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
3819 | VTYNL, VTYNL); | |
91756b38 | 3820 | } |
7c8ff89e DS |
3821 | |
3822 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) | |
3823 | { | |
52dc7ee6 | 3824 | struct listnode *nbr_node; |
1eb8ef25 | 3825 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 3826 | |
91756b38 | 3827 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3828 | |
91756b38 DS |
3829 | /* print Down neighbor status */ |
3830 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) | |
3831 | { | |
3832 | if (nbr_nbma->nbr == NULL | |
3833 | || nbr_nbma->nbr->state == NSM_Down) | |
3834 | { | |
3835 | if (use_json) | |
3836 | { | |
3837 | json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority); | |
3838 | json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown"); | |
3839 | json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi)); | |
3ac237f8 MS |
3840 | json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0); |
3841 | json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0); | |
3842 | json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0); | |
91756b38 DS |
3843 | json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub); |
3844 | } | |
3845 | else | |
3846 | { | |
3847 | vty_out (vty, "%-15s %3d %-15s %9s ", | |
3848 | "-", nbr_nbma->priority, "Down", "-"); | |
3849 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", | |
3850 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), | |
1318e7c8 | 3851 | 0, 0, 0, VTYNL); |
91756b38 DS |
3852 | } |
3853 | } | |
3854 | } | |
718e3744 | 3855 | } |
3856 | ||
91756b38 DS |
3857 | if (use_json) |
3858 | { | |
1318e7c8 | 3859 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
91756b38 DS |
3860 | json_object_free(json); |
3861 | } | |
3862 | else | |
1318e7c8 | 3863 | vty_out (vty, "%s", VTYNL); |
7c8ff89e | 3864 | |
718e3744 | 3865 | return CMD_SUCCESS; |
3866 | } | |
3867 | ||
7c8ff89e DS |
3868 | DEFUN (show_ip_ospf_neighbor_all, |
3869 | show_ip_ospf_neighbor_all_cmd, | |
b162fa78 | 3870 | "show ip ospf neighbor all [json]", |
718e3744 | 3871 | SHOW_STR |
3872 | IP_STR | |
3873 | "OSPF information\n" | |
3874 | "Neighbor list\n" | |
91756b38 | 3875 | "include down status neighbor\n" |
9973d184 | 3876 | JSON_STR) |
7c8ff89e DS |
3877 | { |
3878 | struct ospf *ospf; | |
db7c8528 | 3879 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3880 | |
0bad4851 | 3881 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3882 | return CMD_SUCCESS; |
3883 | ||
db7c8528 | 3884 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
3885 | } |
3886 | ||
3887 | DEFUN (show_ip_ospf_instance_neighbor_all, | |
3888 | show_ip_ospf_instance_neighbor_all_cmd, | |
6147e2c6 | 3889 | "show ip ospf (1-65535) neighbor all [json]", |
7c8ff89e DS |
3890 | SHOW_STR |
3891 | IP_STR | |
3892 | "OSPF information\n" | |
3893 | "Instance ID\n" | |
3894 | "Neighbor list\n" | |
91756b38 | 3895 | "include down status neighbor\n" |
9973d184 | 3896 | JSON_STR) |
718e3744 | 3897 | { |
8d769265 | 3898 | int idx_number = 3; |
020709f9 | 3899 | struct ospf *ospf; |
7c8ff89e | 3900 | u_short instance = 0; |
db7c8528 | 3901 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3902 | |
facfee22 | 3903 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 3904 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3905 | return CMD_SUCCESS; |
3906 | ||
db7c8528 | 3907 | return show_ip_ospf_neighbor_all_common(vty, ospf, uj); |
7c8ff89e DS |
3908 | } |
3909 | ||
3910 | static int | |
3911 | show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base, | |
7a7be519 | 3912 | struct cmd_token **argv, u_char use_json) |
7c8ff89e | 3913 | { |
bb5b7552 | 3914 | struct interface *ifp; |
3915 | struct route_node *rn; | |
91756b38 DS |
3916 | json_object *json = NULL; |
3917 | ||
3918 | if (use_json) | |
3919 | json = json_object_new_object(); | |
3920 | else | |
3921 | show_ip_ospf_neighbour_header (vty); | |
7c8ff89e DS |
3922 | |
3923 | if (ospf->instance) | |
91756b38 DS |
3924 | { |
3925 | if (use_json) | |
3926 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
3927 | else | |
1318e7c8 QY |
3928 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
3929 | VTYNL, VTYNL); | |
91756b38 | 3930 | } |
7c8ff89e | 3931 | |
1306c09a | 3932 | ifp = if_lookup_by_name (argv[arg_base]->arg, VRF_DEFAULT); |
bb5b7552 | 3933 | if (!ifp) |
718e3744 | 3934 | { |
91756b38 DS |
3935 | if (use_json) |
3936 | json_object_boolean_true_add(json, "noSuchIface"); | |
3937 | else | |
1318e7c8 | 3938 | vty_out (vty, "No such interface.%s", VTYNL); |
718e3744 | 3939 | return CMD_WARNING; |
3940 | } | |
d24f6e2a | 3941 | |
bb5b7552 | 3942 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
718e3744 | 3943 | { |
bb5b7552 | 3944 | struct ospf_interface *oi = rn->info; |
3945 | ||
3946 | if (oi == NULL) | |
91756b38 | 3947 | continue; |
bb5b7552 | 3948 | |
91756b38 | 3949 | show_ip_ospf_neighbor_sub (vty, oi, json, use_json); |
718e3744 | 3950 | } |
3951 | ||
91756b38 DS |
3952 | if (use_json) |
3953 | { | |
1318e7c8 | 3954 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
91756b38 DS |
3955 | json_object_free(json); |
3956 | } | |
3957 | else | |
1318e7c8 | 3958 | vty_out (vty, "%s", VTYNL); |
91756b38 | 3959 | |
718e3744 | 3960 | return CMD_SUCCESS; |
3961 | } | |
3962 | ||
7c8ff89e DS |
3963 | DEFUN (show_ip_ospf_neighbor_int, |
3964 | show_ip_ospf_neighbor_int_cmd, | |
b162fa78 | 3965 | "show ip ospf neighbor IFNAME [json]", |
7c8ff89e DS |
3966 | SHOW_STR |
3967 | IP_STR | |
3968 | "OSPF information\n" | |
3969 | "Neighbor list\n" | |
91756b38 | 3970 | "Interface name\n" |
9973d184 | 3971 | JSON_STR) |
7c8ff89e DS |
3972 | { |
3973 | struct ospf *ospf; | |
db7c8528 | 3974 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3975 | |
0bad4851 | 3976 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
3977 | return CMD_SUCCESS; |
3978 | ||
db7c8528 | 3979 | return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
3980 | } |
3981 | ||
3982 | DEFUN (show_ip_ospf_instance_neighbor_int, | |
3983 | show_ip_ospf_instance_neighbor_int_cmd, | |
6147e2c6 | 3984 | "show ip ospf (1-65535) neighbor IFNAME [json]", |
7c8ff89e DS |
3985 | SHOW_STR |
3986 | IP_STR | |
3987 | "OSPF information\n" | |
3988 | "Instance ID\n" | |
3989 | "Neighbor list\n" | |
91756b38 | 3990 | "Interface name\n" |
9973d184 | 3991 | JSON_STR) |
7c8ff89e | 3992 | { |
8d769265 | 3993 | int idx_number = 3; |
7c8ff89e DS |
3994 | struct ospf *ospf; |
3995 | u_short instance = 0; | |
db7c8528 | 3996 | u_char uj = use_json(argc, argv); |
7c8ff89e | 3997 | |
facfee22 | 3998 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 3999 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4000 | return CMD_SUCCESS; |
4001 | ||
db7c8528 | 4002 | return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4003 | } |
4004 | ||
4dadc291 | 4005 | static void |
3ac237f8 MS |
4006 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma, |
4007 | u_char use_json, json_object *json) | |
718e3744 | 4008 | { |
649654ab | 4009 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4010 | json_object *json_sub = NULL; |
718e3744 | 4011 | |
3ac237f8 MS |
4012 | if (use_json) |
4013 | json_sub = json_object_new_object(); | |
4014 | else /* Show neighbor ID. */ | |
4015 | vty_out (vty, " Neighbor %s,", "-"); | |
718e3744 | 4016 | |
4017 | /* Show interface address. */ | |
3ac237f8 MS |
4018 | if (use_json) |
4019 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr)); | |
4020 | else | |
4021 | vty_out (vty, " interface address %s%s", | |
1318e7c8 | 4022 | inet_ntoa (nbr_nbma->addr), VTYNL); |
3ac237f8 | 4023 | |
718e3744 | 4024 | /* Show Area ID. */ |
3ac237f8 MS |
4025 | if (use_json) |
4026 | { | |
4027 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4028 | json_object_string_add(json_sub, "iface", IF_NAME (oi)); | |
4029 | } | |
4030 | else | |
4031 | vty_out (vty, " In the area %s via interface %s%s", | |
1318e7c8 | 4032 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTYNL); |
3ac237f8 | 4033 | |
718e3744 | 4034 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4035 | if (use_json) |
4036 | { | |
4037 | json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority); | |
4038 | json_object_string_add(json_sub, "nbrState", "down"); | |
4039 | } | |
4040 | else | |
4041 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
4042 | nbr_nbma->priority, "Down"); | |
4043 | ||
718e3744 | 4044 | /* Show state changes. */ |
3ac237f8 MS |
4045 | if (use_json) |
4046 | json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change); | |
4047 | else | |
1318e7c8 | 4048 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTYNL); |
718e3744 | 4049 | |
4050 | /* Show PollInterval */ | |
3ac237f8 MS |
4051 | if (use_json) |
4052 | json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll); | |
4053 | else | |
1318e7c8 | 4054 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTYNL); |
718e3744 | 4055 | |
4056 | /* Show poll-interval timer. */ | |
3ac237f8 MS |
4057 | if (use_json) |
4058 | { | |
cbf3e3eb DL |
4059 | long time_store; |
4060 | time_store = monotime_until(&nbr_nbma->t_poll->u.sands, NULL) / 1000LL; | |
3ac237f8 MS |
4061 | json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store); |
4062 | } | |
4063 | else | |
4064 | vty_out (vty, " Poll timer due in %s%s", | |
4065 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), | |
1318e7c8 | 4066 | VTYNL); |
718e3744 | 4067 | |
4068 | /* Show poll-interval timer thread. */ | |
3ac237f8 MS |
4069 | if (use_json) |
4070 | { | |
4071 | if (nbr_nbma->t_poll != NULL) | |
4072 | json_object_string_add(json_sub, "pollIntervalTimerThread", "on"); | |
4073 | } | |
4074 | else | |
4075 | vty_out (vty, " Thread Poll Timer %s%s", | |
1318e7c8 | 4076 | nbr_nbma->t_poll != NULL ? "on" : "off", VTYNL); |
3ac237f8 MS |
4077 | |
4078 | if (use_json) | |
4079 | json_object_object_add(json, "noNbrId", json_sub); | |
718e3744 | 4080 | } |
4081 | ||
4dadc291 | 4082 | static void |
718e3744 | 4083 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
3ac237f8 | 4084 | struct ospf_neighbor *nbr, u_char use_json, json_object *json) |
718e3744 | 4085 | { |
649654ab | 4086 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
3ac237f8 | 4087 | json_object *json_sub = NULL; |
718e3744 | 4088 | |
3ac237f8 MS |
4089 | if (use_json) |
4090 | json_sub = json_object_new_object(); | |
718e3744 | 4091 | else |
3ac237f8 MS |
4092 | { |
4093 | /* Show neighbor ID. */ | |
4094 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4095 | vty_out (vty, " Neighbor %s,", "-"); | |
4096 | else | |
4097 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); | |
4098 | } | |
718e3744 | 4099 | |
4100 | /* Show interface address. */ | |
3ac237f8 MS |
4101 | if (use_json) |
4102 | json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4)); | |
4103 | else | |
4104 | vty_out (vty, " interface address %s%s", | |
1318e7c8 | 4105 | inet_ntoa (nbr->address.u.prefix4), VTYNL); |
3ac237f8 | 4106 | |
718e3744 | 4107 | /* Show Area ID. */ |
3ac237f8 MS |
4108 | if (use_json) |
4109 | { | |
4110 | json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area)); | |
4111 | json_object_string_add(json_sub, "ifaceName", oi->ifp->name); | |
4112 | } | |
4113 | else | |
4114 | vty_out (vty, " In the area %s via interface %s%s", | |
1318e7c8 | 4115 | ospf_area_desc_string (oi->area), oi->ifp->name, VTYNL); |
3ac237f8 | 4116 | |
718e3744 | 4117 | /* Show neighbor priority and state. */ |
3ac237f8 MS |
4118 | if (use_json) |
4119 | { | |
4120 | json_object_int_add(json_sub, "nbrPriority", nbr->priority); | |
56b40679 | 4121 | json_object_string_add(json_sub, "nbrState", lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); |
3ac237f8 MS |
4122 | } |
4123 | else | |
4124 | vty_out (vty, " Neighbor priority is %d, State is %s,", | |
56b40679 | 4125 | nbr->priority, lookup_msg(ospf_nsm_state_msg, nbr->state, NULL)); |
3ac237f8 | 4126 | |
718e3744 | 4127 | /* Show state changes. */ |
3ac237f8 MS |
4128 | if (use_json) |
4129 | json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change); | |
4130 | else | |
1318e7c8 | 4131 | vty_out (vty, " %d state changes%s", nbr->state_change, VTYNL); |
3ac237f8 | 4132 | |
3fed4160 | 4133 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
90c33177 | 4134 | { |
cbf3e3eb DL |
4135 | struct timeval res; |
4136 | long time_store; | |
4137 | ||
4138 | time_store = monotime_since(&nbr->ts_last_progress, &res) / 1000LL; | |
3ac237f8 MS |
4139 | if (use_json) |
4140 | { | |
3ac237f8 MS |
4141 | json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store); |
4142 | } | |
4143 | else | |
4144 | { | |
4145 | vty_out (vty, " Most recent state change statistics:%s", | |
1318e7c8 | 4146 | VTYNL); |
3ac237f8 MS |
4147 | vty_out (vty, " Progressive change %s ago%s", |
4148 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
1318e7c8 | 4149 | VTYNL); |
3ac237f8 | 4150 | } |
3fed4160 | 4151 | } |
3ac237f8 | 4152 | |
3fed4160 PJ |
4153 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
4154 | { | |
cbf3e3eb DL |
4155 | struct timeval res; |
4156 | long time_store; | |
4157 | ||
4158 | time_store = monotime_since(&nbr->ts_last_regress, &res) / 1000LL; | |
3ac237f8 MS |
4159 | if (use_json) |
4160 | { | |
3ac237f8 MS |
4161 | json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store); |
4162 | if (nbr->last_regress_str) | |
4163 | json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str); | |
4164 | } | |
4165 | else | |
4166 | { | |
4167 | vty_out (vty, " Regressive change %s ago, due to %s%s", | |
4168 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), | |
4169 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), | |
1318e7c8 | 4170 | VTYNL); |
3ac237f8 | 4171 | } |
90c33177 | 4172 | } |
3ac237f8 | 4173 | |
718e3744 | 4174 | /* Show Designated Rotuer ID. */ |
3ac237f8 MS |
4175 | if (use_json) |
4176 | json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router)); | |
4177 | else | |
4178 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); | |
4179 | ||
718e3744 | 4180 | /* Show Backup Designated Rotuer ID. */ |
3ac237f8 MS |
4181 | if (use_json) |
4182 | json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router)); | |
4183 | else | |
1318e7c8 | 4184 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTYNL); |
3ac237f8 | 4185 | |
718e3744 | 4186 | /* Show options. */ |
3ac237f8 MS |
4187 | if (use_json) |
4188 | { | |
4189 | json_object_int_add(json_sub, "optionsCounter", nbr->options); | |
4190 | json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options)); | |
4191 | } | |
4192 | else | |
4193 | vty_out (vty, " Options %d %s%s", nbr->options, | |
1318e7c8 | 4194 | ospf_options_dump (nbr->options), VTYNL); |
3ac237f8 | 4195 | |
718e3744 | 4196 | /* Show Router Dead interval timer. */ |
3ac237f8 MS |
4197 | if (use_json) |
4198 | { | |
45d430e8 DS |
4199 | if (nbr->t_inactivity) |
4200 | { | |
cbf3e3eb DL |
4201 | long time_store; |
4202 | time_store = monotime_until(&nbr->t_inactivity->u.sands, NULL) / 1000LL; | |
45d430e8 DS |
4203 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store); |
4204 | } | |
4205 | else | |
4206 | json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", -1); | |
3ac237f8 MS |
4207 | } |
4208 | else | |
4209 | vty_out (vty, " Dead timer due in %s%s", | |
4210 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), | |
1318e7c8 | 4211 | VTYNL); |
3ac237f8 | 4212 | |
718e3744 | 4213 | /* Show Database Summary list. */ |
3ac237f8 MS |
4214 | if (use_json) |
4215 | json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr)); | |
4216 | else | |
4217 | vty_out (vty, " Database Summary List %d%s", | |
1318e7c8 | 4218 | ospf_db_summary_count (nbr), VTYNL); |
3ac237f8 | 4219 | |
718e3744 | 4220 | /* Show Link State Request list. */ |
3ac237f8 MS |
4221 | if (use_json) |
4222 | json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr)); | |
4223 | else | |
4224 | vty_out (vty, " Link State Request List %ld%s", | |
1318e7c8 | 4225 | ospf_ls_request_count (nbr), VTYNL); |
3ac237f8 | 4226 | |
718e3744 | 4227 | /* Show Link State Retransmission list. */ |
3ac237f8 MS |
4228 | if (use_json) |
4229 | json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr)); | |
4230 | else | |
4231 | vty_out (vty, " Link State Retransmission List %ld%s", | |
1318e7c8 | 4232 | ospf_ls_retransmit_count (nbr), VTYNL); |
3ac237f8 | 4233 | |
718e3744 | 4234 | /* Show inactivity timer thread. */ |
3ac237f8 MS |
4235 | if (use_json) |
4236 | { | |
4237 | if (nbr->t_inactivity != NULL) | |
4238 | json_object_string_add(json_sub, "threadInactivityTimer", "on"); | |
4239 | } | |
4240 | else | |
4241 | vty_out (vty, " Thread Inactivity Timer %s%s", | |
1318e7c8 | 4242 | nbr->t_inactivity != NULL ? "on" : "off", VTYNL); |
3ac237f8 | 4243 | |
718e3744 | 4244 | /* Show Database Description retransmission thread. */ |
3ac237f8 MS |
4245 | if (use_json) |
4246 | { | |
4247 | if (nbr->t_db_desc != NULL) | |
4248 | json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on"); | |
4249 | } | |
4250 | else | |
4251 | vty_out (vty, " Thread Database Description Retransmision %s%s", | |
1318e7c8 | 4252 | nbr->t_db_desc != NULL ? "on" : "off", VTYNL); |
3ac237f8 | 4253 | |
718e3744 | 4254 | /* Show Link State Request Retransmission thread. */ |
3ac237f8 MS |
4255 | if (use_json) |
4256 | { | |
4257 | if (nbr->t_ls_req != NULL) | |
4258 | json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on"); | |
4259 | } | |
4260 | else | |
4261 | vty_out (vty, " Thread Link State Request Retransmission %s%s", | |
1318e7c8 | 4262 | nbr->t_ls_req != NULL ? "on" : "off", VTYNL); |
3ac237f8 | 4263 | |
718e3744 | 4264 | /* Show Link State Update Retransmission thread. */ |
3ac237f8 MS |
4265 | if (use_json) |
4266 | { | |
4267 | if (nbr->t_ls_upd != NULL) | |
4268 | json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on"); | |
4269 | } | |
4270 | else | |
4271 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", | |
1318e7c8 | 4272 | nbr->t_ls_upd != NULL ? "on" : "off", VTYNL, VTYNL); |
3ac237f8 MS |
4273 | |
4274 | if (use_json) | |
4275 | { | |
4276 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) | |
4277 | json_object_object_add(json, "noNbrId", json_sub); | |
4278 | else | |
4279 | json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub); | |
4280 | } | |
68fe91d6 | 4281 | |
4282 | ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0); | |
718e3744 | 4283 | } |
4284 | ||
7c8ff89e DS |
4285 | static int |
4286 | show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 4287 | int arg_base, struct cmd_token **argv, u_char use_json) |
718e3744 | 4288 | { |
52dc7ee6 | 4289 | struct listnode *node; |
718e3744 | 4290 | struct ospf_neighbor *nbr; |
1eb8ef25 | 4291 | struct ospf_interface *oi; |
718e3744 | 4292 | struct in_addr router_id; |
4293 | int ret; | |
3ac237f8 MS |
4294 | json_object *json = NULL; |
4295 | ||
4296 | if (use_json) | |
4297 | json = json_object_new_object(); | |
718e3744 | 4298 | |
7c8ff89e | 4299 | if (ospf->instance) |
3ac237f8 MS |
4300 | { |
4301 | if (use_json) | |
4302 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4303 | else | |
1318e7c8 QY |
4304 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
4305 | VTYNL, VTYNL); | |
3ac237f8 | 4306 | } |
7c8ff89e | 4307 | |
7a7be519 | 4308 | ret = inet_aton (argv[arg_base]->arg, &router_id); |
718e3744 | 4309 | if (!ret) |
4310 | { | |
3ac237f8 | 4311 | if (!use_json) |
1318e7c8 | 4312 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTYNL); |
718e3744 | 4313 | return CMD_WARNING; |
4314 | } | |
4315 | ||
1eb8ef25 | 4316 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
3ac237f8 MS |
4317 | { |
4318 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) | |
4319 | { | |
4320 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4321 | } | |
4322 | } | |
4323 | ||
4324 | if (use_json) | |
4325 | { | |
1318e7c8 | 4326 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
3ac237f8 MS |
4327 | json_object_free(json); |
4328 | } | |
4329 | else | |
1318e7c8 | 4330 | vty_out (vty, "%s", VTYNL); |
718e3744 | 4331 | |
718e3744 | 4332 | return CMD_SUCCESS; |
4333 | } | |
4334 | ||
7c8ff89e DS |
4335 | DEFUN (show_ip_ospf_neighbor_id, |
4336 | show_ip_ospf_neighbor_id_cmd, | |
b162fa78 | 4337 | "show ip ospf neighbor A.B.C.D [json]", |
718e3744 | 4338 | SHOW_STR |
4339 | IP_STR | |
4340 | "OSPF information\n" | |
4341 | "Neighbor list\n" | |
3ac237f8 | 4342 | "Neighbor ID\n" |
9973d184 | 4343 | JSON_STR) |
718e3744 | 4344 | { |
020709f9 | 4345 | struct ospf *ospf; |
db7c8528 | 4346 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4347 | |
0bad4851 | 4348 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4349 | return CMD_SUCCESS; |
4350 | ||
db7c8528 | 4351 | return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4352 | } |
4353 | ||
4354 | DEFUN (show_ip_ospf_instance_neighbor_id, | |
4355 | show_ip_ospf_instance_neighbor_id_cmd, | |
6147e2c6 | 4356 | "show ip ospf (1-65535) neighbor A.B.C.D [json]", |
7c8ff89e DS |
4357 | SHOW_STR |
4358 | IP_STR | |
4359 | "OSPF information\n" | |
4360 | "Instance ID\n" | |
4361 | "Neighbor list\n" | |
3ac237f8 | 4362 | "Neighbor ID\n" |
9973d184 | 4363 | JSON_STR) |
7c8ff89e | 4364 | { |
8d769265 | 4365 | int idx_number = 3; |
7c8ff89e DS |
4366 | struct ospf *ospf; |
4367 | u_short instance = 0; | |
db7c8528 | 4368 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4369 | |
facfee22 | 4370 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 4371 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4372 | return CMD_SUCCESS; |
4373 | ||
db7c8528 | 4374 | return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj); |
7c8ff89e DS |
4375 | } |
4376 | ||
4377 | static int | |
3ac237f8 | 4378 | show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4379 | { |
1eb8ef25 | 4380 | struct ospf_interface *oi; |
52dc7ee6 | 4381 | struct listnode *node; |
3ac237f8 MS |
4382 | json_object *json = NULL; |
4383 | ||
4384 | if (use_json) | |
4385 | json = json_object_new_object(); | |
718e3744 | 4386 | |
7c8ff89e | 4387 | if (ospf->instance) |
3ac237f8 MS |
4388 | { |
4389 | if (use_json) | |
4390 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4391 | else | |
1318e7c8 QY |
4392 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
4393 | VTYNL, VTYNL); | |
3ac237f8 | 4394 | } |
718e3744 | 4395 | |
1eb8ef25 | 4396 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4397 | { |
718e3744 | 4398 | struct route_node *rn; |
4399 | struct ospf_neighbor *nbr; | |
4400 | ||
4401 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
3ac237f8 MS |
4402 | { |
4403 | if ((nbr = rn->info)) | |
4404 | { | |
4405 | if (nbr != oi->nbr_self) | |
4406 | { | |
4407 | if (nbr->state != NSM_Down) | |
4408 | { | |
4409 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4410 | } | |
4411 | } | |
4412 | } | |
4413 | } | |
718e3744 | 4414 | } |
4415 | ||
3ac237f8 MS |
4416 | if (use_json) |
4417 | { | |
1318e7c8 | 4418 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
3ac237f8 MS |
4419 | json_object_free(json); |
4420 | } | |
4421 | else | |
1318e7c8 | 4422 | vty_out (vty, "%s", VTYNL); |
3ac237f8 | 4423 | |
718e3744 | 4424 | return CMD_SUCCESS; |
4425 | } | |
4426 | ||
7c8ff89e DS |
4427 | DEFUN (show_ip_ospf_neighbor_detail, |
4428 | show_ip_ospf_neighbor_detail_cmd, | |
b162fa78 | 4429 | "show ip ospf neighbor detail [json]", |
718e3744 | 4430 | SHOW_STR |
4431 | IP_STR | |
4432 | "OSPF information\n" | |
4433 | "Neighbor list\n" | |
3ac237f8 | 4434 | "detail of all neighbors\n" |
9973d184 | 4435 | JSON_STR) |
718e3744 | 4436 | { |
020709f9 | 4437 | struct ospf *ospf; |
db7c8528 | 4438 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4439 | |
0bad4851 | 4440 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4441 | return CMD_SUCCESS; |
4442 | ||
db7c8528 | 4443 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4444 | } |
4445 | ||
4446 | DEFUN (show_ip_ospf_instance_neighbor_detail, | |
4447 | show_ip_ospf_instance_neighbor_detail_cmd, | |
6147e2c6 | 4448 | "show ip ospf (1-65535) neighbor detail [json]", |
7c8ff89e DS |
4449 | SHOW_STR |
4450 | IP_STR | |
4451 | "OSPF information\n" | |
4452 | "Instance ID\n" | |
4453 | "Neighbor list\n" | |
3ac237f8 | 4454 | "detail of all neighbors\n" |
9973d184 | 4455 | JSON_STR) |
7c8ff89e | 4456 | { |
8d769265 | 4457 | int idx_number = 3; |
7c8ff89e DS |
4458 | struct ospf *ospf; |
4459 | u_short instance = 0; | |
db7c8528 | 4460 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4461 | |
facfee22 | 4462 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 4463 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4464 | return CMD_SUCCESS; |
4465 | ||
db7c8528 | 4466 | return show_ip_ospf_neighbor_detail_common(vty, ospf, uj); |
7c8ff89e DS |
4467 | } |
4468 | ||
4469 | static int | |
3ac237f8 | 4470 | show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json) |
7c8ff89e | 4471 | { |
52dc7ee6 | 4472 | struct listnode *node; |
1eb8ef25 | 4473 | struct ospf_interface *oi; |
3ac237f8 MS |
4474 | json_object *json = NULL; |
4475 | ||
4476 | if (use_json) | |
4477 | json = json_object_new_object(); | |
718e3744 | 4478 | |
7c8ff89e | 4479 | if (ospf->instance) |
3ac237f8 MS |
4480 | { |
4481 | if (use_json) | |
4482 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4483 | else | |
1318e7c8 QY |
4484 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
4485 | VTYNL, VTYNL); | |
3ac237f8 | 4486 | } |
718e3744 | 4487 | |
1eb8ef25 | 4488 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
718e3744 | 4489 | { |
718e3744 | 4490 | struct route_node *rn; |
4491 | struct ospf_neighbor *nbr; | |
1eb8ef25 | 4492 | struct ospf_nbr_nbma *nbr_nbma; |
718e3744 | 4493 | |
4494 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
4495 | if ((nbr = rn->info)) | |
4496 | if (nbr != oi->nbr_self) | |
a452df33 | 4497 | if (nbr->state != NSM_Down) |
3ac237f8 | 4498 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json); |
718e3744 | 4499 | |
4500 | if (oi->type == OSPF_IFTYPE_NBMA) | |
3ac237f8 MS |
4501 | { |
4502 | struct listnode *nd; | |
718e3744 | 4503 | |
3ac237f8 MS |
4504 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
4505 | { | |
4506 | if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down) | |
4507 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json); | |
4508 | } | |
4509 | } | |
4510 | } | |
4511 | ||
4512 | if (use_json) | |
4513 | { | |
1318e7c8 | 4514 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
3ac237f8 MS |
4515 | json_object_free(json); |
4516 | } | |
4517 | else | |
4518 | { | |
1318e7c8 | 4519 | vty_out (vty, "%s", VTYNL); |
718e3744 | 4520 | } |
4521 | ||
4522 | return CMD_SUCCESS; | |
4523 | } | |
4524 | ||
7c8ff89e DS |
4525 | DEFUN (show_ip_ospf_neighbor_detail_all, |
4526 | show_ip_ospf_neighbor_detail_all_cmd, | |
b162fa78 | 4527 | "show ip ospf neighbor detail all [json]", |
718e3744 | 4528 | SHOW_STR |
4529 | IP_STR | |
4530 | "OSPF information\n" | |
4531 | "Neighbor list\n" | |
7c8ff89e | 4532 | "detail of all neighbors\n" |
3ac237f8 | 4533 | "include down status neighbor\n" |
9973d184 | 4534 | JSON_STR) |
718e3744 | 4535 | { |
020709f9 | 4536 | struct ospf *ospf; |
db7c8528 | 4537 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4538 | |
0bad4851 | 4539 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4540 | return CMD_SUCCESS; |
4541 | ||
db7c8528 | 4542 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4543 | } |
4544 | ||
4545 | DEFUN (show_ip_ospf_instance_neighbor_detail_all, | |
4546 | show_ip_ospf_instance_neighbor_detail_all_cmd, | |
6147e2c6 | 4547 | "show ip ospf (1-65535) neighbor detail all [json]", |
7c8ff89e DS |
4548 | SHOW_STR |
4549 | IP_STR | |
4550 | "OSPF information\n" | |
4551 | "Instance ID\n" | |
4552 | "Neighbor list\n" | |
4553 | "detail of all neighbors\n" | |
3ac237f8 | 4554 | "include down status neighbor\n" |
9973d184 | 4555 | JSON_STR) |
7c8ff89e | 4556 | { |
8d769265 | 4557 | int idx_number = 3; |
7c8ff89e DS |
4558 | struct ospf *ospf; |
4559 | u_short instance = 0; | |
db7c8528 | 4560 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4561 | |
facfee22 | 4562 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 4563 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4564 | return CMD_SUCCESS; |
4565 | ||
db7c8528 | 4566 | return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj); |
7c8ff89e DS |
4567 | } |
4568 | ||
4569 | static int | |
4570 | show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 4571 | int arg_base, struct cmd_token **argv, u_char use_json) |
7c8ff89e | 4572 | { |
718e3744 | 4573 | struct ospf_interface *oi; |
bb5b7552 | 4574 | struct interface *ifp; |
4575 | struct route_node *rn, *nrn; | |
4576 | struct ospf_neighbor *nbr; | |
3ac237f8 MS |
4577 | json_object *json = NULL; |
4578 | ||
4579 | if (use_json) | |
4580 | json = json_object_new_object(); | |
bb5b7552 | 4581 | |
7c8ff89e | 4582 | if (ospf->instance) |
3ac237f8 MS |
4583 | { |
4584 | if (use_json) | |
4585 | json_object_int_add(json, "ospfInstance", ospf->instance); | |
4586 | else | |
1318e7c8 QY |
4587 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
4588 | VTYNL, VTYNL); | |
3ac237f8 | 4589 | } |
7c8ff89e | 4590 | |
1306c09a | 4591 | ifp = if_lookup_by_name (argv[arg_base]->arg, VRF_DEFAULT); |
bb5b7552 | 4592 | if (!ifp) |
718e3744 | 4593 | { |
3ac237f8 | 4594 | if (!use_json) |
1318e7c8 | 4595 | vty_out (vty, "No such interface.%s", VTYNL); |
718e3744 | 4596 | return CMD_WARNING; |
4597 | } | |
4598 | ||
bb5b7552 | 4599 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
3ac237f8 MS |
4600 | { |
4601 | if ((oi = rn->info)) | |
4602 | { | |
4603 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) | |
4604 | { | |
4605 | if ((nbr = nrn->info)) | |
4606 | { | |
4607 | if (nbr != oi->nbr_self) | |
4608 | { | |
4609 | if (nbr->state != NSM_Down) | |
4610 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json); | |
4611 | } | |
4612 | } | |
4613 | } | |
4614 | } | |
4615 | } | |
4616 | ||
4617 | if (use_json) | |
4618 | { | |
1318e7c8 | 4619 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTYNL); |
3ac237f8 MS |
4620 | json_object_free(json); |
4621 | } | |
4622 | else | |
1318e7c8 | 4623 | vty_out (vty, "%s", VTYNL); |
718e3744 | 4624 | |
4625 | return CMD_SUCCESS; | |
4626 | } | |
4627 | ||
7c8ff89e DS |
4628 | DEFUN (show_ip_ospf_neighbor_int_detail, |
4629 | show_ip_ospf_neighbor_int_detail_cmd, | |
b162fa78 | 4630 | "show ip ospf neighbor IFNAME detail [json]", |
7c8ff89e DS |
4631 | SHOW_STR |
4632 | IP_STR | |
4633 | "OSPF information\n" | |
4634 | "Neighbor list\n" | |
4635 | "Interface name\n" | |
3ac237f8 | 4636 | "detail of all neighbors\n" |
9973d184 | 4637 | JSON_STR) |
7c8ff89e DS |
4638 | { |
4639 | struct ospf *ospf; | |
db7c8528 | 4640 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4641 | |
0bad4851 | 4642 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4643 | return CMD_SUCCESS; |
4644 | ||
db7c8528 | 4645 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj); |
7c8ff89e DS |
4646 | } |
4647 | ||
4648 | DEFUN (show_ip_ospf_instance_neighbor_int_detail, | |
4649 | show_ip_ospf_instance_neighbor_int_detail_cmd, | |
6147e2c6 | 4650 | "show ip ospf (1-65535) neighbor IFNAME detail [json]", |
7c8ff89e DS |
4651 | SHOW_STR |
4652 | IP_STR | |
4653 | "OSPF information\n" | |
4654 | "Instance ID\n" | |
4655 | "Neighbor list\n" | |
4656 | "Interface name\n" | |
3ac237f8 | 4657 | "detail of all neighbors\n" |
9973d184 | 4658 | JSON_STR) |
7c8ff89e | 4659 | { |
8d769265 | 4660 | int idx_number = 3; |
7c8ff89e DS |
4661 | struct ospf *ospf; |
4662 | u_short instance = 0; | |
db7c8528 | 4663 | u_char uj = use_json(argc, argv); |
7c8ff89e | 4664 | |
facfee22 | 4665 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 4666 | if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
4667 | return CMD_SUCCESS; |
4668 | ||
db7c8528 | 4669 | return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj); |
7c8ff89e | 4670 | } |
6b0655a2 | 4671 | |
718e3744 | 4672 | /* Show functions */ |
4dadc291 | 4673 | static int |
020709f9 | 4674 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
718e3744 | 4675 | { |
718e3744 | 4676 | struct router_lsa *rl; |
4677 | struct summary_lsa *sl; | |
4678 | struct as_external_lsa *asel; | |
4679 | struct prefix_ipv4 p; | |
4680 | ||
4681 | if (lsa != NULL) | |
4682 | /* If self option is set, check LSA self flag. */ | |
4683 | if (self == 0 || IS_LSA_SELF (lsa)) | |
4684 | { | |
4685 | /* LSA common part show. */ | |
4686 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); | |
4687 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", | |
4688 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), | |
4689 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); | |
4690 | /* LSA specific part show. */ | |
4691 | switch (lsa->data->type) | |
4692 | { | |
4693 | case OSPF_ROUTER_LSA: | |
4694 | rl = (struct router_lsa *) lsa->data; | |
4695 | vty_out (vty, " %-d", ntohs (rl->links)); | |
4696 | break; | |
4697 | case OSPF_SUMMARY_LSA: | |
4698 | sl = (struct summary_lsa *) lsa->data; | |
4699 | ||
4700 | p.family = AF_INET; | |
4701 | p.prefix = sl->header.id; | |
4702 | p.prefixlen = ip_masklen (sl->mask); | |
4703 | apply_mask_ipv4 (&p); | |
4704 | ||
4705 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); | |
4706 | break; | |
4707 | case OSPF_AS_EXTERNAL_LSA: | |
551a8979 | 4708 | case OSPF_AS_NSSA_LSA: |
718e3744 | 4709 | asel = (struct as_external_lsa *) lsa->data; |
4710 | ||
4711 | p.family = AF_INET; | |
4712 | p.prefix = asel->header.id; | |
4713 | p.prefixlen = ip_masklen (asel->mask); | |
4714 | apply_mask_ipv4 (&p); | |
4715 | ||
4716 | vty_out (vty, " %s %s/%d [0x%lx]", | |
4717 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", | |
4718 | inet_ntoa (p.prefix), p.prefixlen, | |
4719 | (u_long)ntohl (asel->e[0].route_tag)); | |
4720 | break; | |
4721 | case OSPF_NETWORK_LSA: | |
4722 | case OSPF_ASBR_SUMMARY_LSA: | |
718e3744 | 4723 | case OSPF_OPAQUE_LINK_LSA: |
4724 | case OSPF_OPAQUE_AREA_LSA: | |
4725 | case OSPF_OPAQUE_AS_LSA: | |
718e3744 | 4726 | default: |
4727 | break; | |
4728 | } | |
1318e7c8 | 4729 | vty_out (vty, VTYNL); |
718e3744 | 4730 | } |
4731 | ||
4732 | return 0; | |
4733 | } | |
4734 | ||
8b6a15b2 | 4735 | static const char *show_database_desc[] = |
718e3744 | 4736 | { |
4737 | "unknown", | |
4738 | "Router Link States", | |
4739 | "Net Link States", | |
4740 | "Summary Link States", | |
4741 | "ASBR-Summary Link States", | |
4742 | "AS External Link States", | |
718e3744 | 4743 | "Group Membership LSA", |
4744 | "NSSA-external Link States", | |
718e3744 | 4745 | "Type-8 LSA", |
4746 | "Link-Local Opaque-LSA", | |
4747 | "Area-Local Opaque-LSA", | |
4748 | "AS-external Opaque-LSA", | |
718e3744 | 4749 | }; |
4750 | ||
8b6a15b2 | 4751 | static const char *show_database_header[] = |
718e3744 | 4752 | { |
4753 | "", | |
4754 | "Link ID ADV Router Age Seq# CkSum Link count", | |
4755 | "Link ID ADV Router Age Seq# CkSum", | |
4756 | "Link ID ADV Router Age Seq# CkSum Route", | |
4757 | "Link ID ADV Router Age Seq# CkSum", | |
4758 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4759 | " --- header for Group Member ----", |
4760 | "Link ID ADV Router Age Seq# CkSum Route", | |
718e3744 | 4761 | " --- type-8 ---", |
4762 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4763 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
4764 | "Opaque-Type/Id ADV Router Age Seq# CkSum", | |
718e3744 | 4765 | }; |
4766 | ||
4dadc291 | 4767 | static void |
718e3744 | 4768 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
4769 | { | |
4770 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; | |
4957f494 | 4771 | |
1318e7c8 QY |
4772 | vty_outln (vty, " LS age: %d", LS_AGE (lsa)); |
4773 | vty_outln (vty, " Options: 0x%-2x : %s", lsa->data->options, | |
4774 | ospf_options_dump(lsa->data->options)); | |
4775 | vty_outln (vty, " LS Flags: 0x%-2x %s", | |
4776 | lsa->flags, | |
4777 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? | |
4778 | "(Translated from Type-7)" : "")); | |
718e3744 | 4779 | |
4780 | if (lsa->data->type == OSPF_ROUTER_LSA) | |
4781 | { | |
4782 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); | |
4783 | ||
4784 | if (rlsa->flags) | |
4785 | vty_out (vty, " :%s%s%s%s", | |
4786 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", | |
4787 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", | |
4788 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", | |
4789 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); | |
4790 | ||
e31b6333 | 4791 | vty_out (vty, VTYNL); |
718e3744 | 4792 | } |
1318e7c8 QY |
4793 | vty_outln (vty, " LS Type: %s", |
4794 | lookup_msg(ospf_lsa_type_msg, lsa->data->type, NULL)); | |
4795 | vty_outln (vty, " Link State ID: %s %s", inet_ntoa (lsa->data->id), | |
4796 | lookup_msg(ospf_link_state_id_type_msg, lsa->data->type, NULL)); | |
4797 | vty_outln (vty, " Advertising Router: %s", inet_ntoa (lsa->data->adv_router)); | |
4798 | vty_outln (vty, " LS Seq Number: %08lx", (u_long)ntohl (lsa->data->ls_seqnum)); | |
4799 | vty_outln (vty, " Checksum: 0x%04x", ntohs (lsa->data->checksum)); | |
4800 | vty_outln (vty, " Length: %d%s", ntohs (lsa->data->length), VTYNL); | |
718e3744 | 4801 | } |
4802 | ||
eb1ce605 | 4803 | const char *link_type_desc[] = |
718e3744 | 4804 | { |
4805 | "(null)", | |
4806 | "another Router (point-to-point)", | |
4807 | "a Transit Network", | |
4808 | "Stub Network", | |
4809 | "a Virtual Link", | |
4810 | }; | |
4811 | ||
eb1ce605 | 4812 | const char *link_id_desc[] = |
718e3744 | 4813 | { |
4814 | "(null)", | |
4815 | "Neighboring Router ID", | |
4816 | "Designated Router address", | |
68980084 | 4817 | "Net", |
718e3744 | 4818 | "Neighboring Router ID", |
4819 | }; | |
4820 | ||
eb1ce605 | 4821 | const char *link_data_desc[] = |
718e3744 | 4822 | { |
4823 | "(null)", | |
4824 | "Router Interface address", | |
4825 | "Router Interface address", | |
4826 | "Network Mask", | |
4827 | "Router Interface address", | |
4828 | }; | |
4829 | ||
4830 | /* Show router-LSA each Link information. */ | |
4dadc291 | 4831 | static void |
718e3744 | 4832 | show_ip_ospf_database_router_links (struct vty *vty, |
4833 | struct router_lsa *rl) | |
4834 | { | |
b07c4cb3 DS |
4835 | int len, type; |
4836 | unsigned int i; | |
718e3744 | 4837 | |
4838 | len = ntohs (rl->header.length) - 4; | |
4839 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) | |
4840 | { | |
4841 | type = rl->link[i].type; | |
4842 | ||
4843 | vty_out (vty, " Link connected to: %s%s", | |
1318e7c8 | 4844 | link_type_desc[type], VTYNL); |
718e3744 | 4845 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
1318e7c8 | 4846 | inet_ntoa (rl->link[i].link_id), VTYNL); |
718e3744 | 4847 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
1318e7c8 QY |
4848 | inet_ntoa (rl->link[i].link_data), VTYNL); |
4849 | vty_out (vty, " Number of TOS metrics: 0%s", VTYNL); | |
718e3744 | 4850 | vty_out (vty, " TOS 0 Metric: %d%s", |
1318e7c8 QY |
4851 | ntohs (rl->link[i].metric), VTYNL); |
4852 | vty_out (vty, "%s", VTYNL); | |
718e3744 | 4853 | } |
4854 | } | |
4855 | ||
4856 | /* Show router-LSA detail information. */ | |
4dadc291 | 4857 | static int |
718e3744 | 4858 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4859 | { | |
4860 | if (lsa != NULL) | |
4861 | { | |
4862 | struct router_lsa *rl = (struct router_lsa *) lsa->data; | |
4863 | ||
4864 | show_ip_ospf_database_header (vty, lsa); | |
4865 | ||
4866 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), | |
1318e7c8 | 4867 | VTYNL, VTYNL); |
718e3744 | 4868 | |
4869 | show_ip_ospf_database_router_links (vty, rl); | |
1318e7c8 | 4870 | vty_out (vty, "%s", VTYNL); |
718e3744 | 4871 | } |
4872 | ||
4873 | return 0; | |
4874 | } | |
4875 | ||
4876 | /* Show network-LSA detail information. */ | |
4dadc291 | 4877 | static int |
718e3744 | 4878 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4879 | { | |
4880 | int length, i; | |
4881 | ||
4882 | if (lsa != NULL) | |
4883 | { | |
4884 | struct network_lsa *nl = (struct network_lsa *) lsa->data; | |
4885 | ||
4886 | show_ip_ospf_database_header (vty, lsa); | |
4887 | ||
4888 | vty_out (vty, " Network Mask: /%d%s", | |
1318e7c8 | 4889 | ip_masklen (nl->mask), VTYNL); |
718e3744 | 4890 | |
4891 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; | |
4892 | ||
4893 | for (i = 0; length > 0; i++, length -= 4) | |
4894 | vty_out (vty, " Attached Router: %s%s", | |
1318e7c8 | 4895 | inet_ntoa (nl->routers[i]), VTYNL); |
718e3744 | 4896 | |
1318e7c8 | 4897 | vty_out (vty, "%s", VTYNL); |
718e3744 | 4898 | } |
4899 | ||
4900 | return 0; | |
4901 | } | |
4902 | ||
4903 | /* Show summary-LSA detail information. */ | |
4dadc291 | 4904 | static int |
718e3744 | 4905 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4906 | { | |
4907 | if (lsa != NULL) | |
4908 | { | |
4909 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
4910 | ||
4911 | show_ip_ospf_database_header (vty, lsa); | |
4912 | ||
4913 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), | |
1318e7c8 | 4914 | VTYNL); |
718e3744 | 4915 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
1318e7c8 QY |
4916 | VTYNL); |
4917 | vty_out (vty, "%s", VTYNL); | |
718e3744 | 4918 | } |
4919 | ||
4920 | return 0; | |
4921 | } | |
4922 | ||
4923 | /* Show summary-ASBR-LSA detail information. */ | |
4dadc291 | 4924 | static int |
718e3744 | 4925 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4926 | { | |
4927 | if (lsa != NULL) | |
4928 | { | |
4929 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; | |
4930 | ||
4931 | show_ip_ospf_database_header (vty, lsa); | |
4932 | ||
4933 | vty_out (vty, " Network Mask: /%d%s", | |
1318e7c8 | 4934 | ip_masklen (sl->mask), VTYNL); |
718e3744 | 4935 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
1318e7c8 QY |
4936 | VTYNL); |
4937 | vty_out (vty, "%s", VTYNL); | |
718e3744 | 4938 | } |
4939 | ||
4940 | return 0; | |
4941 | } | |
4942 | ||
4943 | /* Show AS-external-LSA detail information. */ | |
4dadc291 | 4944 | static int |
718e3744 | 4945 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4946 | { | |
4947 | if (lsa != NULL) | |
4948 | { | |
4949 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4950 | ||
4951 | show_ip_ospf_database_header (vty, lsa); | |
4952 | ||
4953 | vty_out (vty, " Network Mask: /%d%s", | |
1318e7c8 | 4954 | ip_masklen (al->mask), VTYNL); |
718e3744 | 4955 | vty_out (vty, " Metric Type: %s%s", |
4956 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
1318e7c8 QY |
4957 | "2 (Larger than any link state path)" : "1", VTYNL); |
4958 | vty_out (vty, " TOS: 0%s", VTYNL); | |
718e3744 | 4959 | vty_out (vty, " Metric: %d%s", |
1318e7c8 | 4960 | GET_METRIC (al->e[0].metric), VTYNL); |
718e3744 | 4961 | vty_out (vty, " Forward Address: %s%s", |
1318e7c8 | 4962 | inet_ntoa (al->e[0].fwd_addr), VTYNL); |
718e3744 | 4963 | |
dc9ffce8 | 4964 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
1318e7c8 | 4965 | (route_tag_t)ntohl (al->e[0].route_tag), VTYNL, VTYNL); |
718e3744 | 4966 | } |
4967 | ||
4968 | return 0; | |
4969 | } | |
075e12f5 | 4970 | #if 0 |
4dadc291 | 4971 | static int |
718e3744 | 4972 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
4973 | { | |
4974 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
4975 | ||
4976 | /* show_ip_ospf_database_header (vty, lsa); */ | |
4977 | ||
2a42e285 | 4978 | zlog_debug( " Network Mask: /%d%s", |
718e3744 | 4979 | ip_masklen (al->mask), "\n"); |
2a42e285 | 4980 | zlog_debug( " Metric Type: %s%s", |
718e3744 | 4981 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
4982 | "2 (Larger than any link state path)" : "1", "\n"); | |
2a42e285 | 4983 | zlog_debug( " TOS: 0%s", "\n"); |
4984 | zlog_debug( " Metric: %d%s", | |
718e3744 | 4985 | GET_METRIC (al->e[0].metric), "\n"); |
2a42e285 | 4986 | zlog_debug( " Forward Address: %s%s", |
718e3744 | 4987 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
4988 | ||
dc9ffce8 CF |
4989 | zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
4990 | (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n"); | |
718e3744 | 4991 | |
4992 | return 0; | |
4993 | } | |
075e12f5 | 4994 | #endif |
718e3744 | 4995 | /* Show AS-NSSA-LSA detail information. */ |
4dadc291 | 4996 | static int |
718e3744 | 4997 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
4998 | { | |
4999 | if (lsa != NULL) | |
5000 | { | |
5001 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; | |
5002 | ||
5003 | show_ip_ospf_database_header (vty, lsa); | |
5004 | ||
5005 | vty_out (vty, " Network Mask: /%d%s", | |
1318e7c8 | 5006 | ip_masklen (al->mask), VTYNL); |
718e3744 | 5007 | vty_out (vty, " Metric Type: %s%s", |
5008 | IS_EXTERNAL_METRIC (al->e[0].tos) ? | |
1318e7c8 QY |
5009 | "2 (Larger than any link state path)" : "1", VTYNL); |
5010 | vty_out (vty, " TOS: 0%s", VTYNL); | |
718e3744 | 5011 | vty_out (vty, " Metric: %d%s", |
1318e7c8 | 5012 | GET_METRIC (al->e[0].metric), VTYNL); |
718e3744 | 5013 | vty_out (vty, " NSSA: Forward Address: %s%s", |
1318e7c8 | 5014 | inet_ntoa (al->e[0].fwd_addr), VTYNL); |
718e3744 | 5015 | |
dc9ffce8 | 5016 | vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s", |
1318e7c8 | 5017 | (route_tag_t)ntohl (al->e[0].route_tag), VTYNL, VTYNL); |
718e3744 | 5018 | } |
5019 | ||
5020 | return 0; | |
5021 | } | |
5022 | ||
4dadc291 | 5023 | static int |
718e3744 | 5024 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
5025 | { | |
5026 | return 0; | |
5027 | } | |
5028 | ||
4dadc291 | 5029 | static int |
718e3744 | 5030 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
5031 | { | |
5032 | if (lsa != NULL) | |
5033 | { | |
5034 | show_ip_ospf_database_header (vty, lsa); | |
5035 | show_opaque_info_detail (vty, lsa); | |
5036 | ||
1318e7c8 | 5037 | vty_out (vty, "%s", VTYNL); |
718e3744 | 5038 | } |
5039 | return 0; | |
5040 | } | |
718e3744 | 5041 | |
5042 | int (*show_function[])(struct vty *, struct ospf_lsa *) = | |
5043 | { | |
5044 | NULL, | |
5045 | show_router_lsa_detail, | |
5046 | show_network_lsa_detail, | |
5047 | show_summary_lsa_detail, | |
5048 | show_summary_asbr_lsa_detail, | |
5049 | show_as_external_lsa_detail, | |
718e3744 | 5050 | show_func_dummy, |
5051 | show_as_nssa_lsa_detail, /* almost same as external */ | |
718e3744 | 5052 | NULL, /* type-8 */ |
5053 | show_opaque_lsa_detail, | |
5054 | show_opaque_lsa_detail, | |
5055 | show_opaque_lsa_detail, | |
718e3744 | 5056 | }; |
5057 | ||
4dadc291 | 5058 | static void |
718e3744 | 5059 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
5060 | struct in_addr *adv_router) | |
5061 | { | |
5062 | memset (lp, 0, sizeof (struct prefix_ls)); | |
5063 | lp->family = 0; | |
5064 | if (id == NULL) | |
5065 | lp->prefixlen = 0; | |
5066 | else if (adv_router == NULL) | |
5067 | { | |
5068 | lp->prefixlen = 32; | |
5069 | lp->id = *id; | |
5070 | } | |
5071 | else | |
5072 | { | |
5073 | lp->prefixlen = 64; | |
5074 | lp->id = *id; | |
5075 | lp->adv_router = *adv_router; | |
5076 | } | |
5077 | } | |
5078 | ||
4dadc291 | 5079 | static void |
718e3744 | 5080 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
5081 | struct in_addr *id, struct in_addr *adv_router) | |
5082 | { | |
5083 | struct prefix_ls lp; | |
5084 | struct route_node *rn, *start; | |
5085 | struct ospf_lsa *lsa; | |
5086 | ||
5087 | show_lsa_prefix_set (vty, &lp, id, adv_router); | |
5088 | start = route_node_get (rt, (struct prefix *) &lp); | |
5089 | if (start) | |
5090 | { | |
5091 | route_lock_node (start); | |
5092 | for (rn = start; rn; rn = route_next_until (rn, start)) | |
5093 | if ((lsa = rn->info)) | |
5094 | { | |
718e3744 | 5095 | if (show_function[lsa->data->type] != NULL) |
5096 | show_function[lsa->data->type] (vty, lsa); | |
5097 | } | |
5098 | route_unlock_node (start); | |
5099 | } | |
5100 | } | |
5101 | ||
5102 | /* Show detail LSA information | |
5103 | -- if id is NULL then show all LSAs. */ | |
4dadc291 | 5104 | static void |
020709f9 | 5105 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5106 | struct in_addr *id, struct in_addr *adv_router) |
5107 | { | |
52dc7ee6 | 5108 | struct listnode *node; |
1eb8ef25 | 5109 | struct ospf_area *area; |
5110 | ||
718e3744 | 5111 | switch (type) |
5112 | { | |
5113 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5114 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5115 | vty_out (vty, " %s %s%s", |
5116 | show_database_desc[type], | |
1318e7c8 | 5117 | VTYNL, VTYNL); |
68980084 | 5118 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
718e3744 | 5119 | break; |
5120 | default: | |
1eb8ef25 | 5121 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5122 | { |
718e3744 | 5123 | vty_out (vty, "%s %s (Area %s)%s%s", |
1318e7c8 QY |
5124 | VTYNL, show_database_desc[type], |
5125 | ospf_area_desc_string (area), VTYNL, VTYNL); | |
718e3744 | 5126 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
5127 | } | |
5128 | break; | |
5129 | } | |
5130 | } | |
5131 | ||
4dadc291 | 5132 | static void |
718e3744 | 5133 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
5134 | struct in_addr *adv_router) | |
5135 | { | |
5136 | struct route_node *rn; | |
5137 | struct ospf_lsa *lsa; | |
5138 | ||
5139 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
5140 | if ((lsa = rn->info)) | |
5141 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) | |
5142 | { | |
718e3744 | 5143 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
5144 | continue; | |
718e3744 | 5145 | if (show_function[lsa->data->type] != NULL) |
5146 | show_function[lsa->data->type] (vty, lsa); | |
5147 | } | |
5148 | } | |
5149 | ||
5150 | /* Show detail LSA information. */ | |
4dadc291 | 5151 | static void |
020709f9 | 5152 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
718e3744 | 5153 | struct in_addr *adv_router) |
5154 | { | |
52dc7ee6 | 5155 | struct listnode *node; |
1eb8ef25 | 5156 | struct ospf_area *area; |
718e3744 | 5157 | |
5158 | switch (type) | |
5159 | { | |
5160 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5161 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5162 | vty_out (vty, " %s %s%s", |
5163 | show_database_desc[type], | |
1318e7c8 | 5164 | VTYNL, VTYNL); |
68980084 | 5165 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
718e3744 | 5166 | adv_router); |
5167 | break; | |
5168 | default: | |
1eb8ef25 | 5169 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5170 | { |
718e3744 | 5171 | vty_out (vty, "%s %s (Area %s)%s%s", |
1318e7c8 QY |
5172 | VTYNL, show_database_desc[type], |
5173 | ospf_area_desc_string (area), VTYNL, VTYNL); | |
718e3744 | 5174 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
5175 | adv_router); | |
5176 | } | |
5177 | break; | |
5178 | } | |
5179 | } | |
5180 | ||
4dadc291 | 5181 | static void |
020709f9 | 5182 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
718e3744 | 5183 | { |
020709f9 | 5184 | struct ospf_lsa *lsa; |
5185 | struct route_node *rn; | |
1eb8ef25 | 5186 | struct ospf_area *area; |
52dc7ee6 | 5187 | struct listnode *node; |
718e3744 | 5188 | int type; |
5189 | ||
1eb8ef25 | 5190 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 5191 | { |
718e3744 | 5192 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
5193 | { | |
5194 | switch (type) | |
5195 | { | |
5196 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5197 | case OSPF_OPAQUE_AS_LSA: |
718e3744 | 5198 | continue; |
5199 | default: | |
5200 | break; | |
5201 | } | |
5202 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || | |
5203 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) | |
5204 | { | |
5205 | vty_out (vty, " %s (Area %s)%s%s", | |
5206 | show_database_desc[type], | |
5207 | ospf_area_desc_string (area), | |
1318e7c8 QY |
5208 | VTYNL, VTYNL); |
5209 | vty_out (vty, "%s%s", show_database_header[type], VTYNL); | |
718e3744 | 5210 | |
020709f9 | 5211 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
5212 | show_lsa_summary (vty, lsa, self); | |
718e3744 | 5213 | |
1318e7c8 | 5214 | vty_out (vty, "%s", VTYNL); |
718e3744 | 5215 | } |
5216 | } | |
5217 | } | |
5218 | ||
5219 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) | |
5220 | { | |
5221 | switch (type) | |
5222 | { | |
5223 | case OSPF_AS_EXTERNAL_LSA: | |
718e3744 | 5224 | case OSPF_OPAQUE_AS_LSA: |
e8e1946e | 5225 | break; |
718e3744 | 5226 | default: |
5227 | continue; | |
5228 | } | |
68980084 | 5229 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
5230 | (!self && ospf_lsdb_count (ospf->lsdb, type))) | |
718e3744 | 5231 | { |
5232 | vty_out (vty, " %s%s%s", | |
5233 | show_database_desc[type], | |
1318e7c8 | 5234 | VTYNL, VTYNL); |
718e3744 | 5235 | vty_out (vty, "%s%s", show_database_header[type], |
1318e7c8 | 5236 | VTYNL); |
020709f9 | 5237 | |
5238 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) | |
5239 | show_lsa_summary (vty, lsa, self); | |
5240 | ||
1318e7c8 | 5241 | vty_out (vty, "%s", VTYNL); |
718e3744 | 5242 | } |
5243 | } | |
5244 | ||
1318e7c8 | 5245 | vty_out (vty, "%s", VTYNL); |
718e3744 | 5246 | } |
5247 | ||
4dadc291 | 5248 | static void |
020709f9 | 5249 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
718e3744 | 5250 | { |
91e6a0e5 | 5251 | struct route_node *rn; |
718e3744 | 5252 | |
5253 | vty_out (vty, "%s MaxAge Link States:%s%s", | |
1318e7c8 | 5254 | VTYNL, VTYNL, VTYNL); |
718e3744 | 5255 | |
91e6a0e5 | 5256 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
1eb8ef25 | 5257 | { |
91e6a0e5 DD |
5258 | struct ospf_lsa *lsa; |
5259 | ||
5260 | if ((lsa = rn->info) != NULL) | |
5261 | { | |
1318e7c8 | 5262 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTYNL); |
91e6a0e5 | 5263 | vty_out (vty, "Link State ID: %s%s", |
1318e7c8 | 5264 | inet_ntoa (lsa->data->id), VTYNL); |
91e6a0e5 | 5265 | vty_out (vty, "Advertising Router: %s%s", |
1318e7c8 QY |
5266 | inet_ntoa (lsa->data->adv_router), VTYNL); |
5267 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTYNL); | |
5268 | vty_out (vty, "%s", VTYNL); | |
91e6a0e5 | 5269 | } |
1eb8ef25 | 5270 | } |
718e3744 | 5271 | } |
5272 | ||
718e3744 | 5273 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
5274 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" | |
718e3744 | 5275 | |
718e3744 | 5276 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
5277 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" | |
5278 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" | |
5279 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" | |
718e3744 | 5280 | |
718e3744 | 5281 | #define OSPF_LSA_TYPES_DESC \ |
5282 | "ASBR summary link states\n" \ | |
5283 | "External link states\n" \ | |
5284 | "Network link states\n" \ | |
5285 | "Router link states\n" \ | |
5286 | "Network summary link states\n" \ | |
5287 | OSPF_LSA_TYPE_NSSA_DESC \ | |
5288 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ | |
5289 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ | |
5290 | OSPF_LSA_TYPE_OPAQUE_AS_DESC | |
5291 | ||
7c8ff89e DS |
5292 | static int |
5293 | show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 5294 | int arg_base, int argc, struct cmd_token **argv) |
718e3744 | 5295 | { |
7a7be519 | 5296 | int idx_type = 4; |
718e3744 | 5297 | int type, ret; |
5298 | struct in_addr id, adv_router; | |
5299 | ||
7c8ff89e | 5300 | if (ospf->instance) |
1318e7c8 QY |
5301 | vty_out (vty, "%sOSPF Instance: %d%s", VTYNL, ospf->instance, |
5302 | VTYNL); | |
718e3744 | 5303 | |
1318e7c8 QY |
5304 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTYNL, |
5305 | inet_ntoa (ospf->router_id), VTYNL, VTYNL); | |
718e3744 | 5306 | |
5307 | /* Show all LSA. */ | |
7a7be519 | 5308 | if (argc == arg_base + 4) |
718e3744 | 5309 | { |
020709f9 | 5310 | show_ip_ospf_database_summary (vty, ospf, 0); |
718e3744 | 5311 | return CMD_SUCCESS; |
5312 | } | |
5313 | ||
5314 | /* Set database type to show. */ | |
7a7be519 | 5315 | if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) |
718e3744 | 5316 | type = OSPF_ROUTER_LSA; |
7a7be519 | 5317 | else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) |
718e3744 | 5318 | type = OSPF_NETWORK_LSA; |
7a7be519 | 5319 | else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) |
718e3744 | 5320 | type = OSPF_AS_NSSA_LSA; |
7a7be519 | 5321 | else if (strncmp (argv[arg_base + idx_type]->text, "su", 2) == 0) |
718e3744 | 5322 | type = OSPF_SUMMARY_LSA; |
7a7be519 | 5323 | else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) |
718e3744 | 5324 | type = OSPF_ASBR_SUMMARY_LSA; |
7a7be519 | 5325 | else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) |
718e3744 | 5326 | type = OSPF_AS_EXTERNAL_LSA; |
7a7be519 | 5327 | else if (strncmp (argv[arg_base + idx_type]->text, "se", 2) == 0) |
718e3744 | 5328 | { |
020709f9 | 5329 | show_ip_ospf_database_summary (vty, ospf, 1); |
718e3744 | 5330 | return CMD_SUCCESS; |
5331 | } | |
7a7be519 | 5332 | else if (strncmp (argv[arg_base + idx_type]->text, "m", 1) == 0) |
718e3744 | 5333 | { |
020709f9 | 5334 | show_ip_ospf_database_maxage (vty, ospf); |
718e3744 | 5335 | return CMD_SUCCESS; |
5336 | } | |
7a7be519 | 5337 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) |
718e3744 | 5338 | type = OSPF_OPAQUE_LINK_LSA; |
7a7be519 | 5339 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) |
718e3744 | 5340 | type = OSPF_OPAQUE_AREA_LSA; |
7a7be519 | 5341 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) |
718e3744 | 5342 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5343 | else |
5344 | return CMD_WARNING; | |
5345 | ||
5346 | /* `show ip ospf database LSA'. */ | |
7a7be519 | 5347 | if (argc == arg_base + 5) |
020709f9 | 5348 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
7a7be519 | 5349 | else if (argc >= arg_base + 6) |
718e3744 | 5350 | { |
7a7be519 | 5351 | ret = inet_aton (argv[arg_base + 5]->arg, &id); |
718e3744 | 5352 | if (!ret) |
5353 | return CMD_WARNING; | |
5354 | ||
5355 | /* `show ip ospf database LSA ID'. */ | |
7a7be519 | 5356 | if (argc == arg_base + 6) |
020709f9 | 5357 | show_lsa_detail (vty, ospf, type, &id, NULL); |
718e3744 | 5358 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
7a7be519 | 5359 | else if (argc == arg_base + 7) |
718e3744 | 5360 | { |
7a7be519 | 5361 | if (strncmp (argv[arg_base + 6]->text, "s", 1) == 0) |
68980084 | 5362 | adv_router = ospf->router_id; |
718e3744 | 5363 | else |
5364 | { | |
7a7be519 | 5365 | ret = inet_aton (argv[arg_base + 7]->arg, &adv_router); |
718e3744 | 5366 | if (!ret) |
5367 | return CMD_WARNING; | |
5368 | } | |
020709f9 | 5369 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
718e3744 | 5370 | } |
5371 | } | |
5372 | ||
5373 | return CMD_SUCCESS; | |
5374 | } | |
5375 | ||
7a7be519 | 5376 | DEFUN (show_ip_ospf_database_max, |
5377 | show_ip_ospf_database_max_cmd, | |
5378 | "show ip ospf database <max-age|self-originate>", | |
5379 | SHOW_STR | |
5380 | IP_STR | |
5381 | "OSPF information\n" | |
5382 | "Database summary\n" | |
5383 | "LSAs in MaxAge list\n" | |
5384 | "Self-originated link states\n") | |
5385 | { | |
5386 | struct ospf *ospf; | |
f412b39a | 5387 | |
7a7be519 | 5388 | if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) |
5389 | return CMD_SUCCESS; | |
f412b39a | 5390 | |
7a7be519 | 5391 | return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv)); |
5392 | } | |
f412b39a | 5393 | |
f412b39a DW |
5394 | DEFUN (show_ip_ospf_instance_database, |
5395 | show_ip_ospf_instance_database_cmd, | |
3a2d747c | 5396 | "show ip ospf [(1-65535)] database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]", |
718e3744 | 5397 | SHOW_STR |
5398 | IP_STR | |
5399 | "OSPF information\n" | |
7c8ff89e | 5400 | "Instance ID\n" |
7a7be519 | 5401 | "Database summary\n" |
5402 | OSPF_LSA_TYPES_DESC | |
5403 | "Link State ID (as an IP address)\n" | |
5404 | "Self-originated link states\n" | |
5405 | "Advertising Router link states\n" | |
5406 | "Advertising Router (as an IP address)\n") | |
7c8ff89e DS |
5407 | { |
5408 | struct ospf *ospf; | |
5409 | u_short instance = 0; | |
5410 | ||
3a2d747c QY |
5411 | int idx = 0; |
5412 | if (argv_find (argv, argc, "(1-65535)", &idx)) | |
5413 | { | |
facfee22 | 5414 | instance = strtoul(argv[idx]->arg, NULL, 10); |
3a2d747c QY |
5415 | ospf = ospf_lookup_instance (instance); |
5416 | } | |
5417 | else { | |
5418 | ospf = ospf_lookup(); | |
5419 | } | |
7c8ff89e | 5420 | |
3a2d747c | 5421 | if (!ospf || !ospf->oi_running) |
7c8ff89e DS |
5422 | return CMD_SUCCESS; |
5423 | ||
3a2d747c | 5424 | return (show_ip_ospf_database_common(vty, ospf, idx ? 1 : 0, argc, argv)); |
7c8ff89e DS |
5425 | } |
5426 | ||
7a7be519 | 5427 | DEFUN (show_ip_ospf_instance_database_max, |
5428 | show_ip_ospf_instance_database_max_cmd, | |
5429 | "show ip ospf (1-65535) database <max-age|self-originate>", | |
5430 | SHOW_STR | |
5431 | IP_STR | |
5432 | "OSPF information\n" | |
5433 | "Instance ID\n" | |
5434 | "Database summary\n" | |
5435 | "LSAs in MaxAge list\n" | |
5436 | "Self-originated link states\n") | |
5437 | { | |
5438 | int idx_number = 3; | |
5439 | struct ospf *ospf; | |
5440 | u_short instance = 0; | |
7c8ff89e | 5441 | |
facfee22 | 5442 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7c8ff89e | 5443 | |
7a7be519 | 5444 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
5445 | return CMD_SUCCESS; | |
7c8ff89e | 5446 | |
7a7be519 | 5447 | return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv)); |
5448 | } | |
7c8ff89e DS |
5449 | |
5450 | ||
5451 | static int | |
5452 | show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf, | |
7a7be519 | 5453 | int arg_base, int argc, struct cmd_token **argv) |
718e3744 | 5454 | { |
7a7be519 | 5455 | int idx_type = 4; |
718e3744 | 5456 | int type, ret; |
5457 | struct in_addr adv_router; | |
5458 | ||
7c8ff89e | 5459 | if (ospf->instance) |
1318e7c8 QY |
5460 | vty_out (vty, "%sOSPF Instance: %d%s", VTYNL, ospf->instance, |
5461 | VTYNL); | |
718e3744 | 5462 | |
1318e7c8 QY |
5463 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTYNL, |
5464 | inet_ntoa (ospf->router_id), VTYNL, VTYNL); | |
718e3744 | 5465 | |
718e3744 | 5466 | /* Set database type to show. */ |
7a7be519 | 5467 | if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) |
718e3744 | 5468 | type = OSPF_ROUTER_LSA; |
7a7be519 | 5469 | else if (strncmp (argv[arg_base + idx_type]->text, "ne", 2) == 0) |
718e3744 | 5470 | type = OSPF_NETWORK_LSA; |
7a7be519 | 5471 | else if (strncmp (argv[arg_base + idx_type]->text, "ns", 2) == 0) |
718e3744 | 5472 | type = OSPF_AS_NSSA_LSA; |
7a7be519 | 5473 | else if (strncmp (argv[arg_base + idx_type]->text, "s", 1) == 0) |
718e3744 | 5474 | type = OSPF_SUMMARY_LSA; |
7a7be519 | 5475 | else if (strncmp (argv[arg_base + idx_type]->text, "a", 1) == 0) |
718e3744 | 5476 | type = OSPF_ASBR_SUMMARY_LSA; |
7a7be519 | 5477 | else if (strncmp (argv[arg_base + idx_type]->text, "e", 1) == 0) |
718e3744 | 5478 | type = OSPF_AS_EXTERNAL_LSA; |
7a7be519 | 5479 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-l", 8) == 0) |
718e3744 | 5480 | type = OSPF_OPAQUE_LINK_LSA; |
7a7be519 | 5481 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-ar", 9) == 0) |
718e3744 | 5482 | type = OSPF_OPAQUE_AREA_LSA; |
7a7be519 | 5483 | else if (strncmp (argv[arg_base + idx_type]->text, "opaque-as", 9) == 0) |
718e3744 | 5484 | type = OSPF_OPAQUE_AS_LSA; |
718e3744 | 5485 | else |
5486 | return CMD_WARNING; | |
5487 | ||
7c8ff89e | 5488 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
7a7be519 | 5489 | if (strncmp (argv[arg_base + 5]->text, "s", 1) == 0) |
7c8ff89e DS |
5490 | adv_router = ospf->router_id; |
5491 | else | |
5492 | { | |
7a7be519 | 5493 | ret = inet_aton (argv[arg_base + 6]->arg, &adv_router); |
7c8ff89e DS |
5494 | if (!ret) |
5495 | return CMD_WARNING; | |
5496 | } | |
5497 | ||
5498 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); | |
5499 | ||
5500 | return CMD_SUCCESS; | |
5501 | } | |
5502 | ||
7c8ff89e DS |
5503 | DEFUN (show_ip_ospf_instance_database_type_adv_router, |
5504 | show_ip_ospf_instance_database_type_adv_router_cmd, | |
36337a6d | 5505 | "show ip ospf [(1-65535)] database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>", |
7c8ff89e DS |
5506 | SHOW_STR |
5507 | IP_STR | |
5508 | "OSPF information\n" | |
5509 | "Instance ID\n" | |
5510 | "Database summary\n" | |
5511 | OSPF_LSA_TYPES_DESC | |
5512 | "Advertising Router link states\n" | |
3a2d747c QY |
5513 | "Advertising Router (as an IP address)\n" |
5514 | "Self-originated link states\n") | |
7c8ff89e DS |
5515 | { |
5516 | struct ospf *ospf; | |
5517 | u_short instance = 0; | |
36337a6d | 5518 | int idx = 0; |
7c8ff89e | 5519 | |
36337a6d DS |
5520 | if (argv_find(argv, argc, "(1-65535)", &idx)) |
5521 | { | |
5522 | instance = strtoul(argv[idx]->arg, NULL, 10); | |
5523 | ospf = ospf_lookup_instance(instance); | |
5524 | } | |
5525 | else | |
5526 | ospf = ospf_lookup(); | |
718e3744 | 5527 | |
36337a6d | 5528 | if (!ospf || !ospf->oi_running) |
7c8ff89e | 5529 | return CMD_SUCCESS; |
718e3744 | 5530 | |
36337a6d | 5531 | return (show_ip_ospf_database_type_adv_router_common(vty, ospf, idx ? 1 : 0, argc, argv)); |
718e3744 | 5532 | } |
5533 | ||
718e3744 | 5534 | DEFUN (ip_ospf_authentication_args, |
5535 | ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 5536 | "ip ospf authentication <null|message-digest> [A.B.C.D]", |
718e3744 | 5537 | "IP Information\n" |
5538 | "OSPF interface commands\n" | |
5539 | "Enable authentication on this interface\n" | |
5540 | "Use null authentication\n" | |
5541 | "Use message-digest authentication\n" | |
7a7be519 | 5542 | "Address of interface\n") |
718e3744 | 5543 | { |
cdc2d765 | 5544 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 DW |
5545 | int idx_encryption = 3; |
5546 | int idx_ipv4 = 4; | |
718e3744 | 5547 | struct in_addr addr; |
5548 | int ret; | |
5549 | struct ospf_if_params *params; | |
5550 | ||
718e3744 | 5551 | params = IF_DEF_PARAMS (ifp); |
5552 | ||
7a7be519 | 5553 | if (argc == 5) |
718e3744 | 5554 | { |
8d769265 | 5555 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5556 | if (!ret) |
5557 | { | |
5558 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5559 | VTYNL); |
718e3744 | 5560 | return CMD_WARNING; |
5561 | } | |
5562 | ||
5563 | params = ospf_get_if_params (ifp, addr); | |
5564 | ospf_if_update_params (ifp, addr); | |
5565 | } | |
5566 | ||
5567 | /* Handle null authentication */ | |
8d769265 | 5568 | if ( argv[idx_encryption]->arg[0] == 'n' ) |
718e3744 | 5569 | { |
5570 | SET_IF_PARAM (params, auth_type); | |
5571 | params->auth_type = OSPF_AUTH_NULL; | |
5572 | return CMD_SUCCESS; | |
5573 | } | |
5574 | ||
5575 | /* Handle message-digest authentication */ | |
8d769265 | 5576 | if ( argv[idx_encryption]->arg[0] == 'm' ) |
718e3744 | 5577 | { |
5578 | SET_IF_PARAM (params, auth_type); | |
5579 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5580 | return CMD_SUCCESS; | |
5581 | } | |
5582 | ||
1318e7c8 | 5583 | vty_out (vty, "You shouldn't get here!%s", VTYNL); |
718e3744 | 5584 | return CMD_WARNING; |
5585 | } | |
5586 | ||
718e3744 | 5587 | DEFUN (ip_ospf_authentication, |
5588 | ip_ospf_authentication_addr_cmd, | |
7a7be519 | 5589 | "ip ospf authentication [A.B.C.D]", |
718e3744 | 5590 | "IP Information\n" |
5591 | "OSPF interface commands\n" | |
5592 | "Enable authentication on this interface\n" | |
5593 | "Address of interface") | |
5594 | { | |
cdc2d765 | 5595 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 5596 | int idx_ipv4 = 3; |
718e3744 | 5597 | struct in_addr addr; |
5598 | int ret; | |
5599 | struct ospf_if_params *params; | |
5600 | ||
718e3744 | 5601 | params = IF_DEF_PARAMS (ifp); |
5602 | ||
7a7be519 | 5603 | if (argc == 4) |
718e3744 | 5604 | { |
8d769265 | 5605 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5606 | if (!ret) |
5607 | { | |
5608 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5609 | VTYNL); |
718e3744 | 5610 | return CMD_WARNING; |
5611 | } | |
5612 | ||
5613 | params = ospf_get_if_params (ifp, addr); | |
5614 | ospf_if_update_params (ifp, addr); | |
5615 | } | |
5616 | ||
5617 | SET_IF_PARAM (params, auth_type); | |
5618 | params->auth_type = OSPF_AUTH_SIMPLE; | |
5619 | ||
5620 | return CMD_SUCCESS; | |
5621 | } | |
5622 | ||
b4a039bf DS |
5623 | DEFUN (no_ip_ospf_authentication_args, |
5624 | no_ip_ospf_authentication_args_addr_cmd, | |
7a7be519 | 5625 | "no ip ospf authentication <null|message-digest> [A.B.C.D]", |
b4a039bf DS |
5626 | NO_STR |
5627 | "IP Information\n" | |
5628 | "OSPF interface commands\n" | |
5629 | "Enable authentication on this interface\n" | |
5630 | "Use null authentication\n" | |
5631 | "Use message-digest authentication\n" | |
5632 | "Address of interface") | |
5633 | { | |
cdc2d765 | 5634 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 DW |
5635 | int idx_encryption = 4; |
5636 | int idx_ipv4 = 5; | |
b4a039bf DS |
5637 | struct in_addr addr; |
5638 | int ret; | |
5639 | struct ospf_if_params *params; | |
5640 | struct route_node *rn; | |
5641 | int auth_type; | |
5642 | ||
b4a039bf DS |
5643 | params = IF_DEF_PARAMS (ifp); |
5644 | ||
7a7be519 | 5645 | if (argc == 6) |
b4a039bf | 5646 | { |
8d769265 | 5647 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
b4a039bf DS |
5648 | if (!ret) |
5649 | { | |
5650 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5651 | VTYNL); |
b4a039bf DS |
5652 | return CMD_WARNING; |
5653 | } | |
5654 | ||
5655 | params = ospf_lookup_if_params (ifp, addr); | |
5656 | if (params == NULL) | |
5657 | { | |
1318e7c8 | 5658 | vty_out (vty, "Ip Address specified is unknown%s", VTYNL); |
b4a039bf DS |
5659 | return CMD_WARNING; |
5660 | } | |
5661 | params->auth_type = OSPF_AUTH_NOTSET; | |
5662 | UNSET_IF_PARAM (params, auth_type); | |
5663 | if (params != IF_DEF_PARAMS (ifp)) | |
5664 | { | |
5665 | ospf_free_if_params (ifp, addr); | |
5666 | ospf_if_update_params (ifp, addr); | |
5667 | } | |
5668 | } | |
5669 | else | |
5670 | { | |
8d769265 | 5671 | if ( argv[idx_encryption]->arg[0] == 'n' ) |
b4a039bf DS |
5672 | { |
5673 | auth_type = OSPF_AUTH_NULL; | |
5674 | } | |
8d769265 | 5675 | else if ( argv[idx_encryption]->arg[0] == 'm' ) |
b4a039bf DS |
5676 | { |
5677 | auth_type = OSPF_AUTH_CRYPTOGRAPHIC; | |
5678 | } | |
5679 | else | |
5680 | { | |
1318e7c8 | 5681 | vty_out (vty, "Unexpected input encountered%s", VTYNL); |
b4a039bf DS |
5682 | return CMD_WARNING; |
5683 | } | |
5684 | /* | |
5685 | * Here we have a case where the user has entered | |
5686 | * 'no ip ospf authentication (null | message_digest )' | |
5687 | * we need to find if we have any ip addresses underneath it that | |
5688 | * correspond to the associated type. | |
5689 | */ | |
813d4307 DW |
5690 | if (params->auth_type == auth_type) |
5691 | { | |
5692 | params->auth_type = OSPF_AUTH_NOTSET; | |
5693 | UNSET_IF_PARAM (params, auth_type); | |
5694 | } | |
5695 | ||
b4a039bf DS |
5696 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
5697 | { | |
5698 | if ((params = rn->info)) | |
5699 | { | |
5700 | if (params->auth_type == auth_type) | |
5701 | { | |
5702 | params->auth_type = OSPF_AUTH_NOTSET; | |
5703 | UNSET_IF_PARAM (params, auth_type); | |
5704 | if (params != IF_DEF_PARAMS (ifp)) | |
5705 | { | |
5706 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
5707 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
5708 | } | |
5709 | } | |
5710 | } | |
5711 | } | |
5712 | } | |
5713 | ||
5714 | return CMD_SUCCESS; | |
5715 | } | |
5716 | ||
718e3744 | 5717 | DEFUN (no_ip_ospf_authentication, |
5718 | no_ip_ospf_authentication_addr_cmd, | |
7a7be519 | 5719 | "no ip ospf authentication [A.B.C.D]", |
718e3744 | 5720 | NO_STR |
5721 | "IP Information\n" | |
5722 | "OSPF interface commands\n" | |
5723 | "Enable authentication on this interface\n" | |
5724 | "Address of interface") | |
5725 | { | |
cdc2d765 | 5726 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 5727 | int idx_ipv4 = 4; |
718e3744 | 5728 | struct in_addr addr; |
5729 | int ret; | |
5730 | struct ospf_if_params *params; | |
b4a039bf DS |
5731 | struct route_node *rn; |
5732 | ||
718e3744 | 5733 | params = IF_DEF_PARAMS (ifp); |
5734 | ||
7a7be519 | 5735 | if (argc == 5) |
718e3744 | 5736 | { |
8d769265 | 5737 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 5738 | if (!ret) |
5739 | { | |
5740 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5741 | VTYNL); |
718e3744 | 5742 | return CMD_WARNING; |
5743 | } | |
5744 | ||
5745 | params = ospf_lookup_if_params (ifp, addr); | |
5746 | if (params == NULL) | |
b4a039bf | 5747 | { |
1318e7c8 | 5748 | vty_out (vty, "Ip Address specified is unknown%s", VTYNL); |
b4a039bf DS |
5749 | return CMD_WARNING; |
5750 | } | |
718e3744 | 5751 | |
b4a039bf DS |
5752 | params->auth_type = OSPF_AUTH_NOTSET; |
5753 | UNSET_IF_PARAM (params, auth_type); | |
5754 | if (params != IF_DEF_PARAMS (ifp)) | |
5755 | { | |
5756 | ospf_free_if_params (ifp, addr); | |
5757 | ospf_if_update_params (ifp, addr); | |
5758 | } | |
5759 | } | |
5760 | else | |
718e3744 | 5761 | { |
b4a039bf DS |
5762 | /* |
5763 | * When a user enters 'no ip ospf authentication' | |
5764 | * We should remove all authentication types from | |
5765 | * the interface. | |
5766 | */ | |
813d4307 DW |
5767 | if ((params->auth_type == OSPF_AUTH_NULL) || |
5768 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
5769 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
5770 | { | |
5771 | params->auth_type = OSPF_AUTH_NOTSET; | |
5772 | UNSET_IF_PARAM (params, auth_type); | |
5773 | } | |
5774 | ||
b4a039bf DS |
5775 | for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn)) |
5776 | { | |
5777 | if ((params = rn->info)) | |
5778 | { | |
813d4307 | 5779 | |
b4a039bf DS |
5780 | if ((params->auth_type == OSPF_AUTH_NULL) || |
5781 | (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) || | |
5782 | (params->auth_type == OSPF_AUTH_SIMPLE)) | |
5783 | { | |
5784 | params->auth_type = OSPF_AUTH_NOTSET; | |
5785 | UNSET_IF_PARAM (params, auth_type); | |
5786 | if (params != IF_DEF_PARAMS (ifp)) | |
5787 | { | |
5788 | ospf_free_if_params (ifp, rn->p.u.prefix4); | |
5789 | ospf_if_update_params(ifp, rn->p.u.prefix4); | |
5790 | } | |
5791 | } | |
5792 | } | |
5793 | } | |
718e3744 | 5794 | } |
5795 | ||
5796 | return CMD_SUCCESS; | |
5797 | } | |
5798 | ||
0d829fa7 | 5799 | |
718e3744 | 5800 | DEFUN (ip_ospf_authentication_key, |
5801 | ip_ospf_authentication_key_addr_cmd, | |
7a7be519 | 5802 | "ip ospf authentication-key AUTH_KEY [A.B.C.D]", |
718e3744 | 5803 | "IP Information\n" |
5804 | "OSPF interface commands\n" | |
5805 | "Authentication password (key)\n" | |
5806 | "The OSPF password (key)\n" | |
5807 | "Address of interface") | |
5808 | { | |
cdc2d765 | 5809 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 5810 | int idx = 0; |
718e3744 | 5811 | struct in_addr addr; |
718e3744 | 5812 | struct ospf_if_params *params; |
5813 | ||
718e3744 | 5814 | params = IF_DEF_PARAMS (ifp); |
5815 | ||
0d829fa7 | 5816 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 5817 | { |
0d829fa7 | 5818 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 5819 | { |
5820 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5821 | VTYNL); |
718e3744 | 5822 | return CMD_WARNING; |
5823 | } | |
5824 | ||
5825 | params = ospf_get_if_params (ifp, addr); | |
5826 | ospf_if_update_params (ifp, addr); | |
5827 | } | |
5828 | ||
718e3744 | 5829 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
7a7be519 | 5830 | strncpy ((char *) params->auth_simple, argv[3]->arg, OSPF_AUTH_SIMPLE_SIZE); |
718e3744 | 5831 | SET_IF_PARAM (params, auth_simple); |
5832 | ||
5833 | return CMD_SUCCESS; | |
5834 | } | |
5835 | ||
7a7be519 | 5836 | DEFUN_HIDDEN (ospf_authentication_key, |
747e489c | 5837 | ospf_authentication_key_cmd, |
0d829fa7 | 5838 | "ospf authentication-key AUTH_KEY [A.B.C.D]", |
747e489c DW |
5839 | "OSPF interface commands\n" |
5840 | "Authentication password (key)\n" | |
0d829fa7 QY |
5841 | "The OSPF password (key)\n" |
5842 | "Address of interface\n") | |
718e3744 | 5843 | { |
0d829fa7 | 5844 | return ip_ospf_authentication_key (self, vty, argc, argv); |
718e3744 | 5845 | } |
5846 | ||
7a7be519 | 5847 | DEFUN (no_ip_ospf_authentication_key, |
5848 | no_ip_ospf_authentication_key_authkey_addr_cmd, | |
5849 | "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
5850 | NO_STR | |
5851 | "IP Information\n" | |
5852 | "OSPF interface commands\n" | |
5853 | "Authentication password (key)\n" | |
5854 | "The OSPF password (key)") | |
5855 | { | |
cdc2d765 | 5856 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 5857 | int idx = 0; |
7a7be519 | 5858 | struct in_addr addr; |
5859 | struct ospf_if_params *params; | |
7a7be519 | 5860 | params = IF_DEF_PARAMS (ifp); |
5861 | ||
0d829fa7 | 5862 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 5863 | { |
0d829fa7 | 5864 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 5865 | { |
5866 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5867 | VTYNL); |
7a7be519 | 5868 | return CMD_WARNING; |
5869 | } | |
813d4307 | 5870 | |
7a7be519 | 5871 | params = ospf_lookup_if_params (ifp, addr); |
5872 | if (params == NULL) | |
5873 | return CMD_SUCCESS; | |
5874 | } | |
718e3744 | 5875 | |
7a7be519 | 5876 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
5877 | UNSET_IF_PARAM (params, auth_simple); | |
718e3744 | 5878 | |
7a7be519 | 5879 | if (params != IF_DEF_PARAMS (ifp)) |
5880 | { | |
5881 | ospf_free_if_params (ifp, addr); | |
5882 | ospf_if_update_params (ifp, addr); | |
5883 | } | |
813d4307 | 5884 | |
7a7be519 | 5885 | return CMD_SUCCESS; |
5886 | } | |
813d4307 | 5887 | |
0d829fa7 QY |
5888 | DEFUN_HIDDEN (no_ospf_authentication_key, |
5889 | no_ospf_authentication_key_authkey_addr_cmd, | |
5890 | "no ospf authentication-key [AUTH_KEY [A.B.C.D]]", | |
5891 | NO_STR | |
5892 | "OSPF interface commands\n" | |
5893 | "Authentication password (key)\n" | |
5894 | "The OSPF password (key)") | |
5895 | { | |
5896 | return no_ip_ospf_authentication_key (self, vty, argc, argv); | |
5897 | } | |
5898 | ||
718e3744 | 5899 | DEFUN (ip_ospf_message_digest_key, |
537eae3f | 5900 | ip_ospf_message_digest_key_cmd, |
7a7be519 | 5901 | "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
718e3744 | 5902 | "IP Information\n" |
5903 | "OSPF interface commands\n" | |
5904 | "Message digest authentication password (key)\n" | |
5905 | "Key ID\n" | |
5906 | "Use MD5 algorithm\n" | |
fefa0d82 QY |
5907 | "The OSPF password (key)\n" |
5908 | "Address of interface\n") | |
718e3744 | 5909 | { |
cdc2d765 | 5910 | VTY_DECLVAR_CONTEXT(interface, ifp); |
718e3744 | 5911 | struct crypt_key *ck; |
5912 | u_char key_id; | |
5913 | struct in_addr addr; | |
718e3744 | 5914 | struct ospf_if_params *params; |
5915 | ||
718e3744 | 5916 | params = IF_DEF_PARAMS (ifp); |
fefa0d82 QY |
5917 | int idx = 0; |
5918 | ||
5919 | argv_find (argv, argc, "(1-255)", &idx); | |
0d829fa7 | 5920 | char *keyid = argv[idx]->arg; |
fefa0d82 QY |
5921 | argv_find (argv, argc, "KEY", &idx); |
5922 | char *cryptkey = argv[idx]->arg; | |
718e3744 | 5923 | |
0d829fa7 | 5924 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 5925 | { |
0d829fa7 | 5926 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 5927 | { |
5928 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5929 | VTYNL); |
718e3744 | 5930 | return CMD_WARNING; |
5931 | } | |
5932 | ||
5933 | params = ospf_get_if_params (ifp, addr); | |
5934 | ospf_if_update_params (ifp, addr); | |
5935 | } | |
5936 | ||
fefa0d82 | 5937 | key_id = strtol (keyid, NULL, 10); |
718e3744 | 5938 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
5939 | { | |
1318e7c8 | 5940 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTYNL); |
718e3744 | 5941 | return CMD_WARNING; |
5942 | } | |
5943 | ||
5944 | ck = ospf_crypt_key_new (); | |
5945 | ck->key_id = (u_char) key_id; | |
5946 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); | |
fefa0d82 | 5947 | strncpy ((char *) ck->auth_key, cryptkey, OSPF_AUTH_MD5_SIZE); |
718e3744 | 5948 | |
5949 | ospf_crypt_key_add (params->auth_crypt, ck); | |
5950 | SET_IF_PARAM (params, auth_crypt); | |
5951 | ||
5952 | return CMD_SUCCESS; | |
5953 | } | |
5954 | ||
7a7be519 | 5955 | DEFUN_HIDDEN (ospf_message_digest_key, |
747e489c | 5956 | ospf_message_digest_key_cmd, |
0d829fa7 | 5957 | "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]", |
747e489c DW |
5958 | "OSPF interface commands\n" |
5959 | "Message digest authentication password (key)\n" | |
5960 | "Key ID\n" | |
5961 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
5962 | "The OSPF password (key)\n" |
5963 | "Address of interface\n") | |
7a7be519 | 5964 | { |
0d829fa7 | 5965 | return ip_ospf_message_digest_key (self, vty, argc, argv); |
7a7be519 | 5966 | } |
718e3744 | 5967 | |
537eae3f QY |
5968 | DEFUN (no_ip_ospf_message_digest_key, |
5969 | no_ip_ospf_message_digest_key_cmd, | |
0d829fa7 | 5970 | "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
813d4307 DW |
5971 | NO_STR |
5972 | "IP Information\n" | |
5973 | "OSPF interface commands\n" | |
5974 | "Message digest authentication password (key)\n" | |
5975 | "Key ID\n" | |
5976 | "Use MD5 algorithm\n" | |
0d829fa7 QY |
5977 | "The OSPF password (key)\n" |
5978 | "Address of interface\n") | |
813d4307 | 5979 | { |
cdc2d765 | 5980 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 5981 | int idx = 0; |
813d4307 DW |
5982 | struct crypt_key *ck; |
5983 | int key_id; | |
5984 | struct in_addr addr; | |
813d4307 | 5985 | struct ospf_if_params *params; |
813d4307 DW |
5986 | params = IF_DEF_PARAMS (ifp); |
5987 | ||
0d829fa7 QY |
5988 | argv_find (argv, argc, "(1-255)", &idx); |
5989 | char *keyid = argv[idx]->arg; | |
7a7be519 | 5990 | |
0d829fa7 | 5991 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 5992 | { |
0d829fa7 | 5993 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 5994 | { |
5995 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 5996 | VTYNL); |
7a7be519 | 5997 | return CMD_WARNING; |
5998 | } | |
5999 | ||
6000 | params = ospf_lookup_if_params (ifp, addr); | |
6001 | if (params == NULL) | |
6002 | return CMD_SUCCESS; | |
6003 | } | |
6004 | ||
0d829fa7 | 6005 | key_id = strtol (keyid, NULL, 10); |
7a7be519 | 6006 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
6007 | if (ck == NULL) | |
6008 | { | |
1318e7c8 | 6009 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTYNL); |
7a7be519 | 6010 | return CMD_WARNING; |
6011 | } | |
6012 | ||
6013 | ospf_crypt_key_delete (params->auth_crypt, key_id); | |
6014 | ||
6015 | if (params != IF_DEF_PARAMS (ifp)) | |
6016 | { | |
6017 | ospf_free_if_params (ifp, addr); | |
6018 | ospf_if_update_params (ifp, addr); | |
6019 | } | |
6020 | ||
6021 | return CMD_SUCCESS; | |
6022 | } | |
813d4307 | 6023 | |
0d829fa7 | 6024 | DEFUN_HIDDEN (no_ospf_message_digest_key, |
537eae3f | 6025 | no_ospf_message_digest_key_cmd, |
0d829fa7 QY |
6026 | "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]", |
6027 | NO_STR | |
6028 | "OSPF interface commands\n" | |
6029 | "Message digest authentication password (key)\n" | |
6030 | "Key ID\n" | |
6031 | "Address of interface") | |
718e3744 | 6032 | { |
537eae3f | 6033 | return no_ip_ospf_message_digest_key (self, vty, argc, argv); |
718e3744 | 6034 | } |
6035 | ||
718e3744 | 6036 | DEFUN (ip_ospf_cost, |
5c2fc921 | 6037 | ip_ospf_cost_cmd, |
7a7be519 | 6038 | "ip ospf cost (1-65535) [A.B.C.D]", |
718e3744 | 6039 | "IP Information\n" |
6040 | "OSPF interface commands\n" | |
6041 | "Interface cost\n" | |
6042 | "Cost\n" | |
5c2fc921 | 6043 | "Address of interface\n") |
718e3744 | 6044 | { |
cdc2d765 | 6045 | VTY_DECLVAR_CONTEXT(interface, ifp); |
5c2fc921 | 6046 | int idx = 0; |
718e3744 | 6047 | u_int32_t cost; |
6048 | struct in_addr addr; | |
718e3744 | 6049 | struct ospf_if_params *params; |
718e3744 | 6050 | params = IF_DEF_PARAMS (ifp); |
6051 | ||
5c2fc921 QY |
6052 | // get arguments |
6053 | char *coststr = NULL, *ifaddr = NULL; | |
6054 | coststr = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL; | |
6055 | ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 6056 | |
5c2fc921 | 6057 | cost = strtol (coststr, NULL, 10); |
718e3744 | 6058 | |
5c2fc921 | 6059 | if (ifaddr) |
718e3744 | 6060 | { |
5c2fc921 | 6061 | if(!inet_aton(ifaddr, &addr)) |
718e3744 | 6062 | { |
6063 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6064 | VTYNL); |
718e3744 | 6065 | return CMD_WARNING; |
6066 | } | |
6067 | ||
6068 | params = ospf_get_if_params (ifp, addr); | |
6069 | ospf_if_update_params (ifp, addr); | |
6070 | } | |
6071 | ||
6072 | SET_IF_PARAM (params, output_cost_cmd); | |
6073 | params->output_cost_cmd = cost; | |
6074 | ||
6075 | ospf_if_recalculate_output_cost (ifp); | |
5c2fc921 | 6076 | |
718e3744 | 6077 | return CMD_SUCCESS; |
6078 | } | |
6079 | ||
7a7be519 | 6080 | DEFUN_HIDDEN (ospf_cost, |
5c2fc921 QY |
6081 | ospf_cost_cmd, |
6082 | "ospf cost (1-65535) [A.B.C.D]", | |
747e489c DW |
6083 | "OSPF interface commands\n" |
6084 | "Interface cost\n" | |
6085 | "Cost\n" | |
5c2fc921 | 6086 | "Address of interface\n") |
7a7be519 | 6087 | { |
5c2fc921 | 6088 | return ip_ospf_cost (self, vty, argc, argv); |
7a7be519 | 6089 | } |
9eff36b3 | 6090 | |
718e3744 | 6091 | DEFUN (no_ip_ospf_cost, |
5c2fc921 QY |
6092 | no_ip_ospf_cost_cmd, |
6093 | "no ip ospf cost [(1-65535)] [A.B.C.D]", | |
718e3744 | 6094 | NO_STR |
718e3744 | 6095 | "OSPF interface commands\n" |
6096 | "Interface cost\n" | |
6097 | "Address of interface") | |
6098 | { | |
cdc2d765 | 6099 | VTY_DECLVAR_CONTEXT(interface, ifp); |
5c2fc921 | 6100 | int idx = 0; |
718e3744 | 6101 | struct in_addr addr; |
718e3744 | 6102 | struct ospf_if_params *params; |
7a7be519 | 6103 | |
718e3744 | 6104 | params = IF_DEF_PARAMS (ifp); |
6105 | ||
5c2fc921 QY |
6106 | // get arguments |
6107 | char *ifaddr = NULL; | |
6108 | ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
718e3744 | 6109 | |
7a7be519 | 6110 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
6111 | * always treated as "no ip ospf cost" regardless of the actual value | |
5c2fc921 | 6112 | * of N already configured for the interface. Thus ignore cost. */ |
7a7be519 | 6113 | |
5c2fc921 | 6114 | if (ifaddr) |
7a7be519 | 6115 | { |
5c2fc921 | 6116 | if (!inet_aton(ifaddr, &addr)) |
7a7be519 | 6117 | { |
6118 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6119 | VTYNL); |
7a7be519 | 6120 | return CMD_WARNING; |
6121 | } | |
6122 | ||
6123 | params = ospf_lookup_if_params (ifp, addr); | |
6124 | if (params == NULL) | |
6125 | return CMD_SUCCESS; | |
6126 | } | |
6127 | ||
6128 | UNSET_IF_PARAM (params, output_cost_cmd); | |
6129 | ||
6130 | if (params != IF_DEF_PARAMS (ifp)) | |
6131 | { | |
6132 | ospf_free_if_params (ifp, addr); | |
6133 | ospf_if_update_params (ifp, addr); | |
6134 | } | |
6135 | ||
6136 | ospf_if_recalculate_output_cost (ifp); | |
6137 | ||
6138 | return CMD_SUCCESS; | |
6139 | } | |
9eff36b3 | 6140 | |
5c2fc921 QY |
6141 | DEFUN_HIDDEN (no_ospf_cost, |
6142 | no_ospf_cost_cmd, | |
6143 | "no ospf cost [(1-65535)] [A.B.C.D]", | |
6144 | NO_STR | |
6145 | "OSPF interface commands\n" | |
6146 | "Interface cost\n" | |
6147 | "Cost\n" | |
6148 | "Address of interface\n") | |
827341b7 | 6149 | { |
5c2fc921 | 6150 | return no_ip_ospf_cost (self, vty, argc, argv); |
827341b7 DO |
6151 | } |
6152 | ||
4dadc291 | 6153 | static void |
718e3744 | 6154 | ospf_nbr_timer_update (struct ospf_interface *oi) |
6155 | { | |
6156 | struct route_node *rn; | |
6157 | struct ospf_neighbor *nbr; | |
6158 | ||
6159 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
6160 | if ((nbr = rn->info)) | |
6161 | { | |
6162 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); | |
6163 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); | |
6164 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); | |
6165 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); | |
6166 | } | |
6167 | } | |
6168 | ||
f9ad937f | 6169 | static int |
6170 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, | |
6171 | const char *nbr_str, | |
6172 | const char *fast_hello_str) | |
718e3744 | 6173 | { |
cdc2d765 | 6174 | VTY_DECLVAR_CONTEXT(interface, ifp); |
718e3744 | 6175 | u_int32_t seconds; |
f9ad937f | 6176 | u_char hellomult; |
718e3744 | 6177 | struct in_addr addr; |
6178 | int ret; | |
6179 | struct ospf_if_params *params; | |
6180 | struct ospf_interface *oi; | |
6181 | struct route_node *rn; | |
6182 | ||
6183 | params = IF_DEF_PARAMS (ifp); | |
f9ad937f | 6184 | |
6185 | if (nbr_str) | |
718e3744 | 6186 | { |
f9ad937f | 6187 | ret = inet_aton(nbr_str, &addr); |
718e3744 | 6188 | if (!ret) |
6189 | { | |
6190 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6191 | VTYNL); |
718e3744 | 6192 | return CMD_WARNING; |
6193 | } | |
6194 | ||
6195 | params = ospf_get_if_params (ifp, addr); | |
6196 | ospf_if_update_params (ifp, addr); | |
6197 | } | |
6198 | ||
f9ad937f | 6199 | if (interval_str) |
6200 | { | |
facfee22 | 6201 | seconds = strtoul(interval_str, NULL, 10); |
f9ad937f | 6202 | |
6203 | /* reset fast_hello too, just to be sure */ | |
6204 | UNSET_IF_PARAM (params, fast_hello); | |
6205 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6206 | } | |
6207 | else if (fast_hello_str) | |
6208 | { | |
facfee22 | 6209 | hellomult = strtoul(fast_hello_str, NULL, 10); |
f9ad937f | 6210 | /* 1s dead-interval with sub-second hellos desired */ |
6211 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; | |
6212 | SET_IF_PARAM (params, fast_hello); | |
6213 | params->fast_hello = hellomult; | |
6214 | } | |
6215 | else | |
6216 | { | |
6217 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", | |
1318e7c8 | 6218 | VTYNL); |
f9ad937f | 6219 | return CMD_WARNING; |
6220 | } | |
6221 | ||
718e3744 | 6222 | SET_IF_PARAM (params, v_wait); |
6223 | params->v_wait = seconds; | |
6224 | ||
6225 | /* Update timer values in neighbor structure. */ | |
f9ad937f | 6226 | if (nbr_str) |
718e3744 | 6227 | { |
cac3b5c4 PJ |
6228 | struct ospf *ospf; |
6229 | if ((ospf = ospf_lookup())) | |
68980084 | 6230 | { |
6231 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6232 | if (oi) | |
6233 | ospf_nbr_timer_update (oi); | |
6234 | } | |
718e3744 | 6235 | } |
6236 | else | |
6237 | { | |
6238 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6239 | if ((oi = rn->info)) | |
6240 | ospf_nbr_timer_update (oi); | |
6241 | } | |
6242 | ||
6243 | return CMD_SUCCESS; | |
6244 | } | |
6245 | ||
f9ad937f | 6246 | DEFUN (ip_ospf_dead_interval, |
0d829fa7 | 6247 | ip_ospf_dead_interval_cmd, |
7a7be519 | 6248 | "ip ospf dead-interval (1-65535) [A.B.C.D]", |
f9ad937f | 6249 | "IP Information\n" |
6250 | "OSPF interface commands\n" | |
99a522c7 | 6251 | "Interval time after which a neighbor is declared down\n" |
f9ad937f | 6252 | "Seconds\n" |
6253 | "Address of interface\n") | |
6254 | { | |
0d829fa7 QY |
6255 | int idx = 0; |
6256 | char *interval = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL; | |
6257 | char *ifaddr = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; | |
6258 | return ospf_vty_dead_interval_set (vty, interval, ifaddr, NULL); | |
f9ad937f | 6259 | } |
6260 | ||
718e3744 | 6261 | |
7a7be519 | 6262 | DEFUN_HIDDEN (ospf_dead_interval, |
747e489c | 6263 | ospf_dead_interval_cmd, |
0d829fa7 | 6264 | "ospf dead-interval (1-65535) [A.B.C.D]", |
747e489c | 6265 | "OSPF interface commands\n" |
99a522c7 | 6266 | "Interval time after which a neighbor is declared down\n" |
0d829fa7 QY |
6267 | "Seconds\n" |
6268 | "Address of interface\n") | |
7a7be519 | 6269 | { |
0d829fa7 | 6270 | return ip_ospf_dead_interval (self, vty, argc, argv); |
7a7be519 | 6271 | } |
718e3744 | 6272 | |
f9ad937f | 6273 | DEFUN (ip_ospf_dead_interval_minimal, |
6274 | ip_ospf_dead_interval_minimal_addr_cmd, | |
7a7be519 | 6275 | "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]", |
f9ad937f | 6276 | "IP Information\n" |
6277 | "OSPF interface commands\n" | |
99a522c7 | 6278 | "Interval time after which a neighbor is declared down\n" |
f9ad937f | 6279 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
6280 | "Hello multiplier factor\n" | |
6281 | "Number of Hellos to send each second\n" | |
6282 | "Address of interface\n") | |
6283 | { | |
8d769265 DW |
6284 | int idx_number = 5; |
6285 | int idx_ipv4 = 6; | |
7a7be519 | 6286 | if (argc == 7) |
8d769265 | 6287 | return ospf_vty_dead_interval_set (vty, NULL, argv[idx_ipv4]->arg, argv[idx_number]->arg); |
f9ad937f | 6288 | else |
8d769265 | 6289 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[idx_number]->arg); |
f9ad937f | 6290 | } |
6291 | ||
718e3744 | 6292 | DEFUN (no_ip_ospf_dead_interval, |
0d829fa7 | 6293 | no_ip_ospf_dead_interval_cmd, |
e83a9414 | 6294 | "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", |
718e3744 | 6295 | NO_STR |
6296 | "IP Information\n" | |
6297 | "OSPF interface commands\n" | |
99a522c7 | 6298 | "Interval time after which a neighbor is declared down\n" |
f9dfba8d | 6299 | "Seconds\n" |
718e3744 | 6300 | "Address of interface") |
6301 | { | |
cdc2d765 | 6302 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7a7be519 | 6303 | int idx_ipv4 = argc - 1; |
c604467a | 6304 | struct in_addr addr = { .s_addr = 0L}; |
718e3744 | 6305 | int ret; |
6306 | struct ospf_if_params *params; | |
6307 | struct ospf_interface *oi; | |
6308 | struct route_node *rn; | |
020709f9 | 6309 | |
718e3744 | 6310 | params = IF_DEF_PARAMS (ifp); |
6311 | ||
7a7be519 | 6312 | if (argv[idx_ipv4]->type == IPV4_TKN) |
718e3744 | 6313 | { |
8d769265 | 6314 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
718e3744 | 6315 | if (!ret) |
6316 | { | |
6317 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6318 | VTYNL); |
718e3744 | 6319 | return CMD_WARNING; |
6320 | } | |
6321 | ||
6322 | params = ospf_lookup_if_params (ifp, addr); | |
6323 | if (params == NULL) | |
6324 | return CMD_SUCCESS; | |
6325 | } | |
6326 | ||
6327 | UNSET_IF_PARAM (params, v_wait); | |
6328 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; | |
f9ad937f | 6329 | |
6330 | UNSET_IF_PARAM (params, fast_hello); | |
6331 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; | |
6332 | ||
718e3744 | 6333 | if (params != IF_DEF_PARAMS (ifp)) |
6334 | { | |
6335 | ospf_free_if_params (ifp, addr); | |
6336 | ospf_if_update_params (ifp, addr); | |
6337 | } | |
6338 | ||
6339 | /* Update timer values in neighbor structure. */ | |
6340 | if (argc == 1) | |
6341 | { | |
cac3b5c4 PJ |
6342 | struct ospf *ospf; |
6343 | ||
6344 | if ((ospf = ospf_lookup())) | |
68980084 | 6345 | { |
6346 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); | |
6347 | if (oi) | |
6348 | ospf_nbr_timer_update (oi); | |
6349 | } | |
718e3744 | 6350 | } |
6351 | else | |
6352 | { | |
6353 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6354 | if ((oi = rn->info)) | |
6355 | ospf_nbr_timer_update (oi); | |
6356 | } | |
6357 | ||
6358 | return CMD_SUCCESS; | |
6359 | } | |
6360 | ||
0d829fa7 QY |
6361 | DEFUN_HIDDEN (no_ospf_dead_interval, |
6362 | no_ospf_dead_interval_cmd, | |
6363 | "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]", | |
6364 | NO_STR | |
6365 | "OSPF interface commands\n" | |
99a522c7 | 6366 | "Interval time after which a neighbor is declared down\n" |
0d829fa7 QY |
6367 | "Seconds\n" |
6368 | "Address of interface") | |
6369 | { | |
6370 | return no_ip_ospf_dead_interval (self, vty, argc, argv); | |
6371 | } | |
6372 | ||
718e3744 | 6373 | DEFUN (ip_ospf_hello_interval, |
0d829fa7 | 6374 | ip_ospf_hello_interval_cmd, |
7a7be519 | 6375 | "ip ospf hello-interval (1-65535) [A.B.C.D]", |
718e3744 | 6376 | "IP Information\n" |
6377 | "OSPF interface commands\n" | |
6378 | "Time between HELLO packets\n" | |
6379 | "Seconds\n" | |
0d829fa7 | 6380 | "Address of interface\n") |
718e3744 | 6381 | { |
cdc2d765 | 6382 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6383 | int idx = 0; |
718e3744 | 6384 | struct in_addr addr; |
718e3744 | 6385 | struct ospf_if_params *params; |
718e3744 | 6386 | params = IF_DEF_PARAMS (ifp); |
0d829fa7 | 6387 | u_int32_t seconds = 0; |
718e3744 | 6388 | |
0d829fa7 QY |
6389 | argv_find (argv, argc, "(1-65535)", &idx); |
6390 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6391 | |
0d829fa7 | 6392 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6393 | { |
0d829fa7 | 6394 | if(!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6395 | { |
6396 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6397 | VTYNL); |
718e3744 | 6398 | return CMD_WARNING; |
6399 | } | |
6400 | ||
6401 | params = ospf_get_if_params (ifp, addr); | |
6402 | ospf_if_update_params (ifp, addr); | |
6403 | } | |
6404 | ||
f9ad937f | 6405 | SET_IF_PARAM (params, v_hello); |
718e3744 | 6406 | params->v_hello = seconds; |
6407 | ||
6408 | return CMD_SUCCESS; | |
6409 | } | |
6410 | ||
7a7be519 | 6411 | DEFUN_HIDDEN (ospf_hello_interval, |
747e489c | 6412 | ospf_hello_interval_cmd, |
0d829fa7 | 6413 | "ospf hello-interval (1-65535) [A.B.C.D]", |
747e489c DW |
6414 | "OSPF interface commands\n" |
6415 | "Time between HELLO packets\n" | |
0d829fa7 QY |
6416 | "Seconds\n" |
6417 | "Address of interface\n") | |
7a7be519 | 6418 | { |
0d829fa7 | 6419 | return ip_ospf_hello_interval (self, vty, argc, argv); |
7a7be519 | 6420 | } |
718e3744 | 6421 | |
6422 | DEFUN (no_ip_ospf_hello_interval, | |
0d829fa7 QY |
6423 | no_ip_ospf_hello_interval_cmd, |
6424 | "no ip ospf hello-interval [(1-65535) [A.B.C.D]]", | |
718e3744 | 6425 | NO_STR |
6426 | "IP Information\n" | |
6427 | "OSPF interface commands\n" | |
0d829fa7 | 6428 | "Time between HELLO packets\n" // ignored |
f9dfba8d | 6429 | "Seconds\n" |
0d829fa7 | 6430 | "Address of interface\n") |
718e3744 | 6431 | { |
cdc2d765 | 6432 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6433 | int idx = 0; |
718e3744 | 6434 | struct in_addr addr; |
718e3744 | 6435 | struct ospf_if_params *params; |
df581cd3 | 6436 | |
718e3744 | 6437 | params = IF_DEF_PARAMS (ifp); |
6438 | ||
0d829fa7 | 6439 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6440 | { |
0d829fa7 | 6441 | if(!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6442 | { |
6443 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6444 | VTYNL); |
718e3744 | 6445 | return CMD_WARNING; |
6446 | } | |
6447 | ||
6448 | params = ospf_lookup_if_params (ifp, addr); | |
6449 | if (params == NULL) | |
6450 | return CMD_SUCCESS; | |
6451 | } | |
6452 | ||
6453 | UNSET_IF_PARAM (params, v_hello); | |
f9ad937f | 6454 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
718e3744 | 6455 | |
6456 | if (params != IF_DEF_PARAMS (ifp)) | |
6457 | { | |
6458 | ospf_free_if_params (ifp, addr); | |
6459 | ospf_if_update_params (ifp, addr); | |
6460 | } | |
6461 | ||
6462 | return CMD_SUCCESS; | |
6463 | } | |
6464 | ||
0d829fa7 QY |
6465 | DEFUN_HIDDEN (no_ospf_hello_interval, |
6466 | no_ospf_hello_interval_cmd, | |
6467 | "no ospf hello-interval [(1-65535) [A.B.C.D]]", | |
6468 | NO_STR | |
6469 | "OSPF interface commands\n" | |
6470 | "Time between HELLO packets\n" // ignored | |
6471 | "Seconds\n" | |
6472 | "Address of interface\n") | |
6473 | { | |
030204c7 | 6474 | return no_ip_ospf_hello_interval (self, vty, argc, argv); |
0d829fa7 | 6475 | } |
718e3744 | 6476 | |
6477 | DEFUN (ip_ospf_network, | |
6478 | ip_ospf_network_cmd, | |
6147e2c6 | 6479 | "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
718e3744 | 6480 | "IP Information\n" |
6481 | "OSPF interface commands\n" | |
6482 | "Network type\n" | |
6483 | "Specify OSPF broadcast multi-access network\n" | |
6484 | "Specify OSPF NBMA network\n" | |
6485 | "Specify OSPF point-to-multipoint network\n" | |
6486 | "Specify OSPF point-to-point network\n") | |
6487 | { | |
cdc2d765 | 6488 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6489 | int idx = 0; |
718e3744 | 6490 | int old_type = IF_DEF_PARAMS (ifp)->type; |
6491 | struct route_node *rn; | |
4b4bda9b CF |
6492 | |
6493 | if (old_type == OSPF_IFTYPE_LOOPBACK) | |
6494 | { | |
1318e7c8 | 6495 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTYNL); |
4b4bda9b CF |
6496 | return CMD_WARNING; |
6497 | } | |
6498 | ||
0d829fa7 | 6499 | if (argv_find (argv, argc, "broadcast", &idx)) |
718e3744 | 6500 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
0d829fa7 | 6501 | else if (argv_find (argv, argc, "non-broadcast", &idx)) |
718e3744 | 6502 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
0d829fa7 | 6503 | else if (argv_find (argv, argc, "point-to-multipoint", &idx)) |
718e3744 | 6504 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
0d829fa7 | 6505 | else if (argv_find (argv, argc, "point-to-point", &idx)) |
718e3744 | 6506 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
6507 | ||
6508 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6509 | return CMD_SUCCESS; | |
6510 | ||
6511 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); | |
6512 | ||
6513 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6514 | { | |
6515 | struct ospf_interface *oi = rn->info; | |
6516 | ||
6517 | if (!oi) | |
6518 | continue; | |
6519 | ||
6520 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6521 | ||
6522 | if (oi->state > ISM_Down) | |
6523 | { | |
7a7be519 | 6524 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
6525 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6526 | } | |
6527 | } | |
6528 | ||
6529 | return CMD_SUCCESS; | |
6530 | } | |
6531 | ||
6532 | DEFUN_HIDDEN (ospf_network, | |
6533 | ospf_network_cmd, | |
e83a9414 | 6534 | "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>", |
7a7be519 | 6535 | "OSPF interface commands\n" |
6536 | "Network type\n" | |
6537 | "Specify OSPF broadcast multi-access network\n" | |
6538 | "Specify OSPF NBMA network\n" | |
6539 | "Specify OSPF point-to-multipoint network\n" | |
6540 | "Specify OSPF point-to-point network\n") | |
6541 | { | |
0d829fa7 | 6542 | return ip_ospf_network (self, vty, argc, argv); |
7a7be519 | 6543 | } |
6544 | ||
6545 | DEFUN (no_ip_ospf_network, | |
6546 | no_ip_ospf_network_cmd, | |
6547 | "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
6548 | NO_STR | |
6549 | "IP Information\n" | |
6550 | "OSPF interface commands\n" | |
6551 | "Network type\n" | |
6552 | "Specify OSPF broadcast multi-access network\n" | |
6553 | "Specify OSPF NBMA network\n" | |
6554 | "Specify OSPF point-to-multipoint network\n" | |
6555 | "Specify OSPF point-to-point network\n") | |
22b27e95 | 6556 | { |
cdc2d765 | 6557 | VTY_DECLVAR_CONTEXT(interface, ifp); |
7a7be519 | 6558 | int old_type = IF_DEF_PARAMS (ifp)->type; |
6559 | struct route_node *rn; | |
6560 | ||
6561 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); | |
6562 | ||
6563 | if (IF_DEF_PARAMS (ifp)->type == old_type) | |
6564 | return CMD_SUCCESS; | |
6565 | ||
6566 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6567 | { | |
6568 | struct ospf_interface *oi = rn->info; | |
6569 | ||
6570 | if (!oi) | |
6571 | continue; | |
6572 | ||
6573 | oi->type = IF_DEF_PARAMS (ifp)->type; | |
6574 | ||
6575 | if (oi->state > ISM_Down) | |
6576 | { | |
6577 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); | |
6578 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); | |
6579 | } | |
6580 | } | |
6581 | ||
6582 | return CMD_SUCCESS; | |
6583 | } | |
6584 | ||
0d829fa7 QY |
6585 | DEFUN_HIDDEN (no_ospf_network, |
6586 | no_ospf_network_cmd, | |
6587 | "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]", | |
6588 | NO_STR | |
6589 | "OSPF interface commands\n" | |
6590 | "Network type\n" | |
6591 | "Specify OSPF broadcast multi-access network\n" | |
6592 | "Specify OSPF NBMA network\n" | |
6593 | "Specify OSPF point-to-multipoint network\n" | |
6594 | "Specify OSPF point-to-point network\n") | |
6595 | { | |
6596 | return no_ip_ospf_network (self, vty, argc, argv); | |
6597 | } | |
6598 | ||
7a7be519 | 6599 | DEFUN (ip_ospf_priority, |
537eae3f | 6600 | ip_ospf_priority_cmd, |
7a7be519 | 6601 | "ip ospf priority (0-255) [A.B.C.D]", |
6602 | "IP Information\n" | |
6603 | "OSPF interface commands\n" | |
6604 | "Router priority\n" | |
6605 | "Priority\n" | |
6606 | "Address of interface") | |
6607 | { | |
cdc2d765 | 6608 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6609 | int idx = 0; |
7a7be519 | 6610 | long priority; |
6611 | struct route_node *rn; | |
6612 | struct in_addr addr; | |
7a7be519 | 6613 | struct ospf_if_params *params; |
7a7be519 | 6614 | params = IF_DEF_PARAMS (ifp); |
6615 | ||
0d829fa7 QY |
6616 | argv_find (argv, argc, "(0-255)", &idx); |
6617 | priority = strtol (argv[idx]->arg, NULL, 10); | |
7a7be519 | 6618 | |
0d829fa7 | 6619 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
7a7be519 | 6620 | { |
0d829fa7 | 6621 | if (!inet_aton(argv[idx]->arg, &addr)) |
7a7be519 | 6622 | { |
6623 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6624 | VTYNL); |
7a7be519 | 6625 | return CMD_WARNING; |
6626 | } | |
6627 | ||
6628 | params = ospf_get_if_params (ifp, addr); | |
6629 | ospf_if_update_params (ifp, addr); | |
6630 | } | |
6631 | ||
6632 | SET_IF_PARAM (params, priority); | |
6633 | params->priority = priority; | |
6634 | ||
6635 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6636 | { | |
6637 | struct ospf_interface *oi = rn->info; | |
6638 | ||
6639 | if (!oi) | |
6640 | continue; | |
6641 | ||
6642 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) | |
6643 | { | |
6644 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6645 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
718e3744 | 6646 | } |
6647 | } | |
6648 | ||
6649 | return CMD_SUCCESS; | |
6650 | } | |
6651 | ||
7a7be519 | 6652 | DEFUN_HIDDEN (ospf_priority, |
6653 | ospf_priority_cmd, | |
0d829fa7 | 6654 | "ospf priority (0-255) [A.B.C.D]", |
7a7be519 | 6655 | "OSPF interface commands\n" |
6656 | "Router priority\n" | |
3a2d747c QY |
6657 | "Priority\n" |
6658 | "Address of interface") | |
718e3744 | 6659 | { |
0d829fa7 | 6660 | return ip_ospf_priority (self, vty, argc, argv); |
718e3744 | 6661 | } |
6662 | ||
718e3744 | 6663 | DEFUN (no_ip_ospf_priority, |
537eae3f | 6664 | no_ip_ospf_priority_cmd, |
7a7be519 | 6665 | "no ip ospf priority [(0-255) [A.B.C.D]]", |
718e3744 | 6666 | NO_STR |
6667 | "IP Information\n" | |
6668 | "OSPF interface commands\n" | |
0d829fa7 | 6669 | "Router priority\n" // ignored |
813d4307 | 6670 | "Priority\n" |
718e3744 | 6671 | "Address of interface") |
6672 | { | |
cdc2d765 | 6673 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6674 | int idx = 0; |
718e3744 | 6675 | struct route_node *rn; |
6676 | struct in_addr addr; | |
718e3744 | 6677 | struct ospf_if_params *params; |
6678 | ||
718e3744 | 6679 | params = IF_DEF_PARAMS (ifp); |
6680 | ||
0d829fa7 | 6681 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6682 | { |
0d829fa7 | 6683 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6684 | { |
6685 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6686 | VTYNL); |
718e3744 | 6687 | return CMD_WARNING; |
6688 | } | |
6689 | ||
6690 | params = ospf_lookup_if_params (ifp, addr); | |
6691 | if (params == NULL) | |
6692 | return CMD_SUCCESS; | |
6693 | } | |
6694 | ||
6695 | UNSET_IF_PARAM (params, priority); | |
6696 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; | |
6697 | ||
6698 | if (params != IF_DEF_PARAMS (ifp)) | |
6699 | { | |
6700 | ospf_free_if_params (ifp, addr); | |
6701 | ospf_if_update_params (ifp, addr); | |
6702 | } | |
6703 | ||
6704 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) | |
6705 | { | |
6706 | struct ospf_interface *oi = rn->info; | |
6707 | ||
6708 | if (!oi) | |
6709 | continue; | |
6710 | ||
718e3744 | 6711 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
6712 | { | |
6713 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); | |
6714 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); | |
6715 | } | |
6716 | } | |
6717 | ||
6718 | return CMD_SUCCESS; | |
6719 | } | |
6720 | ||
0d829fa7 | 6721 | DEFUN_HIDDEN (no_ospf_priority, |
537eae3f | 6722 | no_ospf_priority_cmd, |
0d829fa7 QY |
6723 | "no ospf priority [(0-255) [A.B.C.D]]", |
6724 | NO_STR | |
6725 | "OSPF interface commands\n" | |
6726 | "Router priority\n" | |
6727 | "Priority\n" | |
6728 | "Address of interface") | |
6729 | { | |
6730 | return no_ip_ospf_priority (self, vty, argc, argv); | |
6731 | } | |
a1afa410 | 6732 | |
718e3744 | 6733 | DEFUN (ip_ospf_retransmit_interval, |
6734 | ip_ospf_retransmit_interval_addr_cmd, | |
7a7be519 | 6735 | "ip ospf retransmit-interval (3-65535) [A.B.C.D]", |
718e3744 | 6736 | "IP Information\n" |
6737 | "OSPF interface commands\n" | |
6738 | "Time between retransmitting lost link state advertisements\n" | |
6739 | "Seconds\n" | |
6740 | "Address of interface") | |
6741 | { | |
cdc2d765 | 6742 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6743 | int idx = 0; |
718e3744 | 6744 | u_int32_t seconds; |
6745 | struct in_addr addr; | |
718e3744 | 6746 | struct ospf_if_params *params; |
718e3744 | 6747 | params = IF_DEF_PARAMS (ifp); |
718e3744 | 6748 | |
0d829fa7 QY |
6749 | argv_find (argv, argc, "(3-65535)", &idx); |
6750 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6751 | |
0d829fa7 | 6752 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6753 | { |
0d829fa7 | 6754 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6755 | { |
6756 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6757 | VTYNL); |
718e3744 | 6758 | return CMD_WARNING; |
6759 | } | |
6760 | ||
6761 | params = ospf_get_if_params (ifp, addr); | |
6762 | ospf_if_update_params (ifp, addr); | |
6763 | } | |
6764 | ||
6765 | SET_IF_PARAM (params, retransmit_interval); | |
6766 | params->retransmit_interval = seconds; | |
6767 | ||
6768 | return CMD_SUCCESS; | |
6769 | } | |
6770 | ||
7a7be519 | 6771 | DEFUN_HIDDEN (ospf_retransmit_interval, |
747e489c | 6772 | ospf_retransmit_interval_cmd, |
0d829fa7 | 6773 | "ospf retransmit-interval (3-65535) [A.B.C.D]", |
747e489c DW |
6774 | "OSPF interface commands\n" |
6775 | "Time between retransmitting lost link state advertisements\n" | |
3a2d747c QY |
6776 | "Seconds\n" |
6777 | "Address of interface") | |
7a7be519 | 6778 | { |
0d829fa7 | 6779 | return ip_ospf_retransmit_interval (self, vty, argc, argv); |
7a7be519 | 6780 | } |
718e3744 | 6781 | |
6782 | DEFUN (no_ip_ospf_retransmit_interval, | |
6783 | no_ip_ospf_retransmit_interval_addr_cmd, | |
0d829fa7 | 6784 | "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]", |
718e3744 | 6785 | NO_STR |
6786 | "IP Information\n" | |
6787 | "OSPF interface commands\n" | |
3a2d747c QY |
6788 | "Time between retransmitting lost link state advertisements\n" |
6789 | "Seconds\n" | |
0d829fa7 | 6790 | "Address of interface\n") |
718e3744 | 6791 | { |
cdc2d765 | 6792 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6793 | int idx = 0; |
718e3744 | 6794 | struct in_addr addr; |
718e3744 | 6795 | struct ospf_if_params *params; |
47b91972 | 6796 | |
718e3744 | 6797 | params = IF_DEF_PARAMS (ifp); |
6798 | ||
47b91972 | 6799 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6800 | { |
0d829fa7 | 6801 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6802 | { |
6803 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6804 | VTYNL); |
718e3744 | 6805 | return CMD_WARNING; |
6806 | } | |
6807 | ||
6808 | params = ospf_lookup_if_params (ifp, addr); | |
6809 | if (params == NULL) | |
6810 | return CMD_SUCCESS; | |
6811 | } | |
6812 | ||
6813 | UNSET_IF_PARAM (params, retransmit_interval); | |
6814 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; | |
6815 | ||
6816 | if (params != IF_DEF_PARAMS (ifp)) | |
6817 | { | |
6818 | ospf_free_if_params (ifp, addr); | |
6819 | ospf_if_update_params (ifp, addr); | |
6820 | } | |
6821 | ||
6822 | return CMD_SUCCESS; | |
6823 | } | |
6824 | ||
0d829fa7 QY |
6825 | DEFUN_HIDDEN (no_ospf_retransmit_interval, |
6826 | no_ospf_retransmit_interval_cmd, | |
6827 | "no ospf retransmit-interval [(3-65535)] [A.B.C.D]", | |
6828 | NO_STR | |
6829 | "OSPF interface commands\n" | |
3a2d747c QY |
6830 | "Time between retransmitting lost link state advertisements\n" |
6831 | "Seconds\n" | |
6832 | "Address of interface\n") | |
0d829fa7 QY |
6833 | { |
6834 | return no_ip_ospf_retransmit_interval (self, vty, argc, argv); | |
6835 | } | |
813d4307 | 6836 | |
718e3744 | 6837 | DEFUN (ip_ospf_transmit_delay, |
6838 | ip_ospf_transmit_delay_addr_cmd, | |
7a7be519 | 6839 | "ip ospf transmit-delay (1-65535) [A.B.C.D]", |
718e3744 | 6840 | "IP Information\n" |
6841 | "OSPF interface commands\n" | |
6842 | "Link state transmit delay\n" | |
6843 | "Seconds\n" | |
6844 | "Address of interface") | |
6845 | { | |
cdc2d765 | 6846 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6847 | int idx = 0; |
718e3744 | 6848 | u_int32_t seconds; |
6849 | struct in_addr addr; | |
718e3744 | 6850 | struct ospf_if_params *params; |
47b91972 | 6851 | |
718e3744 | 6852 | params = IF_DEF_PARAMS (ifp); |
0d829fa7 QY |
6853 | argv_find (argv, argc, "(1-65535)", &idx); |
6854 | seconds = strtol (argv[idx]->arg, NULL, 10); | |
718e3744 | 6855 | |
0d829fa7 | 6856 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6857 | { |
0d829fa7 | 6858 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6859 | { |
6860 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6861 | VTYNL); |
718e3744 | 6862 | return CMD_WARNING; |
6863 | } | |
6864 | ||
6865 | params = ospf_get_if_params (ifp, addr); | |
6866 | ospf_if_update_params (ifp, addr); | |
6867 | } | |
6868 | ||
47b91972 | 6869 | SET_IF_PARAM (params, transmit_delay); |
718e3744 | 6870 | params->transmit_delay = seconds; |
6871 | ||
6872 | return CMD_SUCCESS; | |
6873 | } | |
6874 | ||
7a7be519 | 6875 | DEFUN_HIDDEN (ospf_transmit_delay, |
747e489c | 6876 | ospf_transmit_delay_cmd, |
0d829fa7 | 6877 | "ospf transmit-delay (1-65535) [A.B.C.D]", |
747e489c DW |
6878 | "OSPF interface commands\n" |
6879 | "Link state transmit delay\n" | |
3a2d747c QY |
6880 | "Seconds\n" |
6881 | "Address of interface") | |
7a7be519 | 6882 | { |
0d829fa7 | 6883 | return ip_ospf_transmit_delay (self, vty, argc, argv); |
7a7be519 | 6884 | } |
718e3744 | 6885 | |
6886 | DEFUN (no_ip_ospf_transmit_delay, | |
6887 | no_ip_ospf_transmit_delay_addr_cmd, | |
0d829fa7 | 6888 | "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]", |
718e3744 | 6889 | NO_STR |
6890 | "IP Information\n" | |
6891 | "OSPF interface commands\n" | |
6892 | "Link state transmit delay\n" | |
6893 | "Address of interface") | |
6894 | { | |
cdc2d765 | 6895 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6896 | int idx = 0; |
718e3744 | 6897 | struct in_addr addr; |
718e3744 | 6898 | struct ospf_if_params *params; |
6899 | ||
718e3744 | 6900 | params = IF_DEF_PARAMS (ifp); |
6901 | ||
0d829fa7 | 6902 | if (argv_find (argv, argc, "A.B.C.D", &idx)) |
718e3744 | 6903 | { |
0d829fa7 | 6904 | if (!inet_aton(argv[idx]->arg, &addr)) |
718e3744 | 6905 | { |
6906 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 6907 | VTYNL); |
718e3744 | 6908 | return CMD_WARNING; |
6909 | } | |
6910 | ||
6911 | params = ospf_lookup_if_params (ifp, addr); | |
6912 | if (params == NULL) | |
6913 | return CMD_SUCCESS; | |
6914 | } | |
6915 | ||
6916 | UNSET_IF_PARAM (params, transmit_delay); | |
6917 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; | |
6918 | ||
6919 | if (params != IF_DEF_PARAMS (ifp)) | |
6920 | { | |
6921 | ospf_free_if_params (ifp, addr); | |
6922 | ospf_if_update_params (ifp, addr); | |
6923 | } | |
6924 | ||
6925 | return CMD_SUCCESS; | |
6926 | } | |
6927 | ||
813d4307 | 6928 | |
0d829fa7 QY |
6929 | DEFUN_HIDDEN (no_ospf_transmit_delay, |
6930 | no_ospf_transmit_delay_cmd, | |
6931 | "no ospf transmit-delay", | |
6932 | NO_STR | |
6933 | "OSPF interface commands\n" | |
6934 | "Link state transmit delay\n") | |
813d4307 | 6935 | { |
0d829fa7 | 6936 | return no_ip_ospf_transmit_delay (self, vty, argc, argv); |
813d4307 DW |
6937 | } |
6938 | ||
e723861d DS |
6939 | DEFUN (ip_ospf_area, |
6940 | ip_ospf_area_cmd, | |
52c62ab8 | 6941 | "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)> [A.B.C.D]", |
e723861d DS |
6942 | "IP Information\n" |
6943 | "OSPF interface commands\n" | |
7a7be519 | 6944 | "Instance ID\n" |
e723861d DS |
6945 | "Enable OSPF on this interface\n" |
6946 | "OSPF area ID in IP address format\n" | |
52c62ab8 JAG |
6947 | "OSPF area ID as a decimal value\n" |
6948 | "Address of interface\n") | |
e723861d | 6949 | { |
cdc2d765 | 6950 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 6951 | int idx = 0; |
e723861d DS |
6952 | int format, ret; |
6953 | struct in_addr area_id; | |
52c62ab8 | 6954 | struct in_addr addr; |
e723861d DS |
6955 | struct ospf_if_params *params; |
6956 | struct route_node *rn; | |
52c62ab8 | 6957 | struct ospf *ospf; |
7c8ff89e | 6958 | u_short instance = 0; |
52c62ab8 | 6959 | char *areaid; |
e723861d | 6960 | |
0d829fa7 QY |
6961 | if (argv_find (argv, argc, "(1-65535)", &idx)) |
6962 | instance = strtol (argv[idx]->arg, NULL, 10); | |
52c62ab8 JAG |
6963 | |
6964 | argv_find (argv, argc, "area", &idx); | |
6965 | areaid = argv[idx + 1]->arg; | |
7c8ff89e DS |
6966 | |
6967 | ospf = ospf_lookup_instance (instance); | |
e723861d DS |
6968 | if (ospf == NULL) |
6969 | { | |
7c8ff89e DS |
6970 | params = IF_DEF_PARAMS (ifp); |
6971 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
6972 | { | |
52c62ab8 JAG |
6973 | UNSET_IF_PARAM (params, if_area); |
6974 | ospf_interface_area_unset (ifp); | |
7c8ff89e DS |
6975 | ospf = ospf_lookup(); |
6976 | ospf->if_ospf_cli_count--; | |
6977 | } | |
e723861d DS |
6978 | return CMD_SUCCESS; |
6979 | } | |
6980 | ||
86573dcb | 6981 | ret = str2area_id (areaid, &area_id, &format); |
e723861d DS |
6982 | if (ret < 0) |
6983 | { | |
6984 | vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s", | |
1318e7c8 | 6985 | VTYNL); |
e723861d DS |
6986 | return CMD_WARNING; |
6987 | } | |
6988 | if (memcmp (ifp->name, "VLINK", 5) == 0) | |
6989 | { | |
1318e7c8 | 6990 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTYNL); |
e723861d DS |
6991 | return CMD_WARNING; |
6992 | } | |
6993 | ||
6994 | params = IF_DEF_PARAMS (ifp); | |
6995 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
6996 | { | |
73b9f703 VK |
6997 | vty_out (vty, |
6998 | "Must remove previous area config before changing ospf area %s", | |
1318e7c8 | 6999 | VTYNL); |
e723861d DS |
7000 | return CMD_WARNING; |
7001 | } | |
7002 | ||
52c62ab8 JAG |
7003 | // Check if we have an address arg and proccess it |
7004 | if (argc == idx + 3) { | |
8c9b5992 | 7005 | inet_aton(argv[idx+2]->arg, &addr); |
52c62ab8 JAG |
7006 | // update/create address-level params |
7007 | params = ospf_get_if_params ((ifp), (addr)); | |
7008 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) | |
7009 | { | |
7010 | vty_out (vty, | |
8e25c8ce | 7011 | "Must remove previous area/address config before changing ospf area"); |
52c62ab8 JAG |
7012 | return CMD_WARNING; |
7013 | } | |
7014 | ospf_if_update_params ((ifp), (addr)); | |
7015 | } | |
7016 | ||
e723861d DS |
7017 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
7018 | { | |
7019 | if (rn->info != NULL) | |
7020 | { | |
1318e7c8 | 7021 | vty_out (vty, "Please remove all network commands first.%s", VTYNL); |
e723861d DS |
7022 | return CMD_WARNING; |
7023 | } | |
7024 | } | |
7025 | ||
7026 | /* enable ospf on this interface with area_id */ | |
52c62ab8 JAG |
7027 | SET_IF_PARAM (params, if_area); |
7028 | params->if_area = area_id; | |
7029 | ospf_interface_area_set (ifp); | |
e723861d DS |
7030 | ospf->if_ospf_cli_count++; |
7031 | ||
7032 | return CMD_SUCCESS; | |
7033 | } | |
7034 | ||
7035 | DEFUN (no_ip_ospf_area, | |
7036 | no_ip_ospf_area_cmd, | |
52c62ab8 | 7037 | "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)> [A.B.C.D]]", |
e723861d DS |
7038 | NO_STR |
7039 | "IP Information\n" | |
7040 | "OSPF interface commands\n" | |
3a2d747c | 7041 | "Instance ID\n" |
7a7be519 | 7042 | "Disable OSPF on this interface\n" |
7043 | "OSPF area ID in IP address format\n" | |
52c62ab8 JAG |
7044 | "OSPF area ID as a decimal value\n" |
7045 | "Address of interface\n") | |
e723861d | 7046 | { |
cdc2d765 | 7047 | VTY_DECLVAR_CONTEXT(interface, ifp); |
0d829fa7 | 7048 | int idx = 0; |
e723861d DS |
7049 | struct ospf *ospf; |
7050 | struct ospf_if_params *params; | |
7c8ff89e | 7051 | u_short instance = 0; |
52c62ab8 JAG |
7052 | struct in_addr addr; |
7053 | ||
0d829fa7 QY |
7054 | if (argv_find (argv, argc, "(1-65535)", &idx)) |
7055 | instance = strtol (argv[idx]->arg, NULL, 10); | |
813d4307 DW |
7056 | |
7057 | if ((ospf = ospf_lookup_instance (instance)) == NULL) | |
7058 | return CMD_SUCCESS; | |
7059 | ||
52c62ab8 JAG |
7060 | argv_find (argv, argc, "area", &idx); |
7061 | ||
7062 | // Check if we have an address arg and proccess it | |
7063 | if (argc == idx + 3) { | |
8c9b5992 | 7064 | inet_aton(argv[idx+2]->arg, &addr); |
52c62ab8 JAG |
7065 | params = ospf_lookup_if_params (ifp, addr); |
7066 | if ((params) == NULL) | |
7067 | return CMD_SUCCESS; | |
7068 | } | |
7069 | else | |
7070 | params = IF_DEF_PARAMS (ifp); | |
7071 | ||
813d4307 DW |
7072 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) |
7073 | { | |
1318e7c8 | 7074 | vty_outln (vty, "Can't find specified interface area configuration."); |
813d4307 | 7075 | return CMD_WARNING; |
52c62ab8 | 7076 | } |
813d4307 | 7077 | |
52c62ab8 JAG |
7078 | UNSET_IF_PARAM (params, if_area); |
7079 | if (params != IF_DEF_PARAMS ((ifp))) | |
7080 | { | |
7081 | ospf_free_if_params ((ifp), (addr)); | |
7082 | ospf_if_update_params ((ifp), (addr)); | |
7083 | } | |
7084 | ||
7085 | ospf_interface_area_unset (ifp); | |
813d4307 DW |
7086 | ospf->if_ospf_cli_count--; |
7087 | return CMD_SUCCESS; | |
7088 | } | |
7089 | ||
6f2a6703 CF |
7090 | DEFUN (ospf_redistribute_source, |
7091 | ospf_redistribute_source_cmd, | |
40d1cbfb | 7092 | "redistribute " FRR_REDIST_STR_OSPFD " [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
d1c65c21 | 7093 | REDIST_STR |
ab0181ee | 7094 | FRR_REDIST_HELP_STR_OSPFD |
718e3744 | 7095 | "Metric for redistributed routes\n" |
7096 | "OSPF default metric\n" | |
7097 | "OSPF exterior metric type for redistributed routes\n" | |
7098 | "Set OSPF External Type 1 metrics\n" | |
7099 | "Set OSPF External Type 2 metrics\n" | |
7100 | "Route map reference\n" | |
7101 | "Pointer to route-map entries\n") | |
7102 | { | |
cdc2d765 | 7103 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7104 | int idx_protocol = 1; |
718e3744 | 7105 | int source; |
7106 | int type = -1; | |
7107 | int metric = -1; | |
7c8ff89e | 7108 | struct ospf_redist *red; |
6d681bd8 | 7109 | int idx = 0; |
6f2a6703 | 7110 | |
7c8ff89e DS |
7111 | if (!ospf) |
7112 | return CMD_SUCCESS; | |
7113 | ||
718e3744 | 7114 | /* Get distribute source. */ |
6d681bd8 QY |
7115 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
7116 | if (source < 0) | |
718e3744 | 7117 | return CMD_WARNING; |
7118 | ||
6d681bd8 QY |
7119 | red = ospf_redist_add(ospf, source, 0); |
7120 | ||
718e3744 | 7121 | /* Get metric value. */ |
6d681bd8 QY |
7122 | if (argv_find (argv, argc, "(0-16777214)", &idx)) { |
7123 | if (!str2metric (argv[idx]->arg, &metric)) | |
718e3744 | 7124 | return CMD_WARNING; |
6d681bd8 | 7125 | } |
718e3744 | 7126 | /* Get metric type. */ |
6d681bd8 QY |
7127 | else if (argv_find (argv, argc, "(1-2)", &idx)) { |
7128 | if (!str2metric_type (argv[idx]->arg, &type)) | |
718e3744 | 7129 | return CMD_WARNING; |
6d681bd8 QY |
7130 | } |
7131 | /* Get route-map */ | |
7132 | else if (argv_find (argv, argc, "WORD", &idx)) { | |
7133 | ospf_routemap_set (red, argv[idx]->arg); | |
7134 | } | |
718e3744 | 7135 | else |
7c8ff89e | 7136 | ospf_routemap_unset (red); |
718e3744 | 7137 | |
7c8ff89e | 7138 | return ospf_redistribute_set (ospf, source, 0, type, metric); |
718e3744 | 7139 | } |
7140 | ||
718e3744 | 7141 | DEFUN (no_ospf_redistribute_source, |
7142 | no_ospf_redistribute_source_cmd, | |
40d1cbfb | 7143 | "no redistribute " FRR_REDIST_STR_OSPFD " [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7144 | NO_STR |
d1c65c21 | 7145 | REDIST_STR |
ab0181ee | 7146 | FRR_REDIST_HELP_STR_OSPFD |
813d4307 DW |
7147 | "Metric for redistributed routes\n" |
7148 | "OSPF default metric\n" | |
7149 | "OSPF exterior metric type for redistributed routes\n" | |
7150 | "Set OSPF External Type 1 metrics\n" | |
7151 | "Set OSPF External Type 2 metrics\n" | |
7152 | "Route map reference\n" | |
7153 | "Pointer to route-map entries\n") | |
718e3744 | 7154 | { |
cdc2d765 | 7155 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7156 | int idx_protocol = 2; |
718e3744 | 7157 | int source; |
7c8ff89e | 7158 | struct ospf_redist *red; |
718e3744 | 7159 | |
6d681bd8 QY |
7160 | source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
7161 | if (source < 0) | |
718e3744 | 7162 | return CMD_WARNING; |
7163 | ||
7c8ff89e DS |
7164 | red = ospf_redist_lookup(ospf, source, 0); |
7165 | if (!red) | |
7166 | return CMD_SUCCESS; | |
7167 | ||
7168 | ospf_routemap_unset (red); | |
7169 | return ospf_redistribute_unset (ospf, source, 0); | |
7170 | } | |
7171 | ||
7172 | DEFUN (ospf_redistribute_instance_source, | |
7173 | ospf_redistribute_instance_source_cmd, | |
1a5ce38b | 7174 | "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
7c8ff89e DS |
7175 | REDIST_STR |
7176 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7177 | "Non-main Kernel Routing Table\n" |
7178 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
7179 | "Metric for redistributed routes\n" |
7180 | "OSPF default metric\n" | |
7181 | "OSPF exterior metric type for redistributed routes\n" | |
7182 | "Set OSPF External Type 1 metrics\n" | |
7183 | "Set OSPF External Type 2 metrics\n" | |
7184 | "Route map reference\n" | |
7185 | "Pointer to route-map entries\n") | |
7186 | { | |
cdc2d765 | 7187 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7188 | int idx_ospf_table = 1; |
7189 | int idx_number = 2; | |
f4d78586 | 7190 | int idx = 3; |
7c8ff89e DS |
7191 | int source; |
7192 | int type = -1; | |
7193 | int metric = -1; | |
7194 | u_short instance; | |
7195 | struct ospf_redist *red; | |
7196 | ||
d8f70b86 DS |
7197 | if (!ospf) |
7198 | return CMD_SUCCESS; | |
7199 | ||
6d681bd8 | 7200 | source = proto_redistnum (AFI_IP, argv[idx_ospf_table]->text); |
2d627ff5 | 7201 | |
facfee22 | 7202 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7c8ff89e DS |
7203 | |
7204 | if (!ospf) | |
7205 | return CMD_SUCCESS; | |
7206 | ||
2d627ff5 | 7207 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7208 | { |
7209 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
1318e7c8 | 7210 | VTYNL); |
7c8ff89e DS |
7211 | return CMD_WARNING; |
7212 | } | |
7213 | ||
2d627ff5 | 7214 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7215 | { |
7216 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
1318e7c8 | 7217 | VTYNL); |
7c8ff89e DS |
7218 | return CMD_WARNING; |
7219 | } | |
7220 | ||
7c8ff89e | 7221 | /* Get metric value. */ |
f4d78586 DS |
7222 | if (argv_find (argv, argc, "metric", &idx)) |
7223 | if (!str2metric (argv[idx+1]->arg, &metric)) | |
7c8ff89e DS |
7224 | return CMD_WARNING; |
7225 | ||
f4d78586 | 7226 | idx = 3; |
7c8ff89e | 7227 | /* Get metric type. */ |
f4d78586 DS |
7228 | if (argv_find (argv, argc, "metric-type", &idx)) |
7229 | if (!str2metric_type (argv[idx+1]->arg, &type)) | |
7c8ff89e DS |
7230 | return CMD_WARNING; |
7231 | ||
7232 | red = ospf_redist_add(ospf, source, instance); | |
7a7be519 | 7233 | |
f4d78586 DS |
7234 | idx = 3; |
7235 | if (argv_find (argv, argc, "route-map", &idx)) | |
7236 | ospf_routemap_set (red, argv[idx+1]->arg); | |
7c8ff89e DS |
7237 | else |
7238 | ospf_routemap_unset (red); | |
7239 | ||
7240 | return ospf_redistribute_set (ospf, source, instance, type, metric); | |
7241 | } | |
7242 | ||
7243 | DEFUN (no_ospf_redistribute_instance_source, | |
7244 | no_ospf_redistribute_instance_source_cmd, | |
1a5ce38b | 7245 | "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", |
7c8ff89e DS |
7246 | NO_STR |
7247 | REDIST_STR | |
7248 | "Open Shortest Path First\n" | |
2d627ff5 DS |
7249 | "Non-main Kernel Routing Table\n" |
7250 | "Instance ID/Table Id\n" | |
7c8ff89e DS |
7251 | "Metric for redistributed routes\n" |
7252 | "OSPF default metric\n" | |
7253 | "OSPF exterior metric type for redistributed routes\n" | |
7254 | "Set OSPF External Type 1 metrics\n" | |
7255 | "Set OSPF External Type 2 metrics\n" | |
7256 | "Route map reference\n" | |
7257 | "Pointer to route-map entries\n") | |
7258 | { | |
cdc2d765 | 7259 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7260 | int idx_ospf_table = 2; |
7261 | int idx_number = 3; | |
7c8ff89e DS |
7262 | u_int instance; |
7263 | struct ospf_redist *red; | |
7264 | int source; | |
7265 | ||
8d769265 | 7266 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
2d627ff5 DS |
7267 | source = ZEBRA_ROUTE_OSPF; |
7268 | else | |
7269 | source = ZEBRA_ROUTE_TABLE; | |
7270 | ||
facfee22 | 7271 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7c8ff89e | 7272 | |
2d627ff5 | 7273 | if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance) |
7c8ff89e DS |
7274 | { |
7275 | vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s", | |
1318e7c8 | 7276 | VTYNL); |
7c8ff89e DS |
7277 | return CMD_WARNING; |
7278 | } | |
7279 | ||
2d627ff5 | 7280 | if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance)) |
7c8ff89e DS |
7281 | { |
7282 | vty_out (vty, "Same instance OSPF redistribution not allowed%s", | |
1318e7c8 | 7283 | VTYNL); |
7c8ff89e DS |
7284 | return CMD_WARNING; |
7285 | } | |
7286 | ||
7c8ff89e DS |
7287 | red = ospf_redist_lookup(ospf, source, instance); |
7288 | if (!red) | |
7289 | return CMD_SUCCESS; | |
7290 | ||
7291 | ospf_routemap_unset (red); | |
7292 | return ospf_redistribute_unset (ospf, source, instance); | |
718e3744 | 7293 | } |
7294 | ||
7295 | DEFUN (ospf_distribute_list_out, | |
7296 | ospf_distribute_list_out_cmd, | |
40d1cbfb | 7297 | "distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
718e3744 | 7298 | "Filter networks in routing updates\n" |
6f2a6703 CF |
7299 | "Access-list name\n" |
7300 | OUT_STR | |
ab0181ee | 7301 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 7302 | { |
cdc2d765 | 7303 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7304 | int idx_word = 1; |
6f2a6703 | 7305 | int source; |
718e3744 | 7306 | |
6d681bd8 QY |
7307 | char *proto = argv[argc - 1]->text; |
7308 | ||
6f2a6703 | 7309 | /* Get distribute source. */ |
6d681bd8 QY |
7310 | source = proto_redistnum(AFI_IP, proto); |
7311 | if (source < 0) | |
6f2a6703 | 7312 | return CMD_WARNING; |
718e3744 | 7313 | |
8d769265 | 7314 | return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); |
718e3744 | 7315 | } |
7316 | ||
6f2a6703 CF |
7317 | DEFUN (no_ospf_distribute_list_out, |
7318 | no_ospf_distribute_list_out_cmd, | |
40d1cbfb | 7319 | "no distribute-list WORD out " FRR_REDIST_STR_OSPFD, |
6f2a6703 CF |
7320 | NO_STR |
7321 | "Filter networks in routing updates\n" | |
7322 | "Access-list name\n" | |
7323 | OUT_STR | |
ab0181ee | 7324 | FRR_REDIST_HELP_STR_OSPFD) |
718e3744 | 7325 | { |
cdc2d765 | 7326 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7327 | int idx_word = 2; |
6f2a6703 | 7328 | int source; |
020709f9 | 7329 | |
6d681bd8 QY |
7330 | char *proto = argv[argc - 1]->text; |
7331 | source = proto_redistnum(AFI_IP, proto); | |
7332 | if (source < 0) | |
6f2a6703 | 7333 | return CMD_WARNING; |
718e3744 | 7334 | |
8d769265 | 7335 | return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); |
718e3744 | 7336 | } |
7337 | ||
6f2a6703 CF |
7338 | /* Default information originate. */ |
7339 | DEFUN (ospf_default_information_originate, | |
7340 | ospf_default_information_originate_cmd, | |
e83a9414 | 7341 | "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7342 | "Control distribution of default information\n" |
7343 | "Distribute a default route\n" | |
7344 | "Always advertise default route\n" | |
6f2a6703 CF |
7345 | "OSPF default metric\n" |
7346 | "OSPF metric\n" | |
718e3744 | 7347 | "OSPF metric type for default routes\n" |
7348 | "Set OSPF External Type 1 metrics\n" | |
7349 | "Set OSPF External Type 2 metrics\n" | |
718e3744 | 7350 | "Route map reference\n" |
7351 | "Pointer to route-map entries\n") | |
7352 | { | |
cdc2d765 | 7353 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
6f2a6703 | 7354 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
718e3744 | 7355 | int type = -1; |
7356 | int metric = -1; | |
7c8ff89e | 7357 | struct ospf_redist *red; |
6d681bd8 | 7358 | int idx = 0; |
7c8ff89e | 7359 | |
6d681bd8 | 7360 | red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); |
6f2a6703 CF |
7361 | |
7362 | /* Check whether "always" was specified */ | |
6d681bd8 | 7363 | if (argv_find (argv, argc, "always", &idx)) |
6f2a6703 | 7364 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
6d681bd8 QY |
7365 | /* Get metric value */ |
7366 | else if (argv_find (argv, argc, "(0-16777214)", &idx)) { | |
7367 | if (!str2metric (argv[idx]->arg, &metric)) | |
718e3744 | 7368 | return CMD_WARNING; |
6d681bd8 | 7369 | } |
718e3744 | 7370 | /* Get metric type. */ |
6d681bd8 QY |
7371 | else if (argv_find (argv, argc, "(1-2)", &idx)) { |
7372 | if (!str2metric_type (argv[idx]->arg, &type)) | |
718e3744 | 7373 | return CMD_WARNING; |
6d681bd8 QY |
7374 | } |
7375 | /* Get route-map */ | |
7376 | else if (argv_find (argv, argc, "WORD", &idx)) | |
7377 | ospf_routemap_set (red, argv[idx]->arg); | |
718e3744 | 7378 | else |
7c8ff89e | 7379 | ospf_routemap_unset (red); |
718e3744 | 7380 | |
6f2a6703 CF |
7381 | return ospf_redistribute_default_set (ospf, default_originate, |
7382 | type, metric); | |
718e3744 | 7383 | } |
7384 | ||
7385 | DEFUN (no_ospf_default_information_originate, | |
7386 | no_ospf_default_information_originate_cmd, | |
12dcf78e | 7387 | "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", |
718e3744 | 7388 | NO_STR |
7389 | "Control distribution of default information\n" | |
813d4307 DW |
7390 | "Distribute a default route\n" |
7391 | "Always advertise default route\n" | |
7392 | "OSPF default metric\n" | |
7393 | "OSPF metric\n" | |
7394 | "OSPF metric type for default routes\n" | |
7395 | "Set OSPF External Type 1 metrics\n" | |
7396 | "Set OSPF External Type 2 metrics\n" | |
7397 | "Route map reference\n" | |
7398 | "Pointer to route-map entries\n") | |
718e3744 | 7399 | { |
cdc2d765 | 7400 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
718e3744 | 7401 | struct prefix_ipv4 p; |
7c8ff89e DS |
7402 | struct ospf_external *ext; |
7403 | struct ospf_redist *red; | |
7c8ff89e | 7404 | |
718e3744 | 7405 | p.family = AF_INET; |
7406 | p.prefix.s_addr = 0; | |
7407 | p.prefixlen = 0; | |
7408 | ||
5339cfdb | 7409 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
718e3744 | 7410 | |
7c8ff89e DS |
7411 | if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) && |
7412 | EXTERNAL_INFO (ext)) { | |
7413 | ospf_external_info_delete (DEFAULT_ROUTE, 0, p); | |
7414 | ospf_external_del (DEFAULT_ROUTE, 0); | |
718e3744 | 7415 | } |
7416 | ||
7c8ff89e DS |
7417 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
7418 | if (!red) | |
7419 | return CMD_SUCCESS; | |
7420 | ||
7421 | ospf_routemap_unset (red); | |
020709f9 | 7422 | return ospf_redistribute_default_unset (ospf); |
718e3744 | 7423 | } |
7424 | ||
7425 | DEFUN (ospf_default_metric, | |
7426 | ospf_default_metric_cmd, | |
6147e2c6 | 7427 | "default-metric (0-16777214)", |
718e3744 | 7428 | "Set metric of redistributed routes\n" |
7429 | "Default metric\n") | |
7430 | { | |
cdc2d765 | 7431 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7432 | int idx_number = 1; |
718e3744 | 7433 | int metric = -1; |
7434 | ||
8d769265 | 7435 | if (!str2metric (argv[idx_number]->arg, &metric)) |
718e3744 | 7436 | return CMD_WARNING; |
7437 | ||
68980084 | 7438 | ospf->default_metric = metric; |
718e3744 | 7439 | |
7440 | return CMD_SUCCESS; | |
7441 | } | |
7442 | ||
7443 | DEFUN (no_ospf_default_metric, | |
7444 | no_ospf_default_metric_cmd, | |
7a7be519 | 7445 | "no default-metric [(0-16777214)]", |
718e3744 | 7446 | NO_STR |
7a7be519 | 7447 | "Set metric of redistributed routes\n" |
7448 | "Default metric\n") | |
718e3744 | 7449 | { |
cdc2d765 | 7450 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
68980084 | 7451 | |
7452 | ospf->default_metric = -1; | |
7453 | ||
718e3744 | 7454 | return CMD_SUCCESS; |
7455 | } | |
7456 | ||
718e3744 | 7457 | |
7458 | DEFUN (ospf_distance, | |
7459 | ospf_distance_cmd, | |
6147e2c6 | 7460 | "distance (1-255)", |
eaa1ae0d | 7461 | "Administrative distance\n" |
718e3744 | 7462 | "OSPF Administrative distance\n") |
7463 | { | |
cdc2d765 | 7464 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7465 | int idx_number = 1; |
68980084 | 7466 | |
8d769265 | 7467 | ospf->distance_all = atoi (argv[idx_number]->arg); |
68980084 | 7468 | |
718e3744 | 7469 | return CMD_SUCCESS; |
7470 | } | |
7471 | ||
7472 | DEFUN (no_ospf_distance, | |
7473 | no_ospf_distance_cmd, | |
6147e2c6 | 7474 | "no distance (1-255)", |
718e3744 | 7475 | NO_STR |
eaa1ae0d | 7476 | "Administrative distance\n" |
718e3744 | 7477 | "OSPF Administrative distance\n") |
7478 | { | |
cdc2d765 | 7479 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
68980084 | 7480 | |
7481 | ospf->distance_all = 0; | |
7482 | ||
718e3744 | 7483 | return CMD_SUCCESS; |
7484 | } | |
7485 | ||
7486 | DEFUN (no_ospf_distance_ospf, | |
7487 | no_ospf_distance_ospf_cmd, | |
eaa1ae0d | 7488 | "no distance ospf [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]", |
718e3744 | 7489 | NO_STR |
eaa1ae0d QY |
7490 | "Administrative distance\n" |
7491 | "OSPF administrative distance\n" | |
718e3744 | 7492 | "Intra-area routes\n" |
813d4307 | 7493 | "Distance for intra-area routes\n" |
718e3744 | 7494 | "Inter-area routes\n" |
813d4307 DW |
7495 | "Distance for inter-area routes\n" |
7496 | "External routes\n" | |
7497 | "Distance for external routes\n") | |
718e3744 | 7498 | { |
cdc2d765 | 7499 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
eaa1ae0d | 7500 | int idx = 0; |
718e3744 | 7501 | |
7c8ff89e DS |
7502 | if (!ospf) |
7503 | return CMD_SUCCESS; | |
7504 | ||
eaa1ae0d QY |
7505 | if (argv_find (argv, argc, "intra-area", &idx) || argc == 3) |
7506 | idx = ospf->distance_intra = 0; | |
7507 | if (argv_find (argv, argc, "inter-area", &idx) || argc == 3) | |
7508 | idx = ospf->distance_inter = 0; | |
7509 | if (argv_find (argv, argc, "external", &idx) || argc == 3) | |
6f2a6703 | 7510 | ospf->distance_external = 0; |
718e3744 | 7511 | |
718e3744 | 7512 | return CMD_SUCCESS; |
7513 | } | |
7514 | ||
6f2a6703 CF |
7515 | DEFUN (ospf_distance_ospf, |
7516 | ospf_distance_ospf_cmd, | |
eaa1ae0d QY |
7517 | "distance ospf {intra-area (1-255)|inter-area (1-255)|external (1-255)}", |
7518 | "Administrative distance\n" | |
7519 | "OSPF administrative distance\n" | |
718e3744 | 7520 | "Intra-area routes\n" |
7521 | "Distance for intra-area routes\n" | |
718e3744 | 7522 | "Inter-area routes\n" |
7523 | "Distance for inter-area routes\n" | |
7524 | "External routes\n" | |
718e3744 | 7525 | "Distance for external routes\n") |
7526 | { | |
cdc2d765 | 7527 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
eaa1ae0d | 7528 | int idx = 0; |
68980084 | 7529 | |
eaa1ae0d QY |
7530 | if (argv_find (argv, argc, "intra-area", &idx)) |
7531 | ospf->distance_intra = atoi(argv[idx + 1]->arg); | |
7532 | idx = 0; | |
7533 | if (argv_find (argv, argc, "inter-area", &idx)) | |
7534 | ospf->distance_inter = atoi(argv[idx + 1]->arg); | |
7535 | idx = 0; | |
7536 | if (argv_find (argv, argc, "external", &idx)) | |
7537 | ospf->distance_external = atoi(argv[idx + 1]->arg); | |
68980084 | 7538 | |
718e3744 | 7539 | return CMD_SUCCESS; |
7540 | } | |
7541 | ||
d7d73ffc | 7542 | #if 0 |
718e3744 | 7543 | DEFUN (ospf_distance_source, |
7544 | ospf_distance_source_cmd, | |
6147e2c6 | 7545 | "distance (1-255) A.B.C.D/M", |
718e3744 | 7546 | "Administrative distance\n" |
7547 | "Distance value\n" | |
7548 | "IP source prefix\n") | |
7549 | { | |
cdc2d765 | 7550 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7551 | int idx_number = 1; |
7552 | int idx_ipv4_prefixlen = 2; | |
020709f9 | 7553 | |
7c8ff89e DS |
7554 | if (!ospf) |
7555 | return CMD_SUCCESS; | |
7556 | ||
8d769265 | 7557 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
68980084 | 7558 | |
718e3744 | 7559 | return CMD_SUCCESS; |
7560 | } | |
7561 | ||
7562 | DEFUN (no_ospf_distance_source, | |
7563 | no_ospf_distance_source_cmd, | |
6147e2c6 | 7564 | "no distance (1-255) A.B.C.D/M", |
718e3744 | 7565 | NO_STR |
7566 | "Administrative distance\n" | |
7567 | "Distance value\n" | |
7568 | "IP source prefix\n") | |
7569 | { | |
cdc2d765 | 7570 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7571 | int idx_number = 2; |
7572 | int idx_ipv4_prefixlen = 3; | |
020709f9 | 7573 | |
7c8ff89e DS |
7574 | if (!ospf) |
7575 | return CMD_SUCCESS; | |
7576 | ||
8d769265 | 7577 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL); |
020709f9 | 7578 | |
718e3744 | 7579 | return CMD_SUCCESS; |
7580 | } | |
7581 | ||
7582 | DEFUN (ospf_distance_source_access_list, | |
7583 | ospf_distance_source_access_list_cmd, | |
6147e2c6 | 7584 | "distance (1-255) A.B.C.D/M WORD", |
718e3744 | 7585 | "Administrative distance\n" |
7586 | "Distance value\n" | |
7587 | "IP source prefix\n" | |
7588 | "Access list name\n") | |
7589 | { | |
cdc2d765 | 7590 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7591 | int idx_number = 1; |
7592 | int idx_ipv4_prefixlen = 2; | |
7593 | int idx_word = 3; | |
020709f9 | 7594 | |
7c8ff89e DS |
7595 | if (!ospf) |
7596 | return CMD_SUCCESS; | |
7597 | ||
8d769265 | 7598 | ospf_distance_set (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 7599 | |
718e3744 | 7600 | return CMD_SUCCESS; |
7601 | } | |
7602 | ||
7603 | DEFUN (no_ospf_distance_source_access_list, | |
7604 | no_ospf_distance_source_access_list_cmd, | |
6147e2c6 | 7605 | "no distance (1-255) A.B.C.D/M WORD", |
718e3744 | 7606 | NO_STR |
7607 | "Administrative distance\n" | |
7608 | "Distance value\n" | |
7609 | "IP source prefix\n" | |
7610 | "Access list name\n") | |
7611 | { | |
cdc2d765 | 7612 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 DW |
7613 | int idx_number = 2; |
7614 | int idx_ipv4_prefixlen = 3; | |
7615 | int idx_word = 4; | |
020709f9 | 7616 | |
7c8ff89e DS |
7617 | if (!ospf) |
7618 | return CMD_SUCCESS; | |
7619 | ||
8d769265 | 7620 | ospf_distance_unset (vty, ospf, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg); |
020709f9 | 7621 | |
718e3744 | 7622 | return CMD_SUCCESS; |
7623 | } | |
d7d73ffc | 7624 | #endif |
718e3744 | 7625 | |
ba682537 | 7626 | DEFUN (ip_ospf_mtu_ignore, |
7627 | ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 7628 | "ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 7629 | "IP Information\n" |
7630 | "OSPF interface commands\n" | |
99a522c7 | 7631 | "Disable MTU mismatch detection on this interface\n" |
ba682537 | 7632 | "Address of interface") |
7633 | { | |
cdc2d765 | 7634 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 7635 | int idx_ipv4 = 3; |
ba682537 | 7636 | struct in_addr addr; |
7637 | int ret; | |
7638 | ||
7639 | struct ospf_if_params *params; | |
7640 | params = IF_DEF_PARAMS (ifp); | |
7641 | ||
7a7be519 | 7642 | if (argc == 4) |
ba682537 | 7643 | { |
8d769265 | 7644 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
ba682537 | 7645 | if (!ret) |
7646 | { | |
7647 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 7648 | VTYNL); |
ba682537 | 7649 | return CMD_WARNING; |
7650 | } | |
7651 | params = ospf_get_if_params (ifp, addr); | |
7652 | ospf_if_update_params (ifp, addr); | |
7653 | } | |
7654 | params->mtu_ignore = 1; | |
7655 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7656 | SET_IF_PARAM (params, mtu_ignore); | |
7657 | else | |
7658 | { | |
7659 | UNSET_IF_PARAM (params, mtu_ignore); | |
7660 | if (params != IF_DEF_PARAMS (ifp)) | |
7661 | { | |
7662 | ospf_free_if_params (ifp, addr); | |
7663 | ospf_if_update_params (ifp, addr); | |
7664 | } | |
7665 | } | |
7666 | return CMD_SUCCESS; | |
7667 | } | |
7668 | ||
ba682537 | 7669 | DEFUN (no_ip_ospf_mtu_ignore, |
7670 | no_ip_ospf_mtu_ignore_addr_cmd, | |
7a7be519 | 7671 | "no ip ospf mtu-ignore [A.B.C.D]", |
ba682537 | 7672 | "IP Information\n" |
7673 | "OSPF interface commands\n" | |
99a522c7 | 7674 | "Disable MTU mismatch detection on this interface\n" |
ba682537 | 7675 | "Address of interface") |
7676 | { | |
cdc2d765 | 7677 | VTY_DECLVAR_CONTEXT(interface, ifp); |
8d769265 | 7678 | int idx_ipv4 = 4; |
ba682537 | 7679 | struct in_addr addr; |
7680 | int ret; | |
7681 | ||
7682 | struct ospf_if_params *params; | |
7683 | params = IF_DEF_PARAMS (ifp); | |
7684 | ||
7a7be519 | 7685 | if (argc == 5) |
ba682537 | 7686 | { |
8d769265 | 7687 | ret = inet_aton(argv[idx_ipv4]->arg, &addr); |
ba682537 | 7688 | if (!ret) |
7689 | { | |
7690 | vty_out (vty, "Please specify interface address by A.B.C.D%s", | |
1318e7c8 | 7691 | VTYNL); |
ba682537 | 7692 | return CMD_WARNING; |
7693 | } | |
7694 | params = ospf_get_if_params (ifp, addr); | |
7695 | ospf_if_update_params (ifp, addr); | |
7696 | } | |
7697 | params->mtu_ignore = 0; | |
7698 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
7699 | SET_IF_PARAM (params, mtu_ignore); | |
7700 | else | |
7701 | { | |
7702 | UNSET_IF_PARAM (params, mtu_ignore); | |
7703 | if (params != IF_DEF_PARAMS (ifp)) | |
7704 | { | |
7705 | ospf_free_if_params (ifp, addr); | |
7706 | ospf_if_update_params (ifp, addr); | |
7707 | } | |
7708 | } | |
7709 | return CMD_SUCCESS; | |
7710 | } | |
7711 | ||
6b0655a2 | 7712 | |
88d6cf37 | 7713 | DEFUN (ospf_max_metric_router_lsa_admin, |
7714 | ospf_max_metric_router_lsa_admin_cmd, | |
7715 | "max-metric router-lsa administrative", | |
7716 | "OSPF maximum / infinite-distance metric\n" | |
7717 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7718 | "Administratively applied, for an indefinite period\n") | |
7719 | { | |
cdc2d765 | 7720 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
88d6cf37 | 7721 | struct listnode *ln; |
7722 | struct ospf_area *area; | |
7c8ff89e | 7723 | |
88d6cf37 | 7724 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7725 | { | |
7726 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7727 | ||
7728 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) | |
c363d386 | 7729 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7730 | } |
4ba4fc85 AB |
7731 | |
7732 | /* Allows for areas configured later to get the property */ | |
7733 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; | |
7734 | ||
88d6cf37 | 7735 | return CMD_SUCCESS; |
7736 | } | |
7737 | ||
7738 | DEFUN (no_ospf_max_metric_router_lsa_admin, | |
7739 | no_ospf_max_metric_router_lsa_admin_cmd, | |
7740 | "no max-metric router-lsa administrative", | |
7741 | NO_STR | |
7742 | "OSPF maximum / infinite-distance metric\n" | |
7743 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7744 | "Administratively applied, for an indefinite period\n") | |
7745 | { | |
cdc2d765 | 7746 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
88d6cf37 | 7747 | struct listnode *ln; |
7748 | struct ospf_area *area; | |
7c8ff89e | 7749 | |
88d6cf37 | 7750 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7751 | { | |
7752 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); | |
7753 | ||
7754 | /* Don't trample on the start-up stub timer */ | |
7755 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) | |
7756 | && !area->t_stub_router) | |
7757 | { | |
7758 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 7759 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7760 | } |
7761 | } | |
4ba4fc85 | 7762 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
88d6cf37 | 7763 | return CMD_SUCCESS; |
7764 | } | |
7765 | ||
7766 | DEFUN (ospf_max_metric_router_lsa_startup, | |
7767 | ospf_max_metric_router_lsa_startup_cmd, | |
6147e2c6 | 7768 | "max-metric router-lsa on-startup (5-86400)", |
88d6cf37 | 7769 | "OSPF maximum / infinite-distance metric\n" |
7770 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7771 | "Automatically advertise stub Router-LSA on startup of OSPF\n" | |
7772 | "Time (seconds) to advertise self as stub-router\n") | |
7773 | { | |
cdc2d765 | 7774 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7775 | int idx_number = 3; |
88d6cf37 | 7776 | unsigned int seconds; |
7c8ff89e | 7777 | |
88d6cf37 | 7778 | if (argc != 1) |
7779 | { | |
7780 | vty_out (vty, "%% Must supply stub-router period"); | |
7781 | return CMD_WARNING; | |
7782 | } | |
7783 | ||
facfee22 | 7784 | seconds = strtoul(argv[idx_number]->arg, NULL, 10); |
88d6cf37 | 7785 | |
7786 | ospf->stub_router_startup_time = seconds; | |
7787 | ||
7788 | return CMD_SUCCESS; | |
7789 | } | |
7790 | ||
7791 | DEFUN (no_ospf_max_metric_router_lsa_startup, | |
7792 | no_ospf_max_metric_router_lsa_startup_cmd, | |
7a7be519 | 7793 | "no max-metric router-lsa on-startup [(5-86400)]", |
88d6cf37 | 7794 | NO_STR |
7795 | "OSPF maximum / infinite-distance metric\n" | |
7796 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
7797 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
7798 | "Time (seconds) to advertise self as stub-router\n") | |
88d6cf37 | 7799 | { |
cdc2d765 | 7800 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
88d6cf37 | 7801 | struct listnode *ln; |
7802 | struct ospf_area *area; | |
7c8ff89e | 7803 | |
88d6cf37 | 7804 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
7805 | ||
7806 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) | |
7807 | { | |
7808 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); | |
7809 | OSPF_TIMER_OFF (area->t_stub_router); | |
7810 | ||
7811 | /* Don't trample on admin stub routed */ | |
7812 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
7813 | { | |
7814 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); | |
c363d386 | 7815 | ospf_router_lsa_update_area (area); |
88d6cf37 | 7816 | } |
7817 | } | |
7818 | return CMD_SUCCESS; | |
7819 | } | |
7820 | ||
a1afa410 | 7821 | |
88d6cf37 | 7822 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
7823 | ospf_max_metric_router_lsa_shutdown_cmd, | |
6147e2c6 | 7824 | "max-metric router-lsa on-shutdown (5-100)", |
88d6cf37 | 7825 | "OSPF maximum / infinite-distance metric\n" |
7826 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
7827 | "Advertise stub-router prior to full shutdown of OSPF\n" | |
7828 | "Time (seconds) to wait till full shutdown\n") | |
7829 | { | |
cdc2d765 | 7830 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
8d769265 | 7831 | int idx_number = 3; |
88d6cf37 | 7832 | unsigned int seconds; |
7c8ff89e | 7833 | |
88d6cf37 | 7834 | if (argc != 1) |
7835 | { | |
7836 | vty_out (vty, "%% Must supply stub-router shutdown period"); | |
7837 | return CMD_WARNING; | |
7838 | } | |
7839 | ||
facfee22 | 7840 | seconds = strtoul(argv[idx_number]->arg, NULL, 10); |
88d6cf37 | 7841 | |
7842 | ospf->stub_router_shutdown_time = seconds; | |
7843 | ||
7844 | return CMD_SUCCESS; | |
7845 | } | |
7846 | ||
7847 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, | |
7848 | no_ospf_max_metric_router_lsa_shutdown_cmd, | |
7a7be519 | 7849 | "no max-metric router-lsa on-shutdown [(5-100)]", |
88d6cf37 | 7850 | NO_STR |
7851 | "OSPF maximum / infinite-distance metric\n" | |
7852 | "Advertise own Router-LSA with infinite distance (stub router)\n" | |
813d4307 DW |
7853 | "Advertise stub-router prior to full shutdown of OSPF\n" |
7854 | "Time (seconds) to wait till full shutdown\n") | |
88d6cf37 | 7855 | { |
cdc2d765 | 7856 | VTY_DECLVAR_CONTEXT(ospf, ospf); |
7c8ff89e | 7857 | |
88d6cf37 | 7858 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
7859 | ||
7860 | return CMD_SUCCESS; | |
7861 | } | |
7862 | ||
a636c635 DW |
7863 | static void |
7864 | config_write_stub_router (struct vty *vty, struct ospf *ospf) | |
88d6cf37 | 7865 | { |
7866 | struct listnode *ln; | |
7867 | struct ospf_area *area; | |
7868 | ||
7869 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) | |
7870 | vty_out (vty, " max-metric router-lsa on-startup %u%s", | |
1318e7c8 | 7871 | ospf->stub_router_startup_time, VTYNL); |
88d6cf37 | 7872 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
7873 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", | |
1318e7c8 | 7874 | ospf->stub_router_shutdown_time, VTYNL); |
88d6cf37 | 7875 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
7876 | { | |
7877 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) | |
7878 | { | |
7879 | vty_out (vty, " max-metric router-lsa administrative%s", | |
1318e7c8 | 7880 | VTYNL); |
88d6cf37 | 7881 | break; |
7882 | } | |
7883 | } | |
7884 | return; | |
7885 | } | |
6b0655a2 | 7886 | |
4dadc291 | 7887 | static void |
718e3744 | 7888 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
7889 | { | |
7890 | struct route_node *rn; | |
7891 | struct ospf_route *or; | |
1eb8ef25 | 7892 | struct listnode *pnode, *pnnode; |
718e3744 | 7893 | struct ospf_path *path; |
7894 | ||
7895 | vty_out (vty, "============ OSPF network routing table ============%s", | |
1318e7c8 | 7896 | VTYNL); |
718e3744 | 7897 | |
7898 | for (rn = route_top (rt); rn; rn = route_next (rn)) | |
7899 | if ((or = rn->info) != NULL) | |
7900 | { | |
7901 | char buf1[19]; | |
7902 | snprintf (buf1, 19, "%s/%d", | |
7903 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
7904 | ||
7905 | switch (or->path_type) | |
7906 | { | |
7907 | case OSPF_PATH_INTER_AREA: | |
7908 | if (or->type == OSPF_DESTINATION_NETWORK) | |
7909 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, | |
1318e7c8 | 7910 | inet_ntoa (or->u.std.area_id), VTYNL); |
718e3744 | 7911 | else if (or->type == OSPF_DESTINATION_DISCARD) |
1318e7c8 | 7912 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTYNL); |
718e3744 | 7913 | break; |
7914 | case OSPF_PATH_INTRA_AREA: | |
7915 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, | |
1318e7c8 | 7916 | inet_ntoa (or->u.std.area_id), VTYNL); |
718e3744 | 7917 | break; |
7918 | default: | |
7919 | break; | |
7920 | } | |
7921 | ||
7922 | if (or->type == OSPF_DESTINATION_NETWORK) | |
1eb8ef25 | 7923 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
96735eea | 7924 | { |
7e2b7603 | 7925 | if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) |
96735eea | 7926 | { |
7927 | if (path->nexthop.s_addr == 0) | |
7928 | vty_out (vty, "%24s directly attached to %s%s", | |
1318e7c8 | 7929 | "", ifindex2ifname (path->ifindex, VRF_DEFAULT), VTYNL); |
96735eea | 7930 | else |
7931 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f | 7932 | inet_ntoa (path->nexthop), |
1318e7c8 | 7933 | ifindex2ifname (path->ifindex, VRF_DEFAULT), VTYNL); |
96735eea | 7934 | } |
7935 | } | |
718e3744 | 7936 | } |
1318e7c8 | 7937 | vty_out (vty, "%s", VTYNL); |
718e3744 | 7938 | } |
7939 | ||
4dadc291 | 7940 | static void |
718e3744 | 7941 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
7942 | { | |
7943 | struct route_node *rn; | |
7944 | struct ospf_route *or; | |
1eb8ef25 | 7945 | struct listnode *pnode; |
7946 | struct listnode *node; | |
718e3744 | 7947 | struct ospf_path *path; |
7948 | ||
7949 | vty_out (vty, "============ OSPF router routing table =============%s", | |
1318e7c8 | 7950 | VTYNL); |
718e3744 | 7951 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
7952 | if (rn->info) | |
7953 | { | |
7954 | int flag = 0; | |
7955 | ||
7956 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); | |
7957 | ||
1eb8ef25 | 7958 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
7959 | { | |
7960 | if (flag++) | |
7961 | vty_out (vty, "%24s", ""); | |
7962 | ||
7963 | /* Show path. */ | |
7964 | vty_out (vty, "%s [%d] area: %s", | |
7965 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), | |
7966 | or->cost, inet_ntoa (or->u.std.area_id)); | |
7967 | /* Show flags. */ | |
7968 | vty_out (vty, "%s%s%s", | |
7969 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), | |
7970 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), | |
1318e7c8 | 7971 | VTYNL); |
1eb8ef25 | 7972 | |
7973 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) | |
7974 | { | |
7e2b7603 | 7975 | if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) |
54bedb55 | 7976 | { |
7977 | if (path->nexthop.s_addr == 0) | |
7978 | vty_out (vty, "%24s directly attached to %s%s", | |
baaea325 | 7979 | "", ifindex2ifname (path->ifindex, VRF_DEFAULT), |
1318e7c8 | 7980 | VTYNL); |
54bedb55 | 7981 | else |
7982 | vty_out (vty, "%24s via %s, %s%s", "", | |
7983 | inet_ntoa (path->nexthop), | |
baaea325 | 7984 | ifindex2ifname (path->ifindex, VRF_DEFAULT), |
1318e7c8 | 7985 | VTYNL); |
54bedb55 | 7986 | } |
1eb8ef25 | 7987 | } |
7988 | } | |
718e3744 | 7989 | } |
1318e7c8 | 7990 | vty_out (vty, "%s", VTYNL); |
718e3744 | 7991 | } |
7992 | ||
4dadc291 | 7993 | static void |
718e3744 | 7994 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
7995 | { | |
7996 | struct route_node *rn; | |
7997 | struct ospf_route *er; | |
1eb8ef25 | 7998 | struct listnode *pnode, *pnnode; |
718e3744 | 7999 | struct ospf_path *path; |
8000 | ||
8001 | vty_out (vty, "============ OSPF external routing table ===========%s", | |
1318e7c8 | 8002 | VTYNL); |
718e3744 | 8003 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
8004 | if ((er = rn->info) != NULL) | |
8005 | { | |
8006 | char buf1[19]; | |
8007 | snprintf (buf1, 19, "%s/%d", | |
8008 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); | |
8009 | ||
8010 | switch (er->path_type) | |
8011 | { | |
8012 | case OSPF_PATH_TYPE1_EXTERNAL: | |
dc9ffce8 | 8013 | vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1, |
1318e7c8 | 8014 | er->cost, er->u.ext.tag, VTYNL); |
718e3744 | 8015 | break; |
8016 | case OSPF_PATH_TYPE2_EXTERNAL: | |
dc9ffce8 | 8017 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost, |
1318e7c8 | 8018 | er->u.ext.type2_cost, er->u.ext.tag, VTYNL); |
718e3744 | 8019 | break; |
8020 | } | |
8021 | ||
1eb8ef25 | 8022 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
718e3744 | 8023 | { |
7e2b7603 | 8024 | if (if_lookup_by_index(path->ifindex, VRF_DEFAULT)) |
718e3744 | 8025 | { |
8026 | if (path->nexthop.s_addr == 0) | |
96735eea | 8027 | vty_out (vty, "%24s directly attached to %s%s", |
1318e7c8 | 8028 | "", ifindex2ifname (path->ifindex, VRF_DEFAULT), VTYNL); |
96735eea | 8029 | else |
8030 | vty_out (vty, "%24s via %s, %s%s", "", | |
a8ba847f | 8031 | inet_ntoa (path->nexthop), |
baaea325 | 8032 | ifindex2ifname (path->ifindex, VRF_DEFAULT), |
1318e7c8 | 8033 | VTYNL); |
718e3744 | 8034 | } |
8035 | } | |
8036 | } | |
1318e7c8 | 8037 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8038 | } |
8039 | ||
7c8ff89e DS |
8040 | static int |
8041 | show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf) | |
718e3744 | 8042 | { |
7c8ff89e | 8043 | if (ospf->instance) |
1318e7c8 QY |
8044 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
8045 | VTYNL, VTYNL); | |
718e3744 | 8046 | |
68980084 | 8047 | if (ospf->new_table == NULL) |
718e3744 | 8048 | { |
1318e7c8 | 8049 | vty_out (vty, "No OSPF routing information exist%s", VTYNL); |
718e3744 | 8050 | return CMD_SUCCESS; |
8051 | } | |
8052 | ||
8053 | /* Show Network routes. | |
020709f9 | 8054 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
718e3744 | 8055 | |
8056 | /* Show Router routes. */ | |
68980084 | 8057 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8058 | |
1318e7c8 | 8059 | vty_out (vty, "%s", VTYNL); |
7c8ff89e | 8060 | |
718e3744 | 8061 | return CMD_SUCCESS; |
8062 | } | |
718e3744 | 8063 | |
7c8ff89e DS |
8064 | DEFUN (show_ip_ospf_border_routers, |
8065 | show_ip_ospf_border_routers_cmd, | |
8066 | "show ip ospf border-routers", | |
718e3744 | 8067 | SHOW_STR |
8068 | IP_STR | |
8069 | "OSPF information\n" | |
7c8ff89e | 8070 | "Show all the ABR's and ASBR's\n") |
718e3744 | 8071 | { |
020709f9 | 8072 | struct ospf *ospf; |
68980084 | 8073 | |
0bad4851 | 8074 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8075 | return CMD_SUCCESS; |
8076 | ||
8077 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8078 | } | |
8079 | ||
8080 | DEFUN (show_ip_ospf_instance_border_routers, | |
8081 | show_ip_ospf_instance_border_routers_cmd, | |
6147e2c6 | 8082 | "show ip ospf (1-65535) border-routers", |
7c8ff89e DS |
8083 | SHOW_STR |
8084 | IP_STR | |
8085 | "OSPF information\n" | |
8086 | "Instance ID\n" | |
8087 | "Show all the ABR's and ASBR's\n") | |
8088 | { | |
8d769265 | 8089 | int idx_number = 3; |
7c8ff89e DS |
8090 | struct ospf *ospf; |
8091 | u_short instance = 0; | |
8092 | ||
facfee22 | 8093 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 8094 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8095 | return CMD_SUCCESS; |
8096 | ||
8097 | return show_ip_ospf_border_routers_common(vty, ospf); | |
8098 | } | |
8099 | ||
8100 | static int | |
8101 | show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf) | |
8102 | { | |
8103 | if (ospf->instance) | |
1318e7c8 QY |
8104 | vty_out (vty, "%sOSPF Instance: %d%s%s", VTYNL, ospf->instance, |
8105 | VTYNL, VTYNL); | |
718e3744 | 8106 | |
68980084 | 8107 | if (ospf->new_table == NULL) |
718e3744 | 8108 | { |
1318e7c8 | 8109 | vty_out (vty, "No OSPF routing information exist%s", VTYNL); |
718e3744 | 8110 | return CMD_SUCCESS; |
8111 | } | |
8112 | ||
8113 | /* Show Network routes. */ | |
68980084 | 8114 | show_ip_ospf_route_network (vty, ospf->new_table); |
718e3744 | 8115 | |
8116 | /* Show Router routes. */ | |
68980084 | 8117 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
718e3744 | 8118 | |
8119 | /* Show AS External routes. */ | |
68980084 | 8120 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
718e3744 | 8121 | |
1318e7c8 | 8122 | vty_out (vty, "%s", VTYNL); |
7c8ff89e | 8123 | |
718e3744 | 8124 | return CMD_SUCCESS; |
8125 | } | |
8126 | ||
7c8ff89e DS |
8127 | DEFUN (show_ip_ospf_route, |
8128 | show_ip_ospf_route_cmd, | |
8129 | "show ip ospf route", | |
8130 | SHOW_STR | |
8131 | IP_STR | |
8132 | "OSPF information\n" | |
8133 | "OSPF routing table\n") | |
8134 | { | |
8135 | struct ospf *ospf; | |
8136 | ||
0bad4851 | 8137 | if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8138 | return CMD_SUCCESS; |
8139 | ||
8140 | return show_ip_ospf_route_common(vty, ospf); | |
8141 | } | |
8142 | ||
8143 | DEFUN (show_ip_ospf_instance_route, | |
8144 | show_ip_ospf_instance_route_cmd, | |
6147e2c6 | 8145 | "show ip ospf (1-65535) route", |
7c8ff89e DS |
8146 | SHOW_STR |
8147 | IP_STR | |
8148 | "OSPF information\n" | |
8149 | "Instance ID\n" | |
8150 | "OSPF routing table\n") | |
8151 | { | |
8d769265 | 8152 | int idx_number = 3; |
7c8ff89e DS |
8153 | struct ospf *ospf; |
8154 | u_short instance = 0; | |
8155 | ||
facfee22 | 8156 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
0bad4851 | 8157 | if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) |
7c8ff89e DS |
8158 | return CMD_SUCCESS; |
8159 | ||
8160 | return show_ip_ospf_route_common(vty, ospf); | |
8161 | } | |
6b0655a2 | 8162 | |
eb1ce605 | 8163 | const char *ospf_abr_type_str[] = |
718e3744 | 8164 | { |
8165 | "unknown", | |
8166 | "standard", | |
8167 | "ibm", | |
8168 | "cisco", | |
8169 | "shortcut" | |
8170 | }; | |
8171 | ||
eb1ce605 | 8172 | const char *ospf_shortcut_mode_str[] = |
718e3744 | 8173 | { |
8174 | "default", | |
8175 | "enable", | |
8176 | "disable" | |
8177 | }; | |
8178 | ||
eb1ce605 | 8179 | const char *ospf_int_type_str[] = |
718e3744 | 8180 | { |
8181 | "unknown", /* should never be used. */ | |
8182 | "point-to-point", | |
8183 | "broadcast", | |
8184 | "non-broadcast", | |
8185 | "point-to-multipoint", | |
8186 | "virtual-link", /* should never be used. */ | |
8187 | "loopback" | |
8188 | }; | |
8189 | ||
8190 | /* Configuration write function for ospfd. */ | |
4dadc291 | 8191 | static int |
718e3744 | 8192 | config_write_interface (struct vty *vty) |
8193 | { | |
52dc7ee6 | 8194 | struct listnode *n1, *n2; |
718e3744 | 8195 | struct interface *ifp; |
8196 | struct crypt_key *ck; | |
8197 | int write = 0; | |
8198 | struct route_node *rn = NULL; | |
8199 | struct ospf_if_params *params; | |
7c8ff89e | 8200 | struct ospf *ospf = ospf_lookup(); |
718e3744 | 8201 | |
b2d7c082 | 8202 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp)) |
718e3744 | 8203 | { |
718e3744 | 8204 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
8205 | continue; | |
8206 | ||
84361d61 DS |
8207 | if (ifp->ifindex == IFINDEX_DELETED) |
8208 | continue; | |
8209 | ||
1318e7c8 | 8210 | vty_out (vty, "!%s", VTYNL); |
718e3744 | 8211 | vty_out (vty, "interface %s%s", ifp->name, |
1318e7c8 | 8212 | VTYNL); |
718e3744 | 8213 | if (ifp->desc) |
8214 | vty_out (vty, " description %s%s", ifp->desc, | |
1318e7c8 | 8215 | VTYNL); |
718e3744 | 8216 | |
8217 | write++; | |
8218 | ||
8219 | params = IF_DEF_PARAMS (ifp); | |
8220 | ||
8221 | do { | |
8222 | /* Interface Network print. */ | |
8223 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && | |
718e3744 | 8224 | params->type != OSPF_IFTYPE_LOOPBACK) |
8225 | { | |
bc18d616 | 8226 | if (params->type != ospf_default_iftype(ifp)) |
7b90143f | 8227 | { |
8228 | vty_out (vty, " ip ospf network %s", | |
8229 | ospf_int_type_str[params->type]); | |
8230 | if (params != IF_DEF_PARAMS (ifp)) | |
8231 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8232 | vty_out (vty, "%s", VTYNL); |
7b90143f | 8233 | } |
718e3744 | 8234 | } |
8235 | ||
8236 | /* OSPF interface authentication print */ | |
8237 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && | |
8238 | params->auth_type != OSPF_AUTH_NOTSET) | |
8239 | { | |
eb1ce605 | 8240 | const char *auth_str; |
718e3744 | 8241 | |
8242 | /* Translation tables are not that much help here due to syntax | |
8243 | of the simple option */ | |
8244 | switch (params->auth_type) | |
8245 | { | |
8246 | ||
8247 | case OSPF_AUTH_NULL: | |
8248 | auth_str = " null"; | |
8249 | break; | |
8250 | ||
8251 | case OSPF_AUTH_SIMPLE: | |
8252 | auth_str = ""; | |
8253 | break; | |
8254 | ||
8255 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
8256 | auth_str = " message-digest"; | |
8257 | break; | |
8258 | ||
8259 | default: | |
8260 | auth_str = ""; | |
8261 | break; | |
8262 | } | |
8263 | ||
8264 | vty_out (vty, " ip ospf authentication%s", auth_str); | |
8265 | if (params != IF_DEF_PARAMS (ifp)) | |
8266 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8267 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8268 | } |
8269 | ||
8270 | /* Simple Authentication Password print. */ | |
8271 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && | |
8272 | params->auth_simple[0] != '\0') | |
8273 | { | |
8274 | vty_out (vty, " ip ospf authentication-key %s", | |
8275 | params->auth_simple); | |
8276 | if (params != IF_DEF_PARAMS (ifp)) | |
8277 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8278 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8279 | } |
8280 | ||
8281 | /* Cryptographic Authentication Key print. */ | |
1eb8ef25 | 8282 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
718e3744 | 8283 | { |
718e3744 | 8284 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
7c8ff89e | 8285 | ck->key_id, ck->auth_key); |
718e3744 | 8286 | if (params != IF_DEF_PARAMS (ifp)) |
8287 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8288 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8289 | } |
8290 | ||
8291 | /* Interface Output Cost print. */ | |
8292 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) | |
8293 | { | |
8294 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); | |
8295 | if (params != IF_DEF_PARAMS (ifp)) | |
8296 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8297 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8298 | } |
8299 | ||
8300 | /* Hello Interval print. */ | |
8301 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && | |
8302 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) | |
8303 | { | |
8304 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); | |
8305 | if (params != IF_DEF_PARAMS (ifp)) | |
8306 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8307 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8308 | } |
8309 | ||
8310 | ||
8311 | /* Router Dead Interval print. */ | |
8312 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && | |
8313 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) | |
8314 | { | |
f9ad937f | 8315 | vty_out (vty, " ip ospf dead-interval "); |
8316 | ||
8317 | /* fast hello ? */ | |
8318 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) | |
8319 | vty_out (vty, "minimal hello-multiplier %d", | |
8320 | params->fast_hello); | |
8321 | else | |
8322 | vty_out (vty, "%u", params->v_wait); | |
8323 | ||
718e3744 | 8324 | if (params != IF_DEF_PARAMS (ifp)) |
8325 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8326 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8327 | } |
8328 | ||
8329 | /* Router Priority print. */ | |
8330 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && | |
8331 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) | |
8332 | { | |
8333 | vty_out (vty, " ip ospf priority %u", params->priority); | |
8334 | if (params != IF_DEF_PARAMS (ifp)) | |
8335 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8336 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8337 | } |
8338 | ||
8339 | /* Retransmit Interval print. */ | |
8340 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && | |
8341 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) | |
8342 | { | |
8343 | vty_out (vty, " ip ospf retransmit-interval %u", | |
8344 | params->retransmit_interval); | |
8345 | if (params != IF_DEF_PARAMS (ifp)) | |
8346 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8347 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8348 | } |
8349 | ||
8350 | /* Transmit Delay print. */ | |
8351 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && | |
8352 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8353 | { | |
8354 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); | |
8355 | if (params != IF_DEF_PARAMS (ifp)) | |
8356 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8357 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8358 | } |
8359 | ||
953cde65 JT |
8360 | /* Area print. */ |
8361 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) | |
8362 | { | |
8363 | if (ospf->instance) | |
52c62ab8 | 8364 | vty_out (vty, " ip ospf %d", ospf->instance); |
953cde65 | 8365 | else |
52c62ab8 | 8366 | vty_out (vty, " ip ospf"); |
953cde65 | 8367 | |
52c62ab8 JAG |
8368 | vty_out (vty, " area %s", inet_ntoa (params->if_area)); |
8369 | if (params != IF_DEF_PARAMS (ifp)) | |
8370 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8371 | vty_out (vty, VTYNL); |
953cde65 JT |
8372 | } |
8373 | ||
d5a5c8f0 | 8374 | /* bfd print. */ |
7f342629 | 8375 | ospf_bfd_write_config(vty, params); |
d5a5c8f0 | 8376 | |
ba682537 | 8377 | /* MTU ignore print. */ |
8378 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && | |
8379 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) | |
8380 | { | |
8381 | if (params->mtu_ignore == 0) | |
8382 | vty_out (vty, " no ip ospf mtu-ignore"); | |
8383 | else | |
8384 | vty_out (vty, " ip ospf mtu-ignore"); | |
8385 | if (params != IF_DEF_PARAMS (ifp)) | |
8386 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); | |
1318e7c8 | 8387 | vty_out (vty, "%s", VTYNL); |
ba682537 | 8388 | } |
8389 | ||
8390 | ||
718e3744 | 8391 | while (1) |
8392 | { | |
8393 | if (rn == NULL) | |
8394 | rn = route_top (IF_OIFS_PARAMS (ifp)); | |
8395 | else | |
8396 | rn = route_next (rn); | |
8397 | ||
8398 | if (rn == NULL) | |
8399 | break; | |
8400 | params = rn->info; | |
8401 | if (params != NULL) | |
8402 | break; | |
8403 | } | |
8404 | } while (rn); | |
8405 | ||
718e3744 | 8406 | ospf_opaque_config_write_if (vty, ifp); |
718e3744 | 8407 | } |
8408 | ||
8409 | return write; | |
8410 | } | |
8411 | ||
4dadc291 | 8412 | static int |
68980084 | 8413 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8414 | { |
8415 | struct route_node *rn; | |
8416 | u_char buf[INET_ADDRSTRLEN]; | |
8417 | ||
8418 | /* `network area' print. */ | |
68980084 | 8419 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
718e3744 | 8420 | if (rn->info) |
8421 | { | |
8422 | struct ospf_network *n = rn->info; | |
8423 | ||
8424 | memset (buf, 0, INET_ADDRSTRLEN); | |
8425 | ||
8426 | /* Create Area ID string by specified Area ID format. */ | |
86573dcb | 8427 | if (n->area_id_fmt == OSPF_AREA_ID_FMT_DOTTEDQUAD) |
c9e52be3 | 8428 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
718e3744 | 8429 | else |
c9e52be3 | 8430 | sprintf ((char *) buf, "%lu", |
718e3744 | 8431 | (unsigned long int) ntohl (n->area_id.s_addr)); |
8432 | ||
8433 | /* Network print. */ | |
8434 | vty_out (vty, " network %s/%d area %s%s", | |
8435 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
1318e7c8 | 8436 | buf, VTYNL); |
718e3744 | 8437 | } |
8438 | ||
8439 | return 0; | |
8440 | } | |
8441 | ||
4dadc291 | 8442 | static int |
68980084 | 8443 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
718e3744 | 8444 | { |
52dc7ee6 | 8445 | struct listnode *node; |
1eb8ef25 | 8446 | struct ospf_area *area; |
718e3744 | 8447 | u_char buf[INET_ADDRSTRLEN]; |
8448 | ||
8449 | /* Area configuration print. */ | |
1eb8ef25 | 8450 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 8451 | { |
718e3744 | 8452 | struct route_node *rn1; |
8453 | ||
86573dcb QY |
8454 | area_id2str ((char *) buf, INET_ADDRSTRLEN, &area->area_id, |
8455 | area->area_id_fmt); | |
718e3744 | 8456 | |
8457 | if (area->auth_type != OSPF_AUTH_NULL) | |
8458 | { | |
8459 | if (area->auth_type == OSPF_AUTH_SIMPLE) | |
1318e7c8 | 8460 | vty_out (vty, " area %s authentication%s", buf, VTYNL); |
718e3744 | 8461 | else |
8462 | vty_out (vty, " area %s authentication message-digest%s", | |
1318e7c8 | 8463 | buf, VTYNL); |
718e3744 | 8464 | } |
8465 | ||
8466 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) | |
8467 | vty_out (vty, " area %s shortcut %s%s", buf, | |
8468 | ospf_shortcut_mode_str[area->shortcut_configured], | |
1318e7c8 | 8469 | VTYNL); |
718e3744 | 8470 | |
8471 | if ((area->external_routing == OSPF_AREA_STUB) | |
718e3744 | 8472 | || (area->external_routing == OSPF_AREA_NSSA) |
718e3744 | 8473 | ) |
8474 | { | |
b0a053be | 8475 | if (area->external_routing == OSPF_AREA_STUB) |
8476 | vty_out (vty, " area %s stub", buf); | |
b0a053be | 8477 | else if (area->external_routing == OSPF_AREA_NSSA) |
8478 | { | |
8479 | vty_out (vty, " area %s nssa", buf); | |
8480 | switch (area->NSSATranslatorRole) | |
8481 | { | |
8482 | case OSPF_NSSA_ROLE_NEVER: | |
8483 | vty_out (vty, " translate-never"); | |
8484 | break; | |
8485 | case OSPF_NSSA_ROLE_ALWAYS: | |
8486 | vty_out (vty, " translate-always"); | |
8487 | break; | |
8488 | case OSPF_NSSA_ROLE_CANDIDATE: | |
8489 | default: | |
8490 | vty_out (vty, " translate-candidate"); | |
8491 | } | |
8492 | } | |
718e3744 | 8493 | |
8494 | if (area->no_summary) | |
8495 | vty_out (vty, " no-summary"); | |
8496 | ||
1318e7c8 | 8497 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8498 | |
8499 | if (area->default_cost != 1) | |
8500 | vty_out (vty, " area %s default-cost %d%s", buf, | |
1318e7c8 | 8501 | area->default_cost, VTYNL); |
718e3744 | 8502 | } |
8503 | ||
8504 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) | |
8505 | if (rn1->info) | |
8506 | { | |
8507 | struct ospf_area_range *range = rn1->info; | |
8508 | ||
8509 | vty_out (vty, " area %s range %s/%d", buf, | |
8510 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); | |
8511 | ||
6c835671 | 8512 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
718e3744 | 8513 | vty_out (vty, " cost %d", range->cost_config); |
8514 | ||
8515 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) | |
8516 | vty_out (vty, " not-advertise"); | |
8517 | ||
8518 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) | |
8519 | vty_out (vty, " substitute %s/%d", | |
8520 | inet_ntoa (range->subst_addr), range->subst_masklen); | |
8521 | ||
1318e7c8 | 8522 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8523 | } |
8524 | ||
8525 | if (EXPORT_NAME (area)) | |
8526 | vty_out (vty, " area %s export-list %s%s", buf, | |
1318e7c8 | 8527 | EXPORT_NAME (area), VTYNL); |
718e3744 | 8528 | |
8529 | if (IMPORT_NAME (area)) | |
8530 | vty_out (vty, " area %s import-list %s%s", buf, | |
1318e7c8 | 8531 | IMPORT_NAME (area), VTYNL); |
718e3744 | 8532 | |
8533 | if (PREFIX_NAME_IN (area)) | |
8534 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, | |
1318e7c8 | 8535 | PREFIX_NAME_IN (area), VTYNL); |
718e3744 | 8536 | |
8537 | if (PREFIX_NAME_OUT (area)) | |
8538 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, | |
1318e7c8 | 8539 | PREFIX_NAME_OUT (area), VTYNL); |
718e3744 | 8540 | } |
8541 | ||
8542 | return 0; | |
8543 | } | |
8544 | ||
4dadc291 | 8545 | static int |
68980084 | 8546 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
718e3744 | 8547 | { |
8548 | struct ospf_nbr_nbma *nbr_nbma; | |
8549 | struct route_node *rn; | |
8550 | ||
8551 | /* Static Neighbor configuration print. */ | |
68980084 | 8552 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
718e3744 | 8553 | if ((nbr_nbma = rn->info)) |
8554 | { | |
8555 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); | |
8556 | ||
8557 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) | |
8558 | vty_out (vty, " priority %d", nbr_nbma->priority); | |
8559 | ||
8560 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) | |
8561 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); | |
8562 | ||
1318e7c8 | 8563 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8564 | } |
8565 | ||
8566 | return 0; | |
8567 | } | |
8568 | ||
4dadc291 | 8569 | static int |
68980084 | 8570 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
718e3744 | 8571 | { |
52dc7ee6 | 8572 | struct listnode *node; |
1eb8ef25 | 8573 | struct ospf_vl_data *vl_data; |
86573dcb | 8574 | char buf[INET_ADDRSTRLEN]; |
718e3744 | 8575 | |
8576 | /* Virtual-Link print */ | |
1eb8ef25 | 8577 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
718e3744 | 8578 | { |
52dc7ee6 | 8579 | struct listnode *n2; |
718e3744 | 8580 | struct crypt_key *ck; |
718e3744 | 8581 | struct ospf_interface *oi; |
8582 | ||
8583 | if (vl_data != NULL) | |
8584 | { | |
8585 | memset (buf, 0, INET_ADDRSTRLEN); | |
86573dcb QY |
8586 | |
8587 | area_id2str (buf, sizeof(buf), &vl_data->vl_area_id, vl_data->vl_area_id_fmt); | |
718e3744 | 8588 | oi = vl_data->vl_oi; |
8589 | ||
8590 | /* timers */ | |
8591 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || | |
8592 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || | |
8593 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || | |
8594 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) | |
8595 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", | |
8596 | buf, | |
8597 | inet_ntoa (vl_data->vl_peer), | |
8598 | OSPF_IF_PARAM (oi, v_hello), | |
8599 | OSPF_IF_PARAM (oi, retransmit_interval), | |
8600 | OSPF_IF_PARAM (oi, transmit_delay), | |
8601 | OSPF_IF_PARAM (oi, v_wait), | |
1318e7c8 | 8602 | VTYNL); |
718e3744 | 8603 | else |
8604 | vty_out (vty, " area %s virtual-link %s%s", buf, | |
1318e7c8 | 8605 | inet_ntoa (vl_data->vl_peer), VTYNL); |
718e3744 | 8606 | /* Auth key */ |
8607 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') | |
8608 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", | |
8609 | buf, | |
8610 | inet_ntoa (vl_data->vl_peer), | |
8611 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, | |
1318e7c8 | 8612 | VTYNL); |
718e3744 | 8613 | /* md5 keys */ |
1eb8ef25 | 8614 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
8615 | n2, ck)) | |
8616 | vty_out (vty, " area %s virtual-link %s" | |
8617 | " message-digest-key %d md5 %s%s", | |
8618 | buf, | |
8619 | inet_ntoa (vl_data->vl_peer), | |
1318e7c8 | 8620 | ck->key_id, ck->auth_key, VTYNL); |
718e3744 | 8621 | |
8622 | } | |
8623 | } | |
8624 | ||
8625 | return 0; | |
8626 | } | |
8627 | ||
6b0655a2 | 8628 | |
4dadc291 | 8629 | static int |
68980084 | 8630 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8631 | { |
8632 | int type; | |
8633 | ||
8634 | /* redistribute print. */ | |
8635 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
7c8ff89e DS |
8636 | { |
8637 | struct list *red_list; | |
8638 | struct listnode *node; | |
8639 | struct ospf_redist *red; | |
718e3744 | 8640 | |
7c8ff89e DS |
8641 | red_list = ospf->redist[type]; |
8642 | if (!red_list) | |
8643 | continue; | |
8644 | ||
8645 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) | |
8646 | { | |
8647 | vty_out (vty, " redistribute %s", zebra_route_string(type)); | |
8648 | if (red->instance) | |
8649 | vty_out (vty, " %d", red->instance); | |
8650 | ||
8651 | if (red->dmetric.value >= 0) | |
8652 | vty_out (vty, " metric %d", red->dmetric.value); | |
8653 | ||
8654 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8655 | vty_out (vty, " metric-type 1"); | |
8656 | ||
8657 | if (ROUTEMAP_NAME (red)) | |
8658 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (red)); | |
8659 | ||
1318e7c8 | 8660 | vty_out (vty, "%s", VTYNL); |
7c8ff89e DS |
8661 | } |
8662 | } | |
718e3744 | 8663 | |
8664 | return 0; | |
8665 | } | |
8666 | ||
4dadc291 | 8667 | static int |
68980084 | 8668 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
718e3744 | 8669 | { |
68980084 | 8670 | if (ospf->default_metric != -1) |
8671 | vty_out (vty, " default-metric %d%s", ospf->default_metric, | |
1318e7c8 | 8672 | VTYNL); |
718e3744 | 8673 | return 0; |
8674 | } | |
8675 | ||
4dadc291 | 8676 | static int |
68980084 | 8677 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
718e3744 | 8678 | { |
8679 | int type; | |
7c8ff89e | 8680 | struct ospf_redist *red; |
718e3744 | 8681 | |
68980084 | 8682 | if (ospf) |
718e3744 | 8683 | { |
8684 | /* distribute-list print. */ | |
8685 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) | |
171c9a99 | 8686 | if (DISTRIBUTE_NAME (ospf, type)) |
718e3744 | 8687 | vty_out (vty, " distribute-list %s out %s%s", |
171c9a99 | 8688 | DISTRIBUTE_NAME (ospf, type), |
1318e7c8 | 8689 | zebra_route_string(type), VTYNL); |
718e3744 | 8690 | |
8691 | /* default-information print. */ | |
68980084 | 8692 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
718e3744 | 8693 | { |
c42c177d | 8694 | vty_out (vty, " default-information originate"); |
8695 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) | |
8696 | vty_out (vty, " always"); | |
718e3744 | 8697 | |
7c8ff89e DS |
8698 | red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0); |
8699 | if (red) | |
8700 | { | |
8701 | if (red->dmetric.value >= 0) | |
8702 | vty_out (vty, " metric %d", | |
8703 | red->dmetric.value); | |
8704 | if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) | |
8705 | vty_out (vty, " metric-type 1"); | |
8706 | ||
8707 | if (ROUTEMAP_NAME (red)) | |
8708 | vty_out (vty, " route-map %s", | |
8709 | ROUTEMAP_NAME (red)); | |
8710 | } | |
718e3744 | 8711 | |
1318e7c8 | 8712 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8713 | } |
8714 | ||
8715 | } | |
8716 | ||
8717 | return 0; | |
8718 | } | |
8719 | ||
4dadc291 | 8720 | static int |
68980084 | 8721 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
718e3744 | 8722 | { |
8723 | struct route_node *rn; | |
8724 | struct ospf_distance *odistance; | |
8725 | ||
68980084 | 8726 | if (ospf->distance_all) |
1318e7c8 | 8727 | vty_out (vty, " distance %d%s", ospf->distance_all, VTYNL); |
718e3744 | 8728 | |
68980084 | 8729 | if (ospf->distance_intra |
8730 | || ospf->distance_inter | |
8731 | || ospf->distance_external) | |
718e3744 | 8732 | { |
8733 | vty_out (vty, " distance ospf"); | |
8734 | ||
68980084 | 8735 | if (ospf->distance_intra) |
8736 | vty_out (vty, " intra-area %d", ospf->distance_intra); | |
8737 | if (ospf->distance_inter) | |
8738 | vty_out (vty, " inter-area %d", ospf->distance_inter); | |
8739 | if (ospf->distance_external) | |
8740 | vty_out (vty, " external %d", ospf->distance_external); | |
718e3744 | 8741 | |
1318e7c8 | 8742 | vty_out (vty, "%s", VTYNL); |
718e3744 | 8743 | } |
8744 | ||
68980084 | 8745 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
718e3744 | 8746 | if ((odistance = rn->info) != NULL) |
8747 | { | |
8748 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, | |
8749 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, | |
8750 | odistance->access_list ? odistance->access_list : "", | |
1318e7c8 | 8751 | VTYNL); |
718e3744 | 8752 | } |
8753 | return 0; | |
8754 | } | |
8755 | ||
8756 | /* OSPF configuration write function. */ | |
4dadc291 | 8757 | static int |
718e3744 | 8758 | ospf_config_write (struct vty *vty) |
8759 | { | |
020709f9 | 8760 | struct ospf *ospf; |
1eb8ef25 | 8761 | struct interface *ifp; |
8762 | struct ospf_interface *oi; | |
52dc7ee6 | 8763 | struct listnode *node; |
718e3744 | 8764 | int write = 0; |
8765 | ||
020709f9 | 8766 | ospf = ospf_lookup (); |
0bad4851 | 8767 | if (ospf != NULL && ospf->oi_running) |
718e3744 | 8768 | { |
8769 | /* `router ospf' print. */ | |
7c8ff89e | 8770 | if (ospf->instance) |
1318e7c8 | 8771 | vty_out (vty, "router ospf %d%s", ospf->instance, VTYNL); |
7c8ff89e | 8772 | else |
1318e7c8 | 8773 | vty_out (vty, "router ospf%s", VTYNL); |
718e3744 | 8774 | |
8775 | write++; | |
8776 | ||
68980084 | 8777 | if (!ospf->networks) |
718e3744 | 8778 | return write; |
8779 | ||
8780 | /* Router ID print. */ | |
68980084 | 8781 | if (ospf->router_id_static.s_addr != 0) |
718e3744 | 8782 | vty_out (vty, " ospf router-id %s%s", |
1318e7c8 | 8783 | inet_ntoa (ospf->router_id_static), VTYNL); |
718e3744 | 8784 | |
8785 | /* ABR type print. */ | |
d57834f6 | 8786 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
718e3744 | 8787 | vty_out (vty, " ospf abr-type %s%s", |
1318e7c8 | 8788 | ospf_abr_type_str[ospf->abr_type], VTYNL); |
718e3744 | 8789 | |
d7e60dd7 AS |
8790 | /* log-adjacency-changes flag print. */ |
8791 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) | |
8792 | { | |
d7e60dd7 | 8793 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
1318e7c8 | 8794 | vty_out(vty, " log-adjacency-changes detail%s", VTYNL); |
8efe88ea | 8795 | else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES) |
1318e7c8 | 8796 | vty_out(vty, " log-adjacency-changes%s", VTYNL); |
d7e60dd7 | 8797 | } |
8efe88ea | 8798 | else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) |
692c7954 | 8799 | { |
1318e7c8 | 8800 | vty_out(vty, " no log-adjacency-changes%s", VTYNL); |
692c7954 | 8801 | } |
d7e60dd7 | 8802 | |
718e3744 | 8803 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
68980084 | 8804 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
1318e7c8 | 8805 | vty_out (vty, " compatible rfc1583%s", VTYNL); |
718e3744 | 8806 | |
8807 | /* auto-cost reference-bandwidth configuration. */ | |
68980084 | 8808 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
f9ad937f | 8809 | { |
8810 | vty_out (vty, "! Important: ensure reference bandwidth " | |
1318e7c8 | 8811 | "is consistent across all routers%s", VTYNL); |
f9ad937f | 8812 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
1318e7c8 | 8813 | ospf->ref_bandwidth, VTYNL); |
f9ad937f | 8814 | } |
718e3744 | 8815 | |
8816 | /* SPF timers print. */ | |
68980084 | 8817 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
ea4ffc90 | 8818 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
8819 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) | |
8820 | vty_out (vty, " timers throttle spf %d %d %d%s", | |
88d6cf37 | 8821 | ospf->spf_delay, ospf->spf_holdtime, |
1318e7c8 | 8822 | ospf->spf_max_holdtime, VTYNL); |
b6927875 DS |
8823 | |
8824 | /* LSA timers print. */ | |
ac7424f9 MR |
8825 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
8826 | vty_out (vty, " timers throttle lsa all %d%s", | |
1318e7c8 | 8827 | ospf->min_ls_interval, VTYNL); |
ac7424f9 | 8828 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) |
b6927875 | 8829 | vty_out (vty, " timers lsa min-arrival %d%s", |
1318e7c8 | 8830 | ospf->min_ls_arrival, VTYNL); |
b6927875 | 8831 | |
2f8f370e | 8832 | /* Write multiplier print. */ |
e8f45e82 | 8833 | if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT) |
2f8f370e | 8834 | vty_out (vty, " ospf write-multiplier %d%s", |
1318e7c8 | 8835 | ospf->write_oi_count, VTYNL); |
2f8f370e | 8836 | |
88d6cf37 | 8837 | /* Max-metric router-lsa print */ |
8838 | config_write_stub_router (vty, ospf); | |
8839 | ||
718e3744 | 8840 | /* SPF refresh parameters print. */ |
68980084 | 8841 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
718e3744 | 8842 | vty_out (vty, " refresh timer %d%s", |
1318e7c8 | 8843 | ospf->lsa_refresh_interval, VTYNL); |
718e3744 | 8844 | |
8845 | /* Redistribute information print. */ | |
68980084 | 8846 | config_write_ospf_redistribute (vty, ospf); |
718e3744 | 8847 | |
8848 | /* passive-interface print. */ | |
7ffa8fa2 | 8849 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
1318e7c8 | 8850 | vty_out (vty, " passive-interface default%s", VTYNL); |
7ffa8fa2 | 8851 | |
1eb8ef25 | 8852 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
7ffa8fa2 PJ |
8853 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
8854 | && IF_DEF_PARAMS (ifp)->passive_interface != | |
8855 | ospf->passive_interface_default) | |
8856 | { | |
8857 | vty_out (vty, " %spassive-interface %s%s", | |
8858 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", | |
1318e7c8 | 8859 | ifp->name, VTYNL); |
7ffa8fa2 | 8860 | } |
1eb8ef25 | 8861 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
7ffa8fa2 PJ |
8862 | { |
8863 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) | |
8864 | continue; | |
8865 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), | |
8866 | passive_interface)) | |
8867 | { | |
8868 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) | |
8869 | continue; | |
8870 | } | |
8871 | else if (oi->params->passive_interface == ospf->passive_interface_default) | |
8872 | continue; | |
8873 | ||
8874 | vty_out (vty, " %spassive-interface %s %s%s", | |
8875 | oi->params->passive_interface ? "" : "no ", | |
1eb8ef25 | 8876 | oi->ifp->name, |
1318e7c8 | 8877 | inet_ntoa (oi->address->u.prefix4), VTYNL); |
7ffa8fa2 | 8878 | } |
718e3744 | 8879 | |
8880 | /* Network area print. */ | |
68980084 | 8881 | config_write_network_area (vty, ospf); |
718e3744 | 8882 | |
8883 | /* Area config print. */ | |
68980084 | 8884 | config_write_ospf_area (vty, ospf); |
718e3744 | 8885 | |
8886 | /* static neighbor print. */ | |
68980084 | 8887 | config_write_ospf_nbr_nbma (vty, ospf); |
718e3744 | 8888 | |
8889 | /* Virtual-Link print. */ | |
68980084 | 8890 | config_write_virtual_link (vty, ospf); |
718e3744 | 8891 | |
8892 | /* Default metric configuration. */ | |
68980084 | 8893 | config_write_ospf_default_metric (vty, ospf); |
718e3744 | 8894 | |
8895 | /* Distribute-list and default-information print. */ | |
68980084 | 8896 | config_write_ospf_distribute (vty, ospf); |
718e3744 | 8897 | |
8898 | /* Distance configuration. */ | |
68980084 | 8899 | config_write_ospf_distance (vty, ospf); |
718e3744 | 8900 | |
68980084 | 8901 | ospf_opaque_config_write_router (vty, ospf); |
718e3744 | 8902 | } |
8903 | ||
8904 | return write; | |
8905 | } | |
8906 | ||
8907 | void | |
4dadc291 | 8908 | ospf_vty_show_init (void) |
718e3744 | 8909 | { |
8910 | /* "show ip ospf" commands. */ | |
8911 | install_element (VIEW_NODE, &show_ip_ospf_cmd); | |
718e3744 | 8912 | |
7c8ff89e | 8913 | install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); |
7c8ff89e | 8914 | |
718e3744 | 8915 | /* "show ip ospf database" commands. */ |
7a7be519 | 8916 | install_element (VIEW_NODE, &show_ip_ospf_database_max_cmd); |
718e3744 | 8917 | |
7c8ff89e | 8918 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd); |
7c8ff89e | 8919 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd); |
7a7be519 | 8920 | install_element (VIEW_NODE, &show_ip_ospf_instance_database_max_cmd); |
7c8ff89e | 8921 | |
718e3744 | 8922 | /* "show ip ospf interface" commands. */ |
8923 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); | |
718e3744 | 8924 | |
7c8ff89e | 8925 | install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd); |
7c8ff89e | 8926 | |
718e3744 | 8927 | /* "show ip ospf neighbor" commands. */ |
8928 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); | |
8929 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); | |
8930 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); | |
8931 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); | |
8932 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); | |
8933 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); | |
8934 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); | |
718e3744 | 8935 | |
7c8ff89e DS |
8936 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd); |
8937 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd); | |
8938 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd); | |
8939 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd); | |
8940 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd); | |
8941 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd); | |
8942 | install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd); | |
7c8ff89e | 8943 | |
718e3744 | 8944 | /* "show ip ospf route" commands. */ |
8945 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); | |
718e3744 | 8946 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
7c8ff89e DS |
8947 | |
8948 | install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd); | |
7c8ff89e | 8949 | install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd); |
718e3744 | 8950 | } |
8951 | ||
6b0655a2 | 8952 | |
718e3744 | 8953 | /* ospfd's interface node. */ |
7fc626de | 8954 | static struct cmd_node interface_node = |
718e3744 | 8955 | { |
8956 | INTERFACE_NODE, | |
8957 | "%s(config-if)# ", | |
8958 | 1 | |
8959 | }; | |
8960 | ||
8961 | /* Initialization of OSPF interface. */ | |
4dadc291 | 8962 | static void |
8963 | ospf_vty_if_init (void) | |
718e3744 | 8964 | { |
8965 | /* Install interface node. */ | |
8966 | install_node (&interface_node, config_write_interface); | |
0b84f294 | 8967 | if_cmd_init (); |
718e3744 | 8968 | |
8969 | /* "ip ospf authentication" commands. */ | |
8970 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); | |
718e3744 | 8971 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
b4a039bf | 8972 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd); |
718e3744 | 8973 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
718e3744 | 8974 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
813d4307 | 8975 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd); |
7a7be519 | 8976 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_addr_cmd); |
718e3744 | 8977 | |
8978 | /* "ip ospf message-digest-key" commands. */ | |
537eae3f QY |
8979 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
8980 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); | |
718e3744 | 8981 | |
8982 | /* "ip ospf cost" commands. */ | |
5c2fc921 QY |
8983 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
8984 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); | |
718e3744 | 8985 | |
ba682537 | 8986 | /* "ip ospf mtu-ignore" commands. */ |
8987 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); | |
ba682537 | 8988 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
ba682537 | 8989 | |
718e3744 | 8990 | /* "ip ospf dead-interval" commands. */ |
0d829fa7 | 8991 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
f9ad937f | 8992 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
0d829fa7 | 8993 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
f9ad937f | 8994 | |
718e3744 | 8995 | /* "ip ospf hello-interval" commands. */ |
0d829fa7 QY |
8996 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
8997 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); | |
718e3744 | 8998 | |
8999 | /* "ip ospf network" commands. */ | |
9000 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); | |
9001 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); | |
9002 | ||
9003 | /* "ip ospf priority" commands. */ | |
537eae3f QY |
9004 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
9005 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); | |
718e3744 | 9006 | |
9007 | /* "ip ospf retransmit-interval" commands. */ | |
9008 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); | |
718e3744 | 9009 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
718e3744 | 9010 | |
9011 | /* "ip ospf transmit-delay" commands. */ | |
9012 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); | |
718e3744 | 9013 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
718e3744 | 9014 | |
953cde65 JT |
9015 | /* "ip ospf area" commands. */ |
9016 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); | |
9017 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); | |
953cde65 | 9018 | |
718e3744 | 9019 | /* These commands are compatibitliy for previous version. */ |
9020 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); | |
718e3744 | 9021 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
537eae3f | 9022 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
718e3744 | 9023 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
537eae3f | 9024 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
718e3744 | 9025 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
537eae3f QY |
9026 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
9027 | install_element (INTERFACE_NODE, &ospf_cost_cmd); | |
9028 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); | |
718e3744 | 9029 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
537eae3f | 9030 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
718e3744 | 9031 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
537eae3f | 9032 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
718e3744 | 9033 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
537eae3f | 9034 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
718e3744 | 9035 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
537eae3f | 9036 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
718e3744 | 9037 | } |
9038 | ||
4dadc291 | 9039 | static void |
9040 | ospf_vty_zebra_init (void) | |
718e3744 | 9041 | { |
718e3744 | 9042 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
718e3744 | 9043 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
7c8ff89e DS |
9044 | install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd); |
9045 | install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd); | |
718e3744 | 9046 | |
9047 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); | |
9048 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); | |
9049 | ||
718e3744 | 9050 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
718e3744 | 9051 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
9052 | ||
9053 | install_element (OSPF_NODE, &ospf_default_metric_cmd); | |
9054 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); | |
718e3744 | 9055 | |
9056 | install_element (OSPF_NODE, &ospf_distance_cmd); | |
9057 | install_element (OSPF_NODE, &no_ospf_distance_cmd); | |
9058 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); | |
6f2a6703 | 9059 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
718e3744 | 9060 | #if 0 |
9061 | install_element (OSPF_NODE, &ospf_distance_source_cmd); | |
9062 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); | |
9063 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); | |
9064 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); | |
9065 | #endif /* 0 */ | |
9066 | } | |
9067 | ||
7fc626de | 9068 | static struct cmd_node ospf_node = |
718e3744 | 9069 | { |
9070 | OSPF_NODE, | |
9071 | "%s(config-router)# ", | |
9072 | 1 | |
9073 | }; | |
9074 | ||
09f35f8c DS |
9075 | static void |
9076 | ospf_interface_clear (struct interface *ifp) | |
9077 | { | |
9078 | if (!if_is_operative (ifp)) return; | |
9079 | ||
9080 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) | |
4525281a | 9081 | zlog_debug("ISM[%s]: clear by reset", ifp->name); |
09f35f8c DS |
9082 | |
9083 | ospf_if_reset(ifp); | |
9084 | } | |
9085 | ||
9086 | DEFUN (clear_ip_ospf_interface, | |
9087 | clear_ip_ospf_interface_cmd, | |
9088 | "clear ip ospf interface [IFNAME]", | |
9089 | CLEAR_STR | |
9090 | IP_STR | |
9091 | "OSPF information\n" | |
9092 | "Interface information\n" | |
9093 | "Interface name\n") | |
9094 | { | |
8d769265 | 9095 | int idx_ifname = 4; |
09f35f8c DS |
9096 | struct interface *ifp; |
9097 | struct listnode *node; | |
9098 | ||
7a7be519 | 9099 | if (argc == 4) /* Clear all the ospfv2 interfaces. */ |
09f35f8c | 9100 | { |
b2d7c082 | 9101 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
09f35f8c DS |
9102 | ospf_interface_clear(ifp); |
9103 | } | |
9104 | else /* Interface name is specified. */ | |
9105 | { | |
fac05f2f | 9106 | if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL) |
1318e7c8 | 9107 | vty_out (vty, "No such interface name%s", VTYNL); |
09f35f8c DS |
9108 | else |
9109 | ospf_interface_clear(ifp); | |
9110 | } | |
9111 | ||
9112 | return CMD_SUCCESS; | |
9113 | } | |
9114 | ||
9115 | void | |
9116 | ospf_vty_clear_init (void) | |
9117 | { | |
9118 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); | |
9119 | } | |
9120 | ||
6b0655a2 | 9121 | |
718e3744 | 9122 | /* Install OSPF related vty commands. */ |
9123 | void | |
4dadc291 | 9124 | ospf_vty_init (void) |
718e3744 | 9125 | { |
9126 | /* Install ospf top node. */ | |
9127 | install_node (&ospf_node, ospf_config_write); | |
9128 | ||
9129 | /* "router ospf" commands. */ | |
9130 | install_element (CONFIG_NODE, &router_ospf_cmd); | |
9131 | install_element (CONFIG_NODE, &no_router_ospf_cmd); | |
9132 | ||
7c8ff89e | 9133 | |
718e3744 | 9134 | install_default (OSPF_NODE); |
9135 | ||
9136 | /* "ospf router-id" commands. */ | |
9137 | install_element (OSPF_NODE, &ospf_router_id_cmd); | |
747e489c | 9138 | install_element (OSPF_NODE, &ospf_router_id_old_cmd); |
718e3744 | 9139 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
718e3744 | 9140 | |
9141 | /* "passive-interface" commands. */ | |
a2c62831 | 9142 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
a2c62831 | 9143 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
718e3744 | 9144 | |
9145 | /* "ospf abr-type" commands. */ | |
9146 | install_element (OSPF_NODE, &ospf_abr_type_cmd); | |
9147 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); | |
9148 | ||
d7e60dd7 AS |
9149 | /* "ospf log-adjacency-changes" commands. */ |
9150 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); | |
9151 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); | |
9152 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); | |
9153 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); | |
9154 | ||
718e3744 | 9155 | /* "ospf rfc1583-compatible" commands. */ |
718e3744 | 9156 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
9157 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); | |
7a7be519 | 9158 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
9159 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); | |
718e3744 | 9160 | |
9161 | /* "network area" commands. */ | |
a2c62831 | 9162 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
9163 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); | |
718e3744 | 9164 | |
9165 | /* "area authentication" commands. */ | |
a2c62831 | 9166 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
9167 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); | |
9168 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); | |
718e3744 | 9169 | |
9170 | /* "area range" commands. */ | |
a2c62831 | 9171 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
7a7be519 | 9172 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
a2c62831 | 9173 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
9174 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); | |
a2c62831 | 9175 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
9176 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); | |
718e3744 | 9177 | |
9178 | /* "area virtual-link" commands. */ | |
a2c62831 | 9179 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
7a7be519 | 9180 | install_element (OSPF_NODE, &ospf_area_vlink_intervals_cmd); |
a2c62831 | 9181 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
7a7be519 | 9182 | install_element (OSPF_NODE, &no_ospf_area_vlink_intervals_cmd); |
718e3744 | 9183 | |
718e3744 | 9184 | |
718e3744 | 9185 | |
718e3744 | 9186 | |
718e3744 | 9187 | |
718e3744 | 9188 | |
718e3744 | 9189 | |
718e3744 | 9190 | |
718e3744 | 9191 | |
718e3744 | 9192 | |
9193 | /* "area stub" commands. */ | |
a2c62831 | 9194 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
9195 | install_element (OSPF_NODE, &ospf_area_stub_cmd); | |
9196 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); | |
9197 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); | |
718e3744 | 9198 | |
718e3744 | 9199 | /* "area nssa" commands. */ |
a2c62831 | 9200 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
9201 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); | |
9202 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); | |
9203 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); | |
9204 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); | |
718e3744 | 9205 | |
a2c62831 | 9206 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
9207 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); | |
718e3744 | 9208 | |
a2c62831 | 9209 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
9210 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); | |
718e3744 | 9211 | |
a2c62831 | 9212 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
9213 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); | |
718e3744 | 9214 | |
a2c62831 | 9215 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
9216 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); | |
718e3744 | 9217 | |
a2c62831 | 9218 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
9219 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); | |
88d6cf37 | 9220 | |
9221 | /* SPF timer commands */ | |
d24f6e2a | 9222 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
9223 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); | |
9224 | ||
b6927875 | 9225 | /* LSA timers commands */ |
ac7424f9 MR |
9226 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
9227 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); | |
9228 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); | |
9229 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); | |
b6927875 DS |
9230 | install_element (OSPF_NODE, &ospf_timers_lsa_cmd); |
9231 | install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd); | |
b6927875 | 9232 | |
88d6cf37 | 9233 | /* refresh timer commands */ |
a2c62831 | 9234 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
9235 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); | |
718e3744 | 9236 | |
88d6cf37 | 9237 | /* max-metric commands */ |
9238 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); | |
9239 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); | |
9240 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); | |
9241 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); | |
9242 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); | |
9243 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); | |
9244 | ||
9245 | /* reference bandwidth commands */ | |
a2c62831 | 9246 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
9247 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); | |
718e3744 | 9248 | |
9249 | /* "neighbor" commands. */ | |
a2c62831 | 9250 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
a2c62831 | 9251 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
a2c62831 | 9252 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
7a7be519 | 9253 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_cmd); |
718e3744 | 9254 | |
2f8f370e DS |
9255 | /* write multiplier commands */ |
9256 | install_element (OSPF_NODE, &ospf_write_multiplier_cmd); | |
7a7be519 | 9257 | install_element (OSPF_NODE, &write_multiplier_cmd); |
2f8f370e | 9258 | install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd); |
7a7be519 | 9259 | install_element (OSPF_NODE, &no_write_multiplier_cmd); |
2f8f370e | 9260 | |
718e3744 | 9261 | /* Init interface related vty commands. */ |
9262 | ospf_vty_if_init (); | |
9263 | ||
9264 | /* Init zebra related vty commands. */ | |
9265 | ospf_vty_zebra_init (); | |
9266 | } |