paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* OSPF VTY interface. |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * Copyright (C) 2000 Toshiaki Takada |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "memory.h" |
| 26 | #include "thread.h" |
| 27 | #include "prefix.h" |
| 28 | #include "table.h" |
| 29 | #include "vty.h" |
| 30 | #include "command.h" |
| 31 | #include "plist.h" |
| 32 | #include "log.h" |
| 33 | #include "zclient.h" |
| 34 | |
| 35 | #include "ospfd/ospfd.h" |
| 36 | #include "ospfd/ospf_asbr.h" |
| 37 | #include "ospfd/ospf_lsa.h" |
| 38 | #include "ospfd/ospf_lsdb.h" |
| 39 | #include "ospfd/ospf_ism.h" |
| 40 | #include "ospfd/ospf_interface.h" |
| 41 | #include "ospfd/ospf_nsm.h" |
| 42 | #include "ospfd/ospf_neighbor.h" |
| 43 | #include "ospfd/ospf_flood.h" |
| 44 | #include "ospfd/ospf_abr.h" |
| 45 | #include "ospfd/ospf_spf.h" |
| 46 | #include "ospfd/ospf_route.h" |
| 47 | #include "ospfd/ospf_zebra.h" |
| 48 | /*#include "ospfd/ospf_routemap.h" */ |
| 49 | #include "ospfd/ospf_vty.h" |
| 50 | #include "ospfd/ospf_dump.h" |
| 51 | |
| 52 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 53 | const static char *ospf_network_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 54 | { |
| 55 | "Null", |
| 56 | "POINTOPOINT", |
| 57 | "BROADCAST", |
| 58 | "NBMA", |
| 59 | "POINTOMULTIPOINT", |
| 60 | "VIRTUALLINK", |
| 61 | "LOOPBACK" |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | /* Utility functions. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 66 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 67 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | { |
| 69 | char *endptr = NULL; |
| 70 | unsigned long ret; |
| 71 | |
| 72 | /* match "A.B.C.D". */ |
| 73 | if (strchr (str, '.') != NULL) |
| 74 | { |
| 75 | ret = inet_aton (str, area_id); |
| 76 | if (!ret) |
| 77 | return -1; |
| 78 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; |
| 79 | } |
| 80 | /* match "<0-4294967295>". */ |
| 81 | else |
| 82 | { |
| 83 | ret = strtoul (str, &endptr, 10); |
| 84 | if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE)) |
| 85 | return -1; |
| 86 | |
| 87 | area_id->s_addr = htonl (ret); |
| 88 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 95 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 96 | str2distribute_source (const char *str, int *source) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 97 | { |
| 98 | /* Sanity check. */ |
| 99 | if (str == NULL) |
| 100 | return 0; |
| 101 | |
| 102 | if (strncmp (str, "k", 1) == 0) |
| 103 | *source = ZEBRA_ROUTE_KERNEL; |
| 104 | else if (strncmp (str, "c", 1) == 0) |
| 105 | *source = ZEBRA_ROUTE_CONNECT; |
| 106 | else if (strncmp (str, "s", 1) == 0) |
| 107 | *source = ZEBRA_ROUTE_STATIC; |
| 108 | else if (strncmp (str, "r", 1) == 0) |
| 109 | *source = ZEBRA_ROUTE_RIP; |
| 110 | else if (strncmp (str, "b", 1) == 0) |
| 111 | *source = ZEBRA_ROUTE_BGP; |
| 112 | else |
| 113 | return 0; |
| 114 | |
| 115 | return 1; |
| 116 | } |
| 117 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 118 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 119 | str2metric (const char *str, int *metric) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 120 | { |
| 121 | /* Sanity check. */ |
| 122 | if (str == NULL) |
| 123 | return 0; |
| 124 | |
| 125 | *metric = strtol (str, NULL, 10); |
| 126 | if (*metric < 0 && *metric > 16777214) |
| 127 | { |
| 128 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | return 1; |
| 133 | } |
| 134 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 135 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 136 | str2metric_type (const char *str, int *metric_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | { |
| 138 | /* Sanity check. */ |
| 139 | if (str == NULL) |
| 140 | return 0; |
| 141 | |
| 142 | if (strncmp (str, "1", 1) == 0) |
| 143 | *metric_type = EXTERNAL_METRIC_TYPE_1; |
| 144 | else if (strncmp (str, "2", 1) == 0) |
| 145 | *metric_type = EXTERNAL_METRIC_TYPE_2; |
| 146 | else |
| 147 | return 0; |
| 148 | |
| 149 | return 1; |
| 150 | } |
| 151 | |
| 152 | int |
| 153 | ospf_oi_count (struct interface *ifp) |
| 154 | { |
| 155 | struct route_node *rn; |
| 156 | int i = 0; |
| 157 | |
| 158 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 159 | if (rn->info) |
| 160 | i++; |
| 161 | |
| 162 | return i; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | DEFUN (router_ospf, |
| 167 | router_ospf_cmd, |
| 168 | "router ospf", |
| 169 | "Enable a routing process\n" |
| 170 | "Start OSPF configuration\n") |
| 171 | { |
| 172 | vty->node = OSPF_NODE; |
| 173 | vty->index = ospf_get (); |
| 174 | |
| 175 | return CMD_SUCCESS; |
| 176 | } |
| 177 | |
| 178 | DEFUN (no_router_ospf, |
| 179 | no_router_ospf_cmd, |
| 180 | "no router ospf", |
| 181 | NO_STR |
| 182 | "Enable a routing process\n" |
| 183 | "Start OSPF configuration\n") |
| 184 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 185 | struct ospf *ospf; |
| 186 | |
| 187 | ospf = ospf_lookup (); |
| 188 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 190 | vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 191 | return CMD_WARNING; |
| 192 | } |
| 193 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 194 | ospf_finish (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | |
| 196 | return CMD_SUCCESS; |
| 197 | } |
| 198 | |
| 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 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 206 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | struct in_addr router_id; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 208 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 209 | |
| 210 | ret = inet_aton (argv[0], &router_id); |
| 211 | if (!ret) |
| 212 | { |
| 213 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); |
| 214 | return CMD_WARNING; |
| 215 | } |
| 216 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 217 | ospf->router_id_static = router_id; |
paul | b29800a | 2005-11-20 14:50:45 +0000 | [diff] [blame] | 218 | |
| 219 | ospf_router_id_update (ospf); |
| 220 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | return CMD_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 225 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 226 | "router-id A.B.C.D", |
| 227 | "router-id for the OSPF process\n" |
| 228 | "OSPF router-id in IP address format\n") |
| 229 | |
| 230 | DEFUN (no_ospf_router_id, |
| 231 | no_ospf_router_id_cmd, |
| 232 | "no ospf router-id", |
| 233 | NO_STR |
| 234 | "OSPF specific commands\n" |
| 235 | "router-id for the OSPF process\n") |
| 236 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 237 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 239 | ospf->router_id_static.s_addr = 0; |
| 240 | |
| 241 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 242 | |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
| 246 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 247 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | "no router-id", |
| 249 | NO_STR |
| 250 | "router-id for the OSPF process\n") |
| 251 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 252 | DEFUN (ospf_passive_interface, |
| 253 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 254 | "passive-interface IFNAME A.B.C.D", |
| 255 | "Suppress routing updates on an interface\n" |
| 256 | "Interface's name\n") |
| 257 | { |
| 258 | struct interface *ifp; |
| 259 | struct in_addr addr; |
| 260 | int ret; |
| 261 | struct ospf_if_params *params; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 262 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 263 | |
| 264 | ifp = if_lookup_by_name (argv[0]); |
| 265 | |
| 266 | if (ifp == NULL) |
| 267 | { |
| 268 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 269 | return CMD_WARNING; |
| 270 | } |
| 271 | |
| 272 | params = IF_DEF_PARAMS (ifp); |
| 273 | |
| 274 | if (argc == 2) |
| 275 | { |
| 276 | ret = inet_aton(argv[1], &addr); |
| 277 | if (!ret) |
| 278 | { |
| 279 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 280 | VTY_NEWLINE); |
| 281 | return CMD_WARNING; |
| 282 | } |
| 283 | |
| 284 | params = ospf_get_if_params (ifp, addr); |
| 285 | ospf_if_update_params (ifp, addr); |
| 286 | } |
| 287 | |
| 288 | SET_IF_PARAM (params, passive_interface); |
| 289 | params->passive_interface = OSPF_IF_PASSIVE; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 290 | |
| 291 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 292 | * interfaces for which the passive property changed. It is too much |
| 293 | * work to determine this set, so we do this for every interface. |
| 294 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 295 | * record of joined groups to avoid systems calls if the desired |
| 296 | * memberships match the current memership. |
| 297 | */ |
| 298 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 299 | { |
| 300 | struct ospf_interface *oi = rn->info; |
| 301 | |
| 302 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
| 303 | ospf_if_set_multicast(oi); |
| 304 | } |
| 305 | /* |
| 306 | * XXX It is not clear what state transitions the interface needs to |
| 307 | * undergo when going from active to passive. Fixing this will |
| 308 | * require precise identification of interfaces having such a |
| 309 | * transition. |
| 310 | */ |
| 311 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 312 | return CMD_SUCCESS; |
| 313 | } |
| 314 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 315 | ALIAS (ospf_passive_interface, |
| 316 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 317 | "passive-interface IFNAME", |
| 318 | "Suppress routing updates on an interface\n" |
| 319 | "Interface's name\n") |
| 320 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 321 | DEFUN (no_ospf_passive_interface, |
| 322 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 323 | "no passive-interface IFNAME A.B.C.D", |
| 324 | NO_STR |
| 325 | "Allow routing updates on an interface\n" |
| 326 | "Interface's name\n") |
| 327 | { |
| 328 | struct interface *ifp; |
| 329 | struct in_addr addr; |
| 330 | struct ospf_if_params *params; |
| 331 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 332 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 333 | |
| 334 | ifp = if_lookup_by_name (argv[0]); |
| 335 | |
| 336 | if (ifp == NULL) |
| 337 | { |
| 338 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 339 | return CMD_WARNING; |
| 340 | } |
| 341 | |
| 342 | params = IF_DEF_PARAMS (ifp); |
| 343 | |
| 344 | if (argc == 2) |
| 345 | { |
| 346 | ret = inet_aton(argv[1], &addr); |
| 347 | if (!ret) |
| 348 | { |
| 349 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 350 | VTY_NEWLINE); |
| 351 | return CMD_WARNING; |
| 352 | } |
| 353 | |
| 354 | params = ospf_lookup_if_params (ifp, addr); |
| 355 | if (params == NULL) |
| 356 | return CMD_SUCCESS; |
| 357 | } |
| 358 | |
| 359 | UNSET_IF_PARAM (params, passive_interface); |
| 360 | params->passive_interface = OSPF_IF_ACTIVE; |
| 361 | |
| 362 | if (params != IF_DEF_PARAMS (ifp)) |
| 363 | { |
| 364 | ospf_free_if_params (ifp, addr); |
| 365 | ospf_if_update_params (ifp, addr); |
| 366 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 367 | |
| 368 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 369 | * interfaces for which the passive property changed. It is too much |
| 370 | * work to determine this set, so we do this for every interface. |
| 371 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 372 | * record of joined groups to avoid systems calls if the desired |
| 373 | * memberships match the current memership. |
| 374 | */ |
| 375 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 376 | { |
| 377 | struct ospf_interface *oi = rn->info; |
| 378 | |
| 379 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 380 | ospf_if_set_multicast(oi); |
| 381 | } |
| 382 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 383 | return CMD_SUCCESS; |
| 384 | } |
| 385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 386 | ALIAS (no_ospf_passive_interface, |
| 387 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 388 | "no passive-interface IFNAME", |
| 389 | NO_STR |
| 390 | "Allow routing updates on an interface\n" |
| 391 | "Interface's name\n") |
| 392 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 393 | DEFUN (ospf_network_area, |
| 394 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 395 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 396 | "Enable routing on an IP network\n" |
| 397 | "OSPF network prefix\n" |
| 398 | "Set the OSPF area ID\n" |
| 399 | "OSPF area ID in IP address format\n" |
| 400 | "OSPF area ID as a decimal value\n") |
| 401 | { |
| 402 | struct ospf *ospf= vty->index; |
| 403 | struct prefix_ipv4 p; |
| 404 | struct in_addr area_id; |
| 405 | int ret, format; |
| 406 | |
| 407 | /* Get network prefix and Area ID. */ |
| 408 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 409 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 410 | |
| 411 | ret = ospf_network_set (ospf, &p, area_id); |
| 412 | if (ret == 0) |
| 413 | { |
| 414 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 415 | return CMD_WARNING; |
| 416 | } |
| 417 | |
| 418 | return CMD_SUCCESS; |
| 419 | } |
| 420 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 421 | DEFUN (no_ospf_network_area, |
| 422 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 423 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 424 | NO_STR |
| 425 | "Enable routing on an IP network\n" |
| 426 | "OSPF network prefix\n" |
| 427 | "Set the OSPF area ID\n" |
| 428 | "OSPF area ID in IP address format\n" |
| 429 | "OSPF area ID as a decimal value\n") |
| 430 | { |
| 431 | struct ospf *ospf = (struct ospf *) vty->index; |
| 432 | struct prefix_ipv4 p; |
| 433 | struct in_addr area_id; |
| 434 | int ret, format; |
| 435 | |
| 436 | /* Get network prefix and Area ID. */ |
| 437 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 438 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 439 | |
| 440 | ret = ospf_network_unset (ospf, &p, area_id); |
| 441 | if (ret == 0) |
| 442 | { |
| 443 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 444 | VTY_NEWLINE); |
| 445 | return CMD_WARNING; |
| 446 | } |
| 447 | |
| 448 | return CMD_SUCCESS; |
| 449 | } |
| 450 | |
| 451 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 452 | DEFUN (ospf_area_range, |
| 453 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 454 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 455 | "OSPF area parameters\n" |
| 456 | "OSPF area ID in IP address format\n" |
| 457 | "OSPF area ID as a decimal value\n" |
| 458 | "Summarize routes matching address/mask (border routers only)\n" |
| 459 | "Area range prefix\n") |
| 460 | { |
| 461 | struct ospf *ospf = vty->index; |
| 462 | struct prefix_ipv4 p; |
| 463 | struct in_addr area_id; |
| 464 | int format; |
| 465 | u_int32_t cost; |
| 466 | |
| 467 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 468 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 469 | |
| 470 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 471 | if (argc > 2) |
| 472 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 473 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 474 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 475 | } |
| 476 | |
| 477 | return CMD_SUCCESS; |
| 478 | } |
| 479 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 480 | ALIAS (ospf_area_range, |
| 481 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 482 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 483 | "OSPF area parameters\n" |
| 484 | "OSPF area ID in IP address format\n" |
| 485 | "OSPF area ID as a decimal value\n" |
| 486 | "OSPF area range for route advertise (default)\n" |
| 487 | "Area range prefix\n" |
| 488 | "Advertise this range (default)\n") |
| 489 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 490 | ALIAS (ospf_area_range, |
| 491 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 492 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 493 | "OSPF area parameters\n" |
| 494 | "OSPF area ID in IP address format\n" |
| 495 | "OSPF area ID as a decimal value\n" |
| 496 | "Summarize routes matching address/mask (border routers only)\n" |
| 497 | "Area range prefix\n" |
| 498 | "User specified metric for this range\n" |
| 499 | "Advertised metric for this range\n") |
| 500 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 501 | ALIAS (ospf_area_range, |
| 502 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 503 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 504 | "OSPF area parameters\n" |
| 505 | "OSPF area ID in IP address format\n" |
| 506 | "OSPF area ID as a decimal value\n" |
| 507 | "Summarize routes matching address/mask (border routers only)\n" |
| 508 | "Area range prefix\n" |
| 509 | "Advertise this range (default)\n" |
| 510 | "User specified metric for this range\n" |
| 511 | "Advertised metric for this range\n") |
| 512 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 513 | DEFUN (ospf_area_range_not_advertise, |
| 514 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 515 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 516 | "OSPF area parameters\n" |
| 517 | "OSPF area ID in IP address format\n" |
| 518 | "OSPF area ID as a decimal value\n" |
| 519 | "Summarize routes matching address/mask (border routers only)\n" |
| 520 | "Area range prefix\n" |
| 521 | "DoNotAdvertise this range\n") |
| 522 | { |
| 523 | struct ospf *ospf = vty->index; |
| 524 | struct prefix_ipv4 p; |
| 525 | struct in_addr area_id; |
| 526 | int format; |
| 527 | |
| 528 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 529 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 530 | |
| 531 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 532 | |
| 533 | return CMD_SUCCESS; |
| 534 | } |
| 535 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 536 | DEFUN (no_ospf_area_range, |
| 537 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 539 | NO_STR |
| 540 | "OSPF area parameters\n" |
| 541 | "OSPF area ID in IP address format\n" |
| 542 | "OSPF area ID as a decimal value\n" |
| 543 | "Summarize routes matching address/mask (border routers only)\n" |
| 544 | "Area range prefix\n") |
| 545 | { |
| 546 | struct ospf *ospf = vty->index; |
| 547 | struct prefix_ipv4 p; |
| 548 | struct in_addr area_id; |
| 549 | int format; |
| 550 | |
| 551 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 552 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 553 | |
| 554 | ospf_area_range_unset (ospf, area_id, &p); |
| 555 | |
| 556 | return CMD_SUCCESS; |
| 557 | } |
| 558 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 559 | ALIAS (no_ospf_area_range, |
| 560 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 562 | NO_STR |
| 563 | "OSPF area parameters\n" |
| 564 | "OSPF area ID in IP address format\n" |
| 565 | "OSPF area ID as a decimal value\n" |
| 566 | "Summarize routes matching address/mask (border routers only)\n" |
| 567 | "Area range prefix\n" |
| 568 | "Advertise this range (default)\n" |
| 569 | "DoNotAdvertise this range\n") |
| 570 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 571 | ALIAS (no_ospf_area_range, |
| 572 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 574 | NO_STR |
| 575 | "OSPF area parameters\n" |
| 576 | "OSPF area ID in IP address format\n" |
| 577 | "OSPF area ID as a decimal value\n" |
| 578 | "Summarize routes matching address/mask (border routers only)\n" |
| 579 | "Area range prefix\n" |
| 580 | "User specified metric for this range\n" |
| 581 | "Advertised metric for this range\n") |
| 582 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 583 | ALIAS (no_ospf_area_range, |
| 584 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 585 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 586 | NO_STR |
| 587 | "OSPF area parameters\n" |
| 588 | "OSPF area ID in IP address format\n" |
| 589 | "OSPF area ID as a decimal value\n" |
| 590 | "Summarize routes matching address/mask (border routers only)\n" |
| 591 | "Area range prefix\n" |
| 592 | "Advertise this range (default)\n" |
| 593 | "User specified metric for this range\n" |
| 594 | "Advertised metric for this range\n") |
| 595 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 596 | DEFUN (ospf_area_range_substitute, |
| 597 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 599 | "OSPF area parameters\n" |
| 600 | "OSPF area ID in IP address format\n" |
| 601 | "OSPF area ID as a decimal value\n" |
| 602 | "Summarize routes matching address/mask (border routers only)\n" |
| 603 | "Area range prefix\n" |
| 604 | "Announce area range as another prefix\n" |
| 605 | "Network prefix to be announced instead of range\n") |
| 606 | { |
| 607 | struct ospf *ospf = vty->index; |
| 608 | struct prefix_ipv4 p, s; |
| 609 | struct in_addr area_id; |
| 610 | int format; |
| 611 | |
| 612 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 613 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 614 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 615 | |
| 616 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 617 | |
| 618 | return CMD_SUCCESS; |
| 619 | } |
| 620 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 621 | DEFUN (no_ospf_area_range_substitute, |
| 622 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 624 | NO_STR |
| 625 | "OSPF area parameters\n" |
| 626 | "OSPF area ID in IP address format\n" |
| 627 | "OSPF area ID as a decimal value\n" |
| 628 | "Summarize routes matching address/mask (border routers only)\n" |
| 629 | "Area range prefix\n" |
| 630 | "Announce area range as another prefix\n" |
| 631 | "Network prefix to be announced instead of range\n") |
| 632 | { |
| 633 | struct ospf *ospf = vty->index; |
| 634 | struct prefix_ipv4 p, s; |
| 635 | struct in_addr area_id; |
| 636 | int format; |
| 637 | |
| 638 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 639 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 640 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 641 | |
| 642 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 643 | |
| 644 | return CMD_SUCCESS; |
| 645 | } |
| 646 | |
| 647 | |
| 648 | /* Command Handler Logic in VLink stuff is delicate!! |
| 649 | |
| 650 | ALTER AT YOUR OWN RISK!!!! |
| 651 | |
| 652 | Various dummy values are used to represent 'NoChange' state for |
| 653 | VLink configuration NOT being changed by a VLink command, and |
| 654 | special syntax is used within the command strings so that the |
| 655 | typed in command verbs can be seen in the configuration command |
| 656 | bacckend handler. This is to drastically reduce the verbeage |
| 657 | required to coe up with a reasonably compatible Cisco VLink command |
| 658 | |
| 659 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 660 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 661 | */ |
| 662 | |
| 663 | |
| 664 | /* Configuration data for virtual links |
| 665 | */ |
| 666 | struct ospf_vl_config_data { |
| 667 | struct vty *vty; /* vty stuff */ |
| 668 | struct in_addr area_id; /* area ID from command line */ |
| 669 | int format; /* command line area ID format */ |
| 670 | struct in_addr vl_peer; /* command line vl_peer */ |
| 671 | int auth_type; /* Authehntication type, if given */ |
| 672 | char *auth_key; /* simple password if present */ |
| 673 | int crypto_key_id; /* Cryptographic key ID */ |
| 674 | char *md5_key; /* MD5 authentication key */ |
| 675 | int hello_interval; /* Obvious what these are... */ |
| 676 | int retransmit_interval; |
| 677 | int transmit_delay; |
| 678 | int dead_interval; |
| 679 | }; |
| 680 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 681 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 682 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 683 | struct vty *vty) |
| 684 | { |
| 685 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 686 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 687 | vl_config->vty = vty; |
| 688 | } |
| 689 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 690 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 691 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 692 | { |
| 693 | struct ospf_area *area; |
| 694 | struct ospf_vl_data *vl_data; |
| 695 | struct vty *vty; |
| 696 | struct in_addr area_id; |
| 697 | |
| 698 | vty = vl_config->vty; |
| 699 | area_id = vl_config->area_id; |
| 700 | |
| 701 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 702 | { |
| 703 | vty_out (vty, |
| 704 | "Configuring VLs over the backbone is not allowed%s", |
| 705 | VTY_NEWLINE); |
| 706 | return NULL; |
| 707 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 708 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | |
| 710 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 711 | { |
| 712 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 713 | vty_out (vty, "Area %s is %s%s", |
| 714 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 715 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 716 | VTY_NEWLINE); |
| 717 | else |
| 718 | vty_out (vty, "Area %ld is %s%s", |
| 719 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 720 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | VTY_NEWLINE); |
| 722 | return NULL; |
| 723 | } |
| 724 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 725 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 726 | { |
| 727 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 728 | if (vl_data->vl_oi == NULL) |
| 729 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 730 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 731 | ospf_vl_add (ospf, vl_data); |
| 732 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 733 | } |
| 734 | } |
| 735 | return vl_data; |
| 736 | } |
| 737 | |
| 738 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 739 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 740 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 741 | struct ospf_vl_config_data *vl_config) |
| 742 | { |
| 743 | struct crypt_key *ck; |
| 744 | struct vty *vty; |
| 745 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 746 | |
| 747 | vty = vl_config->vty; |
| 748 | |
| 749 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 750 | { |
| 751 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 752 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 753 | } |
| 754 | |
| 755 | if (vl_config->auth_key) |
| 756 | { |
| 757 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 758 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 759 | OSPF_AUTH_SIMPLE_SIZE); |
| 760 | } |
| 761 | else if (vl_config->md5_key) |
| 762 | { |
| 763 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 764 | != NULL) |
| 765 | { |
| 766 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 767 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 768 | return CMD_WARNING; |
| 769 | } |
| 770 | ck = ospf_crypt_key_new (); |
| 771 | ck->key_id = vl_config->crypto_key_id; |
| 772 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 773 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 774 | |
| 775 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 776 | } |
| 777 | else if (vl_config->crypto_key_id != 0) |
| 778 | { |
| 779 | /* Delete a key */ |
| 780 | |
| 781 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 782 | vl_config->crypto_key_id) == NULL) |
| 783 | { |
| 784 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 785 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 786 | return CMD_WARNING; |
| 787 | } |
| 788 | |
| 789 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 790 | |
| 791 | } |
| 792 | |
| 793 | return CMD_SUCCESS; |
| 794 | } |
| 795 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 796 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 798 | struct ospf_vl_config_data *vl_config) |
| 799 | { |
| 800 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 801 | /* Virtual Link data initialised to defaults, so only set |
| 802 | if a value given */ |
| 803 | if (vl_config->hello_interval) |
| 804 | { |
| 805 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 806 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 807 | } |
| 808 | |
| 809 | if (vl_config->dead_interval) |
| 810 | { |
| 811 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 812 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 813 | } |
| 814 | |
| 815 | if (vl_config->retransmit_interval) |
| 816 | { |
| 817 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 818 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 819 | } |
| 820 | |
| 821 | if (vl_config->transmit_delay) |
| 822 | { |
| 823 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 824 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 825 | } |
| 826 | |
| 827 | return CMD_SUCCESS; |
| 828 | } |
| 829 | |
| 830 | |
| 831 | |
| 832 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 833 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 834 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 835 | { |
| 836 | struct ospf_vl_data *vl_data; |
| 837 | int ret; |
| 838 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 839 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 840 | if (!vl_data) |
| 841 | return CMD_WARNING; |
| 842 | |
| 843 | /* Process this one first as it can have a fatal result, which can |
| 844 | only logically occur if the virtual link exists already |
| 845 | Thus a command error does not result in a change to the |
| 846 | running configuration such as unexpectedly altered timer |
| 847 | values etc.*/ |
| 848 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 849 | if (ret != CMD_SUCCESS) |
| 850 | return ret; |
| 851 | |
| 852 | /* Set any time based parameters, these area already range checked */ |
| 853 | |
| 854 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 855 | if (ret != CMD_SUCCESS) |
| 856 | return ret; |
| 857 | |
| 858 | return CMD_SUCCESS; |
| 859 | |
| 860 | } |
| 861 | |
| 862 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 863 | */ |
| 864 | #define VLINK_HELPSTR_IPADDR \ |
| 865 | "OSPF area parameters\n" \ |
| 866 | "OSPF area ID in IP address format\n" \ |
| 867 | "OSPF area ID as a decimal value\n" \ |
| 868 | "Configure a virtual link\n" \ |
| 869 | "Router ID of the remote ABR\n" |
| 870 | |
| 871 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 872 | "Enable authentication on this virtual link\n" \ |
| 873 | "dummy string \n" |
| 874 | |
| 875 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 876 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 877 | "Use null authentication\n" \ |
| 878 | "Use message-digest authentication\n" |
| 879 | |
| 880 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 881 | "Time between HELLO packets\n" \ |
| 882 | "Time between retransmitting lost link state advertisements\n" \ |
| 883 | "Link state transmit delay\n" \ |
| 884 | "Interval after which a neighbor is declared dead\n" |
| 885 | |
| 886 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 887 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 888 | "Seconds\n" |
| 889 | |
| 890 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 891 | "Authentication password (key)\n" \ |
| 892 | "The OSPF password (key)" |
| 893 | |
| 894 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 895 | "Message digest authentication password (key)\n" \ |
| 896 | "dummy string \n" \ |
| 897 | "Key ID\n" \ |
| 898 | "Use MD5 algorithm\n" \ |
| 899 | "The OSPF password (key)" |
| 900 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 901 | DEFUN (ospf_area_vlink, |
| 902 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 904 | VLINK_HELPSTR_IPADDR) |
| 905 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 906 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 907 | struct ospf_vl_config_data vl_config; |
| 908 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 909 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 910 | int i; |
| 911 | int ret; |
| 912 | |
| 913 | ospf_vl_config_data_init(&vl_config, vty); |
| 914 | |
| 915 | /* Read off first 2 parameters and check them */ |
| 916 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 917 | if (ret < 0) |
| 918 | { |
| 919 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 920 | return CMD_WARNING; |
| 921 | } |
| 922 | |
| 923 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 924 | if (! ret) |
| 925 | { |
| 926 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 927 | VTY_NEWLINE); |
| 928 | return CMD_WARNING; |
| 929 | } |
| 930 | |
| 931 | if (argc <=2) |
| 932 | { |
| 933 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 934 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 935 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | /* Deal with other parameters */ |
| 939 | for (i=2; i < argc; i++) |
| 940 | { |
| 941 | |
| 942 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 943 | |
| 944 | switch (argv[i][0]) |
| 945 | { |
| 946 | |
| 947 | case 'a': |
| 948 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 949 | { |
| 950 | /* authentication-key - this option can occur anywhere on |
| 951 | command line. At start of command line |
| 952 | must check for authentication option. */ |
| 953 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 954 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 955 | vl_config.auth_key = auth_key; |
| 956 | i++; |
| 957 | } |
| 958 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 959 | { |
| 960 | /* authentication - this option can only occur at start |
| 961 | of command line */ |
| 962 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 963 | if ((i+1) < argc) |
| 964 | { |
| 965 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 966 | { |
| 967 | /* "authentication null" */ |
| 968 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 969 | i++; |
| 970 | } |
| 971 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 972 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 973 | { |
| 974 | /* "authentication message-digest" */ |
| 975 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 976 | i++; |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | break; |
| 981 | |
| 982 | case 'm': |
| 983 | /* message-digest-key */ |
| 984 | i++; |
| 985 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 986 | if (vl_config.crypto_key_id < 0) |
| 987 | return CMD_WARNING; |
| 988 | i++; |
| 989 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 990 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 991 | vl_config.md5_key = md5_key; |
| 992 | break; |
| 993 | |
| 994 | case 'h': |
| 995 | /* Hello interval */ |
| 996 | i++; |
| 997 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 998 | if (vl_config.hello_interval < 0) |
| 999 | return CMD_WARNING; |
| 1000 | break; |
| 1001 | |
| 1002 | case 'r': |
| 1003 | /* Retransmit Interval */ |
| 1004 | i++; |
| 1005 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1006 | if (vl_config.retransmit_interval < 0) |
| 1007 | return CMD_WARNING; |
| 1008 | break; |
| 1009 | |
| 1010 | case 't': |
| 1011 | /* Transmit Delay */ |
| 1012 | i++; |
| 1013 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1014 | if (vl_config.transmit_delay < 0) |
| 1015 | return CMD_WARNING; |
| 1016 | break; |
| 1017 | |
| 1018 | case 'd': |
| 1019 | /* Dead Interval */ |
| 1020 | i++; |
| 1021 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1022 | if (vl_config.dead_interval < 0) |
| 1023 | return CMD_WARNING; |
| 1024 | break; |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | |
| 1029 | /* Action configuration */ |
| 1030 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1031 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1032 | |
| 1033 | } |
| 1034 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1035 | DEFUN (no_ospf_area_vlink, |
| 1036 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1037 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1038 | NO_STR |
| 1039 | VLINK_HELPSTR_IPADDR) |
| 1040 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1041 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1042 | struct ospf_area *area; |
| 1043 | struct ospf_vl_config_data vl_config; |
| 1044 | struct ospf_vl_data *vl_data = NULL; |
| 1045 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1046 | int i; |
| 1047 | int ret, format; |
| 1048 | |
| 1049 | ospf_vl_config_data_init(&vl_config, vty); |
| 1050 | |
| 1051 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1052 | if (ret < 0) |
| 1053 | { |
| 1054 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1055 | return CMD_WARNING; |
| 1056 | } |
| 1057 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1058 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | if (!area) |
| 1060 | { |
| 1061 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1062 | return CMD_WARNING; |
| 1063 | } |
| 1064 | |
| 1065 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1066 | if (! ret) |
| 1067 | { |
| 1068 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1069 | VTY_NEWLINE); |
| 1070 | return CMD_WARNING; |
| 1071 | } |
| 1072 | |
| 1073 | if (argc <=2) |
| 1074 | { |
| 1075 | /* Basic VLink no command */ |
| 1076 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 1077 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1078 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1079 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1080 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1081 | |
| 1082 | return CMD_SUCCESS; |
| 1083 | } |
| 1084 | |
| 1085 | /* If we are down here, we are reseting parameters */ |
| 1086 | |
| 1087 | /* Deal with other parameters */ |
| 1088 | for (i=2; i < argc; i++) |
| 1089 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1090 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1091 | |
| 1092 | switch (argv[i][0]) |
| 1093 | { |
| 1094 | |
| 1095 | case 'a': |
| 1096 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1097 | { |
| 1098 | /* authentication-key - this option can occur anywhere on |
| 1099 | command line. At start of command line |
| 1100 | must check for authentication option. */ |
| 1101 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1102 | vl_config.auth_key = auth_key; |
| 1103 | } |
| 1104 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1105 | { |
| 1106 | /* authentication - this option can only occur at start |
| 1107 | of command line */ |
| 1108 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1109 | } |
| 1110 | break; |
| 1111 | |
| 1112 | case 'm': |
| 1113 | /* message-digest-key */ |
| 1114 | /* Delete one key */ |
| 1115 | i++; |
| 1116 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1117 | if (vl_config.crypto_key_id < 0) |
| 1118 | return CMD_WARNING; |
| 1119 | vl_config.md5_key = NULL; |
| 1120 | break; |
| 1121 | |
| 1122 | case 'h': |
| 1123 | /* Hello interval */ |
| 1124 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1125 | break; |
| 1126 | |
| 1127 | case 'r': |
| 1128 | /* Retransmit Interval */ |
| 1129 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1130 | break; |
| 1131 | |
| 1132 | case 't': |
| 1133 | /* Transmit Delay */ |
| 1134 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1135 | break; |
| 1136 | |
| 1137 | case 'd': |
| 1138 | /* Dead Interval */ |
| 1139 | i++; |
| 1140 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1141 | break; |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | |
| 1146 | /* Action configuration */ |
| 1147 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1148 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1151 | ALIAS (ospf_area_vlink, |
| 1152 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1153 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1154 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1155 | VLINK_HELPSTR_IPADDR |
| 1156 | VLINK_HELPSTR_TIME_PARAM) |
| 1157 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1158 | ALIAS (no_ospf_area_vlink, |
| 1159 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1160 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1161 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1162 | NO_STR |
| 1163 | VLINK_HELPSTR_IPADDR |
| 1164 | VLINK_HELPSTR_TIME_PARAM) |
| 1165 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1166 | ALIAS (ospf_area_vlink, |
| 1167 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1168 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1169 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1170 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1171 | VLINK_HELPSTR_IPADDR |
| 1172 | VLINK_HELPSTR_TIME_PARAM |
| 1173 | VLINK_HELPSTR_TIME_PARAM) |
| 1174 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1175 | ALIAS (no_ospf_area_vlink, |
| 1176 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1177 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1178 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1179 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1180 | NO_STR |
| 1181 | VLINK_HELPSTR_IPADDR |
| 1182 | VLINK_HELPSTR_TIME_PARAM |
| 1183 | VLINK_HELPSTR_TIME_PARAM) |
| 1184 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1185 | ALIAS (ospf_area_vlink, |
| 1186 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1187 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1188 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1189 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1190 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1191 | VLINK_HELPSTR_IPADDR |
| 1192 | VLINK_HELPSTR_TIME_PARAM |
| 1193 | VLINK_HELPSTR_TIME_PARAM |
| 1194 | VLINK_HELPSTR_TIME_PARAM) |
| 1195 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1196 | ALIAS (no_ospf_area_vlink, |
| 1197 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1198 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1199 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1200 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1201 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1202 | NO_STR |
| 1203 | VLINK_HELPSTR_IPADDR |
| 1204 | VLINK_HELPSTR_TIME_PARAM |
| 1205 | VLINK_HELPSTR_TIME_PARAM |
| 1206 | VLINK_HELPSTR_TIME_PARAM) |
| 1207 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1208 | ALIAS (ospf_area_vlink, |
| 1209 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1210 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1211 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1212 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1213 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1214 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1215 | VLINK_HELPSTR_IPADDR |
| 1216 | VLINK_HELPSTR_TIME_PARAM |
| 1217 | VLINK_HELPSTR_TIME_PARAM |
| 1218 | VLINK_HELPSTR_TIME_PARAM |
| 1219 | VLINK_HELPSTR_TIME_PARAM) |
| 1220 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1221 | ALIAS (no_ospf_area_vlink, |
| 1222 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1223 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1224 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1225 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1226 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1227 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1228 | NO_STR |
| 1229 | VLINK_HELPSTR_IPADDR |
| 1230 | VLINK_HELPSTR_TIME_PARAM |
| 1231 | VLINK_HELPSTR_TIME_PARAM |
| 1232 | VLINK_HELPSTR_TIME_PARAM |
| 1233 | VLINK_HELPSTR_TIME_PARAM) |
| 1234 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1235 | ALIAS (ospf_area_vlink, |
| 1236 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1237 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1238 | "(authentication|) (message-digest|null)", |
| 1239 | VLINK_HELPSTR_IPADDR |
| 1240 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1241 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1242 | ALIAS (ospf_area_vlink, |
| 1243 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1244 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1245 | "(authentication|)", |
| 1246 | VLINK_HELPSTR_IPADDR |
| 1247 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1248 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1249 | ALIAS (no_ospf_area_vlink, |
| 1250 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1251 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1252 | "(authentication|)", |
| 1253 | NO_STR |
| 1254 | VLINK_HELPSTR_IPADDR |
| 1255 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1256 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1257 | ALIAS (ospf_area_vlink, |
| 1258 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1259 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1260 | "(message-digest-key|) <1-255> md5 KEY", |
| 1261 | VLINK_HELPSTR_IPADDR |
| 1262 | VLINK_HELPSTR_AUTH_MD5) |
| 1263 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1264 | ALIAS (no_ospf_area_vlink, |
| 1265 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1266 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1267 | "(message-digest-key|) <1-255>", |
| 1268 | NO_STR |
| 1269 | VLINK_HELPSTR_IPADDR |
| 1270 | VLINK_HELPSTR_AUTH_MD5) |
| 1271 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1272 | ALIAS (ospf_area_vlink, |
| 1273 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1274 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1275 | "(authentication-key|) AUTH_KEY", |
| 1276 | VLINK_HELPSTR_IPADDR |
| 1277 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1278 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1279 | ALIAS (no_ospf_area_vlink, |
| 1280 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1281 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1282 | "(authentication-key|)", |
| 1283 | NO_STR |
| 1284 | VLINK_HELPSTR_IPADDR |
| 1285 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1286 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1287 | ALIAS (ospf_area_vlink, |
| 1288 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1289 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1290 | "(authentication|) (message-digest|null) " |
| 1291 | "(authentication-key|) AUTH_KEY", |
| 1292 | VLINK_HELPSTR_IPADDR |
| 1293 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1294 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1295 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1296 | ALIAS (ospf_area_vlink, |
| 1297 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1298 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1299 | "(authentication|) " |
| 1300 | "(authentication-key|) AUTH_KEY", |
| 1301 | VLINK_HELPSTR_IPADDR |
| 1302 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1303 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1304 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1305 | ALIAS (no_ospf_area_vlink, |
| 1306 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1307 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1308 | "(authentication|) " |
| 1309 | "(authentication-key|)", |
| 1310 | NO_STR |
| 1311 | VLINK_HELPSTR_IPADDR |
| 1312 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1313 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1314 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1315 | ALIAS (ospf_area_vlink, |
| 1316 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1317 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1318 | "(authentication|) (message-digest|null) " |
| 1319 | "(message-digest-key|) <1-255> md5 KEY", |
| 1320 | VLINK_HELPSTR_IPADDR |
| 1321 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1322 | VLINK_HELPSTR_AUTH_MD5) |
| 1323 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1324 | ALIAS (ospf_area_vlink, |
| 1325 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1326 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1327 | "(authentication|) " |
| 1328 | "(message-digest-key|) <1-255> md5 KEY", |
| 1329 | VLINK_HELPSTR_IPADDR |
| 1330 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1331 | VLINK_HELPSTR_AUTH_MD5) |
| 1332 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1333 | ALIAS (no_ospf_area_vlink, |
| 1334 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1335 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1336 | "(authentication|) " |
| 1337 | "(message-digest-key|)", |
| 1338 | NO_STR |
| 1339 | VLINK_HELPSTR_IPADDR |
| 1340 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1341 | VLINK_HELPSTR_AUTH_MD5) |
| 1342 | |
| 1343 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1344 | DEFUN (ospf_area_shortcut, |
| 1345 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1346 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1347 | "OSPF area parameters\n" |
| 1348 | "OSPF area ID in IP address format\n" |
| 1349 | "OSPF area ID as a decimal value\n" |
| 1350 | "Configure the area's shortcutting mode\n" |
| 1351 | "Set default shortcutting behavior\n" |
| 1352 | "Enable shortcutting through the area\n" |
| 1353 | "Disable shortcutting through the area\n") |
| 1354 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1355 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1356 | struct ospf_area *area; |
| 1357 | struct in_addr area_id; |
| 1358 | int mode; |
| 1359 | int format; |
| 1360 | |
| 1361 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1362 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1363 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1364 | |
| 1365 | if (strncmp (argv[1], "de", 2) == 0) |
| 1366 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1367 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1368 | mode = OSPF_SHORTCUT_DISABLE; |
| 1369 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1370 | mode = OSPF_SHORTCUT_ENABLE; |
| 1371 | else |
| 1372 | return CMD_WARNING; |
| 1373 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1374 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1375 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1376 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1377 | vty_out (vty, "Shortcut area setting will take effect " |
| 1378 | "only when the router is configured as Shortcut ABR%s", |
| 1379 | VTY_NEWLINE); |
| 1380 | |
| 1381 | return CMD_SUCCESS; |
| 1382 | } |
| 1383 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1384 | DEFUN (no_ospf_area_shortcut, |
| 1385 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1387 | NO_STR |
| 1388 | "OSPF area parameters\n" |
| 1389 | "OSPF area ID in IP address format\n" |
| 1390 | "OSPF area ID as a decimal value\n" |
| 1391 | "Deconfigure the area's shortcutting mode\n" |
| 1392 | "Deconfigure enabled shortcutting through the area\n" |
| 1393 | "Deconfigure disabled shortcutting through the area\n") |
| 1394 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1395 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | struct ospf_area *area; |
| 1397 | struct in_addr area_id; |
| 1398 | int format; |
| 1399 | |
| 1400 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1401 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1402 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1403 | if (!area) |
| 1404 | return CMD_SUCCESS; |
| 1405 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1406 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1407 | |
| 1408 | return CMD_SUCCESS; |
| 1409 | } |
| 1410 | |
| 1411 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1412 | DEFUN (ospf_area_stub, |
| 1413 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1414 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1415 | "OSPF area parameters\n" |
| 1416 | "OSPF area ID in IP address format\n" |
| 1417 | "OSPF area ID as a decimal value\n" |
| 1418 | "Configure OSPF area as stub\n") |
| 1419 | { |
| 1420 | struct ospf *ospf = vty->index; |
| 1421 | struct in_addr area_id; |
| 1422 | int ret, format; |
| 1423 | |
| 1424 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1425 | |
| 1426 | ret = ospf_area_stub_set (ospf, area_id); |
| 1427 | if (ret == 0) |
| 1428 | { |
| 1429 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1430 | VTY_NEWLINE); |
| 1431 | return CMD_WARNING; |
| 1432 | } |
| 1433 | |
| 1434 | ospf_area_no_summary_unset (ospf, area_id); |
| 1435 | |
| 1436 | return CMD_SUCCESS; |
| 1437 | } |
| 1438 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1439 | DEFUN (ospf_area_stub_no_summary, |
| 1440 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1441 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1442 | "OSPF stub parameters\n" |
| 1443 | "OSPF area ID in IP address format\n" |
| 1444 | "OSPF area ID as a decimal value\n" |
| 1445 | "Configure OSPF area as stub\n" |
| 1446 | "Do not inject inter-area routes into stub\n") |
| 1447 | { |
| 1448 | struct ospf *ospf = vty->index; |
| 1449 | struct in_addr area_id; |
| 1450 | int ret, format; |
| 1451 | |
| 1452 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1453 | |
| 1454 | ret = ospf_area_stub_set (ospf, area_id); |
| 1455 | if (ret == 0) |
| 1456 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1457 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1458 | VTY_NEWLINE); |
| 1459 | return CMD_WARNING; |
| 1460 | } |
| 1461 | |
| 1462 | ospf_area_no_summary_set (ospf, area_id); |
| 1463 | |
| 1464 | return CMD_SUCCESS; |
| 1465 | } |
| 1466 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1467 | DEFUN (no_ospf_area_stub, |
| 1468 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1469 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1470 | NO_STR |
| 1471 | "OSPF area parameters\n" |
| 1472 | "OSPF area ID in IP address format\n" |
| 1473 | "OSPF area ID as a decimal value\n" |
| 1474 | "Configure OSPF area as stub\n") |
| 1475 | { |
| 1476 | struct ospf *ospf = vty->index; |
| 1477 | struct in_addr area_id; |
| 1478 | int format; |
| 1479 | |
| 1480 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1481 | |
| 1482 | ospf_area_stub_unset (ospf, area_id); |
| 1483 | ospf_area_no_summary_unset (ospf, area_id); |
| 1484 | |
| 1485 | return CMD_SUCCESS; |
| 1486 | } |
| 1487 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1488 | DEFUN (no_ospf_area_stub_no_summary, |
| 1489 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1490 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1491 | NO_STR |
| 1492 | "OSPF area parameters\n" |
| 1493 | "OSPF area ID in IP address format\n" |
| 1494 | "OSPF area ID as a decimal value\n" |
| 1495 | "Configure OSPF area as stub\n" |
| 1496 | "Do not inject inter-area routes into area\n") |
| 1497 | { |
| 1498 | struct ospf *ospf = vty->index; |
| 1499 | struct in_addr area_id; |
| 1500 | int format; |
| 1501 | |
| 1502 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1503 | ospf_area_no_summary_unset (ospf, area_id); |
| 1504 | |
| 1505 | return CMD_SUCCESS; |
| 1506 | } |
| 1507 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1508 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1509 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1510 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1511 | { |
| 1512 | struct ospf *ospf = vty->index; |
| 1513 | struct in_addr area_id; |
| 1514 | int ret, format; |
| 1515 | |
| 1516 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1517 | |
| 1518 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1519 | if (ret == 0) |
| 1520 | { |
| 1521 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1522 | VTY_NEWLINE); |
| 1523 | return CMD_WARNING; |
| 1524 | } |
| 1525 | |
| 1526 | if (argc > 1) |
| 1527 | { |
| 1528 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1529 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1530 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1531 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1532 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1533 | OSPF_NSSA_ROLE_NEVER); |
| 1534 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1535 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | OSPF_NSSA_ROLE_ALWAYS); |
| 1537 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1538 | else |
| 1539 | { |
| 1540 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1541 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1542 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1543 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1544 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1545 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1546 | else |
| 1547 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1548 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1549 | ospf_schedule_abr_task (ospf); |
| 1550 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1551 | return CMD_SUCCESS; |
| 1552 | } |
| 1553 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1554 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1555 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1556 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1564 | "Do not inject inter-area routes into nssa\n") |
| 1565 | { |
| 1566 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1567 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1568 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1569 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1570 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1571 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 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") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1579 | { |
| 1580 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1581 | } |
| 1582 | |
| 1583 | DEFUN (ospf_area_nssa, |
| 1584 | ospf_area_nssa_cmd, |
| 1585 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1593 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1594 | DEFUN (ospf_area_nssa_no_summary, |
| 1595 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 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 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1603 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1604 | } |
| 1605 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1606 | DEFUN (no_ospf_area_nssa, |
| 1607 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1608 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 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" |
| 1613 | "Configure OSPF area as nssa\n") |
| 1614 | { |
| 1615 | struct ospf *ospf = vty->index; |
| 1616 | struct in_addr area_id; |
| 1617 | int format; |
| 1618 | |
| 1619 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1620 | |
| 1621 | ospf_area_nssa_unset (ospf, area_id); |
| 1622 | ospf_area_no_summary_unset (ospf, area_id); |
| 1623 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1624 | ospf_schedule_abr_task (ospf); |
| 1625 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1626 | return CMD_SUCCESS; |
| 1627 | } |
| 1628 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1629 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1630 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1631 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1632 | NO_STR |
| 1633 | "OSPF area parameters\n" |
| 1634 | "OSPF area ID in IP address format\n" |
| 1635 | "OSPF area ID as a decimal value\n" |
| 1636 | "Configure OSPF area as nssa\n" |
| 1637 | "Do not inject inter-area routes into nssa\n") |
| 1638 | { |
| 1639 | struct ospf *ospf = vty->index; |
| 1640 | struct in_addr area_id; |
| 1641 | int format; |
| 1642 | |
| 1643 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1644 | ospf_area_no_summary_unset (ospf, area_id); |
| 1645 | |
| 1646 | return CMD_SUCCESS; |
| 1647 | } |
| 1648 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1649 | DEFUN (ospf_area_default_cost, |
| 1650 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1651 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1652 | "OSPF area parameters\n" |
| 1653 | "OSPF area ID in IP address format\n" |
| 1654 | "OSPF area ID as a decimal value\n" |
| 1655 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1656 | "Stub's advertised default summary cost\n") |
| 1657 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1658 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1659 | struct ospf_area *area; |
| 1660 | struct in_addr area_id; |
| 1661 | u_int32_t cost; |
| 1662 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1663 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1664 | |
| 1665 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1666 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1667 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1668 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1669 | |
| 1670 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1671 | { |
| 1672 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1673 | return CMD_WARNING; |
| 1674 | } |
| 1675 | |
| 1676 | area->default_cost = cost; |
| 1677 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1678 | p.family = AF_INET; |
| 1679 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1680 | p.prefixlen = 0; |
| 1681 | if (IS_DEBUG_OSPF_EVENT) |
| 1682 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1683 | "announcing 0.0.0.0/0 to area %s", |
| 1684 | inet_ntoa (area->area_id)); |
| 1685 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1686 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1687 | return CMD_SUCCESS; |
| 1688 | } |
| 1689 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1690 | DEFUN (no_ospf_area_default_cost, |
| 1691 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1692 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1693 | NO_STR |
| 1694 | "OSPF area parameters\n" |
| 1695 | "OSPF area ID in IP address format\n" |
| 1696 | "OSPF area ID as a decimal value\n" |
| 1697 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1698 | "Stub's advertised default summary cost\n") |
| 1699 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1700 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1701 | struct ospf_area *area; |
| 1702 | struct in_addr area_id; |
| 1703 | u_int32_t cost; |
| 1704 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1705 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1706 | |
| 1707 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1708 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1709 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1710 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1711 | if (area == NULL) |
| 1712 | return CMD_SUCCESS; |
| 1713 | |
| 1714 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1715 | { |
| 1716 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1717 | return CMD_WARNING; |
| 1718 | } |
| 1719 | |
| 1720 | area->default_cost = 1; |
| 1721 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1722 | p.family = AF_INET; |
| 1723 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1724 | p.prefixlen = 0; |
| 1725 | if (IS_DEBUG_OSPF_EVENT) |
| 1726 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1727 | "announcing 0.0.0.0/0 to area %s", |
| 1728 | inet_ntoa (area->area_id)); |
| 1729 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1730 | |
| 1731 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1732 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1733 | |
| 1734 | return CMD_SUCCESS; |
| 1735 | } |
| 1736 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1737 | DEFUN (ospf_area_export_list, |
| 1738 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1739 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1740 | "OSPF area parameters\n" |
| 1741 | "OSPF area ID in IP address format\n" |
| 1742 | "OSPF area ID as a decimal value\n" |
| 1743 | "Set the filter for networks announced to other areas\n" |
| 1744 | "Name of the access-list\n") |
| 1745 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1746 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1747 | struct ospf_area *area; |
| 1748 | struct in_addr area_id; |
| 1749 | int format; |
| 1750 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1751 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1752 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1753 | area = ospf_area_get (ospf, area_id, format); |
| 1754 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1755 | |
| 1756 | return CMD_SUCCESS; |
| 1757 | } |
| 1758 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1759 | DEFUN (no_ospf_area_export_list, |
| 1760 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1761 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1762 | NO_STR |
| 1763 | "OSPF area parameters\n" |
| 1764 | "OSPF area ID in IP address format\n" |
| 1765 | "OSPF area ID as a decimal value\n" |
| 1766 | "Unset the filter for networks announced to other areas\n" |
| 1767 | "Name of the access-list\n") |
| 1768 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1769 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1770 | struct ospf_area *area; |
| 1771 | struct in_addr area_id; |
| 1772 | int format; |
| 1773 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1774 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1775 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1776 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1777 | if (area == NULL) |
| 1778 | return CMD_SUCCESS; |
| 1779 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1780 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1781 | |
| 1782 | return CMD_SUCCESS; |
| 1783 | } |
| 1784 | |
| 1785 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1786 | DEFUN (ospf_area_import_list, |
| 1787 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1788 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1789 | "OSPF area parameters\n" |
| 1790 | "OSPF area ID in IP address format\n" |
| 1791 | "OSPF area ID as a decimal value\n" |
| 1792 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1793 | "Name of the access-list\n") |
| 1794 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1795 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1796 | struct ospf_area *area; |
| 1797 | struct in_addr area_id; |
| 1798 | int format; |
| 1799 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1800 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1801 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1802 | area = ospf_area_get (ospf, area_id, format); |
| 1803 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1804 | |
| 1805 | return CMD_SUCCESS; |
| 1806 | } |
| 1807 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1808 | DEFUN (no_ospf_area_import_list, |
| 1809 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1810 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1811 | NO_STR |
| 1812 | "OSPF area parameters\n" |
| 1813 | "OSPF area ID in IP address format\n" |
| 1814 | "OSPF area ID as a decimal value\n" |
| 1815 | "Unset the filter for networks announced to other areas\n" |
| 1816 | "Name of the access-list\n") |
| 1817 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1818 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1819 | struct ospf_area *area; |
| 1820 | struct in_addr area_id; |
| 1821 | int format; |
| 1822 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1823 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1824 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1825 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1826 | if (area == NULL) |
| 1827 | return CMD_SUCCESS; |
| 1828 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1829 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1830 | |
| 1831 | return CMD_SUCCESS; |
| 1832 | } |
| 1833 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1834 | DEFUN (ospf_area_filter_list, |
| 1835 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1836 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1837 | "OSPF area parameters\n" |
| 1838 | "OSPF area ID in IP address format\n" |
| 1839 | "OSPF area ID as a decimal value\n" |
| 1840 | "Filter networks between OSPF areas\n" |
| 1841 | "Filter prefixes between OSPF areas\n" |
| 1842 | "Name of an IP prefix-list\n" |
| 1843 | "Filter networks sent to this area\n" |
| 1844 | "Filter networks sent from this area\n") |
| 1845 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1846 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1847 | struct ospf_area *area; |
| 1848 | struct in_addr area_id; |
| 1849 | struct prefix_list *plist; |
| 1850 | int format; |
| 1851 | |
| 1852 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1853 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1854 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1855 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1856 | if (strncmp (argv[2], "in", 2) == 0) |
| 1857 | { |
| 1858 | PREFIX_LIST_IN (area) = plist; |
| 1859 | if (PREFIX_NAME_IN (area)) |
| 1860 | free (PREFIX_NAME_IN (area)); |
| 1861 | |
| 1862 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1863 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1864 | } |
| 1865 | else |
| 1866 | { |
| 1867 | PREFIX_LIST_OUT (area) = plist; |
| 1868 | if (PREFIX_NAME_OUT (area)) |
| 1869 | free (PREFIX_NAME_OUT (area)); |
| 1870 | |
| 1871 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1872 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | } |
| 1874 | |
| 1875 | return CMD_SUCCESS; |
| 1876 | } |
| 1877 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1878 | DEFUN (no_ospf_area_filter_list, |
| 1879 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1880 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1881 | NO_STR |
| 1882 | "OSPF area parameters\n" |
| 1883 | "OSPF area ID in IP address format\n" |
| 1884 | "OSPF area ID as a decimal value\n" |
| 1885 | "Filter networks between OSPF areas\n" |
| 1886 | "Filter prefixes between OSPF areas\n" |
| 1887 | "Name of an IP prefix-list\n" |
| 1888 | "Filter networks sent to this area\n" |
| 1889 | "Filter networks sent from this area\n") |
| 1890 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1891 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1892 | struct ospf_area *area; |
| 1893 | struct in_addr area_id; |
| 1894 | struct prefix_list *plist; |
| 1895 | int format; |
| 1896 | |
| 1897 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1898 | |
Paul Jakma | 1a8ec2b | 2006-05-11 13:34:08 +0000 | [diff] [blame] | 1899 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
| 1900 | return CMD_SUCCESS; |
| 1901 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1902 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1903 | if (strncmp (argv[2], "in", 2) == 0) |
| 1904 | { |
| 1905 | if (PREFIX_NAME_IN (area)) |
| 1906 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1907 | return CMD_SUCCESS; |
| 1908 | |
| 1909 | PREFIX_LIST_IN (area) = NULL; |
| 1910 | if (PREFIX_NAME_IN (area)) |
| 1911 | free (PREFIX_NAME_IN (area)); |
| 1912 | |
| 1913 | PREFIX_NAME_IN (area) = NULL; |
| 1914 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1915 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1916 | } |
| 1917 | else |
| 1918 | { |
| 1919 | if (PREFIX_NAME_OUT (area)) |
| 1920 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1921 | return CMD_SUCCESS; |
| 1922 | |
| 1923 | PREFIX_LIST_OUT (area) = NULL; |
| 1924 | if (PREFIX_NAME_OUT (area)) |
| 1925 | free (PREFIX_NAME_OUT (area)); |
| 1926 | |
| 1927 | PREFIX_NAME_OUT (area) = NULL; |
| 1928 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1929 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1930 | } |
| 1931 | |
| 1932 | return CMD_SUCCESS; |
| 1933 | } |
| 1934 | |
| 1935 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1936 | DEFUN (ospf_area_authentication_message_digest, |
| 1937 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1938 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1939 | "OSPF area parameters\n" |
| 1940 | "Enable authentication\n" |
| 1941 | "Use message-digest authentication\n") |
| 1942 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1943 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1944 | struct ospf_area *area; |
| 1945 | struct in_addr area_id; |
| 1946 | int format; |
| 1947 | |
| 1948 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1949 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1950 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1951 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1952 | |
| 1953 | return CMD_SUCCESS; |
| 1954 | } |
| 1955 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1956 | DEFUN (ospf_area_authentication, |
| 1957 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1958 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1959 | "OSPF area parameters\n" |
| 1960 | "OSPF area ID in IP address format\n" |
| 1961 | "OSPF area ID as a decimal value\n" |
| 1962 | "Enable authentication\n") |
| 1963 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1964 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1965 | struct ospf_area *area; |
| 1966 | struct in_addr area_id; |
| 1967 | int format; |
| 1968 | |
| 1969 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1970 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1971 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1972 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1973 | |
| 1974 | return CMD_SUCCESS; |
| 1975 | } |
| 1976 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1977 | DEFUN (no_ospf_area_authentication, |
| 1978 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1979 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1980 | NO_STR |
| 1981 | "OSPF area parameters\n" |
| 1982 | "OSPF area ID in IP address format\n" |
| 1983 | "OSPF area ID as a decimal value\n" |
| 1984 | "Enable authentication\n") |
| 1985 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1986 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1987 | struct ospf_area *area; |
| 1988 | struct in_addr area_id; |
| 1989 | int format; |
| 1990 | |
| 1991 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1992 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1993 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1994 | if (area == NULL) |
| 1995 | return CMD_SUCCESS; |
| 1996 | |
| 1997 | area->auth_type = OSPF_AUTH_NULL; |
| 1998 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1999 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2000 | |
| 2001 | return CMD_SUCCESS; |
| 2002 | } |
| 2003 | |
| 2004 | |
| 2005 | DEFUN (ospf_abr_type, |
| 2006 | ospf_abr_type_cmd, |
| 2007 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 2008 | "OSPF specific commands\n" |
| 2009 | "Set OSPF ABR type\n" |
| 2010 | "Alternative ABR, cisco implementation\n" |
| 2011 | "Alternative ABR, IBM implementation\n" |
| 2012 | "Shortcut ABR\n" |
| 2013 | "Standard behavior (RFC2328)\n") |
| 2014 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2015 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2016 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2017 | |
| 2018 | if (strncmp (argv[0], "c", 1) == 0) |
| 2019 | abr_type = OSPF_ABR_CISCO; |
| 2020 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2021 | abr_type = OSPF_ABR_IBM; |
| 2022 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2023 | abr_type = OSPF_ABR_SHORTCUT; |
| 2024 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2025 | abr_type = OSPF_ABR_STAND; |
| 2026 | else |
| 2027 | return CMD_WARNING; |
| 2028 | |
| 2029 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2030 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2031 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2032 | ospf->abr_type = abr_type; |
| 2033 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2034 | } |
| 2035 | |
| 2036 | return CMD_SUCCESS; |
| 2037 | } |
| 2038 | |
| 2039 | DEFUN (no_ospf_abr_type, |
| 2040 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2041 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2042 | NO_STR |
| 2043 | "OSPF specific commands\n" |
| 2044 | "Set OSPF ABR type\n" |
| 2045 | "Alternative ABR, cisco implementation\n" |
| 2046 | "Alternative ABR, IBM implementation\n" |
| 2047 | "Shortcut ABR\n") |
| 2048 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2049 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2050 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2051 | |
| 2052 | if (strncmp (argv[0], "c", 1) == 0) |
| 2053 | abr_type = OSPF_ABR_CISCO; |
| 2054 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2055 | abr_type = OSPF_ABR_IBM; |
| 2056 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2057 | abr_type = OSPF_ABR_SHORTCUT; |
| 2058 | else |
| 2059 | return CMD_WARNING; |
| 2060 | |
| 2061 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2062 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2064 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2065 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | return CMD_SUCCESS; |
| 2069 | } |
| 2070 | |
| 2071 | DEFUN (ospf_compatible_rfc1583, |
| 2072 | ospf_compatible_rfc1583_cmd, |
| 2073 | "compatible rfc1583", |
| 2074 | "OSPF compatibility list\n" |
| 2075 | "compatible with RFC 1583\n") |
| 2076 | { |
| 2077 | struct ospf *ospf = vty->index; |
| 2078 | |
| 2079 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2080 | { |
| 2081 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2082 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2083 | } |
| 2084 | return CMD_SUCCESS; |
| 2085 | } |
| 2086 | |
| 2087 | DEFUN (no_ospf_compatible_rfc1583, |
| 2088 | no_ospf_compatible_rfc1583_cmd, |
| 2089 | "no compatible rfc1583", |
| 2090 | NO_STR |
| 2091 | "OSPF compatibility list\n" |
| 2092 | "compatible with RFC 1583\n") |
| 2093 | { |
| 2094 | struct ospf *ospf = vty->index; |
| 2095 | |
| 2096 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2097 | { |
| 2098 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2099 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2100 | } |
| 2101 | return CMD_SUCCESS; |
| 2102 | } |
| 2103 | |
| 2104 | ALIAS (ospf_compatible_rfc1583, |
| 2105 | ospf_rfc1583_flag_cmd, |
| 2106 | "ospf rfc1583compatibility", |
| 2107 | "OSPF specific commands\n" |
| 2108 | "Enable the RFC1583Compatibility flag\n") |
| 2109 | |
| 2110 | ALIAS (no_ospf_compatible_rfc1583, |
| 2111 | no_ospf_rfc1583_flag_cmd, |
| 2112 | "no ospf rfc1583compatibility", |
| 2113 | NO_STR |
| 2114 | "OSPF specific commands\n" |
| 2115 | "Disable the RFC1583Compatibility flag\n") |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2116 | |
| 2117 | static int |
| 2118 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2119 | unsigned int hold, |
| 2120 | unsigned int max) |
| 2121 | { |
| 2122 | struct ospf *ospf = vty->index; |
| 2123 | |
| 2124 | ospf->spf_delay = delay; |
| 2125 | ospf->spf_holdtime = hold; |
| 2126 | ospf->spf_max_holdtime = max; |
| 2127 | |
| 2128 | return CMD_SUCCESS; |
| 2129 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2130 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2131 | DEFUN (ospf_timers_throttle_spf, |
| 2132 | ospf_timers_throttle_spf_cmd, |
| 2133 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2134 | "Adjust routing timers\n" |
| 2135 | "Throttling adaptive timer\n" |
| 2136 | "OSPF SPF timers\n" |
| 2137 | "Delay (msec) from first change received till SPF calculation\n" |
| 2138 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2139 | "Maximum hold time (msec)\n") |
| 2140 | { |
| 2141 | unsigned int delay, hold, max; |
| 2142 | |
| 2143 | if (argc != 3) |
| 2144 | { |
| 2145 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2146 | return CMD_WARNING; |
| 2147 | } |
| 2148 | |
| 2149 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2150 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2151 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2152 | |
| 2153 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2154 | } |
| 2155 | |
| 2156 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2157 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2158 | "timers spf <0-4294967295> <0-4294967295>", |
| 2159 | "Adjust routing timers\n" |
| 2160 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2161 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2162 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2163 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2164 | unsigned int delay, hold; |
| 2165 | |
| 2166 | if (argc != 2) |
| 2167 | { |
| 2168 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2169 | return CMD_WARNING; |
| 2170 | } |
| 2171 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2172 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2173 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2174 | |
| 2175 | /* truncate down the second values if they're greater than 600000ms */ |
| 2176 | if (delay > (600000 / 1000)) |
| 2177 | delay = 600000; |
| 2178 | else if (delay == 0) |
| 2179 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2180 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2181 | if (hold > (600000 / 1000)) |
| 2182 | hold = 600000; |
| 2183 | |
| 2184 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2185 | } |
| 2186 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2187 | DEFUN (no_ospf_timers_throttle_spf, |
| 2188 | no_ospf_timers_throttle_spf_cmd, |
| 2189 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2190 | NO_STR |
| 2191 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2192 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2193 | "OSPF SPF timers\n") |
| 2194 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2195 | return ospf_timers_spf_set (vty, |
| 2196 | OSPF_SPF_DELAY_DEFAULT, |
| 2197 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2198 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2199 | } |
| 2200 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2201 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2202 | no_ospf_timers_spf_cmd, |
| 2203 | "no timers spf", |
| 2204 | NO_STR |
| 2205 | "Adjust routing timers\n" |
| 2206 | "OSPF SPF timers\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2207 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2208 | DEFUN (ospf_neighbor, |
| 2209 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | "neighbor A.B.C.D", |
| 2211 | NEIGHBOR_STR |
| 2212 | "Neighbor IP address\n") |
| 2213 | { |
| 2214 | struct ospf *ospf = vty->index; |
| 2215 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2216 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2217 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2218 | |
| 2219 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2220 | |
| 2221 | if (argc > 1) |
| 2222 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2223 | |
| 2224 | if (argc > 2) |
| 2225 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2226 | |
| 2227 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2228 | if (argc > 1) |
| 2229 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2230 | if (argc > 2) |
| 2231 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2232 | |
| 2233 | return CMD_SUCCESS; |
| 2234 | } |
| 2235 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2236 | ALIAS (ospf_neighbor, |
| 2237 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2239 | NEIGHBOR_STR |
| 2240 | "Neighbor IP address\n" |
| 2241 | "Neighbor Priority\n" |
| 2242 | "Priority\n" |
| 2243 | "Dead Neighbor Polling interval\n" |
| 2244 | "Seconds\n") |
| 2245 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2246 | ALIAS (ospf_neighbor, |
| 2247 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | "neighbor A.B.C.D priority <0-255>", |
| 2249 | NEIGHBOR_STR |
| 2250 | "Neighbor IP address\n" |
| 2251 | "Neighbor Priority\n" |
| 2252 | "Seconds\n") |
| 2253 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2254 | DEFUN (ospf_neighbor_poll_interval, |
| 2255 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2257 | NEIGHBOR_STR |
| 2258 | "Neighbor IP address\n" |
| 2259 | "Dead Neighbor Polling interval\n" |
| 2260 | "Seconds\n") |
| 2261 | { |
| 2262 | struct ospf *ospf = vty->index; |
| 2263 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2264 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2265 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2266 | |
| 2267 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2268 | |
| 2269 | if (argc > 1) |
| 2270 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2271 | |
| 2272 | if (argc > 2) |
| 2273 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2274 | |
| 2275 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2276 | if (argc > 1) |
| 2277 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2278 | if (argc > 2) |
| 2279 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2280 | |
| 2281 | return CMD_SUCCESS; |
| 2282 | } |
| 2283 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2284 | ALIAS (ospf_neighbor_poll_interval, |
| 2285 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2287 | NEIGHBOR_STR |
| 2288 | "Neighbor address\n" |
| 2289 | "OSPF dead-router polling interval\n" |
| 2290 | "Seconds\n" |
| 2291 | "OSPF priority of non-broadcast neighbor\n" |
| 2292 | "Priority\n") |
| 2293 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2294 | DEFUN (no_ospf_neighbor, |
| 2295 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2296 | "no neighbor A.B.C.D", |
| 2297 | NO_STR |
| 2298 | NEIGHBOR_STR |
| 2299 | "Neighbor IP address\n") |
| 2300 | { |
| 2301 | struct ospf *ospf = vty->index; |
| 2302 | struct in_addr nbr_addr; |
| 2303 | int ret; |
| 2304 | |
| 2305 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2306 | |
| 2307 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2308 | |
| 2309 | return CMD_SUCCESS; |
| 2310 | } |
| 2311 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2312 | ALIAS (no_ospf_neighbor, |
| 2313 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2314 | "no neighbor A.B.C.D priority <0-255>", |
| 2315 | NO_STR |
| 2316 | NEIGHBOR_STR |
| 2317 | "Neighbor IP address\n" |
| 2318 | "Neighbor Priority\n" |
| 2319 | "Priority\n") |
| 2320 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2321 | ALIAS (no_ospf_neighbor, |
| 2322 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2323 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2324 | NO_STR |
| 2325 | NEIGHBOR_STR |
| 2326 | "Neighbor IP address\n" |
| 2327 | "Dead Neighbor Polling interval\n" |
| 2328 | "Seconds\n") |
| 2329 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2330 | ALIAS (no_ospf_neighbor, |
| 2331 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2332 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2333 | NO_STR |
| 2334 | NEIGHBOR_STR |
| 2335 | "Neighbor IP address\n" |
| 2336 | "Neighbor Priority\n" |
| 2337 | "Priority\n" |
| 2338 | "Dead Neighbor Polling interval\n" |
| 2339 | "Seconds\n") |
| 2340 | |
| 2341 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2342 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2343 | "refresh timer <10-1800>", |
| 2344 | "Adjust refresh parameters\n" |
| 2345 | "Set refresh timer\n" |
| 2346 | "Timer value in seconds\n") |
| 2347 | { |
| 2348 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2349 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | |
| 2351 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2352 | interval = (interval / 10) * 10; |
| 2353 | |
| 2354 | ospf_timers_refresh_set (ospf, interval); |
| 2355 | |
| 2356 | return CMD_SUCCESS; |
| 2357 | } |
| 2358 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2359 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | "no refresh timer <10-1800>", |
| 2361 | "Adjust refresh parameters\n" |
| 2362 | "Unset refresh timer\n" |
| 2363 | "Timer value in seconds\n") |
| 2364 | { |
| 2365 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2366 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | |
| 2368 | if (argc == 1) |
| 2369 | { |
| 2370 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2371 | |
| 2372 | if (ospf->lsa_refresh_interval != interval || |
| 2373 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2374 | return CMD_SUCCESS; |
| 2375 | } |
| 2376 | |
| 2377 | ospf_timers_refresh_unset (ospf); |
| 2378 | |
| 2379 | return CMD_SUCCESS; |
| 2380 | } |
| 2381 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2382 | ALIAS (no_ospf_refresh_timer, |
| 2383 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | "no refresh timer", |
| 2385 | "Adjust refresh parameters\n" |
| 2386 | "Unset refresh timer\n") |
| 2387 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2388 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2389 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2390 | "auto-cost reference-bandwidth <1-4294967>", |
| 2391 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2392 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2393 | "The reference bandwidth in terms of Mbits per second\n") |
| 2394 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2395 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2396 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2397 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2398 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2399 | |
| 2400 | refbw = strtol (argv[0], NULL, 10); |
| 2401 | if (refbw < 1 || refbw > 4294967) |
| 2402 | { |
| 2403 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2404 | return CMD_WARNING; |
| 2405 | } |
| 2406 | |
| 2407 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2408 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2409 | return CMD_SUCCESS; |
| 2410 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2411 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2412 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2413 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2414 | |
| 2415 | return CMD_SUCCESS; |
| 2416 | } |
| 2417 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2418 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2419 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2420 | "no auto-cost reference-bandwidth", |
| 2421 | NO_STR |
| 2422 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2423 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2424 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2425 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2426 | struct listnode *node, *nnode; |
| 2427 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2428 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2429 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2430 | return CMD_SUCCESS; |
| 2431 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2432 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2433 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2434 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2435 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2436 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2437 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2438 | |
| 2439 | return CMD_SUCCESS; |
| 2440 | } |
| 2441 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2442 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2443 | { |
| 2444 | "Unknown", |
| 2445 | "Standard (RFC2328)", |
| 2446 | "Alternative IBM", |
| 2447 | "Alternative Cisco", |
| 2448 | "Alternative Shortcut" |
| 2449 | }; |
| 2450 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2451 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2452 | { |
| 2453 | "Default", |
| 2454 | "Enabled", |
| 2455 | "Disabled" |
| 2456 | }; |
| 2457 | |
| 2458 | |
| 2459 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2460 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2461 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2462 | { |
| 2463 | /* Show Area ID. */ |
| 2464 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2465 | |
| 2466 | /* Show Area type/mode. */ |
| 2467 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2468 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2469 | else |
| 2470 | { |
| 2471 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2472 | vty_out (vty, " (Stub%s%s)", |
| 2473 | area->no_summary ? ", no summary" : "", |
| 2474 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2475 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2476 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2477 | vty_out (vty, " (NSSA%s%s)", |
| 2478 | area->no_summary ? ", no summary" : "", |
| 2479 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2480 | |
| 2481 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2482 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2483 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2484 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2485 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2486 | } |
| 2487 | |
| 2488 | /* Show number of interfaces. */ |
| 2489 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2490 | "Active: %d%s", listcount (area->oiflist), |
| 2491 | area->act_ints, VTY_NEWLINE); |
| 2492 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2493 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2494 | { |
| 2495 | vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2496 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2497 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2498 | VTY_NEWLINE); |
| 2499 | else if (area->NSSATranslatorState) |
| 2500 | { |
| 2501 | vty_out (vty, " We are an ABR and "); |
| 2502 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2503 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2504 | VTY_NEWLINE); |
| 2505 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2506 | vty_out (vty, "always an NSSA Translator. %s", |
| 2507 | VTY_NEWLINE); |
| 2508 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2509 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2510 | { |
| 2511 | vty_out (vty, " We are an ABR, but "); |
| 2512 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2513 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2514 | VTY_NEWLINE); |
| 2515 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2516 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2517 | VTY_NEWLINE); |
| 2518 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2519 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2520 | /* Stub-router state for this area */ |
| 2521 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2522 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2523 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2524 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2525 | VTY_NEWLINE); |
| 2526 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2527 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2528 | VTY_NEWLINE); |
| 2529 | if (area->t_stub_router) |
| 2530 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2531 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2532 | sizeof(timebuf)), VTY_NEWLINE); |
| 2533 | } |
| 2534 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2535 | /* Show number of fully adjacent neighbors. */ |
| 2536 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2537 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2538 | |
| 2539 | /* Show authentication type. */ |
| 2540 | vty_out (vty, " Area has "); |
| 2541 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2542 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2543 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2544 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2545 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2546 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2547 | |
| 2548 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2549 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2550 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2551 | |
| 2552 | /* Show SPF calculation times. */ |
| 2553 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2554 | area->spf_calculation, VTY_NEWLINE); |
| 2555 | |
| 2556 | /* Show number of LSA. */ |
| 2557 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2558 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2559 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2560 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2561 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2562 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2563 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2564 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2565 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2566 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2567 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2568 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2569 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2570 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2571 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2572 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2573 | #ifdef HAVE_OPAQUE_LSA |
| 2574 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2575 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2576 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2577 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2578 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2579 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2580 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2581 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2582 | } |
| 2583 | |
| 2584 | DEFUN (show_ip_ospf, |
| 2585 | show_ip_ospf_cmd, |
| 2586 | "show ip ospf", |
| 2587 | SHOW_STR |
| 2588 | IP_STR |
| 2589 | "OSPF information\n") |
| 2590 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2591 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2592 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2593 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2594 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2595 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2596 | |
| 2597 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2598 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2599 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2600 | { |
| 2601 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2602 | return CMD_SUCCESS; |
| 2603 | } |
| 2604 | |
| 2605 | /* Show Router ID. */ |
| 2606 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2607 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2608 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2609 | |
| 2610 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2611 | if (ospf->t_deferred_shutdown) |
| 2612 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2613 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2614 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2615 | /* Show capability. */ |
| 2616 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2617 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2618 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2619 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2620 | "enabled" : "disabled", VTY_NEWLINE); |
| 2621 | #ifdef HAVE_OPAQUE_LSA |
| 2622 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2623 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2624 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2625 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2626 | " (origination blocked)" : "", |
| 2627 | VTY_NEWLINE); |
| 2628 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2629 | |
| 2630 | /* Show stub-router configuration */ |
| 2631 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2632 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2633 | { |
| 2634 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2635 | VTY_NEWLINE); |
| 2636 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2637 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2638 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2639 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2640 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2641 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2642 | } |
| 2643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2644 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2645 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2646 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2647 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2648 | " Hold time multiplier is currently %d%s", |
| 2649 | ospf->spf_delay, VTY_NEWLINE, |
| 2650 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2651 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2652 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2653 | vty_out (vty, " SPF algorithm "); |
| 2654 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2655 | { |
paul | c8c1521 | 2005-11-04 12:31:39 +0000 | [diff] [blame] | 2656 | result = tv_sub (recent_time, ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2657 | vty_out (vty, "last executed %s ago%s", |
| 2658 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2659 | VTY_NEWLINE); |
| 2660 | } |
| 2661 | else |
| 2662 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2663 | vty_out (vty, " SPF timer %s%s%s", |
| 2664 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2665 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2666 | VTY_NEWLINE); |
| 2667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2668 | /* Show refresh parameters. */ |
| 2669 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2670 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2671 | |
| 2672 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2673 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2674 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2675 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2676 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2677 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2678 | vty_out (vty, " This router is an ASBR " |
| 2679 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2680 | |
| 2681 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2682 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2683 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2684 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2685 | #ifdef HAVE_OPAQUE_LSA |
| 2686 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2687 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2688 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2689 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2690 | /* Show number of areas attached. */ |
| 2691 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2692 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2693 | |
| 2694 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2695 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2696 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2697 | |
| 2698 | return CMD_SUCCESS; |
| 2699 | } |
| 2700 | |
| 2701 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2702 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2703 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2704 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2705 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2706 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2707 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2708 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2709 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2710 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2711 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2712 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2713 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2714 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2715 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | |
| 2717 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2718 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2719 | { |
| 2720 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2721 | return; |
| 2722 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2723 | else if (!is_up) |
| 2724 | { |
| 2725 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2726 | VTY_NEWLINE); |
| 2727 | return; |
| 2728 | } |
| 2729 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2730 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2731 | { |
| 2732 | struct ospf_interface *oi = rn->info; |
| 2733 | |
| 2734 | if (oi == NULL) |
| 2735 | continue; |
| 2736 | |
| 2737 | /* Show OSPF interface information. */ |
| 2738 | vty_out (vty, " Internet Address %s/%d,", |
| 2739 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2740 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2741 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2742 | { |
| 2743 | struct in_addr *dest; |
| 2744 | const char *dstr; |
| 2745 | |
| 2746 | if ((ifp->flags & IFF_POINTOPOINT) |
| 2747 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2748 | dstr = "Peer"; |
| 2749 | else |
| 2750 | dstr = "Broadcast"; |
| 2751 | |
| 2752 | /* For Vlinks, showing the peer address is probably more |
| 2753 | * informative than the local interface that is being used |
| 2754 | */ |
| 2755 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2756 | dest = &oi->vl_data->peer_addr; |
| 2757 | else |
| 2758 | dest = &oi->connected->destination->u.prefix4; |
| 2759 | |
| 2760 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); |
| 2761 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2762 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2763 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2764 | VTY_NEWLINE); |
| 2765 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2766 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2767 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2768 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2769 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2770 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2771 | oi->output_cost, VTY_NEWLINE); |
| 2772 | |
| 2773 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2774 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2775 | PRIORITY (oi), VTY_NEWLINE); |
| 2776 | |
| 2777 | /* Show DR information. */ |
| 2778 | if (DR (oi).s_addr == 0) |
| 2779 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2780 | else |
| 2781 | { |
| 2782 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2783 | if (nbr == NULL) |
| 2784 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2785 | else |
| 2786 | { |
| 2787 | vty_out (vty, " Designated Router (ID) %s,", |
| 2788 | inet_ntoa (nbr->router_id)); |
| 2789 | vty_out (vty, " Interface Address %s%s", |
| 2790 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2791 | } |
| 2792 | } |
| 2793 | |
| 2794 | /* Show BDR information. */ |
| 2795 | if (BDR (oi).s_addr == 0) |
| 2796 | vty_out (vty, " No backup designated router on this network%s", |
| 2797 | VTY_NEWLINE); |
| 2798 | else |
| 2799 | { |
| 2800 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2801 | if (nbr == NULL) |
| 2802 | vty_out (vty, " No backup designated router on this network%s", |
| 2803 | VTY_NEWLINE); |
| 2804 | else |
| 2805 | { |
| 2806 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2807 | inet_ntoa (nbr->router_id)); |
| 2808 | vty_out (vty, " Interface Address %s%s", |
| 2809 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2810 | } |
| 2811 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2812 | |
| 2813 | vty_out (vty, " Multicast group memberships:"); |
Paul Jakma | 429ac78 | 2006-06-15 18:40:49 +0000 | [diff] [blame^] | 2814 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
| 2815 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2816 | { |
| 2817 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) |
| 2818 | vty_out (vty, " OSPFAllRouters"); |
| 2819 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2820 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2821 | } |
| 2822 | else |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2823 | vty_out (vty, " <None>"); |
| 2824 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2825 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2826 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2827 | vty_out (vty, " Hello "); |
| 2828 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 2829 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 2830 | else |
| 2831 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 2832 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 2833 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2834 | OSPF_IF_PARAM (oi, v_wait), |
| 2835 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2836 | VTY_NEWLINE); |
| 2837 | |
| 2838 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2839 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2840 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2841 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2842 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2843 | VTY_NEWLINE); |
| 2844 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2845 | else /* OSPF_IF_PASSIVE is set */ |
| 2846 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2847 | |
| 2848 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2849 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2850 | VTY_NEWLINE); |
| 2851 | } |
| 2852 | } |
| 2853 | |
| 2854 | DEFUN (show_ip_ospf_interface, |
| 2855 | show_ip_ospf_interface_cmd, |
| 2856 | "show ip ospf interface [INTERFACE]", |
| 2857 | SHOW_STR |
| 2858 | IP_STR |
| 2859 | "OSPF information\n" |
| 2860 | "Interface information\n" |
| 2861 | "Interface name\n") |
| 2862 | { |
| 2863 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2864 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2865 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2866 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2867 | ospf = ospf_lookup (); |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 2868 | if (ospf == NULL) |
| 2869 | { |
| 2870 | vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2871 | return CMD_SUCCESS; |
| 2872 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2873 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2874 | /* Show All Interfaces. */ |
| 2875 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2876 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 2877 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2878 | /* Interface name is specified. */ |
| 2879 | else |
| 2880 | { |
| 2881 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2882 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2883 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2884 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2885 | } |
| 2886 | |
| 2887 | return CMD_SUCCESS; |
| 2888 | } |
| 2889 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2890 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2891 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 2892 | { |
| 2893 | vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
| 2894 | VTY_NEWLINE, |
| 2895 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 2896 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 2897 | VTY_NEWLINE); |
| 2898 | } |
| 2899 | |
| 2900 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2901 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2902 | { |
| 2903 | struct route_node *rn; |
| 2904 | struct ospf_neighbor *nbr; |
| 2905 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2906 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2907 | |
| 2908 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2909 | if ((nbr = rn->info)) |
| 2910 | /* Do not show myself. */ |
| 2911 | if (nbr != oi->nbr_self) |
| 2912 | /* Down state is not shown. */ |
| 2913 | if (nbr->state != NSM_Down) |
| 2914 | { |
| 2915 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2916 | |
| 2917 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2918 | vty_out (vty, "%-15s %3d %-15s ", |
| 2919 | "-", nbr->priority, |
| 2920 | msgbuf); |
| 2921 | else |
| 2922 | vty_out (vty, "%-15s %3d %-15s ", |
| 2923 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2924 | msgbuf); |
| 2925 | |
| 2926 | vty_out (vty, "%9s ", |
| 2927 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 2928 | sizeof(timebuf))); |
| 2929 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2930 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2931 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2932 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2933 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2934 | VTY_NEWLINE); |
| 2935 | } |
| 2936 | } |
| 2937 | |
| 2938 | DEFUN (show_ip_ospf_neighbor, |
| 2939 | show_ip_ospf_neighbor_cmd, |
| 2940 | "show ip ospf neighbor", |
| 2941 | SHOW_STR |
| 2942 | IP_STR |
| 2943 | "OSPF information\n" |
| 2944 | "Neighbor list\n") |
| 2945 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2946 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2947 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2948 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2949 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2950 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2951 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2952 | { |
| 2953 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2954 | return CMD_SUCCESS; |
| 2955 | } |
| 2956 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2957 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2958 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2959 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 2960 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2961 | |
| 2962 | return CMD_SUCCESS; |
| 2963 | } |
| 2964 | |
| 2965 | DEFUN (show_ip_ospf_neighbor_all, |
| 2966 | show_ip_ospf_neighbor_all_cmd, |
| 2967 | "show ip ospf neighbor all", |
| 2968 | SHOW_STR |
| 2969 | IP_STR |
| 2970 | "OSPF information\n" |
| 2971 | "Neighbor list\n" |
| 2972 | "include down status neighbor\n") |
| 2973 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2974 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2975 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2976 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2977 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2978 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2979 | { |
| 2980 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2981 | return CMD_SUCCESS; |
| 2982 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2983 | |
| 2984 | show_ip_ospf_neighbour_header (vty); |
| 2985 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2986 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2987 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2988 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2989 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2990 | |
| 2991 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2992 | |
| 2993 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2994 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2995 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2996 | if (nbr_nbma->nbr == NULL |
| 2997 | || nbr_nbma->nbr->state == NSM_Down) |
| 2998 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2999 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3000 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3001 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3002 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 3003 | 0, 0, 0, VTY_NEWLINE); |
| 3004 | } |
| 3005 | } |
| 3006 | } |
| 3007 | |
| 3008 | return CMD_SUCCESS; |
| 3009 | } |
| 3010 | |
| 3011 | DEFUN (show_ip_ospf_neighbor_int, |
| 3012 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3013 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3014 | SHOW_STR |
| 3015 | IP_STR |
| 3016 | "OSPF information\n" |
| 3017 | "Neighbor list\n" |
| 3018 | "Interface name\n") |
| 3019 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3020 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3021 | struct interface *ifp; |
| 3022 | struct route_node *rn; |
| 3023 | |
| 3024 | ifp = if_lookup_by_name (argv[0]); |
| 3025 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3026 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3027 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3028 | return CMD_WARNING; |
| 3029 | } |
| 3030 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3031 | ospf = ospf_lookup (); |
| 3032 | if (ospf == NULL) |
| 3033 | { |
| 3034 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3035 | return CMD_SUCCESS; |
| 3036 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3037 | |
| 3038 | show_ip_ospf_neighbour_header (vty); |
| 3039 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3040 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3041 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3042 | struct ospf_interface *oi = rn->info; |
| 3043 | |
| 3044 | if (oi == NULL) |
| 3045 | continue; |
| 3046 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3047 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3048 | } |
| 3049 | |
| 3050 | return CMD_SUCCESS; |
| 3051 | } |
| 3052 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3053 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3054 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3055 | struct ospf_nbr_nbma *nbr_nbma) |
| 3056 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3057 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3058 | |
| 3059 | /* Show neighbor ID. */ |
| 3060 | vty_out (vty, " Neighbor %s,", "-"); |
| 3061 | |
| 3062 | /* Show interface address. */ |
| 3063 | vty_out (vty, " interface address %s%s", |
| 3064 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3065 | /* Show Area ID. */ |
| 3066 | vty_out (vty, " In the area %s via interface %s%s", |
| 3067 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3068 | /* Show neighbor priority and state. */ |
| 3069 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3070 | nbr_nbma->priority, "Down"); |
| 3071 | /* Show state changes. */ |
| 3072 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3073 | |
| 3074 | /* Show PollInterval */ |
| 3075 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3076 | |
| 3077 | /* Show poll-interval timer. */ |
| 3078 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3079 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3080 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3081 | |
| 3082 | /* Show poll-interval timer thread. */ |
| 3083 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3084 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3085 | } |
| 3086 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3087 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3088 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3089 | struct ospf_neighbor *nbr) |
| 3090 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3091 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3092 | |
| 3093 | /* Show neighbor ID. */ |
| 3094 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3095 | vty_out (vty, " Neighbor %s,", "-"); |
| 3096 | else |
| 3097 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3098 | |
| 3099 | /* Show interface address. */ |
| 3100 | vty_out (vty, " interface address %s%s", |
| 3101 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3102 | /* Show Area ID. */ |
| 3103 | vty_out (vty, " In the area %s via interface %s%s", |
| 3104 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3105 | /* Show neighbor priority and state. */ |
| 3106 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3107 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3108 | /* Show state changes. */ |
| 3109 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 3110 | |
| 3111 | /* Show Designated Rotuer ID. */ |
| 3112 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3113 | /* Show Backup Designated Rotuer ID. */ |
| 3114 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3115 | /* Show options. */ |
| 3116 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3117 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3118 | /* Show Router Dead interval timer. */ |
| 3119 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3120 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3121 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3122 | /* Show Database Summary list. */ |
| 3123 | vty_out (vty, " Database Summary List %d%s", |
| 3124 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3125 | /* Show Link State Request list. */ |
| 3126 | vty_out (vty, " Link State Request List %ld%s", |
| 3127 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3128 | /* Show Link State Retransmission list. */ |
| 3129 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3130 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3131 | /* Show inactivity timer thread. */ |
| 3132 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3133 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3134 | /* Show Database Description retransmission thread. */ |
| 3135 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3136 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3137 | /* Show Link State Request Retransmission thread. */ |
| 3138 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3139 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3140 | /* Show Link State Update Retransmission thread. */ |
| 3141 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3142 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3143 | } |
| 3144 | |
| 3145 | DEFUN (show_ip_ospf_neighbor_id, |
| 3146 | show_ip_ospf_neighbor_id_cmd, |
| 3147 | "show ip ospf neighbor A.B.C.D", |
| 3148 | SHOW_STR |
| 3149 | IP_STR |
| 3150 | "OSPF information\n" |
| 3151 | "Neighbor list\n" |
| 3152 | "Neighbor ID\n") |
| 3153 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3154 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3155 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3156 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3157 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3158 | struct in_addr router_id; |
| 3159 | int ret; |
| 3160 | |
| 3161 | ret = inet_aton (argv[0], &router_id); |
| 3162 | if (!ret) |
| 3163 | { |
| 3164 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3165 | return CMD_WARNING; |
| 3166 | } |
| 3167 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3168 | ospf = ospf_lookup (); |
| 3169 | if (ospf == NULL) |
| 3170 | { |
| 3171 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3172 | return CMD_SUCCESS; |
| 3173 | } |
| 3174 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3175 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3176 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 3177 | { |
| 3178 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3179 | return CMD_SUCCESS; |
| 3180 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3181 | |
| 3182 | /* Nothing to show. */ |
| 3183 | return CMD_SUCCESS; |
| 3184 | } |
| 3185 | |
| 3186 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3187 | show_ip_ospf_neighbor_detail_cmd, |
| 3188 | "show ip ospf neighbor detail", |
| 3189 | SHOW_STR |
| 3190 | IP_STR |
| 3191 | "OSPF information\n" |
| 3192 | "Neighbor list\n" |
| 3193 | "detail of all neighbors\n") |
| 3194 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3195 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3196 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3197 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3198 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3199 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3200 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3201 | { |
| 3202 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3203 | return CMD_SUCCESS; |
| 3204 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3205 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3206 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3207 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3208 | struct route_node *rn; |
| 3209 | struct ospf_neighbor *nbr; |
| 3210 | |
| 3211 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3212 | if ((nbr = rn->info)) |
| 3213 | if (nbr != oi->nbr_self) |
| 3214 | if (nbr->state != NSM_Down) |
| 3215 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3216 | } |
| 3217 | |
| 3218 | return CMD_SUCCESS; |
| 3219 | } |
| 3220 | |
| 3221 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3222 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3223 | "show ip ospf neighbor detail all", |
| 3224 | SHOW_STR |
| 3225 | IP_STR |
| 3226 | "OSPF information\n" |
| 3227 | "Neighbor list\n" |
| 3228 | "detail of all neighbors\n" |
| 3229 | "include down status neighbor\n") |
| 3230 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3231 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3232 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3233 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3235 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3236 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3237 | { |
| 3238 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3239 | return CMD_SUCCESS; |
| 3240 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3241 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3242 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3243 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3244 | struct route_node *rn; |
| 3245 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3246 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3247 | |
| 3248 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3249 | if ((nbr = rn->info)) |
| 3250 | if (nbr != oi->nbr_self) |
| 3251 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3252 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3253 | |
| 3254 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3255 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3256 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3257 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3258 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3259 | if (nbr_nbma->nbr == NULL |
| 3260 | || nbr_nbma->nbr->state == NSM_Down) |
| 3261 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3262 | } |
| 3263 | } |
| 3264 | |
| 3265 | return CMD_SUCCESS; |
| 3266 | } |
| 3267 | |
| 3268 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3269 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3270 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3271 | SHOW_STR |
| 3272 | IP_STR |
| 3273 | "OSPF information\n" |
| 3274 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3275 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3276 | "detail of all neighbors") |
| 3277 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3278 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3279 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3280 | struct interface *ifp; |
| 3281 | struct route_node *rn, *nrn; |
| 3282 | struct ospf_neighbor *nbr; |
| 3283 | |
| 3284 | ifp = if_lookup_by_name (argv[0]); |
| 3285 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3286 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3287 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3288 | return CMD_WARNING; |
| 3289 | } |
| 3290 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3291 | ospf = ospf_lookup (); |
| 3292 | if (ospf == NULL) |
| 3293 | { |
| 3294 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3295 | return CMD_SUCCESS; |
| 3296 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3297 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3298 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3299 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3300 | if ((oi = rn->info)) |
| 3301 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3302 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3303 | if (nbr != oi->nbr_self) |
| 3304 | if (nbr->state != NSM_Down) |
| 3305 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3306 | |
| 3307 | return CMD_SUCCESS; |
| 3308 | } |
| 3309 | |
| 3310 | |
| 3311 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3312 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3313 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3314 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3315 | struct router_lsa *rl; |
| 3316 | struct summary_lsa *sl; |
| 3317 | struct as_external_lsa *asel; |
| 3318 | struct prefix_ipv4 p; |
| 3319 | |
| 3320 | if (lsa != NULL) |
| 3321 | /* If self option is set, check LSA self flag. */ |
| 3322 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3323 | { |
| 3324 | /* LSA common part show. */ |
| 3325 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3326 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3327 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3328 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3329 | /* LSA specific part show. */ |
| 3330 | switch (lsa->data->type) |
| 3331 | { |
| 3332 | case OSPF_ROUTER_LSA: |
| 3333 | rl = (struct router_lsa *) lsa->data; |
| 3334 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3335 | break; |
| 3336 | case OSPF_SUMMARY_LSA: |
| 3337 | sl = (struct summary_lsa *) lsa->data; |
| 3338 | |
| 3339 | p.family = AF_INET; |
| 3340 | p.prefix = sl->header.id; |
| 3341 | p.prefixlen = ip_masklen (sl->mask); |
| 3342 | apply_mask_ipv4 (&p); |
| 3343 | |
| 3344 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3345 | break; |
| 3346 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3347 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3348 | asel = (struct as_external_lsa *) lsa->data; |
| 3349 | |
| 3350 | p.family = AF_INET; |
| 3351 | p.prefix = asel->header.id; |
| 3352 | p.prefixlen = ip_masklen (asel->mask); |
| 3353 | apply_mask_ipv4 (&p); |
| 3354 | |
| 3355 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3356 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3357 | inet_ntoa (p.prefix), p.prefixlen, |
| 3358 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3359 | break; |
| 3360 | case OSPF_NETWORK_LSA: |
| 3361 | case OSPF_ASBR_SUMMARY_LSA: |
| 3362 | #ifdef HAVE_OPAQUE_LSA |
| 3363 | case OSPF_OPAQUE_LINK_LSA: |
| 3364 | case OSPF_OPAQUE_AREA_LSA: |
| 3365 | case OSPF_OPAQUE_AS_LSA: |
| 3366 | #endif /* HAVE_OPAQUE_LSA */ |
| 3367 | default: |
| 3368 | break; |
| 3369 | } |
| 3370 | vty_out (vty, VTY_NEWLINE); |
| 3371 | } |
| 3372 | |
| 3373 | return 0; |
| 3374 | } |
| 3375 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3376 | const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3377 | { |
| 3378 | "unknown", |
| 3379 | "Router Link States", |
| 3380 | "Net Link States", |
| 3381 | "Summary Link States", |
| 3382 | "ASBR-Summary Link States", |
| 3383 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3384 | "Group Membership LSA", |
| 3385 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3386 | #ifdef HAVE_OPAQUE_LSA |
| 3387 | "Type-8 LSA", |
| 3388 | "Link-Local Opaque-LSA", |
| 3389 | "Area-Local Opaque-LSA", |
| 3390 | "AS-external Opaque-LSA", |
| 3391 | #endif /* HAVE_OPAQUE_LSA */ |
| 3392 | }; |
| 3393 | |
| 3394 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3395 | "Link ID ADV Router Age Seq# CkSum" |
| 3396 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3397 | const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3398 | { |
| 3399 | "", |
| 3400 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3401 | "Link ID ADV Router Age Seq# CkSum", |
| 3402 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3403 | "Link ID ADV Router Age Seq# CkSum", |
| 3404 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3405 | " --- header for Group Member ----", |
| 3406 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3407 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3408 | " --- type-8 ---", |
| 3409 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3410 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3411 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3412 | #endif /* HAVE_OPAQUE_LSA */ |
| 3413 | }; |
| 3414 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3415 | const char *show_lsa_flags[] = |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3416 | { |
| 3417 | "Self-originated", |
| 3418 | "Checked", |
| 3419 | "Received", |
| 3420 | "Approved", |
| 3421 | "Discard", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3422 | "Translated", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3423 | }; |
| 3424 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3425 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3426 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3427 | { |
| 3428 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3430 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3431 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3432 | lsa->data->options, |
| 3433 | ospf_options_dump(lsa->data->options), |
| 3434 | VTY_NEWLINE); |
| 3435 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3436 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3437 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3438 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3439 | |
| 3440 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3441 | { |
| 3442 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3443 | |
| 3444 | if (rlsa->flags) |
| 3445 | vty_out (vty, " :%s%s%s%s", |
| 3446 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3447 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3448 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3449 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3450 | |
| 3451 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3452 | } |
| 3453 | vty_out (vty, " LS Type: %s%s", |
| 3454 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3455 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3456 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3457 | vty_out (vty, " Advertising Router: %s%s", |
| 3458 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3459 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3460 | VTY_NEWLINE); |
| 3461 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3462 | VTY_NEWLINE); |
| 3463 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3464 | } |
| 3465 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3466 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3467 | { |
| 3468 | "(null)", |
| 3469 | "another Router (point-to-point)", |
| 3470 | "a Transit Network", |
| 3471 | "Stub Network", |
| 3472 | "a Virtual Link", |
| 3473 | }; |
| 3474 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3475 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3476 | { |
| 3477 | "(null)", |
| 3478 | "Neighboring Router ID", |
| 3479 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3480 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3481 | "Neighboring Router ID", |
| 3482 | }; |
| 3483 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3484 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3485 | { |
| 3486 | "(null)", |
| 3487 | "Router Interface address", |
| 3488 | "Router Interface address", |
| 3489 | "Network Mask", |
| 3490 | "Router Interface address", |
| 3491 | }; |
| 3492 | |
| 3493 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3494 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3495 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3496 | struct router_lsa *rl) |
| 3497 | { |
| 3498 | int len, i, type; |
| 3499 | |
| 3500 | len = ntohs (rl->header.length) - 4; |
| 3501 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3502 | { |
| 3503 | type = rl->link[i].type; |
| 3504 | |
| 3505 | vty_out (vty, " Link connected to: %s%s", |
| 3506 | link_type_desc[type], VTY_NEWLINE); |
| 3507 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3508 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3509 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3510 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3511 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3512 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3513 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3514 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3515 | } |
| 3516 | } |
| 3517 | |
| 3518 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3519 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3520 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3521 | { |
| 3522 | if (lsa != NULL) |
| 3523 | { |
| 3524 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3525 | |
| 3526 | show_ip_ospf_database_header (vty, lsa); |
| 3527 | |
| 3528 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3529 | VTY_NEWLINE, VTY_NEWLINE); |
| 3530 | |
| 3531 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3532 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3533 | } |
| 3534 | |
| 3535 | return 0; |
| 3536 | } |
| 3537 | |
| 3538 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3539 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3540 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3541 | { |
| 3542 | int length, i; |
| 3543 | |
| 3544 | if (lsa != NULL) |
| 3545 | { |
| 3546 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3547 | |
| 3548 | show_ip_ospf_database_header (vty, lsa); |
| 3549 | |
| 3550 | vty_out (vty, " Network Mask: /%d%s", |
| 3551 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3552 | |
| 3553 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3554 | |
| 3555 | for (i = 0; length > 0; i++, length -= 4) |
| 3556 | vty_out (vty, " Attached Router: %s%s", |
| 3557 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3558 | |
| 3559 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3560 | } |
| 3561 | |
| 3562 | return 0; |
| 3563 | } |
| 3564 | |
| 3565 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3566 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3567 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3568 | { |
| 3569 | if (lsa != NULL) |
| 3570 | { |
| 3571 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3572 | |
| 3573 | show_ip_ospf_database_header (vty, lsa); |
| 3574 | |
| 3575 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3576 | VTY_NEWLINE); |
| 3577 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3578 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3579 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3580 | } |
| 3581 | |
| 3582 | return 0; |
| 3583 | } |
| 3584 | |
| 3585 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3586 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3587 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3588 | { |
| 3589 | if (lsa != NULL) |
| 3590 | { |
| 3591 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3592 | |
| 3593 | show_ip_ospf_database_header (vty, lsa); |
| 3594 | |
| 3595 | vty_out (vty, " Network Mask: /%d%s", |
| 3596 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3597 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3598 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3599 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3600 | } |
| 3601 | |
| 3602 | return 0; |
| 3603 | } |
| 3604 | |
| 3605 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3606 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3607 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3608 | { |
| 3609 | if (lsa != NULL) |
| 3610 | { |
| 3611 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3612 | |
| 3613 | show_ip_ospf_database_header (vty, lsa); |
| 3614 | |
| 3615 | vty_out (vty, " Network Mask: /%d%s", |
| 3616 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3617 | vty_out (vty, " Metric Type: %s%s", |
| 3618 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3619 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3620 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3621 | vty_out (vty, " Metric: %d%s", |
| 3622 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3623 | vty_out (vty, " Forward Address: %s%s", |
| 3624 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3625 | |
| 3626 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3627 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3628 | } |
| 3629 | |
| 3630 | return 0; |
| 3631 | } |
| 3632 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3633 | /* N.B. This function currently seems to be unused. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3634 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3635 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3636 | { |
| 3637 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3638 | |
| 3639 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3640 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3641 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3643 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3644 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3645 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3646 | zlog_debug( " TOS: 0%s", "\n"); |
| 3647 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3649 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3650 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3651 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3652 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3653 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3654 | |
| 3655 | return 0; |
| 3656 | } |
| 3657 | |
| 3658 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3659 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3660 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3661 | { |
| 3662 | if (lsa != NULL) |
| 3663 | { |
| 3664 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3665 | |
| 3666 | show_ip_ospf_database_header (vty, lsa); |
| 3667 | |
| 3668 | vty_out (vty, " Network Mask: /%d%s", |
| 3669 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3670 | vty_out (vty, " Metric Type: %s%s", |
| 3671 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3672 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3673 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3674 | vty_out (vty, " Metric: %d%s", |
| 3675 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3676 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3677 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3678 | |
| 3679 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3680 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3681 | } |
| 3682 | |
| 3683 | return 0; |
| 3684 | } |
| 3685 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3686 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3687 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3688 | { |
| 3689 | return 0; |
| 3690 | } |
| 3691 | |
| 3692 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3693 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3694 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3695 | { |
| 3696 | if (lsa != NULL) |
| 3697 | { |
| 3698 | show_ip_ospf_database_header (vty, lsa); |
| 3699 | show_opaque_info_detail (vty, lsa); |
| 3700 | |
| 3701 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3702 | } |
| 3703 | return 0; |
| 3704 | } |
| 3705 | #endif /* HAVE_OPAQUE_LSA */ |
| 3706 | |
| 3707 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3708 | { |
| 3709 | NULL, |
| 3710 | show_router_lsa_detail, |
| 3711 | show_network_lsa_detail, |
| 3712 | show_summary_lsa_detail, |
| 3713 | show_summary_asbr_lsa_detail, |
| 3714 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3715 | show_func_dummy, |
| 3716 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3717 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3718 | NULL, /* type-8 */ |
| 3719 | show_opaque_lsa_detail, |
| 3720 | show_opaque_lsa_detail, |
| 3721 | show_opaque_lsa_detail, |
| 3722 | #endif /* HAVE_OPAQUE_LSA */ |
| 3723 | }; |
| 3724 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3725 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3726 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3727 | struct in_addr *adv_router) |
| 3728 | { |
| 3729 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3730 | lp->family = 0; |
| 3731 | if (id == NULL) |
| 3732 | lp->prefixlen = 0; |
| 3733 | else if (adv_router == NULL) |
| 3734 | { |
| 3735 | lp->prefixlen = 32; |
| 3736 | lp->id = *id; |
| 3737 | } |
| 3738 | else |
| 3739 | { |
| 3740 | lp->prefixlen = 64; |
| 3741 | lp->id = *id; |
| 3742 | lp->adv_router = *adv_router; |
| 3743 | } |
| 3744 | } |
| 3745 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3746 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3747 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3748 | struct in_addr *id, struct in_addr *adv_router) |
| 3749 | { |
| 3750 | struct prefix_ls lp; |
| 3751 | struct route_node *rn, *start; |
| 3752 | struct ospf_lsa *lsa; |
| 3753 | |
| 3754 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3755 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3756 | if (start) |
| 3757 | { |
| 3758 | route_lock_node (start); |
| 3759 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3760 | if ((lsa = rn->info)) |
| 3761 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3762 | if (show_function[lsa->data->type] != NULL) |
| 3763 | show_function[lsa->data->type] (vty, lsa); |
| 3764 | } |
| 3765 | route_unlock_node (start); |
| 3766 | } |
| 3767 | } |
| 3768 | |
| 3769 | /* Show detail LSA information |
| 3770 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3771 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3772 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3773 | struct in_addr *id, struct in_addr *adv_router) |
| 3774 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3775 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3776 | struct ospf_area *area; |
| 3777 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3778 | switch (type) |
| 3779 | { |
| 3780 | case OSPF_AS_EXTERNAL_LSA: |
| 3781 | #ifdef HAVE_OPAQUE_LSA |
| 3782 | case OSPF_OPAQUE_AS_LSA: |
| 3783 | #endif /* HAVE_OPAQUE_LSA */ |
| 3784 | vty_out (vty, " %s %s%s", |
| 3785 | show_database_desc[type], |
| 3786 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3787 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3788 | break; |
| 3789 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3790 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3791 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3792 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3793 | VTY_NEWLINE, show_database_desc[type], |
| 3794 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3795 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3796 | } |
| 3797 | break; |
| 3798 | } |
| 3799 | } |
| 3800 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3801 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3802 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3803 | struct in_addr *adv_router) |
| 3804 | { |
| 3805 | struct route_node *rn; |
| 3806 | struct ospf_lsa *lsa; |
| 3807 | |
| 3808 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3809 | if ((lsa = rn->info)) |
| 3810 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3811 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3812 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3813 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3814 | if (show_function[lsa->data->type] != NULL) |
| 3815 | show_function[lsa->data->type] (vty, lsa); |
| 3816 | } |
| 3817 | } |
| 3818 | |
| 3819 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3820 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3821 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3822 | struct in_addr *adv_router) |
| 3823 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3824 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3825 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3826 | |
| 3827 | switch (type) |
| 3828 | { |
| 3829 | case OSPF_AS_EXTERNAL_LSA: |
| 3830 | #ifdef HAVE_OPAQUE_LSA |
| 3831 | case OSPF_OPAQUE_AS_LSA: |
| 3832 | #endif /* HAVE_OPAQUE_LSA */ |
| 3833 | vty_out (vty, " %s %s%s", |
| 3834 | show_database_desc[type], |
| 3835 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3836 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3837 | adv_router); |
| 3838 | break; |
| 3839 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3840 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3841 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3842 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3843 | VTY_NEWLINE, show_database_desc[type], |
| 3844 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3845 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3846 | adv_router); |
| 3847 | } |
| 3848 | break; |
| 3849 | } |
| 3850 | } |
| 3851 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3852 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3853 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3854 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3855 | struct ospf_lsa *lsa; |
| 3856 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3857 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3858 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3859 | int type; |
| 3860 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3861 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3862 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3863 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3864 | { |
| 3865 | switch (type) |
| 3866 | { |
| 3867 | case OSPF_AS_EXTERNAL_LSA: |
| 3868 | #ifdef HAVE_OPAQUE_LSA |
| 3869 | case OSPF_OPAQUE_AS_LSA: |
| 3870 | #endif /* HAVE_OPAQUE_LSA */ |
| 3871 | continue; |
| 3872 | default: |
| 3873 | break; |
| 3874 | } |
| 3875 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3876 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3877 | { |
| 3878 | vty_out (vty, " %s (Area %s)%s%s", |
| 3879 | show_database_desc[type], |
| 3880 | ospf_area_desc_string (area), |
| 3881 | VTY_NEWLINE, VTY_NEWLINE); |
| 3882 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3883 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3884 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3885 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3886 | |
| 3887 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3888 | } |
| 3889 | } |
| 3890 | } |
| 3891 | |
| 3892 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3893 | { |
| 3894 | switch (type) |
| 3895 | { |
| 3896 | case OSPF_AS_EXTERNAL_LSA: |
| 3897 | #ifdef HAVE_OPAQUE_LSA |
| 3898 | case OSPF_OPAQUE_AS_LSA: |
| 3899 | #endif /* HAVE_OPAQUE_LSA */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 3900 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3901 | default: |
| 3902 | continue; |
| 3903 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3904 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3905 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3906 | { |
| 3907 | vty_out (vty, " %s%s%s", |
| 3908 | show_database_desc[type], |
| 3909 | VTY_NEWLINE, VTY_NEWLINE); |
| 3910 | vty_out (vty, "%s%s", show_database_header[type], |
| 3911 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3912 | |
| 3913 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3914 | show_lsa_summary (vty, lsa, self); |
| 3915 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3916 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3917 | } |
| 3918 | } |
| 3919 | |
| 3920 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3921 | } |
| 3922 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3923 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3924 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3925 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3926 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3927 | struct ospf_lsa *lsa; |
| 3928 | |
| 3929 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3930 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3931 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3932 | for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa)) |
| 3933 | { |
| 3934 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3935 | vty_out (vty, "Link State ID: %s%s", |
| 3936 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3937 | vty_out (vty, "Advertising Router: %s%s", |
| 3938 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3939 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3940 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3941 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3942 | } |
| 3943 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3944 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3945 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3946 | |
| 3947 | #ifdef HAVE_OPAQUE_LSA |
| 3948 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3949 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3950 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3951 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3952 | #else /* HAVE_OPAQUE_LSA */ |
| 3953 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3954 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3955 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3956 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3957 | #endif /* HAVE_OPAQUE_LSA */ |
| 3958 | |
| 3959 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3960 | "asbr-summary|external|network|router|summary" \ |
| 3961 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3962 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3963 | |
| 3964 | #define OSPF_LSA_TYPES_DESC \ |
| 3965 | "ASBR summary link states\n" \ |
| 3966 | "External link states\n" \ |
| 3967 | "Network link states\n" \ |
| 3968 | "Router link states\n" \ |
| 3969 | "Network summary link states\n" \ |
| 3970 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3971 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3972 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3973 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3974 | |
| 3975 | DEFUN (show_ip_ospf_database, |
| 3976 | show_ip_ospf_database_cmd, |
| 3977 | "show ip ospf database", |
| 3978 | SHOW_STR |
| 3979 | IP_STR |
| 3980 | "OSPF information\n" |
| 3981 | "Database summary\n") |
| 3982 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3983 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3984 | int type, ret; |
| 3985 | struct in_addr id, adv_router; |
| 3986 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3987 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3988 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 3989 | { |
| 3990 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3991 | return CMD_SUCCESS; |
| 3992 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3993 | |
| 3994 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3995 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3996 | |
| 3997 | /* Show all LSA. */ |
| 3998 | if (argc == 0) |
| 3999 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4000 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4001 | return CMD_SUCCESS; |
| 4002 | } |
| 4003 | |
| 4004 | /* Set database type to show. */ |
| 4005 | if (strncmp (argv[0], "r", 1) == 0) |
| 4006 | type = OSPF_ROUTER_LSA; |
| 4007 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4008 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4009 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4010 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4011 | else if (strncmp (argv[0], "su", 2) == 0) |
| 4012 | type = OSPF_SUMMARY_LSA; |
| 4013 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4014 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4015 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4016 | type = OSPF_AS_EXTERNAL_LSA; |
| 4017 | else if (strncmp (argv[0], "se", 2) == 0) |
| 4018 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4019 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4020 | return CMD_SUCCESS; |
| 4021 | } |
| 4022 | else if (strncmp (argv[0], "m", 1) == 0) |
| 4023 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4024 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4025 | return CMD_SUCCESS; |
| 4026 | } |
| 4027 | #ifdef HAVE_OPAQUE_LSA |
| 4028 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4029 | type = OSPF_OPAQUE_LINK_LSA; |
| 4030 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4031 | type = OSPF_OPAQUE_AREA_LSA; |
| 4032 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4033 | type = OSPF_OPAQUE_AS_LSA; |
| 4034 | #endif /* HAVE_OPAQUE_LSA */ |
| 4035 | else |
| 4036 | return CMD_WARNING; |
| 4037 | |
| 4038 | /* `show ip ospf database LSA'. */ |
| 4039 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4040 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4041 | else if (argc >= 2) |
| 4042 | { |
| 4043 | ret = inet_aton (argv[1], &id); |
| 4044 | if (!ret) |
| 4045 | return CMD_WARNING; |
| 4046 | |
| 4047 | /* `show ip ospf database LSA ID'. */ |
| 4048 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4049 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4050 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4051 | else if (argc == 3) |
| 4052 | { |
| 4053 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4054 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4055 | else |
| 4056 | { |
| 4057 | ret = inet_aton (argv[2], &adv_router); |
| 4058 | if (!ret) |
| 4059 | return CMD_WARNING; |
| 4060 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4061 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4062 | } |
| 4063 | } |
| 4064 | |
| 4065 | return CMD_SUCCESS; |
| 4066 | } |
| 4067 | |
| 4068 | ALIAS (show_ip_ospf_database, |
| 4069 | show_ip_ospf_database_type_cmd, |
| 4070 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4071 | SHOW_STR |
| 4072 | IP_STR |
| 4073 | "OSPF information\n" |
| 4074 | "Database summary\n" |
| 4075 | OSPF_LSA_TYPES_DESC |
| 4076 | "LSAs in MaxAge list\n" |
| 4077 | "Self-originated link states\n") |
| 4078 | |
| 4079 | ALIAS (show_ip_ospf_database, |
| 4080 | show_ip_ospf_database_type_id_cmd, |
| 4081 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4082 | SHOW_STR |
| 4083 | IP_STR |
| 4084 | "OSPF information\n" |
| 4085 | "Database summary\n" |
| 4086 | OSPF_LSA_TYPES_DESC |
| 4087 | "Link State ID (as an IP address)\n") |
| 4088 | |
| 4089 | ALIAS (show_ip_ospf_database, |
| 4090 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4091 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4092 | SHOW_STR |
| 4093 | IP_STR |
| 4094 | "OSPF information\n" |
| 4095 | "Database summary\n" |
| 4096 | OSPF_LSA_TYPES_DESC |
| 4097 | "Link State ID (as an IP address)\n" |
| 4098 | "Advertising Router link states\n" |
| 4099 | "Advertising Router (as an IP address)\n") |
| 4100 | |
| 4101 | ALIAS (show_ip_ospf_database, |
| 4102 | show_ip_ospf_database_type_id_self_cmd, |
| 4103 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4104 | SHOW_STR |
| 4105 | IP_STR |
| 4106 | "OSPF information\n" |
| 4107 | "Database summary\n" |
| 4108 | OSPF_LSA_TYPES_DESC |
| 4109 | "Link State ID (as an IP address)\n" |
| 4110 | "Self-originated link states\n" |
| 4111 | "\n") |
| 4112 | |
| 4113 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4114 | show_ip_ospf_database_type_adv_router_cmd, |
| 4115 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4116 | SHOW_STR |
| 4117 | IP_STR |
| 4118 | "OSPF information\n" |
| 4119 | "Database summary\n" |
| 4120 | OSPF_LSA_TYPES_DESC |
| 4121 | "Advertising Router link states\n" |
| 4122 | "Advertising Router (as an IP address)\n") |
| 4123 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4124 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4125 | int type, ret; |
| 4126 | struct in_addr adv_router; |
| 4127 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4128 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4129 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4130 | { |
| 4131 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4132 | return CMD_SUCCESS; |
| 4133 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4134 | |
| 4135 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4136 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4137 | |
| 4138 | if (argc != 2) |
| 4139 | return CMD_WARNING; |
| 4140 | |
| 4141 | /* Set database type to show. */ |
| 4142 | if (strncmp (argv[0], "r", 1) == 0) |
| 4143 | type = OSPF_ROUTER_LSA; |
| 4144 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4145 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4146 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4147 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4148 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4149 | type = OSPF_SUMMARY_LSA; |
| 4150 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4151 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4152 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4153 | type = OSPF_AS_EXTERNAL_LSA; |
| 4154 | #ifdef HAVE_OPAQUE_LSA |
| 4155 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4156 | type = OSPF_OPAQUE_LINK_LSA; |
| 4157 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4158 | type = OSPF_OPAQUE_AREA_LSA; |
| 4159 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4160 | type = OSPF_OPAQUE_AS_LSA; |
| 4161 | #endif /* HAVE_OPAQUE_LSA */ |
| 4162 | else |
| 4163 | return CMD_WARNING; |
| 4164 | |
| 4165 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4166 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4167 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4168 | else |
| 4169 | { |
| 4170 | ret = inet_aton (argv[1], &adv_router); |
| 4171 | if (!ret) |
| 4172 | return CMD_WARNING; |
| 4173 | } |
| 4174 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4175 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4176 | |
| 4177 | return CMD_SUCCESS; |
| 4178 | } |
| 4179 | |
| 4180 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4181 | show_ip_ospf_database_type_self_cmd, |
| 4182 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4183 | SHOW_STR |
| 4184 | IP_STR |
| 4185 | "OSPF information\n" |
| 4186 | "Database summary\n" |
| 4187 | OSPF_LSA_TYPES_DESC |
| 4188 | "Self-originated link states\n") |
| 4189 | |
| 4190 | |
| 4191 | DEFUN (ip_ospf_authentication_args, |
| 4192 | ip_ospf_authentication_args_addr_cmd, |
| 4193 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4194 | "IP Information\n" |
| 4195 | "OSPF interface commands\n" |
| 4196 | "Enable authentication on this interface\n" |
| 4197 | "Use null authentication\n" |
| 4198 | "Use message-digest authentication\n" |
| 4199 | "Address of interface") |
| 4200 | { |
| 4201 | struct interface *ifp; |
| 4202 | struct in_addr addr; |
| 4203 | int ret; |
| 4204 | struct ospf_if_params *params; |
| 4205 | |
| 4206 | ifp = vty->index; |
| 4207 | params = IF_DEF_PARAMS (ifp); |
| 4208 | |
| 4209 | if (argc == 2) |
| 4210 | { |
| 4211 | ret = inet_aton(argv[1], &addr); |
| 4212 | if (!ret) |
| 4213 | { |
| 4214 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4215 | VTY_NEWLINE); |
| 4216 | return CMD_WARNING; |
| 4217 | } |
| 4218 | |
| 4219 | params = ospf_get_if_params (ifp, addr); |
| 4220 | ospf_if_update_params (ifp, addr); |
| 4221 | } |
| 4222 | |
| 4223 | /* Handle null authentication */ |
| 4224 | if ( argv[0][0] == 'n' ) |
| 4225 | { |
| 4226 | SET_IF_PARAM (params, auth_type); |
| 4227 | params->auth_type = OSPF_AUTH_NULL; |
| 4228 | return CMD_SUCCESS; |
| 4229 | } |
| 4230 | |
| 4231 | /* Handle message-digest authentication */ |
| 4232 | if ( argv[0][0] == 'm' ) |
| 4233 | { |
| 4234 | SET_IF_PARAM (params, auth_type); |
| 4235 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4236 | return CMD_SUCCESS; |
| 4237 | } |
| 4238 | |
| 4239 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4240 | return CMD_WARNING; |
| 4241 | } |
| 4242 | |
| 4243 | ALIAS (ip_ospf_authentication_args, |
| 4244 | ip_ospf_authentication_args_cmd, |
| 4245 | "ip ospf authentication (null|message-digest)", |
| 4246 | "IP Information\n" |
| 4247 | "OSPF interface commands\n" |
| 4248 | "Enable authentication on this interface\n" |
| 4249 | "Use null authentication\n" |
| 4250 | "Use message-digest authentication\n") |
| 4251 | |
| 4252 | DEFUN (ip_ospf_authentication, |
| 4253 | ip_ospf_authentication_addr_cmd, |
| 4254 | "ip ospf authentication A.B.C.D", |
| 4255 | "IP Information\n" |
| 4256 | "OSPF interface commands\n" |
| 4257 | "Enable authentication on this interface\n" |
| 4258 | "Address of interface") |
| 4259 | { |
| 4260 | struct interface *ifp; |
| 4261 | struct in_addr addr; |
| 4262 | int ret; |
| 4263 | struct ospf_if_params *params; |
| 4264 | |
| 4265 | ifp = vty->index; |
| 4266 | params = IF_DEF_PARAMS (ifp); |
| 4267 | |
| 4268 | if (argc == 1) |
| 4269 | { |
| 4270 | ret = inet_aton(argv[1], &addr); |
| 4271 | if (!ret) |
| 4272 | { |
| 4273 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4274 | VTY_NEWLINE); |
| 4275 | return CMD_WARNING; |
| 4276 | } |
| 4277 | |
| 4278 | params = ospf_get_if_params (ifp, addr); |
| 4279 | ospf_if_update_params (ifp, addr); |
| 4280 | } |
| 4281 | |
| 4282 | SET_IF_PARAM (params, auth_type); |
| 4283 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4284 | |
| 4285 | return CMD_SUCCESS; |
| 4286 | } |
| 4287 | |
| 4288 | ALIAS (ip_ospf_authentication, |
| 4289 | ip_ospf_authentication_cmd, |
| 4290 | "ip ospf authentication", |
| 4291 | "IP Information\n" |
| 4292 | "OSPF interface commands\n" |
| 4293 | "Enable authentication on this interface\n") |
| 4294 | |
| 4295 | DEFUN (no_ip_ospf_authentication, |
| 4296 | no_ip_ospf_authentication_addr_cmd, |
| 4297 | "no ip ospf authentication A.B.C.D", |
| 4298 | NO_STR |
| 4299 | "IP Information\n" |
| 4300 | "OSPF interface commands\n" |
| 4301 | "Enable authentication on this interface\n" |
| 4302 | "Address of interface") |
| 4303 | { |
| 4304 | struct interface *ifp; |
| 4305 | struct in_addr addr; |
| 4306 | int ret; |
| 4307 | struct ospf_if_params *params; |
| 4308 | |
| 4309 | ifp = vty->index; |
| 4310 | params = IF_DEF_PARAMS (ifp); |
| 4311 | |
| 4312 | if (argc == 1) |
| 4313 | { |
| 4314 | ret = inet_aton(argv[1], &addr); |
| 4315 | if (!ret) |
| 4316 | { |
| 4317 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4318 | VTY_NEWLINE); |
| 4319 | return CMD_WARNING; |
| 4320 | } |
| 4321 | |
| 4322 | params = ospf_lookup_if_params (ifp, addr); |
| 4323 | if (params == NULL) |
| 4324 | return CMD_SUCCESS; |
| 4325 | } |
| 4326 | |
| 4327 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4328 | UNSET_IF_PARAM (params, auth_type); |
| 4329 | |
| 4330 | if (params != IF_DEF_PARAMS (ifp)) |
| 4331 | { |
| 4332 | ospf_free_if_params (ifp, addr); |
| 4333 | ospf_if_update_params (ifp, addr); |
| 4334 | } |
| 4335 | |
| 4336 | return CMD_SUCCESS; |
| 4337 | } |
| 4338 | |
| 4339 | ALIAS (no_ip_ospf_authentication, |
| 4340 | no_ip_ospf_authentication_cmd, |
| 4341 | "no ip ospf authentication", |
| 4342 | NO_STR |
| 4343 | "IP Information\n" |
| 4344 | "OSPF interface commands\n" |
| 4345 | "Enable authentication on this interface\n") |
| 4346 | |
| 4347 | DEFUN (ip_ospf_authentication_key, |
| 4348 | ip_ospf_authentication_key_addr_cmd, |
| 4349 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4350 | "IP Information\n" |
| 4351 | "OSPF interface commands\n" |
| 4352 | "Authentication password (key)\n" |
| 4353 | "The OSPF password (key)\n" |
| 4354 | "Address of interface") |
| 4355 | { |
| 4356 | struct interface *ifp; |
| 4357 | struct in_addr addr; |
| 4358 | int ret; |
| 4359 | struct ospf_if_params *params; |
| 4360 | |
| 4361 | ifp = vty->index; |
| 4362 | params = IF_DEF_PARAMS (ifp); |
| 4363 | |
| 4364 | if (argc == 2) |
| 4365 | { |
| 4366 | ret = inet_aton(argv[1], &addr); |
| 4367 | if (!ret) |
| 4368 | { |
| 4369 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4370 | VTY_NEWLINE); |
| 4371 | return CMD_WARNING; |
| 4372 | } |
| 4373 | |
| 4374 | params = ospf_get_if_params (ifp, addr); |
| 4375 | ospf_if_update_params (ifp, addr); |
| 4376 | } |
| 4377 | |
| 4378 | |
| 4379 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4380 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4381 | SET_IF_PARAM (params, auth_simple); |
| 4382 | |
| 4383 | return CMD_SUCCESS; |
| 4384 | } |
| 4385 | |
| 4386 | ALIAS (ip_ospf_authentication_key, |
| 4387 | ip_ospf_authentication_key_cmd, |
| 4388 | "ip ospf authentication-key AUTH_KEY", |
| 4389 | "IP Information\n" |
| 4390 | "OSPF interface commands\n" |
| 4391 | "Authentication password (key)\n" |
| 4392 | "The OSPF password (key)") |
| 4393 | |
| 4394 | ALIAS (ip_ospf_authentication_key, |
| 4395 | ospf_authentication_key_cmd, |
| 4396 | "ospf authentication-key AUTH_KEY", |
| 4397 | "OSPF interface commands\n" |
| 4398 | "Authentication password (key)\n" |
| 4399 | "The OSPF password (key)") |
| 4400 | |
| 4401 | DEFUN (no_ip_ospf_authentication_key, |
| 4402 | no_ip_ospf_authentication_key_addr_cmd, |
| 4403 | "no ip ospf authentication-key A.B.C.D", |
| 4404 | NO_STR |
| 4405 | "IP Information\n" |
| 4406 | "OSPF interface commands\n" |
| 4407 | "Authentication password (key)\n" |
| 4408 | "Address of interface") |
| 4409 | { |
| 4410 | struct interface *ifp; |
| 4411 | struct in_addr addr; |
| 4412 | int ret; |
| 4413 | struct ospf_if_params *params; |
| 4414 | |
| 4415 | ifp = vty->index; |
| 4416 | params = IF_DEF_PARAMS (ifp); |
| 4417 | |
| 4418 | if (argc == 2) |
| 4419 | { |
| 4420 | ret = inet_aton(argv[1], &addr); |
| 4421 | if (!ret) |
| 4422 | { |
| 4423 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4424 | VTY_NEWLINE); |
| 4425 | return CMD_WARNING; |
| 4426 | } |
| 4427 | |
| 4428 | params = ospf_lookup_if_params (ifp, addr); |
| 4429 | if (params == NULL) |
| 4430 | return CMD_SUCCESS; |
| 4431 | } |
| 4432 | |
| 4433 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4434 | UNSET_IF_PARAM (params, auth_simple); |
| 4435 | |
| 4436 | if (params != IF_DEF_PARAMS (ifp)) |
| 4437 | { |
| 4438 | ospf_free_if_params (ifp, addr); |
| 4439 | ospf_if_update_params (ifp, addr); |
| 4440 | } |
| 4441 | |
| 4442 | return CMD_SUCCESS; |
| 4443 | } |
| 4444 | |
| 4445 | ALIAS (no_ip_ospf_authentication_key, |
| 4446 | no_ip_ospf_authentication_key_cmd, |
| 4447 | "no ip ospf authentication-key", |
| 4448 | NO_STR |
| 4449 | "IP Information\n" |
| 4450 | "OSPF interface commands\n" |
| 4451 | "Authentication password (key)\n") |
| 4452 | |
| 4453 | ALIAS (no_ip_ospf_authentication_key, |
| 4454 | no_ospf_authentication_key_cmd, |
| 4455 | "no ospf authentication-key", |
| 4456 | NO_STR |
| 4457 | "OSPF interface commands\n" |
| 4458 | "Authentication password (key)\n") |
| 4459 | |
| 4460 | DEFUN (ip_ospf_message_digest_key, |
| 4461 | ip_ospf_message_digest_key_addr_cmd, |
| 4462 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4463 | "IP Information\n" |
| 4464 | "OSPF interface commands\n" |
| 4465 | "Message digest authentication password (key)\n" |
| 4466 | "Key ID\n" |
| 4467 | "Use MD5 algorithm\n" |
| 4468 | "The OSPF password (key)" |
| 4469 | "Address of interface") |
| 4470 | { |
| 4471 | struct interface *ifp; |
| 4472 | struct crypt_key *ck; |
| 4473 | u_char key_id; |
| 4474 | struct in_addr addr; |
| 4475 | int ret; |
| 4476 | struct ospf_if_params *params; |
| 4477 | |
| 4478 | ifp = vty->index; |
| 4479 | params = IF_DEF_PARAMS (ifp); |
| 4480 | |
| 4481 | if (argc == 3) |
| 4482 | { |
| 4483 | ret = inet_aton(argv[2], &addr); |
| 4484 | if (!ret) |
| 4485 | { |
| 4486 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4487 | VTY_NEWLINE); |
| 4488 | return CMD_WARNING; |
| 4489 | } |
| 4490 | |
| 4491 | params = ospf_get_if_params (ifp, addr); |
| 4492 | ospf_if_update_params (ifp, addr); |
| 4493 | } |
| 4494 | |
| 4495 | key_id = strtol (argv[0], NULL, 10); |
| 4496 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4497 | { |
| 4498 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4499 | return CMD_WARNING; |
| 4500 | } |
| 4501 | |
| 4502 | ck = ospf_crypt_key_new (); |
| 4503 | ck->key_id = (u_char) key_id; |
| 4504 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4505 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4506 | |
| 4507 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4508 | SET_IF_PARAM (params, auth_crypt); |
| 4509 | |
| 4510 | return CMD_SUCCESS; |
| 4511 | } |
| 4512 | |
| 4513 | ALIAS (ip_ospf_message_digest_key, |
| 4514 | ip_ospf_message_digest_key_cmd, |
| 4515 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4516 | "IP Information\n" |
| 4517 | "OSPF interface commands\n" |
| 4518 | "Message digest authentication password (key)\n" |
| 4519 | "Key ID\n" |
| 4520 | "Use MD5 algorithm\n" |
| 4521 | "The OSPF password (key)") |
| 4522 | |
| 4523 | ALIAS (ip_ospf_message_digest_key, |
| 4524 | ospf_message_digest_key_cmd, |
| 4525 | "ospf message-digest-key <1-255> md5 KEY", |
| 4526 | "OSPF interface commands\n" |
| 4527 | "Message digest authentication password (key)\n" |
| 4528 | "Key ID\n" |
| 4529 | "Use MD5 algorithm\n" |
| 4530 | "The OSPF password (key)") |
| 4531 | |
| 4532 | DEFUN (no_ip_ospf_message_digest_key, |
| 4533 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4534 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4535 | NO_STR |
| 4536 | "IP Information\n" |
| 4537 | "OSPF interface commands\n" |
| 4538 | "Message digest authentication password (key)\n" |
| 4539 | "Key ID\n" |
| 4540 | "Address of interface") |
| 4541 | { |
| 4542 | struct interface *ifp; |
| 4543 | struct crypt_key *ck; |
| 4544 | int key_id; |
| 4545 | struct in_addr addr; |
| 4546 | int ret; |
| 4547 | struct ospf_if_params *params; |
| 4548 | |
| 4549 | ifp = vty->index; |
| 4550 | params = IF_DEF_PARAMS (ifp); |
| 4551 | |
| 4552 | if (argc == 2) |
| 4553 | { |
| 4554 | ret = inet_aton(argv[1], &addr); |
| 4555 | if (!ret) |
| 4556 | { |
| 4557 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4558 | VTY_NEWLINE); |
| 4559 | return CMD_WARNING; |
| 4560 | } |
| 4561 | |
| 4562 | params = ospf_lookup_if_params (ifp, addr); |
| 4563 | if (params == NULL) |
| 4564 | return CMD_SUCCESS; |
| 4565 | } |
| 4566 | |
| 4567 | key_id = strtol (argv[0], NULL, 10); |
| 4568 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4569 | if (ck == NULL) |
| 4570 | { |
| 4571 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4572 | return CMD_WARNING; |
| 4573 | } |
| 4574 | |
| 4575 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4576 | |
| 4577 | if (params != IF_DEF_PARAMS (ifp)) |
| 4578 | { |
| 4579 | ospf_free_if_params (ifp, addr); |
| 4580 | ospf_if_update_params (ifp, addr); |
| 4581 | } |
| 4582 | |
| 4583 | return CMD_SUCCESS; |
| 4584 | } |
| 4585 | |
| 4586 | ALIAS (no_ip_ospf_message_digest_key, |
| 4587 | no_ip_ospf_message_digest_key_cmd, |
| 4588 | "no ip ospf message-digest-key <1-255>", |
| 4589 | NO_STR |
| 4590 | "IP Information\n" |
| 4591 | "OSPF interface commands\n" |
| 4592 | "Message digest authentication password (key)\n" |
| 4593 | "Key ID\n") |
| 4594 | |
| 4595 | ALIAS (no_ip_ospf_message_digest_key, |
| 4596 | no_ospf_message_digest_key_cmd, |
| 4597 | "no ospf message-digest-key <1-255>", |
| 4598 | NO_STR |
| 4599 | "OSPF interface commands\n" |
| 4600 | "Message digest authentication password (key)\n" |
| 4601 | "Key ID\n") |
| 4602 | |
| 4603 | DEFUN (ip_ospf_cost, |
| 4604 | ip_ospf_cost_addr_cmd, |
| 4605 | "ip ospf cost <1-65535> A.B.C.D", |
| 4606 | "IP Information\n" |
| 4607 | "OSPF interface commands\n" |
| 4608 | "Interface cost\n" |
| 4609 | "Cost\n" |
| 4610 | "Address of interface") |
| 4611 | { |
| 4612 | struct interface *ifp = vty->index; |
| 4613 | u_int32_t cost; |
| 4614 | struct in_addr addr; |
| 4615 | int ret; |
| 4616 | struct ospf_if_params *params; |
| 4617 | |
| 4618 | params = IF_DEF_PARAMS (ifp); |
| 4619 | |
| 4620 | cost = strtol (argv[0], NULL, 10); |
| 4621 | |
| 4622 | /* cost range is <1-65535>. */ |
| 4623 | if (cost < 1 || cost > 65535) |
| 4624 | { |
| 4625 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4626 | return CMD_WARNING; |
| 4627 | } |
| 4628 | |
| 4629 | if (argc == 2) |
| 4630 | { |
| 4631 | ret = inet_aton(argv[1], &addr); |
| 4632 | if (!ret) |
| 4633 | { |
| 4634 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4635 | VTY_NEWLINE); |
| 4636 | return CMD_WARNING; |
| 4637 | } |
| 4638 | |
| 4639 | params = ospf_get_if_params (ifp, addr); |
| 4640 | ospf_if_update_params (ifp, addr); |
| 4641 | } |
| 4642 | |
| 4643 | SET_IF_PARAM (params, output_cost_cmd); |
| 4644 | params->output_cost_cmd = cost; |
| 4645 | |
| 4646 | ospf_if_recalculate_output_cost (ifp); |
| 4647 | |
| 4648 | return CMD_SUCCESS; |
| 4649 | } |
| 4650 | |
| 4651 | ALIAS (ip_ospf_cost, |
| 4652 | ip_ospf_cost_cmd, |
| 4653 | "ip ospf cost <1-65535>", |
| 4654 | "IP Information\n" |
| 4655 | "OSPF interface commands\n" |
| 4656 | "Interface cost\n" |
| 4657 | "Cost") |
| 4658 | |
| 4659 | ALIAS (ip_ospf_cost, |
| 4660 | ospf_cost_cmd, |
| 4661 | "ospf cost <1-65535>", |
| 4662 | "OSPF interface commands\n" |
| 4663 | "Interface cost\n" |
| 4664 | "Cost") |
| 4665 | |
| 4666 | DEFUN (no_ip_ospf_cost, |
| 4667 | no_ip_ospf_cost_addr_cmd, |
| 4668 | "no ip ospf cost A.B.C.D", |
| 4669 | NO_STR |
| 4670 | "IP Information\n" |
| 4671 | "OSPF interface commands\n" |
| 4672 | "Interface cost\n" |
| 4673 | "Address of interface") |
| 4674 | { |
| 4675 | struct interface *ifp = vty->index; |
| 4676 | struct in_addr addr; |
| 4677 | int ret; |
| 4678 | struct ospf_if_params *params; |
| 4679 | |
| 4680 | ifp = vty->index; |
| 4681 | params = IF_DEF_PARAMS (ifp); |
| 4682 | |
| 4683 | if (argc == 1) |
| 4684 | { |
| 4685 | ret = inet_aton(argv[0], &addr); |
| 4686 | if (!ret) |
| 4687 | { |
| 4688 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4689 | VTY_NEWLINE); |
| 4690 | return CMD_WARNING; |
| 4691 | } |
| 4692 | |
| 4693 | params = ospf_lookup_if_params (ifp, addr); |
| 4694 | if (params == NULL) |
| 4695 | return CMD_SUCCESS; |
| 4696 | } |
| 4697 | |
| 4698 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4699 | |
| 4700 | if (params != IF_DEF_PARAMS (ifp)) |
| 4701 | { |
| 4702 | ospf_free_if_params (ifp, addr); |
| 4703 | ospf_if_update_params (ifp, addr); |
| 4704 | } |
| 4705 | |
| 4706 | ospf_if_recalculate_output_cost (ifp); |
| 4707 | |
| 4708 | return CMD_SUCCESS; |
| 4709 | } |
| 4710 | |
| 4711 | ALIAS (no_ip_ospf_cost, |
| 4712 | no_ip_ospf_cost_cmd, |
| 4713 | "no ip ospf cost", |
| 4714 | NO_STR |
| 4715 | "IP Information\n" |
| 4716 | "OSPF interface commands\n" |
| 4717 | "Interface cost\n") |
| 4718 | |
| 4719 | ALIAS (no_ip_ospf_cost, |
| 4720 | no_ospf_cost_cmd, |
| 4721 | "no ospf cost", |
| 4722 | NO_STR |
| 4723 | "OSPF interface commands\n" |
| 4724 | "Interface cost\n") |
| 4725 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4726 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4727 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4728 | { |
| 4729 | struct route_node *rn; |
| 4730 | struct ospf_neighbor *nbr; |
| 4731 | |
| 4732 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4733 | if ((nbr = rn->info)) |
| 4734 | { |
| 4735 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4736 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4737 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4738 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4739 | } |
| 4740 | } |
| 4741 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4742 | static int |
| 4743 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 4744 | const char *nbr_str, |
| 4745 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4746 | { |
| 4747 | struct interface *ifp = vty->index; |
| 4748 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4749 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4750 | struct in_addr addr; |
| 4751 | int ret; |
| 4752 | struct ospf_if_params *params; |
| 4753 | struct ospf_interface *oi; |
| 4754 | struct route_node *rn; |
| 4755 | |
| 4756 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4757 | |
| 4758 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4759 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4760 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4761 | if (!ret) |
| 4762 | { |
| 4763 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4764 | VTY_NEWLINE); |
| 4765 | return CMD_WARNING; |
| 4766 | } |
| 4767 | |
| 4768 | params = ospf_get_if_params (ifp, addr); |
| 4769 | ospf_if_update_params (ifp, addr); |
| 4770 | } |
| 4771 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4772 | if (interval_str) |
| 4773 | { |
| 4774 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 4775 | 1, 65535); |
| 4776 | |
| 4777 | /* reset fast_hello too, just to be sure */ |
| 4778 | UNSET_IF_PARAM (params, fast_hello); |
| 4779 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4780 | } |
| 4781 | else if (fast_hello_str) |
| 4782 | { |
| 4783 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 4784 | 1, 10); |
| 4785 | /* 1s dead-interval with sub-second hellos desired */ |
| 4786 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 4787 | SET_IF_PARAM (params, fast_hello); |
| 4788 | params->fast_hello = hellomult; |
| 4789 | } |
| 4790 | else |
| 4791 | { |
| 4792 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 4793 | VTY_NEWLINE); |
| 4794 | return CMD_WARNING; |
| 4795 | } |
| 4796 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4797 | SET_IF_PARAM (params, v_wait); |
| 4798 | params->v_wait = seconds; |
| 4799 | |
| 4800 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4801 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4802 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4803 | struct ospf *ospf; |
| 4804 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4805 | { |
| 4806 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4807 | if (oi) |
| 4808 | ospf_nbr_timer_update (oi); |
| 4809 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4810 | } |
| 4811 | else |
| 4812 | { |
| 4813 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4814 | if ((oi = rn->info)) |
| 4815 | ospf_nbr_timer_update (oi); |
| 4816 | } |
| 4817 | |
| 4818 | return CMD_SUCCESS; |
| 4819 | } |
| 4820 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4821 | |
| 4822 | DEFUN (ip_ospf_dead_interval, |
| 4823 | ip_ospf_dead_interval_addr_cmd, |
| 4824 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4825 | "IP Information\n" |
| 4826 | "OSPF interface commands\n" |
| 4827 | "Interval after which a neighbor is declared dead\n" |
| 4828 | "Seconds\n" |
| 4829 | "Address of interface\n") |
| 4830 | { |
| 4831 | if (argc == 2) |
| 4832 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 4833 | else |
| 4834 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 4835 | } |
| 4836 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4837 | ALIAS (ip_ospf_dead_interval, |
| 4838 | ip_ospf_dead_interval_cmd, |
| 4839 | "ip ospf dead-interval <1-65535>", |
| 4840 | "IP Information\n" |
| 4841 | "OSPF interface commands\n" |
| 4842 | "Interval after which a neighbor is declared dead\n" |
| 4843 | "Seconds\n") |
| 4844 | |
| 4845 | ALIAS (ip_ospf_dead_interval, |
| 4846 | ospf_dead_interval_cmd, |
| 4847 | "ospf dead-interval <1-65535>", |
| 4848 | "OSPF interface commands\n" |
| 4849 | "Interval after which a neighbor is declared dead\n" |
| 4850 | "Seconds\n") |
| 4851 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4852 | DEFUN (ip_ospf_dead_interval_minimal, |
| 4853 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 4854 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 4855 | "IP Information\n" |
| 4856 | "OSPF interface commands\n" |
| 4857 | "Interval after which a neighbor is declared dead\n" |
| 4858 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4859 | "Hello multiplier factor\n" |
| 4860 | "Number of Hellos to send each second\n" |
| 4861 | "Address of interface\n") |
| 4862 | { |
| 4863 | if (argc == 2) |
| 4864 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 4865 | else |
| 4866 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 4867 | } |
| 4868 | |
| 4869 | ALIAS (ip_ospf_dead_interval_minimal, |
| 4870 | ip_ospf_dead_interval_minimal_cmd, |
| 4871 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 4872 | "IP Information\n" |
| 4873 | "OSPF interface commands\n" |
| 4874 | "Interval after which a neighbor is declared dead\n" |
| 4875 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4876 | "Hello multiplier factor\n" |
| 4877 | "Number of Hellos to send each second\n") |
| 4878 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4879 | DEFUN (no_ip_ospf_dead_interval, |
| 4880 | no_ip_ospf_dead_interval_addr_cmd, |
| 4881 | "no ip ospf dead-interval A.B.C.D", |
| 4882 | NO_STR |
| 4883 | "IP Information\n" |
| 4884 | "OSPF interface commands\n" |
| 4885 | "Interval after which a neighbor is declared dead\n" |
| 4886 | "Address of interface") |
| 4887 | { |
| 4888 | struct interface *ifp = vty->index; |
| 4889 | struct in_addr addr; |
| 4890 | int ret; |
| 4891 | struct ospf_if_params *params; |
| 4892 | struct ospf_interface *oi; |
| 4893 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4894 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4895 | ifp = vty->index; |
| 4896 | params = IF_DEF_PARAMS (ifp); |
| 4897 | |
| 4898 | if (argc == 1) |
| 4899 | { |
| 4900 | ret = inet_aton(argv[0], &addr); |
| 4901 | if (!ret) |
| 4902 | { |
| 4903 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4904 | VTY_NEWLINE); |
| 4905 | return CMD_WARNING; |
| 4906 | } |
| 4907 | |
| 4908 | params = ospf_lookup_if_params (ifp, addr); |
| 4909 | if (params == NULL) |
| 4910 | return CMD_SUCCESS; |
| 4911 | } |
| 4912 | |
| 4913 | UNSET_IF_PARAM (params, v_wait); |
| 4914 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4915 | |
| 4916 | UNSET_IF_PARAM (params, fast_hello); |
| 4917 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4918 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4919 | if (params != IF_DEF_PARAMS (ifp)) |
| 4920 | { |
| 4921 | ospf_free_if_params (ifp, addr); |
| 4922 | ospf_if_update_params (ifp, addr); |
| 4923 | } |
| 4924 | |
| 4925 | /* Update timer values in neighbor structure. */ |
| 4926 | if (argc == 1) |
| 4927 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4928 | struct ospf *ospf; |
| 4929 | |
| 4930 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4931 | { |
| 4932 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4933 | if (oi) |
| 4934 | ospf_nbr_timer_update (oi); |
| 4935 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4936 | } |
| 4937 | else |
| 4938 | { |
| 4939 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4940 | if ((oi = rn->info)) |
| 4941 | ospf_nbr_timer_update (oi); |
| 4942 | } |
| 4943 | |
| 4944 | return CMD_SUCCESS; |
| 4945 | } |
| 4946 | |
| 4947 | ALIAS (no_ip_ospf_dead_interval, |
| 4948 | no_ip_ospf_dead_interval_cmd, |
| 4949 | "no ip ospf dead-interval", |
| 4950 | NO_STR |
| 4951 | "IP Information\n" |
| 4952 | "OSPF interface commands\n" |
| 4953 | "Interval after which a neighbor is declared dead\n") |
| 4954 | |
| 4955 | ALIAS (no_ip_ospf_dead_interval, |
| 4956 | no_ospf_dead_interval_cmd, |
| 4957 | "no ospf dead-interval", |
| 4958 | NO_STR |
| 4959 | "OSPF interface commands\n" |
| 4960 | "Interval after which a neighbor is declared dead\n") |
| 4961 | |
| 4962 | DEFUN (ip_ospf_hello_interval, |
| 4963 | ip_ospf_hello_interval_addr_cmd, |
| 4964 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4965 | "IP Information\n" |
| 4966 | "OSPF interface commands\n" |
| 4967 | "Time between HELLO packets\n" |
| 4968 | "Seconds\n" |
| 4969 | "Address of interface") |
| 4970 | { |
| 4971 | struct interface *ifp = vty->index; |
| 4972 | u_int32_t seconds; |
| 4973 | struct in_addr addr; |
| 4974 | int ret; |
| 4975 | struct ospf_if_params *params; |
| 4976 | |
| 4977 | params = IF_DEF_PARAMS (ifp); |
| 4978 | |
| 4979 | seconds = strtol (argv[0], NULL, 10); |
| 4980 | |
| 4981 | /* HelloInterval range is <1-65535>. */ |
| 4982 | if (seconds < 1 || seconds > 65535) |
| 4983 | { |
| 4984 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4985 | return CMD_WARNING; |
| 4986 | } |
| 4987 | |
| 4988 | if (argc == 2) |
| 4989 | { |
| 4990 | ret = inet_aton(argv[1], &addr); |
| 4991 | if (!ret) |
| 4992 | { |
| 4993 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4994 | VTY_NEWLINE); |
| 4995 | return CMD_WARNING; |
| 4996 | } |
| 4997 | |
| 4998 | params = ospf_get_if_params (ifp, addr); |
| 4999 | ospf_if_update_params (ifp, addr); |
| 5000 | } |
| 5001 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5002 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5003 | params->v_hello = seconds; |
| 5004 | |
| 5005 | return CMD_SUCCESS; |
| 5006 | } |
| 5007 | |
| 5008 | ALIAS (ip_ospf_hello_interval, |
| 5009 | ip_ospf_hello_interval_cmd, |
| 5010 | "ip ospf hello-interval <1-65535>", |
| 5011 | "IP Information\n" |
| 5012 | "OSPF interface commands\n" |
| 5013 | "Time between HELLO packets\n" |
| 5014 | "Seconds\n") |
| 5015 | |
| 5016 | ALIAS (ip_ospf_hello_interval, |
| 5017 | ospf_hello_interval_cmd, |
| 5018 | "ospf hello-interval <1-65535>", |
| 5019 | "OSPF interface commands\n" |
| 5020 | "Time between HELLO packets\n" |
| 5021 | "Seconds\n") |
| 5022 | |
| 5023 | DEFUN (no_ip_ospf_hello_interval, |
| 5024 | no_ip_ospf_hello_interval_addr_cmd, |
| 5025 | "no ip ospf hello-interval A.B.C.D", |
| 5026 | NO_STR |
| 5027 | "IP Information\n" |
| 5028 | "OSPF interface commands\n" |
| 5029 | "Time between HELLO packets\n" |
| 5030 | "Address of interface") |
| 5031 | { |
| 5032 | struct interface *ifp = vty->index; |
| 5033 | struct in_addr addr; |
| 5034 | int ret; |
| 5035 | struct ospf_if_params *params; |
| 5036 | |
| 5037 | ifp = vty->index; |
| 5038 | params = IF_DEF_PARAMS (ifp); |
| 5039 | |
| 5040 | if (argc == 1) |
| 5041 | { |
| 5042 | ret = inet_aton(argv[0], &addr); |
| 5043 | if (!ret) |
| 5044 | { |
| 5045 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5046 | VTY_NEWLINE); |
| 5047 | return CMD_WARNING; |
| 5048 | } |
| 5049 | |
| 5050 | params = ospf_lookup_if_params (ifp, addr); |
| 5051 | if (params == NULL) |
| 5052 | return CMD_SUCCESS; |
| 5053 | } |
| 5054 | |
| 5055 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5056 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5057 | |
| 5058 | if (params != IF_DEF_PARAMS (ifp)) |
| 5059 | { |
| 5060 | ospf_free_if_params (ifp, addr); |
| 5061 | ospf_if_update_params (ifp, addr); |
| 5062 | } |
| 5063 | |
| 5064 | return CMD_SUCCESS; |
| 5065 | } |
| 5066 | |
| 5067 | ALIAS (no_ip_ospf_hello_interval, |
| 5068 | no_ip_ospf_hello_interval_cmd, |
| 5069 | "no ip ospf hello-interval", |
| 5070 | NO_STR |
| 5071 | "IP Information\n" |
| 5072 | "OSPF interface commands\n" |
| 5073 | "Time between HELLO packets\n") |
| 5074 | |
| 5075 | ALIAS (no_ip_ospf_hello_interval, |
| 5076 | no_ospf_hello_interval_cmd, |
| 5077 | "no ospf hello-interval", |
| 5078 | NO_STR |
| 5079 | "OSPF interface commands\n" |
| 5080 | "Time between HELLO packets\n") |
| 5081 | |
| 5082 | DEFUN (ip_ospf_network, |
| 5083 | ip_ospf_network_cmd, |
| 5084 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5085 | "IP Information\n" |
| 5086 | "OSPF interface commands\n" |
| 5087 | "Network type\n" |
| 5088 | "Specify OSPF broadcast multi-access network\n" |
| 5089 | "Specify OSPF NBMA network\n" |
| 5090 | "Specify OSPF point-to-multipoint network\n" |
| 5091 | "Specify OSPF point-to-point network\n") |
| 5092 | { |
| 5093 | struct interface *ifp = vty->index; |
| 5094 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5095 | struct route_node *rn; |
| 5096 | |
| 5097 | if (strncmp (argv[0], "b", 1) == 0) |
| 5098 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5099 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5100 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5101 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5102 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5103 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5104 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5105 | |
| 5106 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5107 | return CMD_SUCCESS; |
| 5108 | |
| 5109 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5110 | |
| 5111 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5112 | { |
| 5113 | struct ospf_interface *oi = rn->info; |
| 5114 | |
| 5115 | if (!oi) |
| 5116 | continue; |
| 5117 | |
| 5118 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5119 | |
| 5120 | if (oi->state > ISM_Down) |
| 5121 | { |
| 5122 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5123 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5124 | } |
| 5125 | } |
| 5126 | |
| 5127 | return CMD_SUCCESS; |
| 5128 | } |
| 5129 | |
| 5130 | ALIAS (ip_ospf_network, |
| 5131 | ospf_network_cmd, |
| 5132 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5133 | "OSPF interface commands\n" |
| 5134 | "Network type\n" |
| 5135 | "Specify OSPF broadcast multi-access network\n" |
| 5136 | "Specify OSPF NBMA network\n" |
| 5137 | "Specify OSPF point-to-multipoint network\n" |
| 5138 | "Specify OSPF point-to-point network\n") |
| 5139 | |
| 5140 | DEFUN (no_ip_ospf_network, |
| 5141 | no_ip_ospf_network_cmd, |
| 5142 | "no ip ospf network", |
| 5143 | NO_STR |
| 5144 | "IP Information\n" |
| 5145 | "OSPF interface commands\n" |
| 5146 | "Network type\n") |
| 5147 | { |
| 5148 | struct interface *ifp = vty->index; |
| 5149 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5150 | struct route_node *rn; |
| 5151 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5152 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5153 | |
| 5154 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5155 | return CMD_SUCCESS; |
| 5156 | |
| 5157 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5158 | { |
| 5159 | struct ospf_interface *oi = rn->info; |
| 5160 | |
| 5161 | if (!oi) |
| 5162 | continue; |
| 5163 | |
| 5164 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5165 | |
| 5166 | if (oi->state > ISM_Down) |
| 5167 | { |
| 5168 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5169 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5170 | } |
| 5171 | } |
| 5172 | |
| 5173 | return CMD_SUCCESS; |
| 5174 | } |
| 5175 | |
| 5176 | ALIAS (no_ip_ospf_network, |
| 5177 | no_ospf_network_cmd, |
| 5178 | "no ospf network", |
| 5179 | NO_STR |
| 5180 | "OSPF interface commands\n" |
| 5181 | "Network type\n") |
| 5182 | |
| 5183 | DEFUN (ip_ospf_priority, |
| 5184 | ip_ospf_priority_addr_cmd, |
| 5185 | "ip ospf priority <0-255> A.B.C.D", |
| 5186 | "IP Information\n" |
| 5187 | "OSPF interface commands\n" |
| 5188 | "Router priority\n" |
| 5189 | "Priority\n" |
| 5190 | "Address of interface") |
| 5191 | { |
| 5192 | struct interface *ifp = vty->index; |
| 5193 | u_int32_t priority; |
| 5194 | struct route_node *rn; |
| 5195 | struct in_addr addr; |
| 5196 | int ret; |
| 5197 | struct ospf_if_params *params; |
| 5198 | |
| 5199 | params = IF_DEF_PARAMS (ifp); |
| 5200 | |
| 5201 | priority = strtol (argv[0], NULL, 10); |
| 5202 | |
| 5203 | /* Router Priority range is <0-255>. */ |
| 5204 | if (priority < 0 || priority > 255) |
| 5205 | { |
| 5206 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5207 | return CMD_WARNING; |
| 5208 | } |
| 5209 | |
| 5210 | if (argc == 2) |
| 5211 | { |
| 5212 | ret = inet_aton(argv[1], &addr); |
| 5213 | if (!ret) |
| 5214 | { |
| 5215 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5216 | VTY_NEWLINE); |
| 5217 | return CMD_WARNING; |
| 5218 | } |
| 5219 | |
| 5220 | params = ospf_get_if_params (ifp, addr); |
| 5221 | ospf_if_update_params (ifp, addr); |
| 5222 | } |
| 5223 | |
| 5224 | SET_IF_PARAM (params, priority); |
| 5225 | params->priority = priority; |
| 5226 | |
| 5227 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5228 | { |
| 5229 | struct ospf_interface *oi = rn->info; |
| 5230 | |
| 5231 | if (!oi) |
| 5232 | continue; |
| 5233 | |
| 5234 | |
| 5235 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5236 | { |
| 5237 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5238 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5239 | } |
| 5240 | } |
| 5241 | |
| 5242 | return CMD_SUCCESS; |
| 5243 | } |
| 5244 | |
| 5245 | ALIAS (ip_ospf_priority, |
| 5246 | ip_ospf_priority_cmd, |
| 5247 | "ip ospf priority <0-255>", |
| 5248 | "IP Information\n" |
| 5249 | "OSPF interface commands\n" |
| 5250 | "Router priority\n" |
| 5251 | "Priority\n") |
| 5252 | |
| 5253 | ALIAS (ip_ospf_priority, |
| 5254 | ospf_priority_cmd, |
| 5255 | "ospf priority <0-255>", |
| 5256 | "OSPF interface commands\n" |
| 5257 | "Router priority\n" |
| 5258 | "Priority\n") |
| 5259 | |
| 5260 | DEFUN (no_ip_ospf_priority, |
| 5261 | no_ip_ospf_priority_addr_cmd, |
| 5262 | "no ip ospf priority A.B.C.D", |
| 5263 | NO_STR |
| 5264 | "IP Information\n" |
| 5265 | "OSPF interface commands\n" |
| 5266 | "Router priority\n" |
| 5267 | "Address of interface") |
| 5268 | { |
| 5269 | struct interface *ifp = vty->index; |
| 5270 | struct route_node *rn; |
| 5271 | struct in_addr addr; |
| 5272 | int ret; |
| 5273 | struct ospf_if_params *params; |
| 5274 | |
| 5275 | ifp = vty->index; |
| 5276 | params = IF_DEF_PARAMS (ifp); |
| 5277 | |
| 5278 | if (argc == 1) |
| 5279 | { |
| 5280 | ret = inet_aton(argv[0], &addr); |
| 5281 | if (!ret) |
| 5282 | { |
| 5283 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5284 | VTY_NEWLINE); |
| 5285 | return CMD_WARNING; |
| 5286 | } |
| 5287 | |
| 5288 | params = ospf_lookup_if_params (ifp, addr); |
| 5289 | if (params == NULL) |
| 5290 | return CMD_SUCCESS; |
| 5291 | } |
| 5292 | |
| 5293 | UNSET_IF_PARAM (params, priority); |
| 5294 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5295 | |
| 5296 | if (params != IF_DEF_PARAMS (ifp)) |
| 5297 | { |
| 5298 | ospf_free_if_params (ifp, addr); |
| 5299 | ospf_if_update_params (ifp, addr); |
| 5300 | } |
| 5301 | |
| 5302 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5303 | { |
| 5304 | struct ospf_interface *oi = rn->info; |
| 5305 | |
| 5306 | if (!oi) |
| 5307 | continue; |
| 5308 | |
| 5309 | |
| 5310 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5311 | { |
| 5312 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5313 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5314 | } |
| 5315 | } |
| 5316 | |
| 5317 | return CMD_SUCCESS; |
| 5318 | } |
| 5319 | |
| 5320 | ALIAS (no_ip_ospf_priority, |
| 5321 | no_ip_ospf_priority_cmd, |
| 5322 | "no ip ospf priority", |
| 5323 | NO_STR |
| 5324 | "IP Information\n" |
| 5325 | "OSPF interface commands\n" |
| 5326 | "Router priority\n") |
| 5327 | |
| 5328 | ALIAS (no_ip_ospf_priority, |
| 5329 | no_ospf_priority_cmd, |
| 5330 | "no ospf priority", |
| 5331 | NO_STR |
| 5332 | "OSPF interface commands\n" |
| 5333 | "Router priority\n") |
| 5334 | |
| 5335 | DEFUN (ip_ospf_retransmit_interval, |
| 5336 | ip_ospf_retransmit_interval_addr_cmd, |
| 5337 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5338 | "IP Information\n" |
| 5339 | "OSPF interface commands\n" |
| 5340 | "Time between retransmitting lost link state advertisements\n" |
| 5341 | "Seconds\n" |
| 5342 | "Address of interface") |
| 5343 | { |
| 5344 | struct interface *ifp = vty->index; |
| 5345 | u_int32_t seconds; |
| 5346 | struct in_addr addr; |
| 5347 | int ret; |
| 5348 | struct ospf_if_params *params; |
| 5349 | |
| 5350 | params = IF_DEF_PARAMS (ifp); |
| 5351 | seconds = strtol (argv[0], NULL, 10); |
| 5352 | |
| 5353 | /* Retransmit Interval range is <3-65535>. */ |
| 5354 | if (seconds < 3 || seconds > 65535) |
| 5355 | { |
| 5356 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5357 | return CMD_WARNING; |
| 5358 | } |
| 5359 | |
| 5360 | |
| 5361 | if (argc == 2) |
| 5362 | { |
| 5363 | ret = inet_aton(argv[1], &addr); |
| 5364 | if (!ret) |
| 5365 | { |
| 5366 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5367 | VTY_NEWLINE); |
| 5368 | return CMD_WARNING; |
| 5369 | } |
| 5370 | |
| 5371 | params = ospf_get_if_params (ifp, addr); |
| 5372 | ospf_if_update_params (ifp, addr); |
| 5373 | } |
| 5374 | |
| 5375 | SET_IF_PARAM (params, retransmit_interval); |
| 5376 | params->retransmit_interval = seconds; |
| 5377 | |
| 5378 | return CMD_SUCCESS; |
| 5379 | } |
| 5380 | |
| 5381 | ALIAS (ip_ospf_retransmit_interval, |
| 5382 | ip_ospf_retransmit_interval_cmd, |
| 5383 | "ip ospf retransmit-interval <3-65535>", |
| 5384 | "IP Information\n" |
| 5385 | "OSPF interface commands\n" |
| 5386 | "Time between retransmitting lost link state advertisements\n" |
| 5387 | "Seconds\n") |
| 5388 | |
| 5389 | ALIAS (ip_ospf_retransmit_interval, |
| 5390 | ospf_retransmit_interval_cmd, |
| 5391 | "ospf retransmit-interval <3-65535>", |
| 5392 | "OSPF interface commands\n" |
| 5393 | "Time between retransmitting lost link state advertisements\n" |
| 5394 | "Seconds\n") |
| 5395 | |
| 5396 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5397 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5398 | "no ip ospf retransmit-interval A.B.C.D", |
| 5399 | NO_STR |
| 5400 | "IP Information\n" |
| 5401 | "OSPF interface commands\n" |
| 5402 | "Time between retransmitting lost link state advertisements\n" |
| 5403 | "Address of interface") |
| 5404 | { |
| 5405 | struct interface *ifp = vty->index; |
| 5406 | struct in_addr addr; |
| 5407 | int ret; |
| 5408 | struct ospf_if_params *params; |
| 5409 | |
| 5410 | ifp = vty->index; |
| 5411 | params = IF_DEF_PARAMS (ifp); |
| 5412 | |
| 5413 | if (argc == 1) |
| 5414 | { |
| 5415 | ret = inet_aton(argv[0], &addr); |
| 5416 | if (!ret) |
| 5417 | { |
| 5418 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5419 | VTY_NEWLINE); |
| 5420 | return CMD_WARNING; |
| 5421 | } |
| 5422 | |
| 5423 | params = ospf_lookup_if_params (ifp, addr); |
| 5424 | if (params == NULL) |
| 5425 | return CMD_SUCCESS; |
| 5426 | } |
| 5427 | |
| 5428 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5429 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5430 | |
| 5431 | if (params != IF_DEF_PARAMS (ifp)) |
| 5432 | { |
| 5433 | ospf_free_if_params (ifp, addr); |
| 5434 | ospf_if_update_params (ifp, addr); |
| 5435 | } |
| 5436 | |
| 5437 | return CMD_SUCCESS; |
| 5438 | } |
| 5439 | |
| 5440 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5441 | no_ip_ospf_retransmit_interval_cmd, |
| 5442 | "no ip ospf retransmit-interval", |
| 5443 | NO_STR |
| 5444 | "IP Information\n" |
| 5445 | "OSPF interface commands\n" |
| 5446 | "Time between retransmitting lost link state advertisements\n") |
| 5447 | |
| 5448 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5449 | no_ospf_retransmit_interval_cmd, |
| 5450 | "no ospf retransmit-interval", |
| 5451 | NO_STR |
| 5452 | "OSPF interface commands\n" |
| 5453 | "Time between retransmitting lost link state advertisements\n") |
| 5454 | |
| 5455 | DEFUN (ip_ospf_transmit_delay, |
| 5456 | ip_ospf_transmit_delay_addr_cmd, |
| 5457 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5458 | "IP Information\n" |
| 5459 | "OSPF interface commands\n" |
| 5460 | "Link state transmit delay\n" |
| 5461 | "Seconds\n" |
| 5462 | "Address of interface") |
| 5463 | { |
| 5464 | struct interface *ifp = vty->index; |
| 5465 | u_int32_t seconds; |
| 5466 | struct in_addr addr; |
| 5467 | int ret; |
| 5468 | struct ospf_if_params *params; |
| 5469 | |
| 5470 | params = IF_DEF_PARAMS (ifp); |
| 5471 | seconds = strtol (argv[0], NULL, 10); |
| 5472 | |
| 5473 | /* Transmit Delay range is <1-65535>. */ |
| 5474 | if (seconds < 1 || seconds > 65535) |
| 5475 | { |
| 5476 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5477 | return CMD_WARNING; |
| 5478 | } |
| 5479 | |
| 5480 | if (argc == 2) |
| 5481 | { |
| 5482 | ret = inet_aton(argv[1], &addr); |
| 5483 | if (!ret) |
| 5484 | { |
| 5485 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5486 | VTY_NEWLINE); |
| 5487 | return CMD_WARNING; |
| 5488 | } |
| 5489 | |
| 5490 | params = ospf_get_if_params (ifp, addr); |
| 5491 | ospf_if_update_params (ifp, addr); |
| 5492 | } |
| 5493 | |
| 5494 | SET_IF_PARAM (params, transmit_delay); |
| 5495 | params->transmit_delay = seconds; |
| 5496 | |
| 5497 | return CMD_SUCCESS; |
| 5498 | } |
| 5499 | |
| 5500 | ALIAS (ip_ospf_transmit_delay, |
| 5501 | ip_ospf_transmit_delay_cmd, |
| 5502 | "ip ospf transmit-delay <1-65535>", |
| 5503 | "IP Information\n" |
| 5504 | "OSPF interface commands\n" |
| 5505 | "Link state transmit delay\n" |
| 5506 | "Seconds\n") |
| 5507 | |
| 5508 | ALIAS (ip_ospf_transmit_delay, |
| 5509 | ospf_transmit_delay_cmd, |
| 5510 | "ospf transmit-delay <1-65535>", |
| 5511 | "OSPF interface commands\n" |
| 5512 | "Link state transmit delay\n" |
| 5513 | "Seconds\n") |
| 5514 | |
| 5515 | DEFUN (no_ip_ospf_transmit_delay, |
| 5516 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5517 | "no ip ospf transmit-delay A.B.C.D", |
| 5518 | NO_STR |
| 5519 | "IP Information\n" |
| 5520 | "OSPF interface commands\n" |
| 5521 | "Link state transmit delay\n" |
| 5522 | "Address of interface") |
| 5523 | { |
| 5524 | struct interface *ifp = vty->index; |
| 5525 | struct in_addr addr; |
| 5526 | int ret; |
| 5527 | struct ospf_if_params *params; |
| 5528 | |
| 5529 | ifp = vty->index; |
| 5530 | params = IF_DEF_PARAMS (ifp); |
| 5531 | |
| 5532 | if (argc == 1) |
| 5533 | { |
| 5534 | ret = inet_aton(argv[0], &addr); |
| 5535 | if (!ret) |
| 5536 | { |
| 5537 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5538 | VTY_NEWLINE); |
| 5539 | return CMD_WARNING; |
| 5540 | } |
| 5541 | |
| 5542 | params = ospf_lookup_if_params (ifp, addr); |
| 5543 | if (params == NULL) |
| 5544 | return CMD_SUCCESS; |
| 5545 | } |
| 5546 | |
| 5547 | UNSET_IF_PARAM (params, transmit_delay); |
| 5548 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5549 | |
| 5550 | if (params != IF_DEF_PARAMS (ifp)) |
| 5551 | { |
| 5552 | ospf_free_if_params (ifp, addr); |
| 5553 | ospf_if_update_params (ifp, addr); |
| 5554 | } |
| 5555 | |
| 5556 | return CMD_SUCCESS; |
| 5557 | } |
| 5558 | |
| 5559 | ALIAS (no_ip_ospf_transmit_delay, |
| 5560 | no_ip_ospf_transmit_delay_cmd, |
| 5561 | "no ip ospf transmit-delay", |
| 5562 | NO_STR |
| 5563 | "IP Information\n" |
| 5564 | "OSPF interface commands\n" |
| 5565 | "Link state transmit delay\n") |
| 5566 | |
| 5567 | ALIAS (no_ip_ospf_transmit_delay, |
| 5568 | no_ospf_transmit_delay_cmd, |
| 5569 | "no ospf transmit-delay", |
| 5570 | NO_STR |
| 5571 | "OSPF interface commands\n" |
| 5572 | "Link state transmit delay\n") |
| 5573 | |
| 5574 | |
| 5575 | DEFUN (ospf_redistribute_source_metric_type, |
| 5576 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5577 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5578 | "Redistribute information from another routing protocol\n" |
| 5579 | "Kernel routes\n" |
| 5580 | "Connected\n" |
| 5581 | "Static routes\n" |
| 5582 | "Routing Information Protocol (RIP)\n" |
| 5583 | "Border Gateway Protocol (BGP)\n" |
| 5584 | "Metric for redistributed routes\n" |
| 5585 | "OSPF default metric\n" |
| 5586 | "OSPF exterior metric type for redistributed routes\n" |
| 5587 | "Set OSPF External Type 1 metrics\n" |
| 5588 | "Set OSPF External Type 2 metrics\n" |
| 5589 | "Route map reference\n" |
| 5590 | "Pointer to route-map entries\n") |
| 5591 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5592 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5593 | int source; |
| 5594 | int type = -1; |
| 5595 | int metric = -1; |
| 5596 | |
| 5597 | /* Get distribute source. */ |
| 5598 | if (!str2distribute_source (argv[0], &source)) |
| 5599 | return CMD_WARNING; |
| 5600 | |
| 5601 | /* Get metric value. */ |
| 5602 | if (argc >= 2) |
| 5603 | if (!str2metric (argv[1], &metric)) |
| 5604 | return CMD_WARNING; |
| 5605 | |
| 5606 | /* Get metric type. */ |
| 5607 | if (argc >= 3) |
| 5608 | if (!str2metric_type (argv[2], &type)) |
| 5609 | return CMD_WARNING; |
| 5610 | |
| 5611 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5612 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5613 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5614 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5615 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5616 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5617 | } |
| 5618 | |
| 5619 | ALIAS (ospf_redistribute_source_metric_type, |
| 5620 | ospf_redistribute_source_metric_type_cmd, |
| 5621 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5622 | "Redistribute information from another routing protocol\n" |
| 5623 | "Kernel routes\n" |
| 5624 | "Connected\n" |
| 5625 | "Static routes\n" |
| 5626 | "Routing Information Protocol (RIP)\n" |
| 5627 | "Border Gateway Protocol (BGP)\n" |
| 5628 | "Metric for redistributed routes\n" |
| 5629 | "OSPF default metric\n" |
| 5630 | "OSPF exterior metric type for redistributed routes\n" |
| 5631 | "Set OSPF External Type 1 metrics\n" |
| 5632 | "Set OSPF External Type 2 metrics\n") |
| 5633 | |
| 5634 | ALIAS (ospf_redistribute_source_metric_type, |
| 5635 | ospf_redistribute_source_metric_cmd, |
| 5636 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5637 | "Redistribute information from another routing protocol\n" |
| 5638 | "Kernel routes\n" |
| 5639 | "Connected\n" |
| 5640 | "Static routes\n" |
| 5641 | "Routing Information Protocol (RIP)\n" |
| 5642 | "Border Gateway Protocol (BGP)\n" |
| 5643 | "Metric for redistributed routes\n" |
| 5644 | "OSPF default metric\n") |
| 5645 | |
| 5646 | DEFUN (ospf_redistribute_source_type_metric, |
| 5647 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5648 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5649 | "Redistribute information from another routing protocol\n" |
| 5650 | "Kernel routes\n" |
| 5651 | "Connected\n" |
| 5652 | "Static routes\n" |
| 5653 | "Routing Information Protocol (RIP)\n" |
| 5654 | "Border Gateway Protocol (BGP)\n" |
| 5655 | "OSPF exterior metric type for redistributed routes\n" |
| 5656 | "Set OSPF External Type 1 metrics\n" |
| 5657 | "Set OSPF External Type 2 metrics\n" |
| 5658 | "Metric for redistributed routes\n" |
| 5659 | "OSPF default metric\n" |
| 5660 | "Route map reference\n" |
| 5661 | "Pointer to route-map entries\n") |
| 5662 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5663 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5664 | int source; |
| 5665 | int type = -1; |
| 5666 | int metric = -1; |
| 5667 | |
| 5668 | /* Get distribute source. */ |
| 5669 | if (!str2distribute_source (argv[0], &source)) |
| 5670 | return CMD_WARNING; |
| 5671 | |
| 5672 | /* Get metric value. */ |
| 5673 | if (argc >= 2) |
| 5674 | if (!str2metric_type (argv[1], &type)) |
| 5675 | return CMD_WARNING; |
| 5676 | |
| 5677 | /* Get metric type. */ |
| 5678 | if (argc >= 3) |
| 5679 | if (!str2metric (argv[2], &metric)) |
| 5680 | return CMD_WARNING; |
| 5681 | |
| 5682 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5683 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5684 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5685 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5686 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5687 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5688 | } |
| 5689 | |
| 5690 | ALIAS (ospf_redistribute_source_type_metric, |
| 5691 | ospf_redistribute_source_type_metric_cmd, |
| 5692 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5693 | "Redistribute information from another routing protocol\n" |
| 5694 | "Kernel routes\n" |
| 5695 | "Connected\n" |
| 5696 | "Static routes\n" |
| 5697 | "Routing Information Protocol (RIP)\n" |
| 5698 | "Border Gateway Protocol (BGP)\n" |
| 5699 | "OSPF exterior metric type for redistributed routes\n" |
| 5700 | "Set OSPF External Type 1 metrics\n" |
| 5701 | "Set OSPF External Type 2 metrics\n" |
| 5702 | "Metric for redistributed routes\n" |
| 5703 | "OSPF default metric\n") |
| 5704 | |
| 5705 | ALIAS (ospf_redistribute_source_type_metric, |
| 5706 | ospf_redistribute_source_type_cmd, |
| 5707 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5708 | "Redistribute information from another routing protocol\n" |
| 5709 | "Kernel routes\n" |
| 5710 | "Connected\n" |
| 5711 | "Static routes\n" |
| 5712 | "Routing Information Protocol (RIP)\n" |
| 5713 | "Border Gateway Protocol (BGP)\n" |
| 5714 | "OSPF exterior metric type for redistributed routes\n" |
| 5715 | "Set OSPF External Type 1 metrics\n" |
| 5716 | "Set OSPF External Type 2 metrics\n") |
| 5717 | |
| 5718 | ALIAS (ospf_redistribute_source_type_metric, |
| 5719 | ospf_redistribute_source_cmd, |
| 5720 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5721 | "Redistribute information from another routing protocol\n" |
| 5722 | "Kernel routes\n" |
| 5723 | "Connected\n" |
| 5724 | "Static routes\n" |
| 5725 | "Routing Information Protocol (RIP)\n" |
| 5726 | "Border Gateway Protocol (BGP)\n") |
| 5727 | |
| 5728 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5729 | ospf_redistribute_source_metric_routemap_cmd, |
| 5730 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5731 | "Redistribute information from another routing protocol\n" |
| 5732 | "Kernel routes\n" |
| 5733 | "Connected\n" |
| 5734 | "Static routes\n" |
| 5735 | "Routing Information Protocol (RIP)\n" |
| 5736 | "Border Gateway Protocol (BGP)\n" |
| 5737 | "Metric for redistributed routes\n" |
| 5738 | "OSPF default metric\n" |
| 5739 | "Route map reference\n" |
| 5740 | "Pointer to route-map entries\n") |
| 5741 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5742 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5743 | int source; |
| 5744 | int metric = -1; |
| 5745 | |
| 5746 | /* Get distribute source. */ |
| 5747 | if (!str2distribute_source (argv[0], &source)) |
| 5748 | return CMD_WARNING; |
| 5749 | |
| 5750 | /* Get metric value. */ |
| 5751 | if (argc >= 2) |
| 5752 | if (!str2metric (argv[1], &metric)) |
| 5753 | return CMD_WARNING; |
| 5754 | |
| 5755 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5756 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5757 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5758 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5759 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5760 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5761 | } |
| 5762 | |
| 5763 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5764 | ospf_redistribute_source_type_routemap_cmd, |
| 5765 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5766 | "Redistribute information from another routing protocol\n" |
| 5767 | "Kernel routes\n" |
| 5768 | "Connected\n" |
| 5769 | "Static routes\n" |
| 5770 | "Routing Information Protocol (RIP)\n" |
| 5771 | "Border Gateway Protocol (BGP)\n" |
| 5772 | "OSPF exterior metric type for redistributed routes\n" |
| 5773 | "Set OSPF External Type 1 metrics\n" |
| 5774 | "Set OSPF External Type 2 metrics\n" |
| 5775 | "Route map reference\n" |
| 5776 | "Pointer to route-map entries\n") |
| 5777 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5778 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5779 | int source; |
| 5780 | int type = -1; |
| 5781 | |
| 5782 | /* Get distribute source. */ |
| 5783 | if (!str2distribute_source (argv[0], &source)) |
| 5784 | return CMD_WARNING; |
| 5785 | |
| 5786 | /* Get metric value. */ |
| 5787 | if (argc >= 2) |
| 5788 | if (!str2metric_type (argv[1], &type)) |
| 5789 | return CMD_WARNING; |
| 5790 | |
| 5791 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5792 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5793 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5794 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5795 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5796 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5797 | } |
| 5798 | |
| 5799 | DEFUN (ospf_redistribute_source_routemap, |
| 5800 | ospf_redistribute_source_routemap_cmd, |
| 5801 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5802 | "Redistribute information from another routing protocol\n" |
| 5803 | "Kernel routes\n" |
| 5804 | "Connected\n" |
| 5805 | "Static routes\n" |
| 5806 | "Routing Information Protocol (RIP)\n" |
| 5807 | "Border Gateway Protocol (BGP)\n" |
| 5808 | "Route map reference\n" |
| 5809 | "Pointer to route-map entries\n") |
| 5810 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5811 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5812 | int source; |
| 5813 | |
| 5814 | /* Get distribute source. */ |
| 5815 | if (!str2distribute_source (argv[0], &source)) |
| 5816 | return CMD_WARNING; |
| 5817 | |
| 5818 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5819 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5820 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5821 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5822 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5823 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5824 | } |
| 5825 | |
| 5826 | DEFUN (no_ospf_redistribute_source, |
| 5827 | no_ospf_redistribute_source_cmd, |
| 5828 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5829 | NO_STR |
| 5830 | "Redistribute information from another routing protocol\n" |
| 5831 | "Kernel routes\n" |
| 5832 | "Connected\n" |
| 5833 | "Static routes\n" |
| 5834 | "Routing Information Protocol (RIP)\n" |
| 5835 | "Border Gateway Protocol (BGP)\n") |
| 5836 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5837 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5838 | int source; |
| 5839 | |
| 5840 | if (!str2distribute_source (argv[0], &source)) |
| 5841 | return CMD_WARNING; |
| 5842 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5843 | ospf_routemap_unset (ospf, source); |
| 5844 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5845 | } |
| 5846 | |
| 5847 | DEFUN (ospf_distribute_list_out, |
| 5848 | ospf_distribute_list_out_cmd, |
| 5849 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5850 | "Filter networks in routing updates\n" |
| 5851 | "Access-list name\n" |
| 5852 | OUT_STR |
| 5853 | "Kernel routes\n" |
| 5854 | "Connected\n" |
| 5855 | "Static routes\n" |
| 5856 | "Routing Information Protocol (RIP)\n" |
| 5857 | "Border Gateway Protocol (BGP)\n") |
| 5858 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5859 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5860 | int source; |
| 5861 | |
| 5862 | /* Get distribute source. */ |
| 5863 | if (!str2distribute_source (argv[1], &source)) |
| 5864 | return CMD_WARNING; |
| 5865 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5866 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5867 | } |
| 5868 | |
| 5869 | DEFUN (no_ospf_distribute_list_out, |
| 5870 | no_ospf_distribute_list_out_cmd, |
| 5871 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5872 | NO_STR |
| 5873 | "Filter networks in routing updates\n" |
| 5874 | "Access-list name\n" |
| 5875 | OUT_STR |
| 5876 | "Kernel routes\n" |
| 5877 | "Connected\n" |
| 5878 | "Static routes\n" |
| 5879 | "Routing Information Protocol (RIP)\n" |
| 5880 | "Border Gateway Protocol (BGP)\n") |
| 5881 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5882 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5883 | int source; |
| 5884 | |
| 5885 | if (!str2distribute_source (argv[1], &source)) |
| 5886 | return CMD_WARNING; |
| 5887 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5888 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5889 | } |
| 5890 | |
| 5891 | /* Default information originate. */ |
| 5892 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5893 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5894 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5895 | "Control distribution of default information\n" |
| 5896 | "Distribute a default route\n" |
| 5897 | "OSPF default metric\n" |
| 5898 | "OSPF metric\n" |
| 5899 | "OSPF metric type for default routes\n" |
| 5900 | "Set OSPF External Type 1 metrics\n" |
| 5901 | "Set OSPF External Type 2 metrics\n" |
| 5902 | "Route map reference\n" |
| 5903 | "Pointer to route-map entries\n") |
| 5904 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5905 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5906 | int type = -1; |
| 5907 | int metric = -1; |
| 5908 | |
| 5909 | /* Get metric value. */ |
| 5910 | if (argc >= 1) |
| 5911 | if (!str2metric (argv[0], &metric)) |
| 5912 | return CMD_WARNING; |
| 5913 | |
| 5914 | /* Get metric type. */ |
| 5915 | if (argc >= 2) |
| 5916 | if (!str2metric_type (argv[1], &type)) |
| 5917 | return CMD_WARNING; |
| 5918 | |
| 5919 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5920 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5921 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5922 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5923 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5924 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5925 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | } |
| 5927 | |
| 5928 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5929 | ospf_default_information_originate_metric_type_cmd, |
| 5930 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5931 | "Control distribution of default information\n" |
| 5932 | "Distribute a default route\n" |
| 5933 | "OSPF default metric\n" |
| 5934 | "OSPF metric\n" |
| 5935 | "OSPF metric type for default routes\n" |
| 5936 | "Set OSPF External Type 1 metrics\n" |
| 5937 | "Set OSPF External Type 2 metrics\n") |
| 5938 | |
| 5939 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5940 | ospf_default_information_originate_metric_cmd, |
| 5941 | "default-information originate metric <0-16777214>", |
| 5942 | "Control distribution of default information\n" |
| 5943 | "Distribute a default route\n" |
| 5944 | "OSPF default metric\n" |
| 5945 | "OSPF metric\n") |
| 5946 | |
| 5947 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5948 | ospf_default_information_originate_cmd, |
| 5949 | "default-information originate", |
| 5950 | "Control distribution of default information\n" |
| 5951 | "Distribute a default route\n") |
| 5952 | |
| 5953 | /* Default information originate. */ |
| 5954 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5955 | ospf_default_information_originate_metric_routemap_cmd, |
| 5956 | "default-information originate metric <0-16777214> route-map WORD", |
| 5957 | "Control distribution of default information\n" |
| 5958 | "Distribute a default route\n" |
| 5959 | "OSPF default metric\n" |
| 5960 | "OSPF metric\n" |
| 5961 | "Route map reference\n" |
| 5962 | "Pointer to route-map entries\n") |
| 5963 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5964 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5965 | int metric = -1; |
| 5966 | |
| 5967 | /* Get metric value. */ |
| 5968 | if (argc >= 1) |
| 5969 | if (!str2metric (argv[0], &metric)) |
| 5970 | return CMD_WARNING; |
| 5971 | |
| 5972 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5973 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5974 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5975 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5977 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5978 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5979 | } |
| 5980 | |
| 5981 | /* Default information originate. */ |
| 5982 | DEFUN (ospf_default_information_originate_routemap, |
| 5983 | ospf_default_information_originate_routemap_cmd, |
| 5984 | "default-information originate route-map WORD", |
| 5985 | "Control distribution of default information\n" |
| 5986 | "Distribute a default route\n" |
| 5987 | "Route map reference\n" |
| 5988 | "Pointer to route-map entries\n") |
| 5989 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5990 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5991 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5992 | if (argc == 1) |
| 5993 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5994 | else |
| 5995 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5996 | |
| 5997 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5998 | } |
| 5999 | |
| 6000 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 6001 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 6002 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 6003 | "Control distribution of default information\n" |
| 6004 | "Distribute a default route\n" |
| 6005 | "OSPF metric type for default routes\n" |
| 6006 | "Set OSPF External Type 1 metrics\n" |
| 6007 | "Set OSPF External Type 2 metrics\n" |
| 6008 | "OSPF default metric\n" |
| 6009 | "OSPF metric\n" |
| 6010 | "Route map reference\n" |
| 6011 | "Pointer to route-map entries\n") |
| 6012 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6013 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6014 | int type = -1; |
| 6015 | int metric = -1; |
| 6016 | |
| 6017 | /* Get metric type. */ |
| 6018 | if (argc >= 1) |
| 6019 | if (!str2metric_type (argv[0], &type)) |
| 6020 | return CMD_WARNING; |
| 6021 | |
| 6022 | /* Get metric value. */ |
| 6023 | if (argc >= 2) |
| 6024 | if (!str2metric (argv[1], &metric)) |
| 6025 | return CMD_WARNING; |
| 6026 | |
| 6027 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6028 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6029 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6030 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6031 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6032 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6033 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6034 | } |
| 6035 | |
| 6036 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6037 | ospf_default_information_originate_type_metric_cmd, |
| 6038 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 6039 | "Control distribution of default information\n" |
| 6040 | "Distribute a default route\n" |
| 6041 | "OSPF metric type for default routes\n" |
| 6042 | "Set OSPF External Type 1 metrics\n" |
| 6043 | "Set OSPF External Type 2 metrics\n" |
| 6044 | "OSPF default metric\n" |
| 6045 | "OSPF metric\n") |
| 6046 | |
| 6047 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6048 | ospf_default_information_originate_type_cmd, |
| 6049 | "default-information originate metric-type (1|2)", |
| 6050 | "Control distribution of default information\n" |
| 6051 | "Distribute a default route\n" |
| 6052 | "OSPF metric type for default routes\n" |
| 6053 | "Set OSPF External Type 1 metrics\n" |
| 6054 | "Set OSPF External Type 2 metrics\n") |
| 6055 | |
| 6056 | DEFUN (ospf_default_information_originate_type_routemap, |
| 6057 | ospf_default_information_originate_type_routemap_cmd, |
| 6058 | "default-information originate metric-type (1|2) route-map WORD", |
| 6059 | "Control distribution of default information\n" |
| 6060 | "Distribute a default route\n" |
| 6061 | "OSPF metric type for default routes\n" |
| 6062 | "Set OSPF External Type 1 metrics\n" |
| 6063 | "Set OSPF External Type 2 metrics\n" |
| 6064 | "Route map reference\n" |
| 6065 | "Pointer to route-map entries\n") |
| 6066 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6067 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6068 | int type = -1; |
| 6069 | |
| 6070 | /* Get metric type. */ |
| 6071 | if (argc >= 1) |
| 6072 | if (!str2metric_type (argv[0], &type)) |
| 6073 | return CMD_WARNING; |
| 6074 | |
| 6075 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6076 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6077 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6078 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6079 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6080 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6081 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6082 | } |
| 6083 | |
| 6084 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 6085 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 6086 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 6087 | "Control distribution of default information\n" |
| 6088 | "Distribute a default route\n" |
| 6089 | "Always advertise default route\n" |
| 6090 | "OSPF default metric\n" |
| 6091 | "OSPF metric\n" |
| 6092 | "OSPF metric type for default routes\n" |
| 6093 | "Set OSPF External Type 1 metrics\n" |
| 6094 | "Set OSPF External Type 2 metrics\n" |
| 6095 | "Route map reference\n" |
| 6096 | "Pointer to route-map entries\n") |
| 6097 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6098 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6099 | int type = -1; |
| 6100 | int metric = -1; |
| 6101 | |
| 6102 | /* Get metric value. */ |
| 6103 | if (argc >= 1) |
| 6104 | if (!str2metric (argv[0], &metric)) |
| 6105 | return CMD_WARNING; |
| 6106 | |
| 6107 | /* Get metric type. */ |
| 6108 | if (argc >= 2) |
| 6109 | if (!str2metric_type (argv[1], &type)) |
| 6110 | return CMD_WARNING; |
| 6111 | |
| 6112 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6113 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6114 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6115 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6116 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6117 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6118 | type, metric); |
| 6119 | } |
| 6120 | |
| 6121 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6122 | ospf_default_information_originate_always_metric_type_cmd, |
| 6123 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 6124 | "Control distribution of default information\n" |
| 6125 | "Distribute a default route\n" |
| 6126 | "Always advertise default route\n" |
| 6127 | "OSPF default metric\n" |
| 6128 | "OSPF metric\n" |
| 6129 | "OSPF metric type for default routes\n" |
| 6130 | "Set OSPF External Type 1 metrics\n" |
| 6131 | "Set OSPF External Type 2 metrics\n") |
| 6132 | |
| 6133 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6134 | ospf_default_information_originate_always_metric_cmd, |
| 6135 | "default-information originate always metric <0-16777214>", |
| 6136 | "Control distribution of default information\n" |
| 6137 | "Distribute a default route\n" |
| 6138 | "Always advertise default route\n" |
| 6139 | "OSPF default metric\n" |
| 6140 | "OSPF metric\n" |
| 6141 | "OSPF metric type for default routes\n") |
| 6142 | |
| 6143 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6144 | ospf_default_information_originate_always_cmd, |
| 6145 | "default-information originate always", |
| 6146 | "Control distribution of default information\n" |
| 6147 | "Distribute a default route\n" |
| 6148 | "Always advertise default route\n") |
| 6149 | |
| 6150 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 6151 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 6152 | "default-information originate always metric <0-16777214> route-map WORD", |
| 6153 | "Control distribution of default information\n" |
| 6154 | "Distribute a default route\n" |
| 6155 | "Always advertise default route\n" |
| 6156 | "OSPF default metric\n" |
| 6157 | "OSPF metric\n" |
| 6158 | "Route map reference\n" |
| 6159 | "Pointer to route-map entries\n") |
| 6160 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6161 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6162 | int metric = -1; |
| 6163 | |
| 6164 | /* Get metric value. */ |
| 6165 | if (argc >= 1) |
| 6166 | if (!str2metric (argv[0], &metric)) |
| 6167 | return CMD_WARNING; |
| 6168 | |
| 6169 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6170 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6171 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6172 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6173 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6174 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 6175 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6176 | } |
| 6177 | |
| 6178 | DEFUN (ospf_default_information_originate_always_routemap, |
| 6179 | ospf_default_information_originate_always_routemap_cmd, |
| 6180 | "default-information originate always route-map WORD", |
| 6181 | "Control distribution of default information\n" |
| 6182 | "Distribute a default route\n" |
| 6183 | "Always advertise default route\n" |
| 6184 | "Route map reference\n" |
| 6185 | "Pointer to route-map entries\n") |
| 6186 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6187 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6188 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6189 | if (argc == 1) |
| 6190 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 6191 | else |
| 6192 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6193 | |
| 6194 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6195 | } |
| 6196 | |
| 6197 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 6198 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 6199 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 6200 | "Control distribution of default information\n" |
| 6201 | "Distribute a default route\n" |
| 6202 | "Always advertise default route\n" |
| 6203 | "OSPF metric type for default routes\n" |
| 6204 | "Set OSPF External Type 1 metrics\n" |
| 6205 | "Set OSPF External Type 2 metrics\n" |
| 6206 | "OSPF default metric\n" |
| 6207 | "OSPF metric\n" |
| 6208 | "Route map reference\n" |
| 6209 | "Pointer to route-map entries\n") |
| 6210 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6211 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6212 | int type = -1; |
| 6213 | int metric = -1; |
| 6214 | |
| 6215 | /* Get metric type. */ |
| 6216 | if (argc >= 1) |
| 6217 | if (!str2metric_type (argv[0], &type)) |
| 6218 | return CMD_WARNING; |
| 6219 | |
| 6220 | /* Get metric value. */ |
| 6221 | if (argc >= 2) |
| 6222 | if (!str2metric (argv[1], &metric)) |
| 6223 | return CMD_WARNING; |
| 6224 | |
| 6225 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6226 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6228 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6229 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6230 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6231 | type, metric); |
| 6232 | } |
| 6233 | |
| 6234 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6235 | ospf_default_information_originate_always_type_metric_cmd, |
| 6236 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 6237 | "Control distribution of default information\n" |
| 6238 | "Distribute a default route\n" |
| 6239 | "Always advertise default route\n" |
| 6240 | "OSPF metric type for default routes\n" |
| 6241 | "Set OSPF External Type 1 metrics\n" |
| 6242 | "Set OSPF External Type 2 metrics\n" |
| 6243 | "OSPF default metric\n" |
| 6244 | "OSPF metric\n") |
| 6245 | |
| 6246 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6247 | ospf_default_information_originate_always_type_cmd, |
| 6248 | "default-information originate always metric-type (1|2)", |
| 6249 | "Control distribution of default information\n" |
| 6250 | "Distribute a default route\n" |
| 6251 | "Always advertise default route\n" |
| 6252 | "OSPF metric type for default routes\n" |
| 6253 | "Set OSPF External Type 1 metrics\n" |
| 6254 | "Set OSPF External Type 2 metrics\n") |
| 6255 | |
| 6256 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 6257 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6258 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6259 | "Control distribution of default information\n" |
| 6260 | "Distribute a default route\n" |
| 6261 | "Always advertise default route\n" |
| 6262 | "OSPF metric type for default routes\n" |
| 6263 | "Set OSPF External Type 1 metrics\n" |
| 6264 | "Set OSPF External Type 2 metrics\n" |
| 6265 | "Route map reference\n" |
| 6266 | "Pointer to route-map entries\n") |
| 6267 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6268 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6269 | int type = -1; |
| 6270 | |
| 6271 | /* Get metric type. */ |
| 6272 | if (argc >= 1) |
| 6273 | if (!str2metric_type (argv[0], &type)) |
| 6274 | return CMD_WARNING; |
| 6275 | |
| 6276 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6277 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6278 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6279 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6280 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6281 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6282 | type, -1); |
| 6283 | } |
| 6284 | |
| 6285 | DEFUN (no_ospf_default_information_originate, |
| 6286 | no_ospf_default_information_originate_cmd, |
| 6287 | "no default-information originate", |
| 6288 | NO_STR |
| 6289 | "Control distribution of default information\n" |
| 6290 | "Distribute a default route\n") |
| 6291 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6292 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6293 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6294 | |
| 6295 | p.family = AF_INET; |
| 6296 | p.prefix.s_addr = 0; |
| 6297 | p.prefixlen = 0; |
| 6298 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6299 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6300 | |
| 6301 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6302 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6303 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6304 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6305 | } |
| 6306 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6307 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6308 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6309 | } |
| 6310 | |
| 6311 | DEFUN (ospf_default_metric, |
| 6312 | ospf_default_metric_cmd, |
| 6313 | "default-metric <0-16777214>", |
| 6314 | "Set metric of redistributed routes\n" |
| 6315 | "Default metric\n") |
| 6316 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6317 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6318 | int metric = -1; |
| 6319 | |
| 6320 | if (!str2metric (argv[0], &metric)) |
| 6321 | return CMD_WARNING; |
| 6322 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6323 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6324 | |
| 6325 | return CMD_SUCCESS; |
| 6326 | } |
| 6327 | |
| 6328 | DEFUN (no_ospf_default_metric, |
| 6329 | no_ospf_default_metric_cmd, |
| 6330 | "no default-metric", |
| 6331 | NO_STR |
| 6332 | "Set metric of redistributed routes\n") |
| 6333 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6334 | struct ospf *ospf = vty->index; |
| 6335 | |
| 6336 | ospf->default_metric = -1; |
| 6337 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6338 | return CMD_SUCCESS; |
| 6339 | } |
| 6340 | |
| 6341 | ALIAS (no_ospf_default_metric, |
| 6342 | no_ospf_default_metric_val_cmd, |
| 6343 | "no default-metric <0-16777214>", |
| 6344 | NO_STR |
| 6345 | "Set metric of redistributed routes\n" |
| 6346 | "Default metric\n") |
| 6347 | |
| 6348 | DEFUN (ospf_distance, |
| 6349 | ospf_distance_cmd, |
| 6350 | "distance <1-255>", |
| 6351 | "Define an administrative distance\n" |
| 6352 | "OSPF Administrative distance\n") |
| 6353 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6354 | struct ospf *ospf = vty->index; |
| 6355 | |
| 6356 | ospf->distance_all = atoi (argv[0]); |
| 6357 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6358 | return CMD_SUCCESS; |
| 6359 | } |
| 6360 | |
| 6361 | DEFUN (no_ospf_distance, |
| 6362 | no_ospf_distance_cmd, |
| 6363 | "no distance <1-255>", |
| 6364 | NO_STR |
| 6365 | "Define an administrative distance\n" |
| 6366 | "OSPF Administrative distance\n") |
| 6367 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6368 | struct ospf *ospf = vty->index; |
| 6369 | |
| 6370 | ospf->distance_all = 0; |
| 6371 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6372 | return CMD_SUCCESS; |
| 6373 | } |
| 6374 | |
| 6375 | DEFUN (no_ospf_distance_ospf, |
| 6376 | no_ospf_distance_ospf_cmd, |
| 6377 | "no distance ospf", |
| 6378 | NO_STR |
| 6379 | "Define an administrative distance\n" |
| 6380 | "OSPF Administrative distance\n" |
| 6381 | "OSPF Distance\n") |
| 6382 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6383 | struct ospf *ospf = vty->index; |
| 6384 | |
| 6385 | ospf->distance_intra = 0; |
| 6386 | ospf->distance_inter = 0; |
| 6387 | ospf->distance_external = 0; |
| 6388 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6389 | return CMD_SUCCESS; |
| 6390 | } |
| 6391 | |
| 6392 | DEFUN (ospf_distance_ospf_intra, |
| 6393 | ospf_distance_ospf_intra_cmd, |
| 6394 | "distance ospf intra-area <1-255>", |
| 6395 | "Define an administrative distance\n" |
| 6396 | "OSPF Administrative distance\n" |
| 6397 | "Intra-area routes\n" |
| 6398 | "Distance for intra-area routes\n") |
| 6399 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6400 | struct ospf *ospf = vty->index; |
| 6401 | |
| 6402 | ospf->distance_intra = atoi (argv[0]); |
| 6403 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6404 | return CMD_SUCCESS; |
| 6405 | } |
| 6406 | |
| 6407 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6408 | ospf_distance_ospf_intra_inter_cmd, |
| 6409 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6410 | "Define an administrative distance\n" |
| 6411 | "OSPF Administrative distance\n" |
| 6412 | "Intra-area routes\n" |
| 6413 | "Distance for intra-area routes\n" |
| 6414 | "Inter-area routes\n" |
| 6415 | "Distance for inter-area routes\n") |
| 6416 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6417 | struct ospf *ospf = vty->index; |
| 6418 | |
| 6419 | ospf->distance_intra = atoi (argv[0]); |
| 6420 | ospf->distance_inter = atoi (argv[1]); |
| 6421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6422 | return CMD_SUCCESS; |
| 6423 | } |
| 6424 | |
| 6425 | DEFUN (ospf_distance_ospf_intra_external, |
| 6426 | ospf_distance_ospf_intra_external_cmd, |
| 6427 | "distance ospf intra-area <1-255> external <1-255>", |
| 6428 | "Define an administrative distance\n" |
| 6429 | "OSPF Administrative distance\n" |
| 6430 | "Intra-area routes\n" |
| 6431 | "Distance for intra-area routes\n" |
| 6432 | "External routes\n" |
| 6433 | "Distance for external routes\n") |
| 6434 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6435 | struct ospf *ospf = vty->index; |
| 6436 | |
| 6437 | ospf->distance_intra = atoi (argv[0]); |
| 6438 | ospf->distance_external = atoi (argv[1]); |
| 6439 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6440 | return CMD_SUCCESS; |
| 6441 | } |
| 6442 | |
| 6443 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6444 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6445 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6446 | "Define an administrative distance\n" |
| 6447 | "OSPF Administrative distance\n" |
| 6448 | "Intra-area routes\n" |
| 6449 | "Distance for intra-area routes\n" |
| 6450 | "Inter-area routes\n" |
| 6451 | "Distance for inter-area routes\n" |
| 6452 | "External routes\n" |
| 6453 | "Distance for external routes\n") |
| 6454 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6455 | struct ospf *ospf = vty->index; |
| 6456 | |
| 6457 | ospf->distance_intra = atoi (argv[0]); |
| 6458 | ospf->distance_inter = atoi (argv[1]); |
| 6459 | ospf->distance_external = atoi (argv[2]); |
| 6460 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6461 | return CMD_SUCCESS; |
| 6462 | } |
| 6463 | |
| 6464 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6465 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6466 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6467 | "Define an administrative distance\n" |
| 6468 | "OSPF Administrative distance\n" |
| 6469 | "Intra-area routes\n" |
| 6470 | "Distance for intra-area routes\n" |
| 6471 | "External routes\n" |
| 6472 | "Distance for external routes\n" |
| 6473 | "Inter-area routes\n" |
| 6474 | "Distance for inter-area routes\n") |
| 6475 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6476 | struct ospf *ospf = vty->index; |
| 6477 | |
| 6478 | ospf->distance_intra = atoi (argv[0]); |
| 6479 | ospf->distance_external = atoi (argv[1]); |
| 6480 | ospf->distance_inter = atoi (argv[2]); |
| 6481 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6482 | return CMD_SUCCESS; |
| 6483 | } |
| 6484 | |
| 6485 | DEFUN (ospf_distance_ospf_inter, |
| 6486 | ospf_distance_ospf_inter_cmd, |
| 6487 | "distance ospf inter-area <1-255>", |
| 6488 | "Define an administrative distance\n" |
| 6489 | "OSPF Administrative distance\n" |
| 6490 | "Inter-area routes\n" |
| 6491 | "Distance for inter-area routes\n") |
| 6492 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6493 | struct ospf *ospf = vty->index; |
| 6494 | |
| 6495 | ospf->distance_inter = atoi (argv[0]); |
| 6496 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6497 | return CMD_SUCCESS; |
| 6498 | } |
| 6499 | |
| 6500 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6501 | ospf_distance_ospf_inter_intra_cmd, |
| 6502 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6503 | "Define an administrative distance\n" |
| 6504 | "OSPF Administrative distance\n" |
| 6505 | "Inter-area routes\n" |
| 6506 | "Distance for inter-area routes\n" |
| 6507 | "Intra-area routes\n" |
| 6508 | "Distance for intra-area routes\n") |
| 6509 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6510 | struct ospf *ospf = vty->index; |
| 6511 | |
| 6512 | ospf->distance_inter = atoi (argv[0]); |
| 6513 | ospf->distance_intra = atoi (argv[1]); |
| 6514 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6515 | return CMD_SUCCESS; |
| 6516 | } |
| 6517 | |
| 6518 | DEFUN (ospf_distance_ospf_inter_external, |
| 6519 | ospf_distance_ospf_inter_external_cmd, |
| 6520 | "distance ospf inter-area <1-255> external <1-255>", |
| 6521 | "Define an administrative distance\n" |
| 6522 | "OSPF Administrative distance\n" |
| 6523 | "Inter-area routes\n" |
| 6524 | "Distance for inter-area routes\n" |
| 6525 | "External routes\n" |
| 6526 | "Distance for external routes\n") |
| 6527 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6528 | struct ospf *ospf = vty->index; |
| 6529 | |
| 6530 | ospf->distance_inter = atoi (argv[0]); |
| 6531 | ospf->distance_external = atoi (argv[1]); |
| 6532 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6533 | return CMD_SUCCESS; |
| 6534 | } |
| 6535 | |
| 6536 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6537 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6538 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6539 | "Define an administrative distance\n" |
| 6540 | "OSPF Administrative distance\n" |
| 6541 | "Inter-area routes\n" |
| 6542 | "Distance for inter-area routes\n" |
| 6543 | "Intra-area routes\n" |
| 6544 | "Distance for intra-area routes\n" |
| 6545 | "External routes\n" |
| 6546 | "Distance for external routes\n") |
| 6547 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6548 | struct ospf *ospf = vty->index; |
| 6549 | |
| 6550 | ospf->distance_inter = atoi (argv[0]); |
| 6551 | ospf->distance_intra = atoi (argv[1]); |
| 6552 | ospf->distance_external = atoi (argv[2]); |
| 6553 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6554 | return CMD_SUCCESS; |
| 6555 | } |
| 6556 | |
| 6557 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6558 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6559 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6560 | "Define an administrative distance\n" |
| 6561 | "OSPF Administrative distance\n" |
| 6562 | "Inter-area routes\n" |
| 6563 | "Distance for inter-area routes\n" |
| 6564 | "External routes\n" |
| 6565 | "Distance for external routes\n" |
| 6566 | "Intra-area routes\n" |
| 6567 | "Distance for intra-area routes\n") |
| 6568 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6569 | struct ospf *ospf = vty->index; |
| 6570 | |
| 6571 | ospf->distance_inter = atoi (argv[0]); |
| 6572 | ospf->distance_external = atoi (argv[1]); |
| 6573 | ospf->distance_intra = atoi (argv[2]); |
| 6574 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6575 | return CMD_SUCCESS; |
| 6576 | } |
| 6577 | |
| 6578 | DEFUN (ospf_distance_ospf_external, |
| 6579 | ospf_distance_ospf_external_cmd, |
| 6580 | "distance ospf external <1-255>", |
| 6581 | "Define an administrative distance\n" |
| 6582 | "OSPF Administrative distance\n" |
| 6583 | "External routes\n" |
| 6584 | "Distance for external routes\n") |
| 6585 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6586 | struct ospf *ospf = vty->index; |
| 6587 | |
| 6588 | ospf->distance_external = atoi (argv[0]); |
| 6589 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6590 | return CMD_SUCCESS; |
| 6591 | } |
| 6592 | |
| 6593 | DEFUN (ospf_distance_ospf_external_intra, |
| 6594 | ospf_distance_ospf_external_intra_cmd, |
| 6595 | "distance ospf external <1-255> intra-area <1-255>", |
| 6596 | "Define an administrative distance\n" |
| 6597 | "OSPF Administrative distance\n" |
| 6598 | "External routes\n" |
| 6599 | "Distance for external routes\n" |
| 6600 | "Intra-area routes\n" |
| 6601 | "Distance for intra-area routes\n") |
| 6602 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6603 | struct ospf *ospf = vty->index; |
| 6604 | |
| 6605 | ospf->distance_external = atoi (argv[0]); |
| 6606 | ospf->distance_intra = atoi (argv[1]); |
| 6607 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6608 | return CMD_SUCCESS; |
| 6609 | } |
| 6610 | |
| 6611 | DEFUN (ospf_distance_ospf_external_inter, |
| 6612 | ospf_distance_ospf_external_inter_cmd, |
| 6613 | "distance ospf external <1-255> inter-area <1-255>", |
| 6614 | "Define an administrative distance\n" |
| 6615 | "OSPF Administrative distance\n" |
| 6616 | "External routes\n" |
| 6617 | "Distance for external routes\n" |
| 6618 | "Inter-area routes\n" |
| 6619 | "Distance for inter-area routes\n") |
| 6620 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6621 | struct ospf *ospf = vty->index; |
| 6622 | |
| 6623 | ospf->distance_external = atoi (argv[0]); |
| 6624 | ospf->distance_inter = atoi (argv[1]); |
| 6625 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6626 | return CMD_SUCCESS; |
| 6627 | } |
| 6628 | |
| 6629 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6630 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6631 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6632 | "Define an administrative distance\n" |
| 6633 | "OSPF Administrative distance\n" |
| 6634 | "External routes\n" |
| 6635 | "Distance for external routes\n" |
| 6636 | "Intra-area routes\n" |
| 6637 | "Distance for intra-area routes\n" |
| 6638 | "Inter-area routes\n" |
| 6639 | "Distance for inter-area routes\n") |
| 6640 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6641 | struct ospf *ospf = vty->index; |
| 6642 | |
| 6643 | ospf->distance_external = atoi (argv[0]); |
| 6644 | ospf->distance_intra = atoi (argv[1]); |
| 6645 | ospf->distance_inter = atoi (argv[2]); |
| 6646 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6647 | return CMD_SUCCESS; |
| 6648 | } |
| 6649 | |
| 6650 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6651 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6652 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6653 | "Define an administrative distance\n" |
| 6654 | "OSPF Administrative distance\n" |
| 6655 | "External routes\n" |
| 6656 | "Distance for external routes\n" |
| 6657 | "Inter-area routes\n" |
| 6658 | "Distance for inter-area routes\n" |
| 6659 | "Intra-area routes\n" |
| 6660 | "Distance for intra-area routes\n") |
| 6661 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6662 | struct ospf *ospf = vty->index; |
| 6663 | |
| 6664 | ospf->distance_external = atoi (argv[0]); |
| 6665 | ospf->distance_inter = atoi (argv[1]); |
| 6666 | ospf->distance_intra = atoi (argv[2]); |
| 6667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6668 | return CMD_SUCCESS; |
| 6669 | } |
| 6670 | |
| 6671 | DEFUN (ospf_distance_source, |
| 6672 | ospf_distance_source_cmd, |
| 6673 | "distance <1-255> A.B.C.D/M", |
| 6674 | "Administrative distance\n" |
| 6675 | "Distance value\n" |
| 6676 | "IP source prefix\n") |
| 6677 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6678 | struct ospf *ospf = vty->index; |
| 6679 | |
| 6680 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6681 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6682 | return CMD_SUCCESS; |
| 6683 | } |
| 6684 | |
| 6685 | DEFUN (no_ospf_distance_source, |
| 6686 | no_ospf_distance_source_cmd, |
| 6687 | "no distance <1-255> A.B.C.D/M", |
| 6688 | NO_STR |
| 6689 | "Administrative distance\n" |
| 6690 | "Distance value\n" |
| 6691 | "IP source prefix\n") |
| 6692 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6693 | struct ospf *ospf = vty->index; |
| 6694 | |
| 6695 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6696 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6697 | return CMD_SUCCESS; |
| 6698 | } |
| 6699 | |
| 6700 | DEFUN (ospf_distance_source_access_list, |
| 6701 | ospf_distance_source_access_list_cmd, |
| 6702 | "distance <1-255> A.B.C.D/M WORD", |
| 6703 | "Administrative distance\n" |
| 6704 | "Distance value\n" |
| 6705 | "IP source prefix\n" |
| 6706 | "Access list name\n") |
| 6707 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6708 | struct ospf *ospf = vty->index; |
| 6709 | |
| 6710 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6711 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6712 | return CMD_SUCCESS; |
| 6713 | } |
| 6714 | |
| 6715 | DEFUN (no_ospf_distance_source_access_list, |
| 6716 | no_ospf_distance_source_access_list_cmd, |
| 6717 | "no distance <1-255> A.B.C.D/M WORD", |
| 6718 | NO_STR |
| 6719 | "Administrative distance\n" |
| 6720 | "Distance value\n" |
| 6721 | "IP source prefix\n" |
| 6722 | "Access list name\n") |
| 6723 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6724 | struct ospf *ospf = vty->index; |
| 6725 | |
| 6726 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6727 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6728 | return CMD_SUCCESS; |
| 6729 | } |
| 6730 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6731 | DEFUN (ip_ospf_mtu_ignore, |
| 6732 | ip_ospf_mtu_ignore_addr_cmd, |
| 6733 | "ip ospf mtu-ignore A.B.C.D", |
| 6734 | "IP Information\n" |
| 6735 | "OSPF interface commands\n" |
| 6736 | "Disable mtu mismatch detection\n" |
| 6737 | "Address of interface") |
| 6738 | { |
| 6739 | struct interface *ifp = vty->index; |
| 6740 | struct in_addr addr; |
| 6741 | int ret; |
| 6742 | |
| 6743 | struct ospf_if_params *params; |
| 6744 | params = IF_DEF_PARAMS (ifp); |
| 6745 | |
| 6746 | if (argc == 1) |
| 6747 | { |
| 6748 | ret = inet_aton(argv[0], &addr); |
| 6749 | if (!ret) |
| 6750 | { |
| 6751 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6752 | VTY_NEWLINE); |
| 6753 | return CMD_WARNING; |
| 6754 | } |
| 6755 | params = ospf_get_if_params (ifp, addr); |
| 6756 | ospf_if_update_params (ifp, addr); |
| 6757 | } |
| 6758 | params->mtu_ignore = 1; |
| 6759 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6760 | SET_IF_PARAM (params, mtu_ignore); |
| 6761 | else |
| 6762 | { |
| 6763 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6764 | if (params != IF_DEF_PARAMS (ifp)) |
| 6765 | { |
| 6766 | ospf_free_if_params (ifp, addr); |
| 6767 | ospf_if_update_params (ifp, addr); |
| 6768 | } |
| 6769 | } |
| 6770 | return CMD_SUCCESS; |
| 6771 | } |
| 6772 | |
| 6773 | ALIAS (ip_ospf_mtu_ignore, |
| 6774 | ip_ospf_mtu_ignore_cmd, |
| 6775 | "ip ospf mtu-ignore", |
| 6776 | "IP Information\n" |
| 6777 | "OSPF interface commands\n" |
| 6778 | "Disable mtu mismatch detection\n") |
| 6779 | |
| 6780 | |
| 6781 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6782 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6783 | "no ip ospf mtu-ignore A.B.C.D", |
| 6784 | "IP Information\n" |
| 6785 | "OSPF interface commands\n" |
| 6786 | "Disable mtu mismatch detection\n" |
| 6787 | "Address of interface") |
| 6788 | { |
| 6789 | struct interface *ifp = vty->index; |
| 6790 | struct in_addr addr; |
| 6791 | int ret; |
| 6792 | |
| 6793 | struct ospf_if_params *params; |
| 6794 | params = IF_DEF_PARAMS (ifp); |
| 6795 | |
| 6796 | if (argc == 1) |
| 6797 | { |
| 6798 | ret = inet_aton(argv[0], &addr); |
| 6799 | if (!ret) |
| 6800 | { |
| 6801 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6802 | VTY_NEWLINE); |
| 6803 | return CMD_WARNING; |
| 6804 | } |
| 6805 | params = ospf_get_if_params (ifp, addr); |
| 6806 | ospf_if_update_params (ifp, addr); |
| 6807 | } |
| 6808 | params->mtu_ignore = 0; |
| 6809 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6810 | SET_IF_PARAM (params, mtu_ignore); |
| 6811 | else |
| 6812 | { |
| 6813 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6814 | if (params != IF_DEF_PARAMS (ifp)) |
| 6815 | { |
| 6816 | ospf_free_if_params (ifp, addr); |
| 6817 | ospf_if_update_params (ifp, addr); |
| 6818 | } |
| 6819 | } |
| 6820 | return CMD_SUCCESS; |
| 6821 | } |
| 6822 | |
| 6823 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6824 | no_ip_ospf_mtu_ignore_cmd, |
| 6825 | "no ip ospf mtu-ignore", |
| 6826 | "IP Information\n" |
| 6827 | "OSPF interface commands\n" |
| 6828 | "Disable mtu mismatch detection\n") |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6829 | |
| 6830 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6831 | ospf_max_metric_router_lsa_admin_cmd, |
| 6832 | "max-metric router-lsa administrative", |
| 6833 | "OSPF maximum / infinite-distance metric\n" |
| 6834 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6835 | "Administratively applied, for an indefinite period\n") |
| 6836 | { |
| 6837 | struct listnode *ln; |
| 6838 | struct ospf_area *area; |
| 6839 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6840 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6841 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6842 | { |
| 6843 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6844 | |
| 6845 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 6846 | ospf_router_lsa_timer_add (area); |
| 6847 | } |
| 6848 | return CMD_SUCCESS; |
| 6849 | } |
| 6850 | |
| 6851 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6852 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6853 | "no max-metric router-lsa administrative", |
| 6854 | NO_STR |
| 6855 | "OSPF maximum / infinite-distance metric\n" |
| 6856 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6857 | "Administratively applied, for an indefinite period\n") |
| 6858 | { |
| 6859 | struct listnode *ln; |
| 6860 | struct ospf_area *area; |
| 6861 | struct ospf *ospf = vty->index; |
| 6862 | |
| 6863 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6864 | { |
| 6865 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6866 | |
| 6867 | /* Don't trample on the start-up stub timer */ |
| 6868 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6869 | && !area->t_stub_router) |
| 6870 | { |
| 6871 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6872 | ospf_router_lsa_timer_add (area); |
| 6873 | } |
| 6874 | } |
| 6875 | return CMD_SUCCESS; |
| 6876 | } |
| 6877 | |
| 6878 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6879 | ospf_max_metric_router_lsa_startup_cmd, |
| 6880 | "max-metric router-lsa on-startup <5-86400>", |
| 6881 | "OSPF maximum / infinite-distance metric\n" |
| 6882 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6883 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6884 | "Time (seconds) to advertise self as stub-router\n") |
| 6885 | { |
| 6886 | unsigned int seconds; |
| 6887 | struct ospf *ospf = vty->index; |
| 6888 | |
| 6889 | if (argc != 1) |
| 6890 | { |
| 6891 | vty_out (vty, "%% Must supply stub-router period"); |
| 6892 | return CMD_WARNING; |
| 6893 | } |
| 6894 | |
| 6895 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6896 | |
| 6897 | ospf->stub_router_startup_time = seconds; |
| 6898 | |
| 6899 | return CMD_SUCCESS; |
| 6900 | } |
| 6901 | |
| 6902 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6903 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6904 | "no max-metric router-lsa on-startup", |
| 6905 | NO_STR |
| 6906 | "OSPF maximum / infinite-distance metric\n" |
| 6907 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6908 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6909 | { |
| 6910 | struct listnode *ln; |
| 6911 | struct ospf_area *area; |
| 6912 | struct ospf *ospf = vty->index; |
| 6913 | |
| 6914 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6915 | |
| 6916 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6917 | { |
| 6918 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 6919 | OSPF_TIMER_OFF (area->t_stub_router); |
| 6920 | |
| 6921 | /* Don't trample on admin stub routed */ |
| 6922 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6923 | { |
| 6924 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6925 | ospf_router_lsa_timer_add (area); |
| 6926 | } |
| 6927 | } |
| 6928 | return CMD_SUCCESS; |
| 6929 | } |
| 6930 | |
| 6931 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 6932 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 6933 | "max-metric router-lsa on-shutdown <5-86400>", |
| 6934 | "OSPF maximum / infinite-distance metric\n" |
| 6935 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6936 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 6937 | "Time (seconds) to wait till full shutdown\n") |
| 6938 | { |
| 6939 | unsigned int seconds; |
| 6940 | struct ospf *ospf = vty->index; |
| 6941 | |
| 6942 | if (argc != 1) |
| 6943 | { |
| 6944 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 6945 | return CMD_WARNING; |
| 6946 | } |
| 6947 | |
| 6948 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 6949 | |
| 6950 | ospf->stub_router_shutdown_time = seconds; |
| 6951 | |
| 6952 | return CMD_SUCCESS; |
| 6953 | } |
| 6954 | |
| 6955 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 6956 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 6957 | "no max-metric router-lsa on-shutdown", |
| 6958 | NO_STR |
| 6959 | "OSPF maximum / infinite-distance metric\n" |
| 6960 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6961 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 6962 | { |
| 6963 | struct ospf *ospf = vty->index; |
| 6964 | |
| 6965 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6966 | |
| 6967 | return CMD_SUCCESS; |
| 6968 | } |
| 6969 | |
| 6970 | static void |
| 6971 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 6972 | { |
| 6973 | struct listnode *ln; |
| 6974 | struct ospf_area *area; |
| 6975 | |
| 6976 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6977 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 6978 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 6979 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6980 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 6981 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 6982 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6983 | { |
| 6984 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6985 | { |
| 6986 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 6987 | VTY_NEWLINE); |
| 6988 | break; |
| 6989 | } |
| 6990 | } |
| 6991 | return; |
| 6992 | } |
| 6993 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6994 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6995 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6996 | { |
| 6997 | struct route_node *rn; |
| 6998 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6999 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7000 | struct ospf_path *path; |
| 7001 | |
| 7002 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 7003 | VTY_NEWLINE); |
| 7004 | |
| 7005 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 7006 | if ((or = rn->info) != NULL) |
| 7007 | { |
| 7008 | char buf1[19]; |
| 7009 | snprintf (buf1, 19, "%s/%d", |
| 7010 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 7011 | |
| 7012 | switch (or->path_type) |
| 7013 | { |
| 7014 | case OSPF_PATH_INTER_AREA: |
| 7015 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 7016 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 7017 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 7018 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 7019 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 7020 | break; |
| 7021 | case OSPF_PATH_INTRA_AREA: |
| 7022 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 7023 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 7024 | break; |
| 7025 | default: |
| 7026 | break; |
| 7027 | } |
| 7028 | |
| 7029 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7030 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7031 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7032 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7033 | { |
| 7034 | if (path->nexthop.s_addr == 0) |
| 7035 | vty_out (vty, "%24s directly attached to %s%s", |
| 7036 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7037 | else |
| 7038 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7039 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7040 | VTY_NEWLINE); |
| 7041 | } |
| 7042 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7043 | } |
| 7044 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7045 | } |
| 7046 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7047 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7048 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 7049 | { |
| 7050 | struct route_node *rn; |
| 7051 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7052 | struct listnode *pnode; |
| 7053 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7054 | struct ospf_path *path; |
| 7055 | |
| 7056 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 7057 | VTY_NEWLINE); |
| 7058 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 7059 | if (rn->info) |
| 7060 | { |
| 7061 | int flag = 0; |
| 7062 | |
| 7063 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 7064 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7065 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 7066 | { |
| 7067 | if (flag++) |
| 7068 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7069 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7070 | /* Show path. */ |
| 7071 | vty_out (vty, "%s [%d] area: %s", |
| 7072 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 7073 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 7074 | /* Show flags. */ |
| 7075 | vty_out (vty, "%s%s%s", |
| 7076 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 7077 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 7078 | VTY_NEWLINE); |
| 7079 | |
| 7080 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 7081 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7082 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
| 7083 | { |
| 7084 | if (path->nexthop.s_addr == 0) |
| 7085 | vty_out (vty, "%24s directly attached to %s%s", |
| 7086 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7087 | else |
| 7088 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7089 | inet_ntoa (path->nexthop), |
| 7090 | path->oi->ifp->name, VTY_NEWLINE); |
| 7091 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7092 | } |
| 7093 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7094 | } |
| 7095 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7096 | } |
| 7097 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7098 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7099 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 7100 | { |
| 7101 | struct route_node *rn; |
| 7102 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7103 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7104 | struct ospf_path *path; |
| 7105 | |
| 7106 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 7107 | VTY_NEWLINE); |
| 7108 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 7109 | if ((er = rn->info) != NULL) |
| 7110 | { |
| 7111 | char buf1[19]; |
| 7112 | snprintf (buf1, 19, "%s/%d", |
| 7113 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 7114 | |
| 7115 | switch (er->path_type) |
| 7116 | { |
| 7117 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 7118 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 7119 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 7120 | break; |
| 7121 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 7122 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 7123 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 7124 | break; |
| 7125 | } |
| 7126 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7127 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7128 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7129 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7130 | { |
| 7131 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7132 | vty_out (vty, "%24s directly attached to %s%s", |
| 7133 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7134 | else |
| 7135 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7136 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7137 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7138 | } |
| 7139 | } |
| 7140 | } |
| 7141 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7142 | } |
| 7143 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7144 | DEFUN (show_ip_ospf_border_routers, |
| 7145 | show_ip_ospf_border_routers_cmd, |
| 7146 | "show ip ospf border-routers", |
| 7147 | SHOW_STR |
| 7148 | IP_STR |
| 7149 | "show all the ABR's and ASBR's\n" |
| 7150 | "for this area\n") |
| 7151 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7152 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7153 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7154 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7155 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7156 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7157 | return CMD_SUCCESS; |
| 7158 | } |
| 7159 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7160 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7161 | { |
| 7162 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7163 | return CMD_SUCCESS; |
| 7164 | } |
| 7165 | |
| 7166 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7167 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7168 | |
| 7169 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7170 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7171 | |
| 7172 | return CMD_SUCCESS; |
| 7173 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7174 | |
| 7175 | DEFUN (show_ip_ospf_route, |
| 7176 | show_ip_ospf_route_cmd, |
| 7177 | "show ip ospf route", |
| 7178 | SHOW_STR |
| 7179 | IP_STR |
| 7180 | "OSPF information\n" |
| 7181 | "OSPF routing table\n") |
| 7182 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7183 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7184 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7185 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7186 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7187 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7188 | return CMD_SUCCESS; |
| 7189 | } |
| 7190 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7191 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7192 | { |
| 7193 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7194 | return CMD_SUCCESS; |
| 7195 | } |
| 7196 | |
| 7197 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7198 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7199 | |
| 7200 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7201 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7202 | |
| 7203 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7204 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7205 | |
| 7206 | return CMD_SUCCESS; |
| 7207 | } |
| 7208 | |
| 7209 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7210 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7211 | { |
| 7212 | "unknown", |
| 7213 | "standard", |
| 7214 | "ibm", |
| 7215 | "cisco", |
| 7216 | "shortcut" |
| 7217 | }; |
| 7218 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7219 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7220 | { |
| 7221 | "default", |
| 7222 | "enable", |
| 7223 | "disable" |
| 7224 | }; |
| 7225 | |
| 7226 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7227 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7228 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 7229 | { |
| 7230 | memset (buf, 0, length); |
| 7231 | |
| 7232 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 7233 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 7234 | else |
| 7235 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 7236 | } |
| 7237 | |
| 7238 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7239 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7240 | { |
| 7241 | "unknown", /* should never be used. */ |
| 7242 | "point-to-point", |
| 7243 | "broadcast", |
| 7244 | "non-broadcast", |
| 7245 | "point-to-multipoint", |
| 7246 | "virtual-link", /* should never be used. */ |
| 7247 | "loopback" |
| 7248 | }; |
| 7249 | |
| 7250 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7251 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7252 | config_write_interface (struct vty *vty) |
| 7253 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7254 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7255 | struct interface *ifp; |
| 7256 | struct crypt_key *ck; |
| 7257 | int write = 0; |
| 7258 | struct route_node *rn = NULL; |
| 7259 | struct ospf_if_params *params; |
| 7260 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7261 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7262 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7263 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 7264 | continue; |
| 7265 | |
| 7266 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 7267 | vty_out (vty, "interface %s%s", ifp->name, |
| 7268 | VTY_NEWLINE); |
| 7269 | if (ifp->desc) |
| 7270 | vty_out (vty, " description %s%s", ifp->desc, |
| 7271 | VTY_NEWLINE); |
| 7272 | |
| 7273 | write++; |
| 7274 | |
| 7275 | params = IF_DEF_PARAMS (ifp); |
| 7276 | |
| 7277 | do { |
| 7278 | /* Interface Network print. */ |
| 7279 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7280 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 7281 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 7282 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 7283 | { |
| 7284 | vty_out (vty, " ip ospf network %s", |
| 7285 | ospf_int_type_str[params->type]); |
| 7286 | if (params != IF_DEF_PARAMS (ifp)) |
| 7287 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7288 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7289 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7290 | } |
| 7291 | |
| 7292 | /* OSPF interface authentication print */ |
| 7293 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 7294 | params->auth_type != OSPF_AUTH_NOTSET) |
| 7295 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7296 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7297 | |
| 7298 | /* Translation tables are not that much help here due to syntax |
| 7299 | of the simple option */ |
| 7300 | switch (params->auth_type) |
| 7301 | { |
| 7302 | |
| 7303 | case OSPF_AUTH_NULL: |
| 7304 | auth_str = " null"; |
| 7305 | break; |
| 7306 | |
| 7307 | case OSPF_AUTH_SIMPLE: |
| 7308 | auth_str = ""; |
| 7309 | break; |
| 7310 | |
| 7311 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 7312 | auth_str = " message-digest"; |
| 7313 | break; |
| 7314 | |
| 7315 | default: |
| 7316 | auth_str = ""; |
| 7317 | break; |
| 7318 | } |
| 7319 | |
| 7320 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 7321 | if (params != IF_DEF_PARAMS (ifp)) |
| 7322 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7323 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7324 | } |
| 7325 | |
| 7326 | /* Simple Authentication Password print. */ |
| 7327 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 7328 | params->auth_simple[0] != '\0') |
| 7329 | { |
| 7330 | vty_out (vty, " ip ospf authentication-key %s", |
| 7331 | params->auth_simple); |
| 7332 | if (params != IF_DEF_PARAMS (ifp)) |
| 7333 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7334 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7335 | } |
| 7336 | |
| 7337 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7338 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7339 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7340 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 7341 | ck->key_id, ck->auth_key); |
| 7342 | if (params != IF_DEF_PARAMS (ifp)) |
| 7343 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7344 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7345 | } |
| 7346 | |
| 7347 | /* Interface Output Cost print. */ |
| 7348 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 7349 | { |
| 7350 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 7351 | if (params != IF_DEF_PARAMS (ifp)) |
| 7352 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7353 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7354 | } |
| 7355 | |
| 7356 | /* Hello Interval print. */ |
| 7357 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 7358 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 7359 | { |
| 7360 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 7361 | if (params != IF_DEF_PARAMS (ifp)) |
| 7362 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7363 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7364 | } |
| 7365 | |
| 7366 | |
| 7367 | /* Router Dead Interval print. */ |
| 7368 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 7369 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 7370 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7371 | vty_out (vty, " ip ospf dead-interval "); |
| 7372 | |
| 7373 | /* fast hello ? */ |
| 7374 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 7375 | vty_out (vty, "minimal hello-multiplier %d", |
| 7376 | params->fast_hello); |
| 7377 | else |
| 7378 | vty_out (vty, "%u", params->v_wait); |
| 7379 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7380 | if (params != IF_DEF_PARAMS (ifp)) |
| 7381 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7382 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7383 | } |
| 7384 | |
| 7385 | /* Router Priority print. */ |
| 7386 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 7387 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 7388 | { |
| 7389 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 7390 | if (params != IF_DEF_PARAMS (ifp)) |
| 7391 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7392 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7393 | } |
| 7394 | |
| 7395 | /* Retransmit Interval print. */ |
| 7396 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 7397 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 7398 | { |
| 7399 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 7400 | params->retransmit_interval); |
| 7401 | if (params != IF_DEF_PARAMS (ifp)) |
| 7402 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7403 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7404 | } |
| 7405 | |
| 7406 | /* Transmit Delay print. */ |
| 7407 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 7408 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7409 | { |
| 7410 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 7411 | if (params != IF_DEF_PARAMS (ifp)) |
| 7412 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7413 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7414 | } |
| 7415 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7416 | /* MTU ignore print. */ |
| 7417 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 7418 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 7419 | { |
| 7420 | if (params->mtu_ignore == 0) |
| 7421 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 7422 | else |
| 7423 | vty_out (vty, " ip ospf mtu-ignore"); |
| 7424 | if (params != IF_DEF_PARAMS (ifp)) |
| 7425 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7426 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7427 | } |
| 7428 | |
| 7429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7430 | while (1) |
| 7431 | { |
| 7432 | if (rn == NULL) |
| 7433 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 7434 | else |
| 7435 | rn = route_next (rn); |
| 7436 | |
| 7437 | if (rn == NULL) |
| 7438 | break; |
| 7439 | params = rn->info; |
| 7440 | if (params != NULL) |
| 7441 | break; |
| 7442 | } |
| 7443 | } while (rn); |
| 7444 | |
| 7445 | #ifdef HAVE_OPAQUE_LSA |
| 7446 | ospf_opaque_config_write_if (vty, ifp); |
| 7447 | #endif /* HAVE_OPAQUE_LSA */ |
| 7448 | } |
| 7449 | |
| 7450 | return write; |
| 7451 | } |
| 7452 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7453 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7454 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7455 | { |
| 7456 | struct route_node *rn; |
| 7457 | u_char buf[INET_ADDRSTRLEN]; |
| 7458 | |
| 7459 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7460 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7461 | if (rn->info) |
| 7462 | { |
| 7463 | struct ospf_network *n = rn->info; |
| 7464 | |
| 7465 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7466 | |
| 7467 | /* Create Area ID string by specified Area ID format. */ |
| 7468 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7469 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7470 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7471 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7472 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7473 | |
| 7474 | /* Network print. */ |
| 7475 | vty_out (vty, " network %s/%d area %s%s", |
| 7476 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7477 | buf, VTY_NEWLINE); |
| 7478 | } |
| 7479 | |
| 7480 | return 0; |
| 7481 | } |
| 7482 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7483 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7484 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7485 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7486 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7487 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7488 | u_char buf[INET_ADDRSTRLEN]; |
| 7489 | |
| 7490 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7491 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7492 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7493 | struct route_node *rn1; |
| 7494 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7495 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7496 | |
| 7497 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7498 | { |
| 7499 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7500 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7501 | else |
| 7502 | vty_out (vty, " area %s authentication message-digest%s", |
| 7503 | buf, VTY_NEWLINE); |
| 7504 | } |
| 7505 | |
| 7506 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7507 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7508 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7509 | VTY_NEWLINE); |
| 7510 | |
| 7511 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7512 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7513 | ) |
| 7514 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7515 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7516 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7517 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7518 | { |
| 7519 | vty_out (vty, " area %s nssa", buf); |
| 7520 | switch (area->NSSATranslatorRole) |
| 7521 | { |
| 7522 | case OSPF_NSSA_ROLE_NEVER: |
| 7523 | vty_out (vty, " translate-never"); |
| 7524 | break; |
| 7525 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7526 | vty_out (vty, " translate-always"); |
| 7527 | break; |
| 7528 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7529 | default: |
| 7530 | vty_out (vty, " translate-candidate"); |
| 7531 | } |
| 7532 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7533 | |
| 7534 | if (area->no_summary) |
| 7535 | vty_out (vty, " no-summary"); |
| 7536 | |
| 7537 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7538 | |
| 7539 | if (area->default_cost != 1) |
| 7540 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7541 | area->default_cost, VTY_NEWLINE); |
| 7542 | } |
| 7543 | |
| 7544 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7545 | if (rn1->info) |
| 7546 | { |
| 7547 | struct ospf_area_range *range = rn1->info; |
| 7548 | |
| 7549 | vty_out (vty, " area %s range %s/%d", buf, |
| 7550 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7551 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7552 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7553 | vty_out (vty, " cost %d", range->cost_config); |
| 7554 | |
| 7555 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7556 | vty_out (vty, " not-advertise"); |
| 7557 | |
| 7558 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7559 | vty_out (vty, " substitute %s/%d", |
| 7560 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7561 | |
| 7562 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7563 | } |
| 7564 | |
| 7565 | if (EXPORT_NAME (area)) |
| 7566 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7567 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7568 | |
| 7569 | if (IMPORT_NAME (area)) |
| 7570 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7571 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7572 | |
| 7573 | if (PREFIX_NAME_IN (area)) |
| 7574 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7575 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7576 | |
| 7577 | if (PREFIX_NAME_OUT (area)) |
| 7578 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7579 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7580 | } |
| 7581 | |
| 7582 | return 0; |
| 7583 | } |
| 7584 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7585 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7586 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7587 | { |
| 7588 | struct ospf_nbr_nbma *nbr_nbma; |
| 7589 | struct route_node *rn; |
| 7590 | |
| 7591 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7592 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7593 | if ((nbr_nbma = rn->info)) |
| 7594 | { |
| 7595 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7596 | |
| 7597 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7598 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7599 | |
| 7600 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7601 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7602 | |
| 7603 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7604 | } |
| 7605 | |
| 7606 | return 0; |
| 7607 | } |
| 7608 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7609 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7610 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7611 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7612 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7613 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7614 | u_char buf[INET_ADDRSTRLEN]; |
| 7615 | |
| 7616 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7617 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7618 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7619 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7620 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7621 | struct ospf_interface *oi; |
| 7622 | |
| 7623 | if (vl_data != NULL) |
| 7624 | { |
| 7625 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7626 | |
| 7627 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7628 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7629 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7630 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7631 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7632 | oi = vl_data->vl_oi; |
| 7633 | |
| 7634 | /* timers */ |
| 7635 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7636 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7637 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7638 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7639 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7640 | buf, |
| 7641 | inet_ntoa (vl_data->vl_peer), |
| 7642 | OSPF_IF_PARAM (oi, v_hello), |
| 7643 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7644 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7645 | OSPF_IF_PARAM (oi, v_wait), |
| 7646 | VTY_NEWLINE); |
| 7647 | else |
| 7648 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7649 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7650 | /* Auth key */ |
| 7651 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7652 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7653 | buf, |
| 7654 | inet_ntoa (vl_data->vl_peer), |
| 7655 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7656 | VTY_NEWLINE); |
| 7657 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7658 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7659 | n2, ck)) |
| 7660 | vty_out (vty, " area %s virtual-link %s" |
| 7661 | " message-digest-key %d md5 %s%s", |
| 7662 | buf, |
| 7663 | inet_ntoa (vl_data->vl_peer), |
| 7664 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7665 | |
| 7666 | } |
| 7667 | } |
| 7668 | |
| 7669 | return 0; |
| 7670 | } |
| 7671 | |
| 7672 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7673 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7674 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7675 | { |
| 7676 | int type; |
| 7677 | |
| 7678 | /* redistribute print. */ |
| 7679 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7680 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7681 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7682 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7683 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7684 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7685 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7686 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7687 | vty_out (vty, " metric-type 1"); |
| 7688 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7689 | if (ROUTEMAP_NAME (ospf, type)) |
| 7690 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7691 | |
| 7692 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7693 | } |
| 7694 | |
| 7695 | return 0; |
| 7696 | } |
| 7697 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7698 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7699 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7700 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7701 | if (ospf->default_metric != -1) |
| 7702 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7703 | VTY_NEWLINE); |
| 7704 | return 0; |
| 7705 | } |
| 7706 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7707 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7708 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7709 | { |
| 7710 | int type; |
| 7711 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7712 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7713 | { |
| 7714 | /* distribute-list print. */ |
| 7715 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7716 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7717 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7718 | ospf->dlist[type].name, |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7719 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7720 | |
| 7721 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7722 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7723 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7724 | vty_out (vty, " default-information originate"); |
| 7725 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7726 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7727 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7728 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7729 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7730 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7731 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7732 | vty_out (vty, " metric-type 1"); |
| 7733 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7734 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7735 | vty_out (vty, " route-map %s", |
| 7736 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7737 | |
| 7738 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7739 | } |
| 7740 | |
| 7741 | } |
| 7742 | |
| 7743 | return 0; |
| 7744 | } |
| 7745 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7746 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7747 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7748 | { |
| 7749 | struct route_node *rn; |
| 7750 | struct ospf_distance *odistance; |
| 7751 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7752 | if (ospf->distance_all) |
| 7753 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7754 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7755 | if (ospf->distance_intra |
| 7756 | || ospf->distance_inter |
| 7757 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7758 | { |
| 7759 | vty_out (vty, " distance ospf"); |
| 7760 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7761 | if (ospf->distance_intra) |
| 7762 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7763 | if (ospf->distance_inter) |
| 7764 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7765 | if (ospf->distance_external) |
| 7766 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7767 | |
| 7768 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7769 | } |
| 7770 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7771 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7772 | if ((odistance = rn->info) != NULL) |
| 7773 | { |
| 7774 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7775 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7776 | odistance->access_list ? odistance->access_list : "", |
| 7777 | VTY_NEWLINE); |
| 7778 | } |
| 7779 | return 0; |
| 7780 | } |
| 7781 | |
| 7782 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7783 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7784 | ospf_config_write (struct vty *vty) |
| 7785 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7786 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7787 | struct interface *ifp; |
| 7788 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7789 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7790 | int write = 0; |
| 7791 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7792 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7793 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7794 | { |
| 7795 | /* `router ospf' print. */ |
| 7796 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7797 | |
| 7798 | write++; |
| 7799 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7800 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7801 | return write; |
| 7802 | |
| 7803 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7804 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7805 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7806 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | |
| 7808 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7809 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7810 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7811 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7812 | |
| 7813 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7814 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7815 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7816 | |
| 7817 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7818 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7819 | { |
| 7820 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7821 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7822 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7823 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7824 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7825 | |
| 7826 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7827 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7828 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7829 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7830 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7831 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7832 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7833 | |
| 7834 | /* Max-metric router-lsa print */ |
| 7835 | config_write_stub_router (vty, ospf); |
| 7836 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7837 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7838 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7839 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7840 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7841 | |
| 7842 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7843 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7844 | |
| 7845 | /* passive-interface print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7846 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 7847 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7848 | vty_out (vty, " passive-interface %s%s", |
| 7849 | ifp->name, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7850 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7851 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 7852 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7853 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
| 7854 | vty_out (vty, " passive-interface %s %s%s", |
| 7855 | oi->ifp->name, |
| 7856 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7857 | |
| 7858 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7859 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | |
| 7861 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7862 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7863 | |
| 7864 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7865 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7866 | |
| 7867 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7868 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7869 | |
| 7870 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7871 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7872 | |
| 7873 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7874 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7875 | |
| 7876 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7877 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7878 | |
| 7879 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7880 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7881 | #endif /* HAVE_OPAQUE_LSA */ |
| 7882 | } |
| 7883 | |
| 7884 | return write; |
| 7885 | } |
| 7886 | |
| 7887 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7888 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7889 | { |
| 7890 | /* "show ip ospf" commands. */ |
| 7891 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7892 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7893 | |
| 7894 | /* "show ip ospf database" commands. */ |
| 7895 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7896 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7897 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7898 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7899 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7900 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7901 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7902 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7903 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7904 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7905 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7906 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7907 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7908 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7909 | |
| 7910 | /* "show ip ospf interface" commands. */ |
| 7911 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7912 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7913 | |
| 7914 | /* "show ip ospf neighbor" commands. */ |
| 7915 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7916 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7917 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7918 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7919 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7920 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7921 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7922 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7923 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7924 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7925 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7926 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7927 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7928 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7929 | |
| 7930 | /* "show ip ospf route" commands. */ |
| 7931 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7932 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7933 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7934 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7935 | } |
| 7936 | |
| 7937 | |
| 7938 | /* ospfd's interface node. */ |
| 7939 | struct cmd_node interface_node = |
| 7940 | { |
| 7941 | INTERFACE_NODE, |
| 7942 | "%s(config-if)# ", |
| 7943 | 1 |
| 7944 | }; |
| 7945 | |
| 7946 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7947 | static void |
| 7948 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7949 | { |
| 7950 | /* Install interface node. */ |
| 7951 | install_node (&interface_node, config_write_interface); |
| 7952 | |
| 7953 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7954 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7955 | install_default (INTERFACE_NODE); |
| 7956 | |
| 7957 | /* "description" commands. */ |
| 7958 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7959 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7960 | |
| 7961 | /* "ip ospf authentication" commands. */ |
| 7962 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7963 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7964 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7965 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7966 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7967 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7968 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7969 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7970 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7971 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7972 | |
| 7973 | /* "ip ospf message-digest-key" commands. */ |
| 7974 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7975 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7976 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7977 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7978 | |
| 7979 | /* "ip ospf cost" commands. */ |
| 7980 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7981 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7982 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7983 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7984 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7985 | /* "ip ospf mtu-ignore" commands. */ |
| 7986 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7987 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7988 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7989 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7990 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7991 | /* "ip ospf dead-interval" commands. */ |
| 7992 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7993 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7994 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 7995 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7996 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7997 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7998 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7999 | /* "ip ospf hello-interval" commands. */ |
| 8000 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 8001 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 8002 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 8003 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 8004 | |
| 8005 | /* "ip ospf network" commands. */ |
| 8006 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 8007 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 8008 | |
| 8009 | /* "ip ospf priority" commands. */ |
| 8010 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 8011 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 8012 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 8013 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 8014 | |
| 8015 | /* "ip ospf retransmit-interval" commands. */ |
| 8016 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 8017 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 8018 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 8019 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 8020 | |
| 8021 | /* "ip ospf transmit-delay" commands. */ |
| 8022 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 8023 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 8024 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 8025 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 8026 | |
| 8027 | /* These commands are compatibitliy for previous version. */ |
| 8028 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 8029 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 8030 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 8031 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 8032 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 8033 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 8034 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 8035 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 8036 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 8037 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 8038 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 8039 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 8040 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 8041 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 8042 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 8043 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 8044 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 8045 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 8046 | } |
| 8047 | |
| 8048 | /* Zebra node structure. */ |
| 8049 | struct cmd_node zebra_node = |
| 8050 | { |
| 8051 | ZEBRA_NODE, |
| 8052 | "%s(config-router)#", |
| 8053 | }; |
| 8054 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8055 | static void |
| 8056 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8057 | { |
| 8058 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 8059 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 8060 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 8061 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 8062 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 8063 | install_element (OSPF_NODE, |
| 8064 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 8065 | install_element (OSPF_NODE, |
| 8066 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 8067 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 8068 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 8069 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 8070 | |
| 8071 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 8072 | |
| 8073 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 8074 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 8075 | |
| 8076 | install_element (OSPF_NODE, |
| 8077 | &ospf_default_information_originate_metric_type_cmd); |
| 8078 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 8079 | install_element (OSPF_NODE, |
| 8080 | &ospf_default_information_originate_type_metric_cmd); |
| 8081 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 8082 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 8083 | install_element (OSPF_NODE, |
| 8084 | &ospf_default_information_originate_always_metric_type_cmd); |
| 8085 | install_element (OSPF_NODE, |
| 8086 | &ospf_default_information_originate_always_metric_cmd); |
| 8087 | install_element (OSPF_NODE, |
| 8088 | &ospf_default_information_originate_always_cmd); |
| 8089 | install_element (OSPF_NODE, |
| 8090 | &ospf_default_information_originate_always_type_metric_cmd); |
| 8091 | install_element (OSPF_NODE, |
| 8092 | &ospf_default_information_originate_always_type_cmd); |
| 8093 | |
| 8094 | install_element (OSPF_NODE, |
| 8095 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 8096 | install_element (OSPF_NODE, |
| 8097 | &ospf_default_information_originate_metric_routemap_cmd); |
| 8098 | install_element (OSPF_NODE, |
| 8099 | &ospf_default_information_originate_routemap_cmd); |
| 8100 | install_element (OSPF_NODE, |
| 8101 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 8102 | install_element (OSPF_NODE, |
| 8103 | &ospf_default_information_originate_type_routemap_cmd); |
| 8104 | install_element (OSPF_NODE, |
| 8105 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 8106 | install_element (OSPF_NODE, |
| 8107 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 8108 | install_element (OSPF_NODE, |
| 8109 | &ospf_default_information_originate_always_routemap_cmd); |
| 8110 | install_element (OSPF_NODE, |
| 8111 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 8112 | install_element (OSPF_NODE, |
| 8113 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 8114 | |
| 8115 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 8116 | |
| 8117 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 8118 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 8119 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 8120 | |
| 8121 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 8122 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 8123 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 8124 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 8125 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 8126 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 8127 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 8128 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 8129 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 8130 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 8131 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 8132 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 8133 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 8134 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 8135 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 8136 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 8137 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 8138 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 8139 | #if 0 |
| 8140 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 8141 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 8142 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 8143 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 8144 | #endif /* 0 */ |
| 8145 | } |
| 8146 | |
| 8147 | struct cmd_node ospf_node = |
| 8148 | { |
| 8149 | OSPF_NODE, |
| 8150 | "%s(config-router)# ", |
| 8151 | 1 |
| 8152 | }; |
| 8153 | |
| 8154 | |
| 8155 | /* Install OSPF related vty commands. */ |
| 8156 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8157 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8158 | { |
| 8159 | /* Install ospf top node. */ |
| 8160 | install_node (&ospf_node, ospf_config_write); |
| 8161 | |
| 8162 | /* "router ospf" commands. */ |
| 8163 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 8164 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 8165 | |
| 8166 | install_default (OSPF_NODE); |
| 8167 | |
| 8168 | /* "ospf router-id" commands. */ |
| 8169 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 8170 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8171 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 8172 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8173 | |
| 8174 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8175 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 8176 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 8177 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 8178 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8179 | |
| 8180 | /* "ospf abr-type" commands. */ |
| 8181 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 8182 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 8183 | |
| 8184 | /* "ospf rfc1583-compatible" commands. */ |
| 8185 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 8186 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 8187 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 8188 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 8189 | |
| 8190 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8191 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 8192 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8193 | |
| 8194 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8195 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 8196 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 8197 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8198 | |
| 8199 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8200 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 8201 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 8202 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 8203 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 8204 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 8205 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 8206 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 8207 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 8208 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 8209 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 8210 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8211 | |
| 8212 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8213 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 8214 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8215 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8216 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 8217 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8218 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8219 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 8220 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8221 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8222 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 8223 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8224 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8225 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 8226 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8227 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8228 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 8229 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 8230 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8231 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8232 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 8233 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8234 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8235 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 8236 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8237 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8238 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 8239 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 8240 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8241 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8242 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 8243 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 8244 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8245 | |
| 8246 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8247 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 8248 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 8249 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 8250 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8251 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8252 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8253 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 8254 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 8255 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 8256 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 8257 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 8258 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8259 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8260 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 8261 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8262 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8263 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 8264 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8265 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8266 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 8267 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8268 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8269 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 8270 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8271 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8272 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 8273 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8274 | |
| 8275 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8276 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 8277 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 8278 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 8279 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 8280 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8281 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8282 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 8283 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 8284 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8285 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8286 | /* max-metric commands */ |
| 8287 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 8288 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 8289 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 8290 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 8291 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 8292 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 8293 | |
| 8294 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8295 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 8296 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8297 | |
| 8298 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8299 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 8300 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 8301 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 8302 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 8303 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 8304 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 8305 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 8306 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8307 | |
| 8308 | /* Init interface related vty commands. */ |
| 8309 | ospf_vty_if_init (); |
| 8310 | |
| 8311 | /* Init zebra related vty commands. */ |
| 8312 | ospf_vty_zebra_init (); |
| 8313 | } |