paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* OSPF VTY interface. |
| 2 | * Copyright (C) 2000 Toshiaki Takada |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | * 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "memory.h" |
| 25 | #include "thread.h" |
| 26 | #include "prefix.h" |
| 27 | #include "table.h" |
| 28 | #include "vty.h" |
| 29 | #include "command.h" |
| 30 | #include "plist.h" |
| 31 | #include "log.h" |
| 32 | #include "zclient.h" |
| 33 | |
| 34 | #include "ospfd/ospfd.h" |
| 35 | #include "ospfd/ospf_asbr.h" |
| 36 | #include "ospfd/ospf_lsa.h" |
| 37 | #include "ospfd/ospf_lsdb.h" |
| 38 | #include "ospfd/ospf_ism.h" |
| 39 | #include "ospfd/ospf_interface.h" |
| 40 | #include "ospfd/ospf_nsm.h" |
| 41 | #include "ospfd/ospf_neighbor.h" |
| 42 | #include "ospfd/ospf_flood.h" |
| 43 | #include "ospfd/ospf_abr.h" |
| 44 | #include "ospfd/ospf_spf.h" |
| 45 | #include "ospfd/ospf_route.h" |
| 46 | #include "ospfd/ospf_zebra.h" |
| 47 | /*#include "ospfd/ospf_routemap.h" */ |
| 48 | #include "ospfd/ospf_vty.h" |
| 49 | #include "ospfd/ospf_dump.h" |
| 50 | |
| 51 | |
| 52 | static char *ospf_network_type_str[] = |
| 53 | { |
| 54 | "Null", |
| 55 | "POINTOPOINT", |
| 56 | "BROADCAST", |
| 57 | "NBMA", |
| 58 | "POINTOMULTIPOINT", |
| 59 | "VIRTUALLINK", |
| 60 | "LOOPBACK" |
| 61 | }; |
| 62 | |
| 63 | |
| 64 | /* Utility functions. */ |
| 65 | int |
| 66 | ospf_str2area_id (char *str, struct in_addr *area_id, int *format) |
| 67 | { |
| 68 | char *endptr = NULL; |
| 69 | unsigned long ret; |
| 70 | |
| 71 | /* match "A.B.C.D". */ |
| 72 | if (strchr (str, '.') != NULL) |
| 73 | { |
| 74 | ret = inet_aton (str, area_id); |
| 75 | if (!ret) |
| 76 | return -1; |
| 77 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; |
| 78 | } |
| 79 | /* match "<0-4294967295>". */ |
| 80 | else |
| 81 | { |
| 82 | ret = strtoul (str, &endptr, 10); |
| 83 | if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE)) |
| 84 | return -1; |
| 85 | |
| 86 | area_id->s_addr = htonl (ret); |
| 87 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 88 | } |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | int |
| 95 | str2distribute_source (char *str, int *source) |
| 96 | { |
| 97 | /* Sanity check. */ |
| 98 | if (str == NULL) |
| 99 | return 0; |
| 100 | |
| 101 | if (strncmp (str, "k", 1) == 0) |
| 102 | *source = ZEBRA_ROUTE_KERNEL; |
| 103 | else if (strncmp (str, "c", 1) == 0) |
| 104 | *source = ZEBRA_ROUTE_CONNECT; |
| 105 | else if (strncmp (str, "s", 1) == 0) |
| 106 | *source = ZEBRA_ROUTE_STATIC; |
| 107 | else if (strncmp (str, "r", 1) == 0) |
| 108 | *source = ZEBRA_ROUTE_RIP; |
| 109 | else if (strncmp (str, "b", 1) == 0) |
| 110 | *source = ZEBRA_ROUTE_BGP; |
| 111 | else |
| 112 | return 0; |
| 113 | |
| 114 | return 1; |
| 115 | } |
| 116 | |
| 117 | int |
| 118 | str2metric (char *str, int *metric) |
| 119 | { |
| 120 | /* Sanity check. */ |
| 121 | if (str == NULL) |
| 122 | return 0; |
| 123 | |
| 124 | *metric = strtol (str, NULL, 10); |
| 125 | if (*metric < 0 && *metric > 16777214) |
| 126 | { |
| 127 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | return 1; |
| 132 | } |
| 133 | |
| 134 | int |
| 135 | str2metric_type (char *str, int *metric_type) |
| 136 | { |
| 137 | /* Sanity check. */ |
| 138 | if (str == NULL) |
| 139 | return 0; |
| 140 | |
| 141 | if (strncmp (str, "1", 1) == 0) |
| 142 | *metric_type = EXTERNAL_METRIC_TYPE_1; |
| 143 | else if (strncmp (str, "2", 1) == 0) |
| 144 | *metric_type = EXTERNAL_METRIC_TYPE_2; |
| 145 | else |
| 146 | return 0; |
| 147 | |
| 148 | return 1; |
| 149 | } |
| 150 | |
| 151 | int |
| 152 | ospf_oi_count (struct interface *ifp) |
| 153 | { |
| 154 | struct route_node *rn; |
| 155 | int i = 0; |
| 156 | |
| 157 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 158 | if (rn->info) |
| 159 | i++; |
| 160 | |
| 161 | return i; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | DEFUN (router_ospf, |
| 166 | router_ospf_cmd, |
| 167 | "router ospf", |
| 168 | "Enable a routing process\n" |
| 169 | "Start OSPF configuration\n") |
| 170 | { |
| 171 | vty->node = OSPF_NODE; |
| 172 | vty->index = ospf_get (); |
| 173 | |
| 174 | return CMD_SUCCESS; |
| 175 | } |
| 176 | |
| 177 | DEFUN (no_router_ospf, |
| 178 | no_router_ospf_cmd, |
| 179 | "no router ospf", |
| 180 | NO_STR |
| 181 | "Enable a routing process\n" |
| 182 | "Start OSPF configuration\n") |
| 183 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 184 | struct ospf *ospf; |
| 185 | |
| 186 | ospf = ospf_lookup (); |
| 187 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 188 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 189 | vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 190 | return CMD_WARNING; |
| 191 | } |
| 192 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 193 | ospf_finish (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 194 | |
| 195 | return CMD_SUCCESS; |
| 196 | } |
| 197 | |
| 198 | DEFUN (ospf_router_id, |
| 199 | ospf_router_id_cmd, |
| 200 | "ospf router-id A.B.C.D", |
| 201 | "OSPF specific commands\n" |
| 202 | "router-id for the OSPF process\n" |
| 203 | "OSPF router-id in IP address format\n") |
| 204 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 205 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 206 | struct in_addr router_id; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 207 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 208 | |
| 209 | ret = inet_aton (argv[0], &router_id); |
| 210 | if (!ret) |
| 211 | { |
| 212 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); |
| 213 | return CMD_WARNING; |
| 214 | } |
| 215 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 216 | ospf->router_id_static = router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 218 | if (ospf->t_router_id_update == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 219 | OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer, |
| 220 | OSPF_ROUTER_ID_UPDATE_DELAY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | |
| 222 | return CMD_SUCCESS; |
| 223 | } |
| 224 | |
| 225 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 226 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 227 | "router-id A.B.C.D", |
| 228 | "router-id for the OSPF process\n" |
| 229 | "OSPF router-id in IP address format\n") |
| 230 | |
| 231 | DEFUN (no_ospf_router_id, |
| 232 | no_ospf_router_id_cmd, |
| 233 | "no ospf router-id", |
| 234 | NO_STR |
| 235 | "OSPF specific commands\n" |
| 236 | "router-id for the OSPF process\n") |
| 237 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 238 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 239 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 240 | ospf->router_id_static.s_addr = 0; |
| 241 | |
| 242 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 243 | |
| 244 | return CMD_SUCCESS; |
| 245 | } |
| 246 | |
| 247 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 248 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 249 | "no router-id", |
| 250 | NO_STR |
| 251 | "router-id for the OSPF process\n") |
| 252 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 253 | DEFUN (ospf_passive_interface, |
| 254 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | "passive-interface IFNAME A.B.C.D", |
| 256 | "Suppress routing updates on an interface\n" |
| 257 | "Interface's name\n") |
| 258 | { |
| 259 | struct interface *ifp; |
| 260 | struct in_addr addr; |
| 261 | int ret; |
| 262 | struct ospf_if_params *params; |
| 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; |
| 290 | |
| 291 | return CMD_SUCCESS; |
| 292 | } |
| 293 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 294 | ALIAS (ospf_passive_interface, |
| 295 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 296 | "passive-interface IFNAME", |
| 297 | "Suppress routing updates on an interface\n" |
| 298 | "Interface's name\n") |
| 299 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 300 | DEFUN (no_ospf_passive_interface, |
| 301 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 302 | "no passive-interface IFNAME A.B.C.D", |
| 303 | NO_STR |
| 304 | "Allow routing updates on an interface\n" |
| 305 | "Interface's name\n") |
| 306 | { |
| 307 | struct interface *ifp; |
| 308 | struct in_addr addr; |
| 309 | struct ospf_if_params *params; |
| 310 | int ret; |
| 311 | |
| 312 | ifp = if_lookup_by_name (argv[0]); |
| 313 | |
| 314 | if (ifp == NULL) |
| 315 | { |
| 316 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 317 | return CMD_WARNING; |
| 318 | } |
| 319 | |
| 320 | params = IF_DEF_PARAMS (ifp); |
| 321 | |
| 322 | if (argc == 2) |
| 323 | { |
| 324 | ret = inet_aton(argv[1], &addr); |
| 325 | if (!ret) |
| 326 | { |
| 327 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 328 | VTY_NEWLINE); |
| 329 | return CMD_WARNING; |
| 330 | } |
| 331 | |
| 332 | params = ospf_lookup_if_params (ifp, addr); |
| 333 | if (params == NULL) |
| 334 | return CMD_SUCCESS; |
| 335 | } |
| 336 | |
| 337 | UNSET_IF_PARAM (params, passive_interface); |
| 338 | params->passive_interface = OSPF_IF_ACTIVE; |
| 339 | |
| 340 | if (params != IF_DEF_PARAMS (ifp)) |
| 341 | { |
| 342 | ospf_free_if_params (ifp, addr); |
| 343 | ospf_if_update_params (ifp, addr); |
| 344 | } |
| 345 | |
| 346 | return CMD_SUCCESS; |
| 347 | } |
| 348 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 349 | ALIAS (no_ospf_passive_interface, |
| 350 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 351 | "no passive-interface IFNAME", |
| 352 | NO_STR |
| 353 | "Allow routing updates on an interface\n" |
| 354 | "Interface's name\n") |
| 355 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 356 | DEFUN (ospf_network_area, |
| 357 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 358 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 359 | "Enable routing on an IP network\n" |
| 360 | "OSPF network prefix\n" |
| 361 | "Set the OSPF area ID\n" |
| 362 | "OSPF area ID in IP address format\n" |
| 363 | "OSPF area ID as a decimal value\n") |
| 364 | { |
| 365 | struct ospf *ospf= vty->index; |
| 366 | struct prefix_ipv4 p; |
| 367 | struct in_addr area_id; |
| 368 | int ret, format; |
| 369 | |
| 370 | /* Get network prefix and Area ID. */ |
| 371 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 372 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 373 | |
| 374 | ret = ospf_network_set (ospf, &p, area_id); |
| 375 | if (ret == 0) |
| 376 | { |
| 377 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 378 | return CMD_WARNING; |
| 379 | } |
| 380 | |
| 381 | return CMD_SUCCESS; |
| 382 | } |
| 383 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 384 | DEFUN (no_ospf_network_area, |
| 385 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 386 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 387 | NO_STR |
| 388 | "Enable routing on an IP network\n" |
| 389 | "OSPF network prefix\n" |
| 390 | "Set the OSPF area ID\n" |
| 391 | "OSPF area ID in IP address format\n" |
| 392 | "OSPF area ID as a decimal value\n") |
| 393 | { |
| 394 | struct ospf *ospf = (struct ospf *) vty->index; |
| 395 | struct prefix_ipv4 p; |
| 396 | struct in_addr area_id; |
| 397 | int ret, format; |
| 398 | |
| 399 | /* Get network prefix and Area ID. */ |
| 400 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 401 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 402 | |
| 403 | ret = ospf_network_unset (ospf, &p, area_id); |
| 404 | if (ret == 0) |
| 405 | { |
| 406 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 407 | VTY_NEWLINE); |
| 408 | return CMD_WARNING; |
| 409 | } |
| 410 | |
| 411 | return CMD_SUCCESS; |
| 412 | } |
| 413 | |
| 414 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 415 | DEFUN (ospf_area_range, |
| 416 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 417 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 418 | "OSPF area parameters\n" |
| 419 | "OSPF area ID in IP address format\n" |
| 420 | "OSPF area ID as a decimal value\n" |
| 421 | "Summarize routes matching address/mask (border routers only)\n" |
| 422 | "Area range prefix\n") |
| 423 | { |
| 424 | struct ospf *ospf = vty->index; |
| 425 | struct prefix_ipv4 p; |
| 426 | struct in_addr area_id; |
| 427 | int format; |
| 428 | u_int32_t cost; |
| 429 | |
| 430 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 431 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 432 | |
| 433 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 434 | if (argc > 2) |
| 435 | { |
| 436 | VTY_GET_UINT32 ("range cost", cost, argv[2]); |
| 437 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 438 | } |
| 439 | |
| 440 | return CMD_SUCCESS; |
| 441 | } |
| 442 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 443 | ALIAS (ospf_area_range, |
| 444 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 445 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 446 | "OSPF area parameters\n" |
| 447 | "OSPF area ID in IP address format\n" |
| 448 | "OSPF area ID as a decimal value\n" |
| 449 | "OSPF area range for route advertise (default)\n" |
| 450 | "Area range prefix\n" |
| 451 | "Advertise this range (default)\n") |
| 452 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 453 | ALIAS (ospf_area_range, |
| 454 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 455 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 456 | "OSPF area parameters\n" |
| 457 | "OSPF area ID in IP address format\n" |
| 458 | "OSPF area ID as a decimal value\n" |
| 459 | "Summarize routes matching address/mask (border routers only)\n" |
| 460 | "Area range prefix\n" |
| 461 | "User specified metric for this range\n" |
| 462 | "Advertised metric for this range\n") |
| 463 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 464 | ALIAS (ospf_area_range, |
| 465 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 466 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 467 | "OSPF area parameters\n" |
| 468 | "OSPF area ID in IP address format\n" |
| 469 | "OSPF area ID as a decimal value\n" |
| 470 | "Summarize routes matching address/mask (border routers only)\n" |
| 471 | "Area range prefix\n" |
| 472 | "Advertise this range (default)\n" |
| 473 | "User specified metric for this range\n" |
| 474 | "Advertised metric for this range\n") |
| 475 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 476 | DEFUN (ospf_area_range_not_advertise, |
| 477 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 478 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 479 | "OSPF area parameters\n" |
| 480 | "OSPF area ID in IP address format\n" |
| 481 | "OSPF area ID as a decimal value\n" |
| 482 | "Summarize routes matching address/mask (border routers only)\n" |
| 483 | "Area range prefix\n" |
| 484 | "DoNotAdvertise this range\n") |
| 485 | { |
| 486 | struct ospf *ospf = vty->index; |
| 487 | struct prefix_ipv4 p; |
| 488 | struct in_addr area_id; |
| 489 | int format; |
| 490 | |
| 491 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 492 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 493 | |
| 494 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 495 | |
| 496 | return CMD_SUCCESS; |
| 497 | } |
| 498 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 499 | DEFUN (no_ospf_area_range, |
| 500 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 501 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 502 | NO_STR |
| 503 | "OSPF area parameters\n" |
| 504 | "OSPF area ID in IP address format\n" |
| 505 | "OSPF area ID as a decimal value\n" |
| 506 | "Summarize routes matching address/mask (border routers only)\n" |
| 507 | "Area range prefix\n") |
| 508 | { |
| 509 | struct ospf *ospf = vty->index; |
| 510 | struct prefix_ipv4 p; |
| 511 | struct in_addr area_id; |
| 512 | int format; |
| 513 | |
| 514 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 515 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 516 | |
| 517 | ospf_area_range_unset (ospf, area_id, &p); |
| 518 | |
| 519 | return CMD_SUCCESS; |
| 520 | } |
| 521 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 522 | ALIAS (no_ospf_area_range, |
| 523 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 525 | NO_STR |
| 526 | "OSPF area parameters\n" |
| 527 | "OSPF area ID in IP address format\n" |
| 528 | "OSPF area ID as a decimal value\n" |
| 529 | "Summarize routes matching address/mask (border routers only)\n" |
| 530 | "Area range prefix\n" |
| 531 | "Advertise this range (default)\n" |
| 532 | "DoNotAdvertise this range\n") |
| 533 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 534 | ALIAS (no_ospf_area_range, |
| 535 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 537 | NO_STR |
| 538 | "OSPF area parameters\n" |
| 539 | "OSPF area ID in IP address format\n" |
| 540 | "OSPF area ID as a decimal value\n" |
| 541 | "Summarize routes matching address/mask (border routers only)\n" |
| 542 | "Area range prefix\n" |
| 543 | "User specified metric for this range\n" |
| 544 | "Advertised metric for this range\n") |
| 545 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 546 | ALIAS (no_ospf_area_range, |
| 547 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 548 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 549 | NO_STR |
| 550 | "OSPF area parameters\n" |
| 551 | "OSPF area ID in IP address format\n" |
| 552 | "OSPF area ID as a decimal value\n" |
| 553 | "Summarize routes matching address/mask (border routers only)\n" |
| 554 | "Area range prefix\n" |
| 555 | "Advertise this range (default)\n" |
| 556 | "User specified metric for this range\n" |
| 557 | "Advertised metric for this range\n") |
| 558 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 559 | DEFUN (ospf_area_range_substitute, |
| 560 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 562 | "OSPF area parameters\n" |
| 563 | "OSPF area ID in IP address format\n" |
| 564 | "OSPF area ID as a decimal value\n" |
| 565 | "Summarize routes matching address/mask (border routers only)\n" |
| 566 | "Area range prefix\n" |
| 567 | "Announce area range as another prefix\n" |
| 568 | "Network prefix to be announced instead of range\n") |
| 569 | { |
| 570 | struct ospf *ospf = vty->index; |
| 571 | struct prefix_ipv4 p, s; |
| 572 | struct in_addr area_id; |
| 573 | int format; |
| 574 | |
| 575 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 576 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 577 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 578 | |
| 579 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 580 | |
| 581 | return CMD_SUCCESS; |
| 582 | } |
| 583 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 584 | DEFUN (no_ospf_area_range_substitute, |
| 585 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 587 | NO_STR |
| 588 | "OSPF area parameters\n" |
| 589 | "OSPF area ID in IP address format\n" |
| 590 | "OSPF area ID as a decimal value\n" |
| 591 | "Summarize routes matching address/mask (border routers only)\n" |
| 592 | "Area range prefix\n" |
| 593 | "Announce area range as another prefix\n" |
| 594 | "Network prefix to be announced instead of range\n") |
| 595 | { |
| 596 | struct ospf *ospf = vty->index; |
| 597 | struct prefix_ipv4 p, s; |
| 598 | struct in_addr area_id; |
| 599 | int format; |
| 600 | |
| 601 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 602 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 603 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 604 | |
| 605 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 606 | |
| 607 | return CMD_SUCCESS; |
| 608 | } |
| 609 | |
| 610 | |
| 611 | /* Command Handler Logic in VLink stuff is delicate!! |
| 612 | |
| 613 | ALTER AT YOUR OWN RISK!!!! |
| 614 | |
| 615 | Various dummy values are used to represent 'NoChange' state for |
| 616 | VLink configuration NOT being changed by a VLink command, and |
| 617 | special syntax is used within the command strings so that the |
| 618 | typed in command verbs can be seen in the configuration command |
| 619 | bacckend handler. This is to drastically reduce the verbeage |
| 620 | required to coe up with a reasonably compatible Cisco VLink command |
| 621 | |
| 622 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 623 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 624 | */ |
| 625 | |
| 626 | |
| 627 | /* Configuration data for virtual links |
| 628 | */ |
| 629 | struct ospf_vl_config_data { |
| 630 | struct vty *vty; /* vty stuff */ |
| 631 | struct in_addr area_id; /* area ID from command line */ |
| 632 | int format; /* command line area ID format */ |
| 633 | struct in_addr vl_peer; /* command line vl_peer */ |
| 634 | int auth_type; /* Authehntication type, if given */ |
| 635 | char *auth_key; /* simple password if present */ |
| 636 | int crypto_key_id; /* Cryptographic key ID */ |
| 637 | char *md5_key; /* MD5 authentication key */ |
| 638 | int hello_interval; /* Obvious what these are... */ |
| 639 | int retransmit_interval; |
| 640 | int transmit_delay; |
| 641 | int dead_interval; |
| 642 | }; |
| 643 | |
| 644 | void |
| 645 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 646 | struct vty *vty) |
| 647 | { |
| 648 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 649 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 650 | vl_config->vty = vty; |
| 651 | } |
| 652 | |
| 653 | struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 654 | 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] | 655 | { |
| 656 | struct ospf_area *area; |
| 657 | struct ospf_vl_data *vl_data; |
| 658 | struct vty *vty; |
| 659 | struct in_addr area_id; |
| 660 | |
| 661 | vty = vl_config->vty; |
| 662 | area_id = vl_config->area_id; |
| 663 | |
| 664 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 665 | { |
| 666 | vty_out (vty, |
| 667 | "Configuring VLs over the backbone is not allowed%s", |
| 668 | VTY_NEWLINE); |
| 669 | return NULL; |
| 670 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 671 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 672 | |
| 673 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 674 | { |
| 675 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 676 | vty_out (vty, "Area %s is %s%s", |
| 677 | inet_ntoa (area_id), |
| 678 | #ifdef HAVE_NSSA |
| 679 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
| 680 | #else |
| 681 | "stub", |
| 682 | #endif /* HAVE_NSSA */ |
| 683 | VTY_NEWLINE); |
| 684 | else |
| 685 | vty_out (vty, "Area %ld is %s%s", |
| 686 | (u_long)ntohl (area_id.s_addr), |
| 687 | #ifdef HAVE_NSSA |
| 688 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
| 689 | #else |
| 690 | "stub", |
| 691 | #endif /* HAVE_NSSA */ |
| 692 | VTY_NEWLINE); |
| 693 | return NULL; |
| 694 | } |
| 695 | |
| 696 | if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL) |
| 697 | { |
| 698 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 699 | if (vl_data->vl_oi == NULL) |
| 700 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 701 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 702 | ospf_vl_add (ospf, vl_data); |
| 703 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 704 | } |
| 705 | } |
| 706 | return vl_data; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | int |
| 711 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 712 | struct ospf_vl_config_data *vl_config) |
| 713 | { |
| 714 | struct crypt_key *ck; |
| 715 | struct vty *vty; |
| 716 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 717 | |
| 718 | vty = vl_config->vty; |
| 719 | |
| 720 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 721 | { |
| 722 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 723 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 724 | } |
| 725 | |
| 726 | if (vl_config->auth_key) |
| 727 | { |
| 728 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
| 729 | strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
| 730 | OSPF_AUTH_SIMPLE_SIZE); |
| 731 | } |
| 732 | else if (vl_config->md5_key) |
| 733 | { |
| 734 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 735 | != NULL) |
| 736 | { |
| 737 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 738 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 739 | return CMD_WARNING; |
| 740 | } |
| 741 | ck = ospf_crypt_key_new (); |
| 742 | ck->key_id = vl_config->crypto_key_id; |
| 743 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 744 | strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
| 745 | |
| 746 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 747 | } |
| 748 | else if (vl_config->crypto_key_id != 0) |
| 749 | { |
| 750 | /* Delete a key */ |
| 751 | |
| 752 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 753 | vl_config->crypto_key_id) == NULL) |
| 754 | { |
| 755 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 756 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 757 | return CMD_WARNING; |
| 758 | } |
| 759 | |
| 760 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 761 | |
| 762 | } |
| 763 | |
| 764 | return CMD_SUCCESS; |
| 765 | } |
| 766 | |
| 767 | |
| 768 | |
| 769 | int |
| 770 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 771 | struct ospf_vl_config_data *vl_config) |
| 772 | { |
| 773 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 774 | /* Virtual Link data initialised to defaults, so only set |
| 775 | if a value given */ |
| 776 | if (vl_config->hello_interval) |
| 777 | { |
| 778 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 779 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 780 | } |
| 781 | |
| 782 | if (vl_config->dead_interval) |
| 783 | { |
| 784 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 785 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 786 | } |
| 787 | |
| 788 | if (vl_config->retransmit_interval) |
| 789 | { |
| 790 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 791 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 792 | } |
| 793 | |
| 794 | if (vl_config->transmit_delay) |
| 795 | { |
| 796 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 797 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 798 | } |
| 799 | |
| 800 | return CMD_SUCCESS; |
| 801 | } |
| 802 | |
| 803 | |
| 804 | |
| 805 | /* The business end of all of the above */ |
| 806 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 807 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 808 | { |
| 809 | struct ospf_vl_data *vl_data; |
| 810 | int ret; |
| 811 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 812 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | if (!vl_data) |
| 814 | return CMD_WARNING; |
| 815 | |
| 816 | /* Process this one first as it can have a fatal result, which can |
| 817 | only logically occur if the virtual link exists already |
| 818 | Thus a command error does not result in a change to the |
| 819 | running configuration such as unexpectedly altered timer |
| 820 | values etc.*/ |
| 821 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 822 | if (ret != CMD_SUCCESS) |
| 823 | return ret; |
| 824 | |
| 825 | /* Set any time based parameters, these area already range checked */ |
| 826 | |
| 827 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 828 | if (ret != CMD_SUCCESS) |
| 829 | return ret; |
| 830 | |
| 831 | return CMD_SUCCESS; |
| 832 | |
| 833 | } |
| 834 | |
| 835 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 836 | */ |
| 837 | #define VLINK_HELPSTR_IPADDR \ |
| 838 | "OSPF area parameters\n" \ |
| 839 | "OSPF area ID in IP address format\n" \ |
| 840 | "OSPF area ID as a decimal value\n" \ |
| 841 | "Configure a virtual link\n" \ |
| 842 | "Router ID of the remote ABR\n" |
| 843 | |
| 844 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 845 | "Enable authentication on this virtual link\n" \ |
| 846 | "dummy string \n" |
| 847 | |
| 848 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 849 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 850 | "Use null authentication\n" \ |
| 851 | "Use message-digest authentication\n" |
| 852 | |
| 853 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 854 | "Time between HELLO packets\n" \ |
| 855 | "Time between retransmitting lost link state advertisements\n" \ |
| 856 | "Link state transmit delay\n" \ |
| 857 | "Interval after which a neighbor is declared dead\n" |
| 858 | |
| 859 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 860 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 861 | "Seconds\n" |
| 862 | |
| 863 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 864 | "Authentication password (key)\n" \ |
| 865 | "The OSPF password (key)" |
| 866 | |
| 867 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 868 | "Message digest authentication password (key)\n" \ |
| 869 | "dummy string \n" \ |
| 870 | "Key ID\n" \ |
| 871 | "Use MD5 algorithm\n" \ |
| 872 | "The OSPF password (key)" |
| 873 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 874 | DEFUN (ospf_area_vlink, |
| 875 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 876 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 877 | VLINK_HELPSTR_IPADDR) |
| 878 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 879 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 880 | struct ospf_vl_config_data vl_config; |
| 881 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 882 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 883 | int i; |
| 884 | int ret; |
| 885 | |
| 886 | ospf_vl_config_data_init(&vl_config, vty); |
| 887 | |
| 888 | /* Read off first 2 parameters and check them */ |
| 889 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 890 | if (ret < 0) |
| 891 | { |
| 892 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 893 | return CMD_WARNING; |
| 894 | } |
| 895 | |
| 896 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 897 | if (! ret) |
| 898 | { |
| 899 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 900 | VTY_NEWLINE); |
| 901 | return CMD_WARNING; |
| 902 | } |
| 903 | |
| 904 | if (argc <=2) |
| 905 | { |
| 906 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 907 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 908 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | /* Deal with other parameters */ |
| 912 | for (i=2; i < argc; i++) |
| 913 | { |
| 914 | |
| 915 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 916 | |
| 917 | switch (argv[i][0]) |
| 918 | { |
| 919 | |
| 920 | case 'a': |
| 921 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 922 | { |
| 923 | /* authentication-key - this option can occur anywhere on |
| 924 | command line. At start of command line |
| 925 | must check for authentication option. */ |
| 926 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 927 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 928 | vl_config.auth_key = auth_key; |
| 929 | i++; |
| 930 | } |
| 931 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 932 | { |
| 933 | /* authentication - this option can only occur at start |
| 934 | of command line */ |
| 935 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 936 | if ((i+1) < argc) |
| 937 | { |
| 938 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 939 | { |
| 940 | /* "authentication null" */ |
| 941 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 942 | i++; |
| 943 | } |
| 944 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 945 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 946 | { |
| 947 | /* "authentication message-digest" */ |
| 948 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 949 | i++; |
| 950 | } |
| 951 | } |
| 952 | } |
| 953 | break; |
| 954 | |
| 955 | case 'm': |
| 956 | /* message-digest-key */ |
| 957 | i++; |
| 958 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 959 | if (vl_config.crypto_key_id < 0) |
| 960 | return CMD_WARNING; |
| 961 | i++; |
| 962 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 963 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 964 | vl_config.md5_key = md5_key; |
| 965 | break; |
| 966 | |
| 967 | case 'h': |
| 968 | /* Hello interval */ |
| 969 | i++; |
| 970 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 971 | if (vl_config.hello_interval < 0) |
| 972 | return CMD_WARNING; |
| 973 | break; |
| 974 | |
| 975 | case 'r': |
| 976 | /* Retransmit Interval */ |
| 977 | i++; |
| 978 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 979 | if (vl_config.retransmit_interval < 0) |
| 980 | return CMD_WARNING; |
| 981 | break; |
| 982 | |
| 983 | case 't': |
| 984 | /* Transmit Delay */ |
| 985 | i++; |
| 986 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 987 | if (vl_config.transmit_delay < 0) |
| 988 | return CMD_WARNING; |
| 989 | break; |
| 990 | |
| 991 | case 'd': |
| 992 | /* Dead Interval */ |
| 993 | i++; |
| 994 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 995 | if (vl_config.dead_interval < 0) |
| 996 | return CMD_WARNING; |
| 997 | break; |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | |
| 1002 | /* Action configuration */ |
| 1003 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1004 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1005 | |
| 1006 | } |
| 1007 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1008 | DEFUN (no_ospf_area_vlink, |
| 1009 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1010 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1011 | NO_STR |
| 1012 | VLINK_HELPSTR_IPADDR) |
| 1013 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1014 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1015 | struct ospf_area *area; |
| 1016 | struct ospf_vl_config_data vl_config; |
| 1017 | struct ospf_vl_data *vl_data = NULL; |
| 1018 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1019 | int i; |
| 1020 | int ret, format; |
| 1021 | |
| 1022 | ospf_vl_config_data_init(&vl_config, vty); |
| 1023 | |
| 1024 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1025 | if (ret < 0) |
| 1026 | { |
| 1027 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1028 | return CMD_WARNING; |
| 1029 | } |
| 1030 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1031 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1032 | if (!area) |
| 1033 | { |
| 1034 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1035 | return CMD_WARNING; |
| 1036 | } |
| 1037 | |
| 1038 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1039 | if (! ret) |
| 1040 | { |
| 1041 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1042 | VTY_NEWLINE); |
| 1043 | return CMD_WARNING; |
| 1044 | } |
| 1045 | |
| 1046 | if (argc <=2) |
| 1047 | { |
| 1048 | /* Basic VLink no command */ |
| 1049 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 1050 | if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1051 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1052 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1053 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1054 | |
| 1055 | return CMD_SUCCESS; |
| 1056 | } |
| 1057 | |
| 1058 | /* If we are down here, we are reseting parameters */ |
| 1059 | |
| 1060 | /* Deal with other parameters */ |
| 1061 | for (i=2; i < argc; i++) |
| 1062 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1063 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1064 | |
| 1065 | switch (argv[i][0]) |
| 1066 | { |
| 1067 | |
| 1068 | case 'a': |
| 1069 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1070 | { |
| 1071 | /* authentication-key - this option can occur anywhere on |
| 1072 | command line. At start of command line |
| 1073 | must check for authentication option. */ |
| 1074 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1075 | vl_config.auth_key = auth_key; |
| 1076 | } |
| 1077 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1078 | { |
| 1079 | /* authentication - this option can only occur at start |
| 1080 | of command line */ |
| 1081 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1082 | } |
| 1083 | break; |
| 1084 | |
| 1085 | case 'm': |
| 1086 | /* message-digest-key */ |
| 1087 | /* Delete one key */ |
| 1088 | i++; |
| 1089 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1090 | if (vl_config.crypto_key_id < 0) |
| 1091 | return CMD_WARNING; |
| 1092 | vl_config.md5_key = NULL; |
| 1093 | break; |
| 1094 | |
| 1095 | case 'h': |
| 1096 | /* Hello interval */ |
| 1097 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1098 | break; |
| 1099 | |
| 1100 | case 'r': |
| 1101 | /* Retransmit Interval */ |
| 1102 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1103 | break; |
| 1104 | |
| 1105 | case 't': |
| 1106 | /* Transmit Delay */ |
| 1107 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1108 | break; |
| 1109 | |
| 1110 | case 'd': |
| 1111 | /* Dead Interval */ |
| 1112 | i++; |
| 1113 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1114 | break; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | |
| 1119 | /* Action configuration */ |
| 1120 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1121 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1122 | } |
| 1123 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1124 | ALIAS (ospf_area_vlink, |
| 1125 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1126 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1127 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1128 | VLINK_HELPSTR_IPADDR |
| 1129 | VLINK_HELPSTR_TIME_PARAM) |
| 1130 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1131 | ALIAS (no_ospf_area_vlink, |
| 1132 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1133 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1134 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1135 | NO_STR |
| 1136 | VLINK_HELPSTR_IPADDR |
| 1137 | VLINK_HELPSTR_TIME_PARAM) |
| 1138 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1139 | ALIAS (ospf_area_vlink, |
| 1140 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1141 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1142 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1143 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1144 | VLINK_HELPSTR_IPADDR |
| 1145 | VLINK_HELPSTR_TIME_PARAM |
| 1146 | VLINK_HELPSTR_TIME_PARAM) |
| 1147 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1148 | ALIAS (no_ospf_area_vlink, |
| 1149 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1150 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1151 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1152 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1153 | NO_STR |
| 1154 | VLINK_HELPSTR_IPADDR |
| 1155 | VLINK_HELPSTR_TIME_PARAM |
| 1156 | VLINK_HELPSTR_TIME_PARAM) |
| 1157 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1158 | ALIAS (ospf_area_vlink, |
| 1159 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1160 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1161 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1162 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1163 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1164 | VLINK_HELPSTR_IPADDR |
| 1165 | VLINK_HELPSTR_TIME_PARAM |
| 1166 | VLINK_HELPSTR_TIME_PARAM |
| 1167 | VLINK_HELPSTR_TIME_PARAM) |
| 1168 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1169 | ALIAS (no_ospf_area_vlink, |
| 1170 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1171 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1172 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1173 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1174 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1175 | NO_STR |
| 1176 | VLINK_HELPSTR_IPADDR |
| 1177 | VLINK_HELPSTR_TIME_PARAM |
| 1178 | VLINK_HELPSTR_TIME_PARAM |
| 1179 | VLINK_HELPSTR_TIME_PARAM) |
| 1180 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1181 | ALIAS (ospf_area_vlink, |
| 1182 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1183 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1184 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1185 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1186 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1187 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1188 | VLINK_HELPSTR_IPADDR |
| 1189 | VLINK_HELPSTR_TIME_PARAM |
| 1190 | VLINK_HELPSTR_TIME_PARAM |
| 1191 | VLINK_HELPSTR_TIME_PARAM |
| 1192 | VLINK_HELPSTR_TIME_PARAM) |
| 1193 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1194 | ALIAS (no_ospf_area_vlink, |
| 1195 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1196 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1197 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1198 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1199 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1200 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1201 | NO_STR |
| 1202 | VLINK_HELPSTR_IPADDR |
| 1203 | VLINK_HELPSTR_TIME_PARAM |
| 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_authtype_args_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 | "(authentication|) (message-digest|null)", |
| 1212 | VLINK_HELPSTR_IPADDR |
| 1213 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1214 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1215 | ALIAS (ospf_area_vlink, |
| 1216 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1217 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1218 | "(authentication|)", |
| 1219 | VLINK_HELPSTR_IPADDR |
| 1220 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1221 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1222 | ALIAS (no_ospf_area_vlink, |
| 1223 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1224 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1225 | "(authentication|)", |
| 1226 | NO_STR |
| 1227 | VLINK_HELPSTR_IPADDR |
| 1228 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1229 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1230 | ALIAS (ospf_area_vlink, |
| 1231 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1232 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1233 | "(message-digest-key|) <1-255> md5 KEY", |
| 1234 | VLINK_HELPSTR_IPADDR |
| 1235 | VLINK_HELPSTR_AUTH_MD5) |
| 1236 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1237 | ALIAS (no_ospf_area_vlink, |
| 1238 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1239 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1240 | "(message-digest-key|) <1-255>", |
| 1241 | NO_STR |
| 1242 | VLINK_HELPSTR_IPADDR |
| 1243 | VLINK_HELPSTR_AUTH_MD5) |
| 1244 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1245 | ALIAS (ospf_area_vlink, |
| 1246 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1248 | "(authentication-key|) AUTH_KEY", |
| 1249 | VLINK_HELPSTR_IPADDR |
| 1250 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1251 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1252 | ALIAS (no_ospf_area_vlink, |
| 1253 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1254 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1255 | "(authentication-key|)", |
| 1256 | NO_STR |
| 1257 | VLINK_HELPSTR_IPADDR |
| 1258 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1259 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1260 | ALIAS (ospf_area_vlink, |
| 1261 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1262 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1263 | "(authentication|) (message-digest|null) " |
| 1264 | "(authentication-key|) AUTH_KEY", |
| 1265 | VLINK_HELPSTR_IPADDR |
| 1266 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1267 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1268 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1269 | ALIAS (ospf_area_vlink, |
| 1270 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1271 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1272 | "(authentication|) " |
| 1273 | "(authentication-key|) AUTH_KEY", |
| 1274 | VLINK_HELPSTR_IPADDR |
| 1275 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1276 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1277 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1278 | ALIAS (no_ospf_area_vlink, |
| 1279 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1280 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1281 | "(authentication|) " |
| 1282 | "(authentication-key|)", |
| 1283 | NO_STR |
| 1284 | VLINK_HELPSTR_IPADDR |
| 1285 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1286 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1287 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1288 | ALIAS (ospf_area_vlink, |
| 1289 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1290 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1291 | "(authentication|) (message-digest|null) " |
| 1292 | "(message-digest-key|) <1-255> md5 KEY", |
| 1293 | VLINK_HELPSTR_IPADDR |
| 1294 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1295 | VLINK_HELPSTR_AUTH_MD5) |
| 1296 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1297 | ALIAS (ospf_area_vlink, |
| 1298 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1299 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1300 | "(authentication|) " |
| 1301 | "(message-digest-key|) <1-255> md5 KEY", |
| 1302 | VLINK_HELPSTR_IPADDR |
| 1303 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1304 | VLINK_HELPSTR_AUTH_MD5) |
| 1305 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1306 | ALIAS (no_ospf_area_vlink, |
| 1307 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1308 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1309 | "(authentication|) " |
| 1310 | "(message-digest-key|)", |
| 1311 | NO_STR |
| 1312 | VLINK_HELPSTR_IPADDR |
| 1313 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1314 | VLINK_HELPSTR_AUTH_MD5) |
| 1315 | |
| 1316 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1317 | DEFUN (ospf_area_shortcut, |
| 1318 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1319 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1320 | "OSPF area parameters\n" |
| 1321 | "OSPF area ID in IP address format\n" |
| 1322 | "OSPF area ID as a decimal value\n" |
| 1323 | "Configure the area's shortcutting mode\n" |
| 1324 | "Set default shortcutting behavior\n" |
| 1325 | "Enable shortcutting through the area\n" |
| 1326 | "Disable shortcutting through the area\n") |
| 1327 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1328 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1329 | struct ospf_area *area; |
| 1330 | struct in_addr area_id; |
| 1331 | int mode; |
| 1332 | int format; |
| 1333 | |
| 1334 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1335 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1336 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1337 | |
| 1338 | if (strncmp (argv[1], "de", 2) == 0) |
| 1339 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1340 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1341 | mode = OSPF_SHORTCUT_DISABLE; |
| 1342 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1343 | mode = OSPF_SHORTCUT_ENABLE; |
| 1344 | else |
| 1345 | return CMD_WARNING; |
| 1346 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1347 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1348 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1349 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1350 | vty_out (vty, "Shortcut area setting will take effect " |
| 1351 | "only when the router is configured as Shortcut ABR%s", |
| 1352 | VTY_NEWLINE); |
| 1353 | |
| 1354 | return CMD_SUCCESS; |
| 1355 | } |
| 1356 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1357 | DEFUN (no_ospf_area_shortcut, |
| 1358 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1359 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1360 | NO_STR |
| 1361 | "OSPF area parameters\n" |
| 1362 | "OSPF area ID in IP address format\n" |
| 1363 | "OSPF area ID as a decimal value\n" |
| 1364 | "Deconfigure the area's shortcutting mode\n" |
| 1365 | "Deconfigure enabled shortcutting through the area\n" |
| 1366 | "Deconfigure disabled shortcutting through the area\n") |
| 1367 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1368 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1369 | struct ospf_area *area; |
| 1370 | struct in_addr area_id; |
| 1371 | int format; |
| 1372 | |
| 1373 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1374 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1375 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1376 | if (!area) |
| 1377 | return CMD_SUCCESS; |
| 1378 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1379 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1380 | |
| 1381 | return CMD_SUCCESS; |
| 1382 | } |
| 1383 | |
| 1384 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1385 | DEFUN (ospf_area_stub, |
| 1386 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1387 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1388 | "OSPF area parameters\n" |
| 1389 | "OSPF area ID in IP address format\n" |
| 1390 | "OSPF area ID as a decimal value\n" |
| 1391 | "Configure OSPF area as stub\n") |
| 1392 | { |
| 1393 | struct ospf *ospf = vty->index; |
| 1394 | struct in_addr area_id; |
| 1395 | int ret, format; |
| 1396 | |
| 1397 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1398 | |
| 1399 | ret = ospf_area_stub_set (ospf, area_id); |
| 1400 | if (ret == 0) |
| 1401 | { |
| 1402 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1403 | VTY_NEWLINE); |
| 1404 | return CMD_WARNING; |
| 1405 | } |
| 1406 | |
| 1407 | ospf_area_no_summary_unset (ospf, area_id); |
| 1408 | |
| 1409 | return CMD_SUCCESS; |
| 1410 | } |
| 1411 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1412 | DEFUN (ospf_area_stub_no_summary, |
| 1413 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1414 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1415 | "OSPF stub 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 | "Do not inject inter-area routes into stub\n") |
| 1420 | { |
| 1421 | struct ospf *ospf = vty->index; |
| 1422 | struct in_addr area_id; |
| 1423 | int ret, format; |
| 1424 | |
| 1425 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1426 | |
| 1427 | ret = ospf_area_stub_set (ospf, area_id); |
| 1428 | if (ret == 0) |
| 1429 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1430 | 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] | 1431 | VTY_NEWLINE); |
| 1432 | return CMD_WARNING; |
| 1433 | } |
| 1434 | |
| 1435 | ospf_area_no_summary_set (ospf, area_id); |
| 1436 | |
| 1437 | return CMD_SUCCESS; |
| 1438 | } |
| 1439 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1440 | DEFUN (no_ospf_area_stub, |
| 1441 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1442 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1443 | NO_STR |
| 1444 | "OSPF area parameters\n" |
| 1445 | "OSPF area ID in IP address format\n" |
| 1446 | "OSPF area ID as a decimal value\n" |
| 1447 | "Configure OSPF area as stub\n") |
| 1448 | { |
| 1449 | struct ospf *ospf = vty->index; |
| 1450 | struct in_addr area_id; |
| 1451 | int format; |
| 1452 | |
| 1453 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1454 | |
| 1455 | ospf_area_stub_unset (ospf, area_id); |
| 1456 | ospf_area_no_summary_unset (ospf, area_id); |
| 1457 | |
| 1458 | return CMD_SUCCESS; |
| 1459 | } |
| 1460 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1461 | DEFUN (no_ospf_area_stub_no_summary, |
| 1462 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1463 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1464 | NO_STR |
| 1465 | "OSPF area parameters\n" |
| 1466 | "OSPF area ID in IP address format\n" |
| 1467 | "OSPF area ID as a decimal value\n" |
| 1468 | "Configure OSPF area as stub\n" |
| 1469 | "Do not inject inter-area routes into area\n") |
| 1470 | { |
| 1471 | struct ospf *ospf = vty->index; |
| 1472 | struct in_addr area_id; |
| 1473 | int format; |
| 1474 | |
| 1475 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1476 | ospf_area_no_summary_unset (ospf, area_id); |
| 1477 | |
| 1478 | return CMD_SUCCESS; |
| 1479 | } |
| 1480 | |
| 1481 | #ifdef HAVE_NSSA |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1482 | int |
| 1483 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, char **argv, int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1484 | { |
| 1485 | struct ospf *ospf = vty->index; |
| 1486 | struct in_addr area_id; |
| 1487 | int ret, format; |
| 1488 | |
| 1489 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1490 | |
| 1491 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1492 | if (ret == 0) |
| 1493 | { |
| 1494 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1495 | VTY_NEWLINE); |
| 1496 | return CMD_WARNING; |
| 1497 | } |
| 1498 | |
| 1499 | if (argc > 1) |
| 1500 | { |
| 1501 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1502 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1503 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1504 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1505 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1506 | OSPF_NSSA_ROLE_NEVER); |
| 1507 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1508 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1509 | OSPF_NSSA_ROLE_ALWAYS); |
| 1510 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1511 | else |
| 1512 | { |
| 1513 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1514 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1515 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1516 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1517 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1518 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1519 | else |
| 1520 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1521 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1522 | ospf_schedule_abr_task (ospf); |
| 1523 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1524 | return CMD_SUCCESS; |
| 1525 | } |
| 1526 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1527 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1528 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1529 | "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] | 1530 | "OSPF area parameters\n" |
| 1531 | "OSPF area ID in IP address format\n" |
| 1532 | "OSPF area ID as a decimal value\n" |
| 1533 | "Configure OSPF area as nssa\n" |
| 1534 | "Configure NSSA-ABR for translate election (default)\n" |
| 1535 | "Configure NSSA-ABR to never translate\n" |
| 1536 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1537 | "Do not inject inter-area routes into nssa\n") |
| 1538 | { |
| 1539 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1540 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1541 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1542 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1543 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1544 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1545 | "OSPF area parameters\n" |
| 1546 | "OSPF area ID in IP address format\n" |
| 1547 | "OSPF area ID as a decimal value\n" |
| 1548 | "Configure OSPF area as nssa\n" |
| 1549 | "Configure NSSA-ABR for translate election (default)\n" |
| 1550 | "Configure NSSA-ABR to never translate\n" |
| 1551 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1552 | { |
| 1553 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1554 | } |
| 1555 | |
| 1556 | DEFUN (ospf_area_nssa, |
| 1557 | ospf_area_nssa_cmd, |
| 1558 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1559 | "OSPF area parameters\n" |
| 1560 | "OSPF area ID in IP address format\n" |
| 1561 | "OSPF area ID as a decimal value\n" |
| 1562 | "Configure OSPF area as nssa\n") |
| 1563 | { |
| 1564 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1565 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1566 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1567 | DEFUN (ospf_area_nssa_no_summary, |
| 1568 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1569 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1570 | "OSPF area parameters\n" |
| 1571 | "OSPF area ID in IP address format\n" |
| 1572 | "OSPF area ID as a decimal value\n" |
| 1573 | "Configure OSPF area as nssa\n" |
| 1574 | "Do not inject inter-area routes into nssa\n") |
| 1575 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1576 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1577 | } |
| 1578 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1579 | DEFUN (no_ospf_area_nssa, |
| 1580 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1581 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1582 | NO_STR |
| 1583 | "OSPF area parameters\n" |
| 1584 | "OSPF area ID in IP address format\n" |
| 1585 | "OSPF area ID as a decimal value\n" |
| 1586 | "Configure OSPF area as nssa\n") |
| 1587 | { |
| 1588 | struct ospf *ospf = vty->index; |
| 1589 | struct in_addr area_id; |
| 1590 | int format; |
| 1591 | |
| 1592 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1593 | |
| 1594 | ospf_area_nssa_unset (ospf, area_id); |
| 1595 | ospf_area_no_summary_unset (ospf, area_id); |
| 1596 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1597 | ospf_schedule_abr_task (ospf); |
| 1598 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1599 | return CMD_SUCCESS; |
| 1600 | } |
| 1601 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1602 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1603 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1604 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1605 | NO_STR |
| 1606 | "OSPF area parameters\n" |
| 1607 | "OSPF area ID in IP address format\n" |
| 1608 | "OSPF area ID as a decimal value\n" |
| 1609 | "Configure OSPF area as nssa\n" |
| 1610 | "Do not inject inter-area routes into nssa\n") |
| 1611 | { |
| 1612 | struct ospf *ospf = vty->index; |
| 1613 | struct in_addr area_id; |
| 1614 | int format; |
| 1615 | |
| 1616 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1617 | ospf_area_no_summary_unset (ospf, area_id); |
| 1618 | |
| 1619 | return CMD_SUCCESS; |
| 1620 | } |
| 1621 | |
| 1622 | #endif /* HAVE_NSSA */ |
| 1623 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1624 | DEFUN (ospf_area_default_cost, |
| 1625 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1626 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1627 | "OSPF area parameters\n" |
| 1628 | "OSPF area ID in IP address format\n" |
| 1629 | "OSPF area ID as a decimal value\n" |
| 1630 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1631 | "Stub's advertised default summary cost\n") |
| 1632 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1633 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1634 | struct ospf_area *area; |
| 1635 | struct in_addr area_id; |
| 1636 | u_int32_t cost; |
| 1637 | int format; |
| 1638 | |
| 1639 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1640 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1641 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1642 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1643 | |
| 1644 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1645 | { |
| 1646 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1647 | return CMD_WARNING; |
| 1648 | } |
| 1649 | |
| 1650 | area->default_cost = cost; |
| 1651 | |
| 1652 | return CMD_SUCCESS; |
| 1653 | } |
| 1654 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1655 | DEFUN (no_ospf_area_default_cost, |
| 1656 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1657 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1658 | NO_STR |
| 1659 | "OSPF area parameters\n" |
| 1660 | "OSPF area ID in IP address format\n" |
| 1661 | "OSPF area ID as a decimal value\n" |
| 1662 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1663 | "Stub's advertised default summary cost\n") |
| 1664 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1665 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1666 | struct ospf_area *area; |
| 1667 | struct in_addr area_id; |
| 1668 | u_int32_t cost; |
| 1669 | int format; |
| 1670 | |
| 1671 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1672 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1673 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1674 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1675 | if (area == NULL) |
| 1676 | return CMD_SUCCESS; |
| 1677 | |
| 1678 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1679 | { |
| 1680 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1681 | return CMD_WARNING; |
| 1682 | } |
| 1683 | |
| 1684 | area->default_cost = 1; |
| 1685 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1686 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1687 | |
| 1688 | return CMD_SUCCESS; |
| 1689 | } |
| 1690 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1691 | DEFUN (ospf_area_export_list, |
| 1692 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1693 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 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 filter for networks announced to other areas\n" |
| 1698 | "Name of the access-list\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 | int format; |
| 1704 | |
| 1705 | VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]); |
| 1706 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1707 | area = ospf_area_get (ospf, area_id, format); |
| 1708 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1709 | |
| 1710 | return CMD_SUCCESS; |
| 1711 | } |
| 1712 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1713 | DEFUN (no_ospf_area_export_list, |
| 1714 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1715 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1716 | NO_STR |
| 1717 | "OSPF area parameters\n" |
| 1718 | "OSPF area ID in IP address format\n" |
| 1719 | "OSPF area ID as a decimal value\n" |
| 1720 | "Unset the filter for networks announced to other areas\n" |
| 1721 | "Name of the access-list\n") |
| 1722 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1723 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1724 | struct ospf_area *area; |
| 1725 | struct in_addr area_id; |
| 1726 | int format; |
| 1727 | |
| 1728 | VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]); |
| 1729 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1730 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1731 | if (area == NULL) |
| 1732 | return CMD_SUCCESS; |
| 1733 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1734 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1735 | |
| 1736 | return CMD_SUCCESS; |
| 1737 | } |
| 1738 | |
| 1739 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1740 | DEFUN (ospf_area_import_list, |
| 1741 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1742 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1743 | "OSPF area parameters\n" |
| 1744 | "OSPF area ID in IP address format\n" |
| 1745 | "OSPF area ID as a decimal value\n" |
| 1746 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1747 | "Name of the access-list\n") |
| 1748 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1749 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1750 | struct ospf_area *area; |
| 1751 | struct in_addr area_id; |
| 1752 | int format; |
| 1753 | |
| 1754 | VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]); |
| 1755 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1756 | area = ospf_area_get (ospf, area_id, format); |
| 1757 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1758 | |
| 1759 | return CMD_SUCCESS; |
| 1760 | } |
| 1761 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1762 | DEFUN (no_ospf_area_import_list, |
| 1763 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1764 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1765 | NO_STR |
| 1766 | "OSPF area parameters\n" |
| 1767 | "OSPF area ID in IP address format\n" |
| 1768 | "OSPF area ID as a decimal value\n" |
| 1769 | "Unset the filter for networks announced to other areas\n" |
| 1770 | "Name of the access-list\n") |
| 1771 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1772 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1773 | struct ospf_area *area; |
| 1774 | struct in_addr area_id; |
| 1775 | int format; |
| 1776 | |
| 1777 | VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1778 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1779 | if (area == NULL) |
| 1780 | return CMD_SUCCESS; |
| 1781 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1782 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1783 | |
| 1784 | return CMD_SUCCESS; |
| 1785 | } |
| 1786 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1787 | DEFUN (ospf_area_filter_list, |
| 1788 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1789 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1790 | "OSPF area parameters\n" |
| 1791 | "OSPF area ID in IP address format\n" |
| 1792 | "OSPF area ID as a decimal value\n" |
| 1793 | "Filter networks between OSPF areas\n" |
| 1794 | "Filter prefixes between OSPF areas\n" |
| 1795 | "Name of an IP prefix-list\n" |
| 1796 | "Filter networks sent to this area\n" |
| 1797 | "Filter networks sent from this area\n") |
| 1798 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1799 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1800 | struct ospf_area *area; |
| 1801 | struct in_addr area_id; |
| 1802 | struct prefix_list *plist; |
| 1803 | int format; |
| 1804 | |
| 1805 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1806 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1807 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1808 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1809 | if (strncmp (argv[2], "in", 2) == 0) |
| 1810 | { |
| 1811 | PREFIX_LIST_IN (area) = plist; |
| 1812 | if (PREFIX_NAME_IN (area)) |
| 1813 | free (PREFIX_NAME_IN (area)); |
| 1814 | |
| 1815 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1816 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1817 | } |
| 1818 | else |
| 1819 | { |
| 1820 | PREFIX_LIST_OUT (area) = plist; |
| 1821 | if (PREFIX_NAME_OUT (area)) |
| 1822 | free (PREFIX_NAME_OUT (area)); |
| 1823 | |
| 1824 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1825 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1826 | } |
| 1827 | |
| 1828 | return CMD_SUCCESS; |
| 1829 | } |
| 1830 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1831 | DEFUN (no_ospf_area_filter_list, |
| 1832 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1833 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1834 | NO_STR |
| 1835 | "OSPF area parameters\n" |
| 1836 | "OSPF area ID in IP address format\n" |
| 1837 | "OSPF area ID as a decimal value\n" |
| 1838 | "Filter networks between OSPF areas\n" |
| 1839 | "Filter prefixes between OSPF areas\n" |
| 1840 | "Name of an IP prefix-list\n" |
| 1841 | "Filter networks sent to this area\n" |
| 1842 | "Filter networks sent from this area\n") |
| 1843 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1844 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1845 | struct ospf_area *area; |
| 1846 | struct in_addr area_id; |
| 1847 | struct prefix_list *plist; |
| 1848 | int format; |
| 1849 | |
| 1850 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1851 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1852 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1853 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1854 | if (strncmp (argv[2], "in", 2) == 0) |
| 1855 | { |
| 1856 | if (PREFIX_NAME_IN (area)) |
| 1857 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1858 | return CMD_SUCCESS; |
| 1859 | |
| 1860 | PREFIX_LIST_IN (area) = NULL; |
| 1861 | if (PREFIX_NAME_IN (area)) |
| 1862 | free (PREFIX_NAME_IN (area)); |
| 1863 | |
| 1864 | PREFIX_NAME_IN (area) = NULL; |
| 1865 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1866 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1867 | } |
| 1868 | else |
| 1869 | { |
| 1870 | if (PREFIX_NAME_OUT (area)) |
| 1871 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1872 | return CMD_SUCCESS; |
| 1873 | |
| 1874 | PREFIX_LIST_OUT (area) = NULL; |
| 1875 | if (PREFIX_NAME_OUT (area)) |
| 1876 | free (PREFIX_NAME_OUT (area)); |
| 1877 | |
| 1878 | PREFIX_NAME_OUT (area) = NULL; |
| 1879 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1880 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | return CMD_SUCCESS; |
| 1884 | } |
| 1885 | |
| 1886 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1887 | DEFUN (ospf_area_authentication_message_digest, |
| 1888 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1889 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1890 | "OSPF area parameters\n" |
| 1891 | "Enable authentication\n" |
| 1892 | "Use message-digest authentication\n") |
| 1893 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1894 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1895 | struct ospf_area *area; |
| 1896 | struct in_addr area_id; |
| 1897 | int format; |
| 1898 | |
| 1899 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1900 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1901 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1902 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1903 | |
| 1904 | return CMD_SUCCESS; |
| 1905 | } |
| 1906 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1907 | DEFUN (ospf_area_authentication, |
| 1908 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1909 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1910 | "OSPF area parameters\n" |
| 1911 | "OSPF area ID in IP address format\n" |
| 1912 | "OSPF area ID as a decimal value\n" |
| 1913 | "Enable authentication\n") |
| 1914 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1915 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1916 | struct ospf_area *area; |
| 1917 | struct in_addr area_id; |
| 1918 | int format; |
| 1919 | |
| 1920 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1921 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1922 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1923 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1924 | |
| 1925 | return CMD_SUCCESS; |
| 1926 | } |
| 1927 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1928 | DEFUN (no_ospf_area_authentication, |
| 1929 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1930 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1931 | NO_STR |
| 1932 | "OSPF area parameters\n" |
| 1933 | "OSPF area ID in IP address format\n" |
| 1934 | "OSPF area ID as a decimal value\n" |
| 1935 | "Enable authentication\n") |
| 1936 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1937 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1938 | struct ospf_area *area; |
| 1939 | struct in_addr area_id; |
| 1940 | int format; |
| 1941 | |
| 1942 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1943 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1944 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1945 | if (area == NULL) |
| 1946 | return CMD_SUCCESS; |
| 1947 | |
| 1948 | area->auth_type = OSPF_AUTH_NULL; |
| 1949 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1950 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1951 | |
| 1952 | return CMD_SUCCESS; |
| 1953 | } |
| 1954 | |
| 1955 | |
| 1956 | DEFUN (ospf_abr_type, |
| 1957 | ospf_abr_type_cmd, |
| 1958 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 1959 | "OSPF specific commands\n" |
| 1960 | "Set OSPF ABR type\n" |
| 1961 | "Alternative ABR, cisco implementation\n" |
| 1962 | "Alternative ABR, IBM implementation\n" |
| 1963 | "Shortcut ABR\n" |
| 1964 | "Standard behavior (RFC2328)\n") |
| 1965 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1966 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1967 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 1968 | |
| 1969 | if (strncmp (argv[0], "c", 1) == 0) |
| 1970 | abr_type = OSPF_ABR_CISCO; |
| 1971 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1972 | abr_type = OSPF_ABR_IBM; |
| 1973 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 1974 | abr_type = OSPF_ABR_SHORTCUT; |
| 1975 | else if (strncmp (argv[0], "st", 2) == 0) |
| 1976 | abr_type = OSPF_ABR_STAND; |
| 1977 | else |
| 1978 | return CMD_WARNING; |
| 1979 | |
| 1980 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1981 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1982 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1983 | ospf->abr_type = abr_type; |
| 1984 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1985 | } |
| 1986 | |
| 1987 | return CMD_SUCCESS; |
| 1988 | } |
| 1989 | |
| 1990 | DEFUN (no_ospf_abr_type, |
| 1991 | no_ospf_abr_type_cmd, |
| 1992 | "no ospf abr-type (cisco|ibm|shortcut)", |
| 1993 | NO_STR |
| 1994 | "OSPF specific commands\n" |
| 1995 | "Set OSPF ABR type\n" |
| 1996 | "Alternative ABR, cisco implementation\n" |
| 1997 | "Alternative ABR, IBM implementation\n" |
| 1998 | "Shortcut ABR\n") |
| 1999 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2000 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2001 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2002 | |
| 2003 | if (strncmp (argv[0], "c", 1) == 0) |
| 2004 | abr_type = OSPF_ABR_CISCO; |
| 2005 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2006 | abr_type = OSPF_ABR_IBM; |
| 2007 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2008 | abr_type = OSPF_ABR_SHORTCUT; |
| 2009 | else |
| 2010 | return CMD_WARNING; |
| 2011 | |
| 2012 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2013 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2014 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2015 | ospf->abr_type = OSPF_ABR_STAND; |
| 2016 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | return CMD_SUCCESS; |
| 2020 | } |
| 2021 | |
| 2022 | DEFUN (ospf_compatible_rfc1583, |
| 2023 | ospf_compatible_rfc1583_cmd, |
| 2024 | "compatible rfc1583", |
| 2025 | "OSPF compatibility list\n" |
| 2026 | "compatible with RFC 1583\n") |
| 2027 | { |
| 2028 | struct ospf *ospf = vty->index; |
| 2029 | |
| 2030 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2031 | { |
| 2032 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2033 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2034 | } |
| 2035 | return CMD_SUCCESS; |
| 2036 | } |
| 2037 | |
| 2038 | DEFUN (no_ospf_compatible_rfc1583, |
| 2039 | no_ospf_compatible_rfc1583_cmd, |
| 2040 | "no compatible rfc1583", |
| 2041 | NO_STR |
| 2042 | "OSPF compatibility list\n" |
| 2043 | "compatible with RFC 1583\n") |
| 2044 | { |
| 2045 | struct ospf *ospf = vty->index; |
| 2046 | |
| 2047 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2048 | { |
| 2049 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2050 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2051 | } |
| 2052 | return CMD_SUCCESS; |
| 2053 | } |
| 2054 | |
| 2055 | ALIAS (ospf_compatible_rfc1583, |
| 2056 | ospf_rfc1583_flag_cmd, |
| 2057 | "ospf rfc1583compatibility", |
| 2058 | "OSPF specific commands\n" |
| 2059 | "Enable the RFC1583Compatibility flag\n") |
| 2060 | |
| 2061 | ALIAS (no_ospf_compatible_rfc1583, |
| 2062 | no_ospf_rfc1583_flag_cmd, |
| 2063 | "no ospf rfc1583compatibility", |
| 2064 | NO_STR |
| 2065 | "OSPF specific commands\n" |
| 2066 | "Disable the RFC1583Compatibility flag\n") |
| 2067 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2068 | DEFUN (ospf_timers_spf, |
| 2069 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2070 | "timers spf <0-4294967295> <0-4294967295>", |
| 2071 | "Adjust routing timers\n" |
| 2072 | "OSPF SPF timers\n" |
| 2073 | "Delay between receiving a change to SPF calculation\n" |
| 2074 | "Hold time between consecutive SPF calculations\n") |
| 2075 | { |
| 2076 | struct ospf *ospf = vty->index; |
| 2077 | u_int32_t delay, hold; |
| 2078 | |
| 2079 | VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]); |
| 2080 | VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]); |
| 2081 | |
| 2082 | ospf_timers_spf_set (ospf, delay, hold); |
| 2083 | |
| 2084 | return CMD_SUCCESS; |
| 2085 | } |
| 2086 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2087 | DEFUN (no_ospf_timers_spf, |
| 2088 | no_ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2089 | "no timers spf", |
| 2090 | NO_STR |
| 2091 | "Adjust routing timers\n" |
| 2092 | "OSPF SPF timers\n") |
| 2093 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2094 | struct ospf *ospf = vty->index; |
| 2095 | |
| 2096 | ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT; |
| 2097 | ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2098 | |
| 2099 | return CMD_SUCCESS; |
| 2100 | } |
| 2101 | |
| 2102 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2103 | DEFUN (ospf_neighbor, |
| 2104 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2105 | "neighbor A.B.C.D", |
| 2106 | NEIGHBOR_STR |
| 2107 | "Neighbor IP address\n") |
| 2108 | { |
| 2109 | struct ospf *ospf = vty->index; |
| 2110 | struct in_addr nbr_addr; |
| 2111 | int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2112 | int interval = OSPF_POLL_INTERVAL_DEFAULT; |
| 2113 | |
| 2114 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2115 | |
| 2116 | if (argc > 1) |
| 2117 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2118 | |
| 2119 | if (argc > 2) |
| 2120 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2121 | |
| 2122 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2123 | if (argc > 1) |
| 2124 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2125 | if (argc > 2) |
| 2126 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2127 | |
| 2128 | return CMD_SUCCESS; |
| 2129 | } |
| 2130 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2131 | ALIAS (ospf_neighbor, |
| 2132 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2133 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2134 | NEIGHBOR_STR |
| 2135 | "Neighbor IP address\n" |
| 2136 | "Neighbor Priority\n" |
| 2137 | "Priority\n" |
| 2138 | "Dead Neighbor Polling interval\n" |
| 2139 | "Seconds\n") |
| 2140 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2141 | ALIAS (ospf_neighbor, |
| 2142 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2143 | "neighbor A.B.C.D priority <0-255>", |
| 2144 | NEIGHBOR_STR |
| 2145 | "Neighbor IP address\n" |
| 2146 | "Neighbor Priority\n" |
| 2147 | "Seconds\n") |
| 2148 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2149 | DEFUN (ospf_neighbor_poll_interval, |
| 2150 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2151 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2152 | NEIGHBOR_STR |
| 2153 | "Neighbor IP address\n" |
| 2154 | "Dead Neighbor Polling interval\n" |
| 2155 | "Seconds\n") |
| 2156 | { |
| 2157 | struct ospf *ospf = vty->index; |
| 2158 | struct in_addr nbr_addr; |
| 2159 | int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2160 | int interval = OSPF_POLL_INTERVAL_DEFAULT; |
| 2161 | |
| 2162 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2163 | |
| 2164 | if (argc > 1) |
| 2165 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2166 | |
| 2167 | if (argc > 2) |
| 2168 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2169 | |
| 2170 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2171 | if (argc > 1) |
| 2172 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2173 | if (argc > 2) |
| 2174 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2175 | |
| 2176 | return CMD_SUCCESS; |
| 2177 | } |
| 2178 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2179 | ALIAS (ospf_neighbor_poll_interval, |
| 2180 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2181 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2182 | NEIGHBOR_STR |
| 2183 | "Neighbor address\n" |
| 2184 | "OSPF dead-router polling interval\n" |
| 2185 | "Seconds\n" |
| 2186 | "OSPF priority of non-broadcast neighbor\n" |
| 2187 | "Priority\n") |
| 2188 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2189 | DEFUN (no_ospf_neighbor, |
| 2190 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | "no neighbor A.B.C.D", |
| 2192 | NO_STR |
| 2193 | NEIGHBOR_STR |
| 2194 | "Neighbor IP address\n") |
| 2195 | { |
| 2196 | struct ospf *ospf = vty->index; |
| 2197 | struct in_addr nbr_addr; |
| 2198 | int ret; |
| 2199 | |
| 2200 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2201 | |
| 2202 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2203 | |
| 2204 | return CMD_SUCCESS; |
| 2205 | } |
| 2206 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2207 | ALIAS (no_ospf_neighbor, |
| 2208 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2209 | "no neighbor A.B.C.D priority <0-255>", |
| 2210 | NO_STR |
| 2211 | NEIGHBOR_STR |
| 2212 | "Neighbor IP address\n" |
| 2213 | "Neighbor Priority\n" |
| 2214 | "Priority\n") |
| 2215 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2216 | ALIAS (no_ospf_neighbor, |
| 2217 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2218 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2219 | NO_STR |
| 2220 | NEIGHBOR_STR |
| 2221 | "Neighbor IP address\n" |
| 2222 | "Dead Neighbor Polling interval\n" |
| 2223 | "Seconds\n") |
| 2224 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2225 | ALIAS (no_ospf_neighbor, |
| 2226 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2227 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2228 | NO_STR |
| 2229 | NEIGHBOR_STR |
| 2230 | "Neighbor IP address\n" |
| 2231 | "Neighbor Priority\n" |
| 2232 | "Priority\n" |
| 2233 | "Dead Neighbor Polling interval\n" |
| 2234 | "Seconds\n") |
| 2235 | |
| 2236 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2237 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | "refresh timer <10-1800>", |
| 2239 | "Adjust refresh parameters\n" |
| 2240 | "Set refresh timer\n" |
| 2241 | "Timer value in seconds\n") |
| 2242 | { |
| 2243 | struct ospf *ospf = vty->index; |
| 2244 | int interval; |
| 2245 | |
| 2246 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2247 | interval = (interval / 10) * 10; |
| 2248 | |
| 2249 | ospf_timers_refresh_set (ospf, interval); |
| 2250 | |
| 2251 | return CMD_SUCCESS; |
| 2252 | } |
| 2253 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2254 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2255 | "no refresh timer <10-1800>", |
| 2256 | "Adjust refresh parameters\n" |
| 2257 | "Unset refresh timer\n" |
| 2258 | "Timer value in seconds\n") |
| 2259 | { |
| 2260 | struct ospf *ospf = vty->index; |
| 2261 | int interval; |
| 2262 | |
| 2263 | if (argc == 1) |
| 2264 | { |
| 2265 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2266 | |
| 2267 | if (ospf->lsa_refresh_interval != interval || |
| 2268 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2269 | return CMD_SUCCESS; |
| 2270 | } |
| 2271 | |
| 2272 | ospf_timers_refresh_unset (ospf); |
| 2273 | |
| 2274 | return CMD_SUCCESS; |
| 2275 | } |
| 2276 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2277 | ALIAS (no_ospf_refresh_timer, |
| 2278 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | "no refresh timer", |
| 2280 | "Adjust refresh parameters\n" |
| 2281 | "Unset refresh timer\n") |
| 2282 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2283 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2284 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2285 | "auto-cost reference-bandwidth <1-4294967>", |
| 2286 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2287 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2288 | "The reference bandwidth in terms of Mbits per second\n") |
| 2289 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2290 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2291 | u_int32_t refbw; |
| 2292 | listnode node; |
| 2293 | |
| 2294 | refbw = strtol (argv[0], NULL, 10); |
| 2295 | if (refbw < 1 || refbw > 4294967) |
| 2296 | { |
| 2297 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2298 | return CMD_WARNING; |
| 2299 | } |
| 2300 | |
| 2301 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2302 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | return CMD_SUCCESS; |
| 2304 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2305 | ospf->ref_bandwidth = refbw * 1000; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2306 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2307 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2308 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2309 | for (node = listhead (om->iflist); node; nextnode (node)) |
| 2310 | ospf_if_recalculate_output_cost (getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | |
| 2312 | return CMD_SUCCESS; |
| 2313 | } |
| 2314 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2315 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2316 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2317 | "no auto-cost reference-bandwidth", |
| 2318 | NO_STR |
| 2319 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2320 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2321 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2322 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2323 | listnode node; |
| 2324 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2325 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2326 | return CMD_SUCCESS; |
| 2327 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2328 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2329 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2330 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2331 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2332 | for (node = listhead (om->iflist); node; nextnode (node)) |
| 2333 | ospf_if_recalculate_output_cost (getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2334 | |
| 2335 | return CMD_SUCCESS; |
| 2336 | } |
| 2337 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | char *ospf_abr_type_descr_str[] = |
| 2339 | { |
| 2340 | "Unknown", |
| 2341 | "Standard (RFC2328)", |
| 2342 | "Alternative IBM", |
| 2343 | "Alternative Cisco", |
| 2344 | "Alternative Shortcut" |
| 2345 | }; |
| 2346 | |
| 2347 | char *ospf_shortcut_mode_descr_str[] = |
| 2348 | { |
| 2349 | "Default", |
| 2350 | "Enabled", |
| 2351 | "Disabled" |
| 2352 | }; |
| 2353 | |
| 2354 | |
| 2355 | |
| 2356 | void |
| 2357 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2358 | { |
| 2359 | /* Show Area ID. */ |
| 2360 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2361 | |
| 2362 | /* Show Area type/mode. */ |
| 2363 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2364 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2365 | else |
| 2366 | { |
| 2367 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2368 | vty_out (vty, " (Stub%s%s)", |
| 2369 | area->no_summary ? ", no summary" : "", |
| 2370 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2371 | |
| 2372 | #ifdef HAVE_NSSA |
| 2373 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2374 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2375 | vty_out (vty, " (NSSA%s%s)", |
| 2376 | area->no_summary ? ", no summary" : "", |
| 2377 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2378 | #endif /* HAVE_NSSA */ |
| 2379 | |
| 2380 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2381 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2382 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2383 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2384 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2385 | } |
| 2386 | |
| 2387 | /* Show number of interfaces. */ |
| 2388 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2389 | "Active: %d%s", listcount (area->oiflist), |
| 2390 | area->act_ints, VTY_NEWLINE); |
| 2391 | |
| 2392 | #ifdef HAVE_NSSA |
| 2393 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2394 | { |
| 2395 | 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] | 2396 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2397 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2398 | VTY_NEWLINE); |
| 2399 | else if (area->NSSATranslatorState) |
| 2400 | { |
| 2401 | vty_out (vty, " We are an ABR and "); |
| 2402 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2403 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2404 | VTY_NEWLINE); |
| 2405 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2406 | vty_out (vty, "always an NSSA Translator. %s", |
| 2407 | VTY_NEWLINE); |
| 2408 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2409 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2410 | { |
| 2411 | vty_out (vty, " We are an ABR, but "); |
| 2412 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2413 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2414 | VTY_NEWLINE); |
| 2415 | else |
| 2416 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2417 | VTY_NEWLINE); |
| 2418 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2419 | } |
| 2420 | #endif /* HAVE_NSSA */ |
| 2421 | |
| 2422 | /* Show number of fully adjacent neighbors. */ |
| 2423 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2424 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2425 | |
| 2426 | /* Show authentication type. */ |
| 2427 | vty_out (vty, " Area has "); |
| 2428 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2429 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2430 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2431 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2432 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2433 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2434 | |
| 2435 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2436 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2437 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2438 | |
| 2439 | /* Show SPF calculation times. */ |
| 2440 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2441 | area->spf_calculation, VTY_NEWLINE); |
| 2442 | |
| 2443 | /* Show number of LSA. */ |
| 2444 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
| 2445 | |
| 2446 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2447 | } |
| 2448 | |
| 2449 | DEFUN (show_ip_ospf, |
| 2450 | show_ip_ospf_cmd, |
| 2451 | "show ip ospf", |
| 2452 | SHOW_STR |
| 2453 | IP_STR |
| 2454 | "OSPF information\n") |
| 2455 | { |
| 2456 | listnode node; |
| 2457 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2458 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2459 | |
| 2460 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2461 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2462 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2463 | { |
| 2464 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2465 | return CMD_SUCCESS; |
| 2466 | } |
| 2467 | |
| 2468 | /* Show Router ID. */ |
| 2469 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2470 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2471 | VTY_NEWLINE); |
| 2472 | |
| 2473 | /* Show capability. */ |
| 2474 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2475 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2476 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2477 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | "enabled" : "disabled", VTY_NEWLINE); |
| 2479 | #ifdef HAVE_OPAQUE_LSA |
| 2480 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2481 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2483 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2484 | " (origination blocked)" : "", |
| 2485 | VTY_NEWLINE); |
| 2486 | #endif /* HAVE_OPAQUE_LSA */ |
| 2487 | |
| 2488 | /* Show SPF timers. */ |
| 2489 | vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2490 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2491 | |
| 2492 | /* Show refresh parameters. */ |
| 2493 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2494 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2495 | |
| 2496 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2497 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2498 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2499 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2500 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2501 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2502 | vty_out (vty, " This router is an ASBR " |
| 2503 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2504 | |
| 2505 | /* Show Number of AS-external-LSAs. */ |
| 2506 | vty_out (vty, " Number of external LSA %ld%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2507 | ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | |
| 2509 | /* Show number of areas attached. */ |
| 2510 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2511 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2512 | |
| 2513 | /* Show each area status. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2514 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2515 | if ((area = getdata (node)) != NULL) |
| 2516 | show_ip_ospf_area (vty, area); |
| 2517 | |
| 2518 | return CMD_SUCCESS; |
| 2519 | } |
| 2520 | |
| 2521 | |
| 2522 | void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2523 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2524 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2525 | { |
| 2526 | struct ospf_neighbor *nbr; |
| 2527 | int oi_count; |
| 2528 | struct route_node *rn; |
| 2529 | char buf[9]; |
| 2530 | |
| 2531 | oi_count = ospf_oi_count (ifp); |
| 2532 | |
| 2533 | /* Is interface up? */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 2534 | if (if_is_operative (ifp)) { |
| 2535 | vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE); |
| 2536 | } else |
| 2537 | { |
| 2538 | vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2539 | |
| 2540 | |
| 2541 | if (oi_count == 0) |
| 2542 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2543 | else |
| 2544 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2545 | VTY_NEWLINE); |
| 2546 | return; |
| 2547 | } |
| 2548 | |
| 2549 | /* Is interface OSPF enabled? */ |
| 2550 | if (oi_count == 0) |
| 2551 | { |
| 2552 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2553 | return; |
| 2554 | } |
| 2555 | |
| 2556 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2557 | { |
| 2558 | struct ospf_interface *oi = rn->info; |
| 2559 | |
| 2560 | if (oi == NULL) |
| 2561 | continue; |
| 2562 | |
| 2563 | /* Show OSPF interface information. */ |
| 2564 | vty_out (vty, " Internet Address %s/%d,", |
| 2565 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2566 | |
| 2567 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2568 | VTY_NEWLINE); |
| 2569 | |
| 2570 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2571 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2572 | oi->output_cost, VTY_NEWLINE); |
| 2573 | |
| 2574 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2575 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2576 | PRIORITY (oi), VTY_NEWLINE); |
| 2577 | |
| 2578 | /* Show DR information. */ |
| 2579 | if (DR (oi).s_addr == 0) |
| 2580 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2581 | else |
| 2582 | { |
| 2583 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2584 | if (nbr == NULL) |
| 2585 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2586 | else |
| 2587 | { |
| 2588 | vty_out (vty, " Designated Router (ID) %s,", |
| 2589 | inet_ntoa (nbr->router_id)); |
| 2590 | vty_out (vty, " Interface Address %s%s", |
| 2591 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2592 | } |
| 2593 | } |
| 2594 | |
| 2595 | /* Show BDR information. */ |
| 2596 | if (BDR (oi).s_addr == 0) |
| 2597 | vty_out (vty, " No backup designated router on this network%s", |
| 2598 | VTY_NEWLINE); |
| 2599 | else |
| 2600 | { |
| 2601 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2602 | if (nbr == NULL) |
| 2603 | vty_out (vty, " No backup designated router on this network%s", |
| 2604 | VTY_NEWLINE); |
| 2605 | else |
| 2606 | { |
| 2607 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2608 | inet_ntoa (nbr->router_id)); |
| 2609 | vty_out (vty, " Interface Address %s%s", |
| 2610 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2611 | } |
| 2612 | } |
| 2613 | vty_out (vty, " Timer intervals configured,"); |
| 2614 | vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s", |
| 2615 | OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait), |
| 2616 | OSPF_IF_PARAM (oi, v_wait), |
| 2617 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2618 | VTY_NEWLINE); |
| 2619 | |
| 2620 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
| 2621 | vty_out (vty, " Hello due in %s%s", |
| 2622 | ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE); |
| 2623 | else /* OSPF_IF_PASSIVE is set */ |
| 2624 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2625 | |
| 2626 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2627 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2628 | VTY_NEWLINE); |
| 2629 | } |
| 2630 | } |
| 2631 | |
| 2632 | DEFUN (show_ip_ospf_interface, |
| 2633 | show_ip_ospf_interface_cmd, |
| 2634 | "show ip ospf interface [INTERFACE]", |
| 2635 | SHOW_STR |
| 2636 | IP_STR |
| 2637 | "OSPF information\n" |
| 2638 | "Interface information\n" |
| 2639 | "Interface name\n") |
| 2640 | { |
| 2641 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2642 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2643 | listnode node; |
| 2644 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2645 | ospf = ospf_lookup (); |
| 2646 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2647 | /* Show All Interfaces. */ |
| 2648 | if (argc == 0) |
| 2649 | for (node = listhead (iflist); node; nextnode (node)) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2650 | show_ip_ospf_interface_sub (vty, ospf, node->data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2651 | /* Interface name is specified. */ |
| 2652 | else |
| 2653 | { |
| 2654 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2655 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2656 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2657 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2658 | } |
| 2659 | |
| 2660 | return CMD_SUCCESS; |
| 2661 | } |
| 2662 | |
| 2663 | void |
| 2664 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2665 | { |
| 2666 | struct route_node *rn; |
| 2667 | struct ospf_neighbor *nbr; |
| 2668 | char msgbuf[16]; |
| 2669 | char timebuf[9]; |
| 2670 | |
| 2671 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2672 | if ((nbr = rn->info)) |
| 2673 | /* Do not show myself. */ |
| 2674 | if (nbr != oi->nbr_self) |
| 2675 | /* Down state is not shown. */ |
| 2676 | if (nbr->state != NSM_Down) |
| 2677 | { |
| 2678 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2679 | |
| 2680 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2681 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2682 | "-", nbr->priority, |
| 2683 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2684 | else |
| 2685 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2686 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2687 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2688 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
| 2689 | vty_out (vty, "%-15s %5ld %5ld %5d%s", |
| 2690 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2691 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2692 | VTY_NEWLINE); |
| 2693 | } |
| 2694 | } |
| 2695 | |
| 2696 | DEFUN (show_ip_ospf_neighbor, |
| 2697 | show_ip_ospf_neighbor_cmd, |
| 2698 | "show ip ospf neighbor", |
| 2699 | SHOW_STR |
| 2700 | IP_STR |
| 2701 | "OSPF information\n" |
| 2702 | "Neighbor list\n") |
| 2703 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2704 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2705 | listnode node; |
| 2706 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2707 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2708 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2709 | { |
| 2710 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2711 | return CMD_SUCCESS; |
| 2712 | } |
| 2713 | |
| 2714 | /* Show All neighbors. */ |
| 2715 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2716 | "Time Address Interface RXmtL " |
| 2717 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2718 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2719 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2720 | show_ip_ospf_neighbor_sub (vty, getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2721 | |
| 2722 | return CMD_SUCCESS; |
| 2723 | } |
| 2724 | |
| 2725 | DEFUN (show_ip_ospf_neighbor_all, |
| 2726 | show_ip_ospf_neighbor_all_cmd, |
| 2727 | "show ip ospf neighbor all", |
| 2728 | SHOW_STR |
| 2729 | IP_STR |
| 2730 | "OSPF information\n" |
| 2731 | "Neighbor list\n" |
| 2732 | "include down status neighbor\n") |
| 2733 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2734 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2735 | listnode node; |
| 2736 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2737 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2738 | { |
| 2739 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2740 | return CMD_SUCCESS; |
| 2741 | } |
| 2742 | |
| 2743 | /* Show All neighbors. */ |
| 2744 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2745 | "Time Address Interface RXmtL " |
| 2746 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2747 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2748 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2749 | { |
| 2750 | struct ospf_interface *oi = getdata (node); |
| 2751 | listnode nbr_node; |
| 2752 | |
| 2753 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2754 | |
| 2755 | /* print Down neighbor status */ |
| 2756 | for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node)) |
| 2757 | { |
| 2758 | struct ospf_nbr_nbma *nbr_nbma; |
| 2759 | |
| 2760 | nbr_nbma = getdata (nbr_node); |
| 2761 | |
| 2762 | if (nbr_nbma->nbr == NULL |
| 2763 | || nbr_nbma->nbr->state == NSM_Down) |
| 2764 | { |
| 2765 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2766 | "-", nbr_nbma->priority, "Down", "-"); |
| 2767 | vty_out (vty, "%-15s %-15s %5d %5d %5d%s", |
| 2768 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 2769 | 0, 0, 0, VTY_NEWLINE); |
| 2770 | } |
| 2771 | } |
| 2772 | } |
| 2773 | |
| 2774 | return CMD_SUCCESS; |
| 2775 | } |
| 2776 | |
| 2777 | DEFUN (show_ip_ospf_neighbor_int, |
| 2778 | show_ip_ospf_neighbor_int_cmd, |
| 2779 | "show ip ospf neighbor A.B.C.D", |
| 2780 | SHOW_STR |
| 2781 | IP_STR |
| 2782 | "OSPF information\n" |
| 2783 | "Neighbor list\n" |
| 2784 | "Interface name\n") |
| 2785 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2786 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2787 | struct ospf_interface *oi; |
| 2788 | struct in_addr addr; |
| 2789 | int ret; |
| 2790 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2791 | ret = inet_aton (argv[0], &addr); |
| 2792 | if (!ret) |
| 2793 | { |
| 2794 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 2795 | VTY_NEWLINE); |
| 2796 | return CMD_WARNING; |
| 2797 | } |
| 2798 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2799 | ospf = ospf_lookup (); |
| 2800 | if (ospf == NULL) |
| 2801 | { |
| 2802 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2803 | return CMD_SUCCESS; |
| 2804 | } |
| 2805 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2806 | if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2807 | vty_out (vty, "No such interface address%s", VTY_NEWLINE); |
| 2808 | else |
| 2809 | { |
| 2810 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2811 | "Time Address Interface RXmtL " |
| 2812 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2813 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2814 | } |
| 2815 | |
| 2816 | return CMD_SUCCESS; |
| 2817 | } |
| 2818 | |
| 2819 | void |
| 2820 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2821 | struct ospf_nbr_nbma *nbr_nbma) |
| 2822 | { |
| 2823 | char timebuf[9]; |
| 2824 | |
| 2825 | /* Show neighbor ID. */ |
| 2826 | vty_out (vty, " Neighbor %s,", "-"); |
| 2827 | |
| 2828 | /* Show interface address. */ |
| 2829 | vty_out (vty, " interface address %s%s", |
| 2830 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 2831 | /* Show Area ID. */ |
| 2832 | vty_out (vty, " In the area %s via interface %s%s", |
| 2833 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 2834 | /* Show neighbor priority and state. */ |
| 2835 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2836 | nbr_nbma->priority, "Down"); |
| 2837 | /* Show state changes. */ |
| 2838 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 2839 | |
| 2840 | /* Show PollInterval */ |
| 2841 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 2842 | |
| 2843 | /* Show poll-interval timer. */ |
| 2844 | vty_out (vty, " Poll timer due in %s%s", |
| 2845 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE); |
| 2846 | |
| 2847 | /* Show poll-interval timer thread. */ |
| 2848 | vty_out (vty, " Thread Poll Timer %s%s", |
| 2849 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 2850 | } |
| 2851 | |
| 2852 | void |
| 2853 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2854 | struct ospf_neighbor *nbr) |
| 2855 | { |
| 2856 | char timebuf[9]; |
| 2857 | |
| 2858 | /* Show neighbor ID. */ |
| 2859 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2860 | vty_out (vty, " Neighbor %s,", "-"); |
| 2861 | else |
| 2862 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 2863 | |
| 2864 | /* Show interface address. */ |
| 2865 | vty_out (vty, " interface address %s%s", |
| 2866 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2867 | /* Show Area ID. */ |
| 2868 | vty_out (vty, " In the area %s via interface %s%s", |
| 2869 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 2870 | /* Show neighbor priority and state. */ |
| 2871 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2872 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 2873 | /* Show state changes. */ |
| 2874 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 2875 | |
| 2876 | /* Show Designated Rotuer ID. */ |
| 2877 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 2878 | /* Show Backup Designated Rotuer ID. */ |
| 2879 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 2880 | /* Show options. */ |
| 2881 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 2882 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 2883 | /* Show Router Dead interval timer. */ |
| 2884 | vty_out (vty, " Dead timer due in %s%s", |
| 2885 | ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE); |
| 2886 | /* Show Database Summary list. */ |
| 2887 | vty_out (vty, " Database Summary List %d%s", |
| 2888 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 2889 | /* Show Link State Request list. */ |
| 2890 | vty_out (vty, " Link State Request List %ld%s", |
| 2891 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 2892 | /* Show Link State Retransmission list. */ |
| 2893 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 2894 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 2895 | /* Show inactivity timer thread. */ |
| 2896 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 2897 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 2898 | /* Show Database Description retransmission thread. */ |
| 2899 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 2900 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 2901 | /* Show Link State Request Retransmission thread. */ |
| 2902 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 2903 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 2904 | /* Show Link State Update Retransmission thread. */ |
| 2905 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 2906 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 2907 | } |
| 2908 | |
| 2909 | DEFUN (show_ip_ospf_neighbor_id, |
| 2910 | show_ip_ospf_neighbor_id_cmd, |
| 2911 | "show ip ospf neighbor A.B.C.D", |
| 2912 | SHOW_STR |
| 2913 | IP_STR |
| 2914 | "OSPF information\n" |
| 2915 | "Neighbor list\n" |
| 2916 | "Neighbor ID\n") |
| 2917 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2918 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2919 | listnode node; |
| 2920 | struct ospf_neighbor *nbr; |
| 2921 | struct in_addr router_id; |
| 2922 | int ret; |
| 2923 | |
| 2924 | ret = inet_aton (argv[0], &router_id); |
| 2925 | if (!ret) |
| 2926 | { |
| 2927 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 2928 | return CMD_WARNING; |
| 2929 | } |
| 2930 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2931 | ospf = ospf_lookup (); |
| 2932 | if (ospf == NULL) |
| 2933 | { |
| 2934 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2935 | return CMD_SUCCESS; |
| 2936 | } |
| 2937 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2938 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2939 | { |
| 2940 | struct ospf_interface *oi = getdata (node); |
| 2941 | |
| 2942 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 2943 | { |
| 2944 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 2945 | return CMD_SUCCESS; |
| 2946 | } |
| 2947 | } |
| 2948 | |
| 2949 | /* Nothing to show. */ |
| 2950 | return CMD_SUCCESS; |
| 2951 | } |
| 2952 | |
| 2953 | DEFUN (show_ip_ospf_neighbor_detail, |
| 2954 | show_ip_ospf_neighbor_detail_cmd, |
| 2955 | "show ip ospf neighbor detail", |
| 2956 | SHOW_STR |
| 2957 | IP_STR |
| 2958 | "OSPF information\n" |
| 2959 | "Neighbor list\n" |
| 2960 | "detail of all neighbors\n") |
| 2961 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2962 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2963 | listnode node; |
| 2964 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2965 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2966 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2967 | { |
| 2968 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2969 | return CMD_SUCCESS; |
| 2970 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2971 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2972 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2973 | { |
| 2974 | struct ospf_interface *oi = getdata (node); |
| 2975 | struct route_node *rn; |
| 2976 | struct ospf_neighbor *nbr; |
| 2977 | |
| 2978 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2979 | if ((nbr = rn->info)) |
| 2980 | if (nbr != oi->nbr_self) |
| 2981 | if (nbr->state != NSM_Down) |
| 2982 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 2983 | } |
| 2984 | |
| 2985 | return CMD_SUCCESS; |
| 2986 | } |
| 2987 | |
| 2988 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 2989 | show_ip_ospf_neighbor_detail_all_cmd, |
| 2990 | "show ip ospf neighbor detail all", |
| 2991 | SHOW_STR |
| 2992 | IP_STR |
| 2993 | "OSPF information\n" |
| 2994 | "Neighbor list\n" |
| 2995 | "detail of all neighbors\n" |
| 2996 | "include down status neighbor\n") |
| 2997 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2998 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2999 | listnode node; |
| 3000 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3001 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3002 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3003 | { |
| 3004 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3005 | return CMD_SUCCESS; |
| 3006 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3007 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3008 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3009 | { |
| 3010 | struct ospf_interface *oi = getdata (node); |
| 3011 | struct route_node *rn; |
| 3012 | struct ospf_neighbor *nbr; |
| 3013 | |
| 3014 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3015 | if ((nbr = rn->info)) |
| 3016 | if (nbr != oi->nbr_self) |
| 3017 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3018 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3019 | |
| 3020 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3021 | { |
| 3022 | listnode nd; |
| 3023 | |
| 3024 | for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd)) |
| 3025 | { |
| 3026 | struct ospf_nbr_nbma *nbr_nbma = getdata (nd); |
| 3027 | if (nbr_nbma->nbr == NULL |
| 3028 | || nbr_nbma->nbr->state == NSM_Down) |
| 3029 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
| 3030 | } |
| 3031 | } |
| 3032 | } |
| 3033 | |
| 3034 | return CMD_SUCCESS; |
| 3035 | } |
| 3036 | |
| 3037 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3038 | show_ip_ospf_neighbor_int_detail_cmd, |
| 3039 | "show ip ospf neighbor A.B.C.D detail", |
| 3040 | SHOW_STR |
| 3041 | IP_STR |
| 3042 | "OSPF information\n" |
| 3043 | "Neighbor list\n" |
| 3044 | "Interface address\n" |
| 3045 | "detail of all neighbors") |
| 3046 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3047 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | struct ospf_interface *oi; |
| 3049 | struct in_addr addr; |
| 3050 | int ret; |
| 3051 | |
| 3052 | ret = inet_aton (argv[0], &addr); |
| 3053 | if (!ret) |
| 3054 | { |
| 3055 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 3056 | VTY_NEWLINE); |
| 3057 | return CMD_WARNING; |
| 3058 | } |
| 3059 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3060 | ospf = ospf_lookup (); |
| 3061 | if (ospf == NULL) |
| 3062 | { |
| 3063 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3064 | return CMD_SUCCESS; |
| 3065 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3066 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3067 | if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3068 | vty_out (vty, "No such interface address%s", VTY_NEWLINE); |
| 3069 | else |
| 3070 | { |
| 3071 | struct route_node *rn; |
| 3072 | struct ospf_neighbor *nbr; |
| 3073 | |
| 3074 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3075 | if ((nbr = rn->info)) |
| 3076 | if (nbr != oi->nbr_self) |
| 3077 | if (nbr->state != NSM_Down) |
| 3078 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3079 | } |
| 3080 | |
| 3081 | return CMD_SUCCESS; |
| 3082 | } |
| 3083 | |
| 3084 | |
| 3085 | /* Show functions */ |
| 3086 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3087 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3088 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3089 | struct router_lsa *rl; |
| 3090 | struct summary_lsa *sl; |
| 3091 | struct as_external_lsa *asel; |
| 3092 | struct prefix_ipv4 p; |
| 3093 | |
| 3094 | if (lsa != NULL) |
| 3095 | /* If self option is set, check LSA self flag. */ |
| 3096 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3097 | { |
| 3098 | /* LSA common part show. */ |
| 3099 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3100 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3101 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3102 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3103 | /* LSA specific part show. */ |
| 3104 | switch (lsa->data->type) |
| 3105 | { |
| 3106 | case OSPF_ROUTER_LSA: |
| 3107 | rl = (struct router_lsa *) lsa->data; |
| 3108 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3109 | break; |
| 3110 | case OSPF_SUMMARY_LSA: |
| 3111 | sl = (struct summary_lsa *) lsa->data; |
| 3112 | |
| 3113 | p.family = AF_INET; |
| 3114 | p.prefix = sl->header.id; |
| 3115 | p.prefixlen = ip_masklen (sl->mask); |
| 3116 | apply_mask_ipv4 (&p); |
| 3117 | |
| 3118 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3119 | break; |
| 3120 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3121 | #ifdef HAVE_NSSA |
| 3122 | case OSPF_AS_NSSA_LSA: |
| 3123 | #endif /* HAVE_NSSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3124 | asel = (struct as_external_lsa *) lsa->data; |
| 3125 | |
| 3126 | p.family = AF_INET; |
| 3127 | p.prefix = asel->header.id; |
| 3128 | p.prefixlen = ip_masklen (asel->mask); |
| 3129 | apply_mask_ipv4 (&p); |
| 3130 | |
| 3131 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3132 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3133 | inet_ntoa (p.prefix), p.prefixlen, |
| 3134 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3135 | break; |
| 3136 | case OSPF_NETWORK_LSA: |
| 3137 | case OSPF_ASBR_SUMMARY_LSA: |
| 3138 | #ifdef HAVE_OPAQUE_LSA |
| 3139 | case OSPF_OPAQUE_LINK_LSA: |
| 3140 | case OSPF_OPAQUE_AREA_LSA: |
| 3141 | case OSPF_OPAQUE_AS_LSA: |
| 3142 | #endif /* HAVE_OPAQUE_LSA */ |
| 3143 | default: |
| 3144 | break; |
| 3145 | } |
| 3146 | vty_out (vty, VTY_NEWLINE); |
| 3147 | } |
| 3148 | |
| 3149 | return 0; |
| 3150 | } |
| 3151 | |
| 3152 | char *show_database_desc[] = |
| 3153 | { |
| 3154 | "unknown", |
| 3155 | "Router Link States", |
| 3156 | "Net Link States", |
| 3157 | "Summary Link States", |
| 3158 | "ASBR-Summary Link States", |
| 3159 | "AS External Link States", |
| 3160 | #if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA) |
| 3161 | "Group Membership LSA", |
| 3162 | "NSSA-external Link States", |
| 3163 | #endif /* HAVE_NSSA */ |
| 3164 | #ifdef HAVE_OPAQUE_LSA |
| 3165 | "Type-8 LSA", |
| 3166 | "Link-Local Opaque-LSA", |
| 3167 | "Area-Local Opaque-LSA", |
| 3168 | "AS-external Opaque-LSA", |
| 3169 | #endif /* HAVE_OPAQUE_LSA */ |
| 3170 | }; |
| 3171 | |
| 3172 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3173 | "Link ID ADV Router Age Seq# CkSum" |
| 3174 | |
| 3175 | char *show_database_header[] = |
| 3176 | { |
| 3177 | "", |
| 3178 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3179 | "Link ID ADV Router Age Seq# CkSum", |
| 3180 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3181 | "Link ID ADV Router Age Seq# CkSum", |
| 3182 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3183 | #ifdef HAVE_NSSA |
| 3184 | " --- header for Group Member ----", |
| 3185 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3186 | #endif /* HAVE_NSSA */ |
| 3187 | #ifdef HAVE_OPAQUE_LSA |
| 3188 | #ifndef HAVE_NSSA |
| 3189 | " --- type-6 ---", |
| 3190 | " --- type-7 ---", |
| 3191 | #endif /* HAVE_NSSA */ |
| 3192 | " --- type-8 ---", |
| 3193 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3194 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3195 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3196 | #endif /* HAVE_OPAQUE_LSA */ |
| 3197 | }; |
| 3198 | |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame^] | 3199 | char *show_lsa_flags[] = |
| 3200 | { |
| 3201 | "Self-originated", |
| 3202 | "Checked", |
| 3203 | "Received", |
| 3204 | "Approved", |
| 3205 | "Discard", |
| 3206 | #ifdef HAVE_NSSA |
| 3207 | "Translated", |
| 3208 | #endif |
| 3209 | }; |
| 3210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3211 | void |
| 3212 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3213 | { |
| 3214 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame^] | 3215 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3216 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame^] | 3217 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3218 | lsa->data->options, |
| 3219 | ospf_options_dump(lsa->data->options), |
| 3220 | VTY_NEWLINE); |
| 3221 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
| 3222 | lsa->flags, |
| 3223 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3224 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3225 | |
| 3226 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3227 | { |
| 3228 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3229 | |
| 3230 | if (rlsa->flags) |
| 3231 | vty_out (vty, " :%s%s%s%s", |
| 3232 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3233 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3234 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3235 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3236 | |
| 3237 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3238 | } |
| 3239 | vty_out (vty, " LS Type: %s%s", |
| 3240 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3241 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3242 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3243 | vty_out (vty, " Advertising Router: %s%s", |
| 3244 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3245 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3246 | VTY_NEWLINE); |
| 3247 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3248 | VTY_NEWLINE); |
| 3249 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3250 | } |
| 3251 | |
| 3252 | char *link_type_desc[] = |
| 3253 | { |
| 3254 | "(null)", |
| 3255 | "another Router (point-to-point)", |
| 3256 | "a Transit Network", |
| 3257 | "Stub Network", |
| 3258 | "a Virtual Link", |
| 3259 | }; |
| 3260 | |
| 3261 | char *link_id_desc[] = |
| 3262 | { |
| 3263 | "(null)", |
| 3264 | "Neighboring Router ID", |
| 3265 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3266 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3267 | "Neighboring Router ID", |
| 3268 | }; |
| 3269 | |
| 3270 | char *link_data_desc[] = |
| 3271 | { |
| 3272 | "(null)", |
| 3273 | "Router Interface address", |
| 3274 | "Router Interface address", |
| 3275 | "Network Mask", |
| 3276 | "Router Interface address", |
| 3277 | }; |
| 3278 | |
| 3279 | /* Show router-LSA each Link information. */ |
| 3280 | void |
| 3281 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3282 | struct router_lsa *rl) |
| 3283 | { |
| 3284 | int len, i, type; |
| 3285 | |
| 3286 | len = ntohs (rl->header.length) - 4; |
| 3287 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3288 | { |
| 3289 | type = rl->link[i].type; |
| 3290 | |
| 3291 | vty_out (vty, " Link connected to: %s%s", |
| 3292 | link_type_desc[type], VTY_NEWLINE); |
| 3293 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3294 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3295 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3296 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3297 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3298 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3299 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3300 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3301 | } |
| 3302 | } |
| 3303 | |
| 3304 | /* Show router-LSA detail information. */ |
| 3305 | int |
| 3306 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3307 | { |
| 3308 | if (lsa != NULL) |
| 3309 | { |
| 3310 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3311 | |
| 3312 | show_ip_ospf_database_header (vty, lsa); |
| 3313 | |
| 3314 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3315 | VTY_NEWLINE, VTY_NEWLINE); |
| 3316 | |
| 3317 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3318 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3319 | } |
| 3320 | |
| 3321 | return 0; |
| 3322 | } |
| 3323 | |
| 3324 | /* Show network-LSA detail information. */ |
| 3325 | int |
| 3326 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3327 | { |
| 3328 | int length, i; |
| 3329 | |
| 3330 | if (lsa != NULL) |
| 3331 | { |
| 3332 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3333 | |
| 3334 | show_ip_ospf_database_header (vty, lsa); |
| 3335 | |
| 3336 | vty_out (vty, " Network Mask: /%d%s", |
| 3337 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3338 | |
| 3339 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3340 | |
| 3341 | for (i = 0; length > 0; i++, length -= 4) |
| 3342 | vty_out (vty, " Attached Router: %s%s", |
| 3343 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3344 | |
| 3345 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3346 | } |
| 3347 | |
| 3348 | return 0; |
| 3349 | } |
| 3350 | |
| 3351 | /* Show summary-LSA detail information. */ |
| 3352 | int |
| 3353 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3354 | { |
| 3355 | if (lsa != NULL) |
| 3356 | { |
| 3357 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3358 | |
| 3359 | show_ip_ospf_database_header (vty, lsa); |
| 3360 | |
| 3361 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3362 | VTY_NEWLINE); |
| 3363 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3364 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3365 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3366 | } |
| 3367 | |
| 3368 | return 0; |
| 3369 | } |
| 3370 | |
| 3371 | /* Show summary-ASBR-LSA detail information. */ |
| 3372 | int |
| 3373 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3374 | { |
| 3375 | if (lsa != NULL) |
| 3376 | { |
| 3377 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3378 | |
| 3379 | show_ip_ospf_database_header (vty, lsa); |
| 3380 | |
| 3381 | vty_out (vty, " Network Mask: /%d%s", |
| 3382 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3383 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3384 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3385 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3386 | } |
| 3387 | |
| 3388 | return 0; |
| 3389 | } |
| 3390 | |
| 3391 | /* Show AS-external-LSA detail information. */ |
| 3392 | int |
| 3393 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3394 | { |
| 3395 | if (lsa != NULL) |
| 3396 | { |
| 3397 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3398 | |
| 3399 | show_ip_ospf_database_header (vty, lsa); |
| 3400 | |
| 3401 | vty_out (vty, " Network Mask: /%d%s", |
| 3402 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3403 | vty_out (vty, " Metric Type: %s%s", |
| 3404 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3405 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3406 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3407 | vty_out (vty, " Metric: %d%s", |
| 3408 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3409 | vty_out (vty, " Forward Address: %s%s", |
| 3410 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3411 | |
| 3412 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3413 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3414 | } |
| 3415 | |
| 3416 | return 0; |
| 3417 | } |
| 3418 | |
| 3419 | #ifdef HAVE_NSSA |
| 3420 | int |
| 3421 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3422 | { |
| 3423 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3424 | |
| 3425 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3426 | |
| 3427 | zlog_info( " Network Mask: /%d%s", |
| 3428 | ip_masklen (al->mask), "\n"); |
| 3429 | zlog_info( " Metric Type: %s%s", |
| 3430 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3431 | "2 (Larger than any link state path)" : "1", "\n"); |
| 3432 | zlog_info( " TOS: 0%s", "\n"); |
| 3433 | zlog_info( " Metric: %d%s", |
| 3434 | GET_METRIC (al->e[0].metric), "\n"); |
| 3435 | zlog_info( " Forward Address: %s%s", |
| 3436 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3437 | |
| 3438 | zlog_info( " External Route Tag: %u%s%s", |
| 3439 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3440 | |
| 3441 | return 0; |
| 3442 | } |
| 3443 | |
| 3444 | /* Show AS-NSSA-LSA detail information. */ |
| 3445 | int |
| 3446 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3447 | { |
| 3448 | if (lsa != NULL) |
| 3449 | { |
| 3450 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3451 | |
| 3452 | show_ip_ospf_database_header (vty, lsa); |
| 3453 | |
| 3454 | vty_out (vty, " Network Mask: /%d%s", |
| 3455 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3456 | vty_out (vty, " Metric Type: %s%s", |
| 3457 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3458 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3459 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3460 | vty_out (vty, " Metric: %d%s", |
| 3461 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3462 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3463 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3464 | |
| 3465 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3466 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3467 | } |
| 3468 | |
| 3469 | return 0; |
| 3470 | } |
| 3471 | |
| 3472 | #endif /* HAVE_NSSA */ |
| 3473 | |
| 3474 | int |
| 3475 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3476 | { |
| 3477 | return 0; |
| 3478 | } |
| 3479 | |
| 3480 | #ifdef HAVE_OPAQUE_LSA |
| 3481 | int |
| 3482 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3483 | { |
| 3484 | if (lsa != NULL) |
| 3485 | { |
| 3486 | show_ip_ospf_database_header (vty, lsa); |
| 3487 | show_opaque_info_detail (vty, lsa); |
| 3488 | |
| 3489 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3490 | } |
| 3491 | return 0; |
| 3492 | } |
| 3493 | #endif /* HAVE_OPAQUE_LSA */ |
| 3494 | |
| 3495 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3496 | { |
| 3497 | NULL, |
| 3498 | show_router_lsa_detail, |
| 3499 | show_network_lsa_detail, |
| 3500 | show_summary_lsa_detail, |
| 3501 | show_summary_asbr_lsa_detail, |
| 3502 | show_as_external_lsa_detail, |
| 3503 | #ifdef HAVE_NSSA |
| 3504 | show_func_dummy, |
| 3505 | show_as_nssa_lsa_detail, /* almost same as external */ |
| 3506 | #endif /* HAVE_NSSA */ |
| 3507 | #ifdef HAVE_OPAQUE_LSA |
| 3508 | #ifndef HAVE_NSSA |
| 3509 | show_func_dummy, |
| 3510 | show_func_dummy, |
| 3511 | #endif /* HAVE_NSSA */ |
| 3512 | NULL, /* type-8 */ |
| 3513 | show_opaque_lsa_detail, |
| 3514 | show_opaque_lsa_detail, |
| 3515 | show_opaque_lsa_detail, |
| 3516 | #endif /* HAVE_OPAQUE_LSA */ |
| 3517 | }; |
| 3518 | |
| 3519 | void |
| 3520 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3521 | struct in_addr *adv_router) |
| 3522 | { |
| 3523 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3524 | lp->family = 0; |
| 3525 | if (id == NULL) |
| 3526 | lp->prefixlen = 0; |
| 3527 | else if (adv_router == NULL) |
| 3528 | { |
| 3529 | lp->prefixlen = 32; |
| 3530 | lp->id = *id; |
| 3531 | } |
| 3532 | else |
| 3533 | { |
| 3534 | lp->prefixlen = 64; |
| 3535 | lp->id = *id; |
| 3536 | lp->adv_router = *adv_router; |
| 3537 | } |
| 3538 | } |
| 3539 | |
| 3540 | void |
| 3541 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3542 | struct in_addr *id, struct in_addr *adv_router) |
| 3543 | { |
| 3544 | struct prefix_ls lp; |
| 3545 | struct route_node *rn, *start; |
| 3546 | struct ospf_lsa *lsa; |
| 3547 | |
| 3548 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3549 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3550 | if (start) |
| 3551 | { |
| 3552 | route_lock_node (start); |
| 3553 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3554 | if ((lsa = rn->info)) |
| 3555 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3556 | if (show_function[lsa->data->type] != NULL) |
| 3557 | show_function[lsa->data->type] (vty, lsa); |
| 3558 | } |
| 3559 | route_unlock_node (start); |
| 3560 | } |
| 3561 | } |
| 3562 | |
| 3563 | /* Show detail LSA information |
| 3564 | -- if id is NULL then show all LSAs. */ |
| 3565 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3566 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3567 | struct in_addr *id, struct in_addr *adv_router) |
| 3568 | { |
| 3569 | listnode node; |
| 3570 | |
| 3571 | switch (type) |
| 3572 | { |
| 3573 | case OSPF_AS_EXTERNAL_LSA: |
| 3574 | #ifdef HAVE_OPAQUE_LSA |
| 3575 | case OSPF_OPAQUE_AS_LSA: |
| 3576 | #endif /* HAVE_OPAQUE_LSA */ |
| 3577 | vty_out (vty, " %s %s%s", |
| 3578 | show_database_desc[type], |
| 3579 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3580 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3581 | break; |
| 3582 | default: |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3583 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3584 | { |
| 3585 | struct ospf_area *area = node->data; |
| 3586 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3587 | VTY_NEWLINE, show_database_desc[type], |
| 3588 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3589 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3590 | } |
| 3591 | break; |
| 3592 | } |
| 3593 | } |
| 3594 | |
| 3595 | void |
| 3596 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3597 | struct in_addr *adv_router) |
| 3598 | { |
| 3599 | struct route_node *rn; |
| 3600 | struct ospf_lsa *lsa; |
| 3601 | |
| 3602 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3603 | if ((lsa = rn->info)) |
| 3604 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3605 | { |
| 3606 | #ifdef HAVE_NSSA |
| 3607 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3608 | continue; |
| 3609 | #endif /* HAVE_NSSA */ |
| 3610 | if (show_function[lsa->data->type] != NULL) |
| 3611 | show_function[lsa->data->type] (vty, lsa); |
| 3612 | } |
| 3613 | } |
| 3614 | |
| 3615 | /* Show detail LSA information. */ |
| 3616 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3617 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3618 | struct in_addr *adv_router) |
| 3619 | { |
| 3620 | listnode node; |
| 3621 | |
| 3622 | switch (type) |
| 3623 | { |
| 3624 | case OSPF_AS_EXTERNAL_LSA: |
| 3625 | #ifdef HAVE_OPAQUE_LSA |
| 3626 | case OSPF_OPAQUE_AS_LSA: |
| 3627 | #endif /* HAVE_OPAQUE_LSA */ |
| 3628 | vty_out (vty, " %s %s%s", |
| 3629 | show_database_desc[type], |
| 3630 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3631 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3632 | adv_router); |
| 3633 | break; |
| 3634 | default: |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3635 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | { |
| 3637 | struct ospf_area *area = node->data; |
| 3638 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3639 | VTY_NEWLINE, show_database_desc[type], |
| 3640 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3641 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3642 | adv_router); |
| 3643 | } |
| 3644 | break; |
| 3645 | } |
| 3646 | } |
| 3647 | |
| 3648 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3649 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3650 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3651 | struct ospf_lsa *lsa; |
| 3652 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3653 | listnode node; |
| 3654 | int type; |
| 3655 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3656 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3657 | { |
| 3658 | struct ospf_area *area = node->data; |
| 3659 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3660 | { |
| 3661 | switch (type) |
| 3662 | { |
| 3663 | case OSPF_AS_EXTERNAL_LSA: |
| 3664 | #ifdef HAVE_OPAQUE_LSA |
| 3665 | case OSPF_OPAQUE_AS_LSA: |
| 3666 | #endif /* HAVE_OPAQUE_LSA */ |
| 3667 | continue; |
| 3668 | default: |
| 3669 | break; |
| 3670 | } |
| 3671 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3672 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3673 | { |
| 3674 | vty_out (vty, " %s (Area %s)%s%s", |
| 3675 | show_database_desc[type], |
| 3676 | ospf_area_desc_string (area), |
| 3677 | VTY_NEWLINE, VTY_NEWLINE); |
| 3678 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3679 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3680 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3681 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3682 | |
| 3683 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3684 | } |
| 3685 | } |
| 3686 | } |
| 3687 | |
| 3688 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3689 | { |
| 3690 | switch (type) |
| 3691 | { |
| 3692 | case OSPF_AS_EXTERNAL_LSA: |
| 3693 | #ifdef HAVE_OPAQUE_LSA |
| 3694 | case OSPF_OPAQUE_AS_LSA: |
| 3695 | #endif /* HAVE_OPAQUE_LSA */ |
| 3696 | break;; |
| 3697 | default: |
| 3698 | continue; |
| 3699 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3700 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3701 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3702 | { |
| 3703 | vty_out (vty, " %s%s%s", |
| 3704 | show_database_desc[type], |
| 3705 | VTY_NEWLINE, VTY_NEWLINE); |
| 3706 | vty_out (vty, "%s%s", show_database_header[type], |
| 3707 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3708 | |
| 3709 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3710 | show_lsa_summary (vty, lsa, self); |
| 3711 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3712 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3713 | } |
| 3714 | } |
| 3715 | |
| 3716 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3717 | } |
| 3718 | |
| 3719 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3720 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3721 | { |
| 3722 | listnode node; |
| 3723 | struct ospf_lsa *lsa; |
| 3724 | |
| 3725 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3726 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3727 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3728 | for (node = listhead (ospf->maxage_lsa); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3729 | if ((lsa = node->data) != NULL) |
| 3730 | { |
| 3731 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3732 | vty_out (vty, "Link State ID: %s%s", |
| 3733 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3734 | vty_out (vty, "Advertising Router: %s%s", |
| 3735 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3736 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3737 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3738 | } |
| 3739 | } |
| 3740 | |
| 3741 | #ifdef HAVE_NSSA |
| 3742 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3743 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
| 3744 | #else /* HAVE_NSSA */ |
| 3745 | #define OSPF_LSA_TYPE_NSSA_DESC "" |
| 3746 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "" |
| 3747 | #endif /* HAVE_NSSA */ |
| 3748 | |
| 3749 | #ifdef HAVE_OPAQUE_LSA |
| 3750 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3751 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3752 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3753 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3754 | #else /* HAVE_OPAQUE_LSA */ |
| 3755 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3756 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3757 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3758 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3759 | #endif /* HAVE_OPAQUE_LSA */ |
| 3760 | |
| 3761 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3762 | "asbr-summary|external|network|router|summary" \ |
| 3763 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3764 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3765 | |
| 3766 | #define OSPF_LSA_TYPES_DESC \ |
| 3767 | "ASBR summary link states\n" \ |
| 3768 | "External link states\n" \ |
| 3769 | "Network link states\n" \ |
| 3770 | "Router link states\n" \ |
| 3771 | "Network summary link states\n" \ |
| 3772 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3773 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3774 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3775 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3776 | |
| 3777 | DEFUN (show_ip_ospf_database, |
| 3778 | show_ip_ospf_database_cmd, |
| 3779 | "show ip ospf database", |
| 3780 | SHOW_STR |
| 3781 | IP_STR |
| 3782 | "OSPF information\n" |
| 3783 | "Database summary\n") |
| 3784 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3785 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3786 | int type, ret; |
| 3787 | struct in_addr id, adv_router; |
| 3788 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3789 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3790 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3791 | return CMD_SUCCESS; |
| 3792 | |
| 3793 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3794 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3795 | |
| 3796 | /* Show all LSA. */ |
| 3797 | if (argc == 0) |
| 3798 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3799 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3800 | return CMD_SUCCESS; |
| 3801 | } |
| 3802 | |
| 3803 | /* Set database type to show. */ |
| 3804 | if (strncmp (argv[0], "r", 1) == 0) |
| 3805 | type = OSPF_ROUTER_LSA; |
| 3806 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3807 | type = OSPF_NETWORK_LSA; |
| 3808 | #ifdef HAVE_NSSA |
| 3809 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3810 | type = OSPF_AS_NSSA_LSA; |
| 3811 | #endif /* HAVE_NSSA */ |
| 3812 | else if (strncmp (argv[0], "su", 2) == 0) |
| 3813 | type = OSPF_SUMMARY_LSA; |
| 3814 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3815 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3816 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3817 | type = OSPF_AS_EXTERNAL_LSA; |
| 3818 | else if (strncmp (argv[0], "se", 2) == 0) |
| 3819 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3820 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3821 | return CMD_SUCCESS; |
| 3822 | } |
| 3823 | else if (strncmp (argv[0], "m", 1) == 0) |
| 3824 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3825 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3826 | return CMD_SUCCESS; |
| 3827 | } |
| 3828 | #ifdef HAVE_OPAQUE_LSA |
| 3829 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3830 | type = OSPF_OPAQUE_LINK_LSA; |
| 3831 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3832 | type = OSPF_OPAQUE_AREA_LSA; |
| 3833 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3834 | type = OSPF_OPAQUE_AS_LSA; |
| 3835 | #endif /* HAVE_OPAQUE_LSA */ |
| 3836 | else |
| 3837 | return CMD_WARNING; |
| 3838 | |
| 3839 | /* `show ip ospf database LSA'. */ |
| 3840 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3841 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3842 | else if (argc >= 2) |
| 3843 | { |
| 3844 | ret = inet_aton (argv[1], &id); |
| 3845 | if (!ret) |
| 3846 | return CMD_WARNING; |
| 3847 | |
| 3848 | /* `show ip ospf database LSA ID'. */ |
| 3849 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3850 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3851 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 3852 | else if (argc == 3) |
| 3853 | { |
| 3854 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3855 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3856 | else |
| 3857 | { |
| 3858 | ret = inet_aton (argv[2], &adv_router); |
| 3859 | if (!ret) |
| 3860 | return CMD_WARNING; |
| 3861 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3862 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3863 | } |
| 3864 | } |
| 3865 | |
| 3866 | return CMD_SUCCESS; |
| 3867 | } |
| 3868 | |
| 3869 | ALIAS (show_ip_ospf_database, |
| 3870 | show_ip_ospf_database_type_cmd, |
| 3871 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 3872 | SHOW_STR |
| 3873 | IP_STR |
| 3874 | "OSPF information\n" |
| 3875 | "Database summary\n" |
| 3876 | OSPF_LSA_TYPES_DESC |
| 3877 | "LSAs in MaxAge list\n" |
| 3878 | "Self-originated link states\n") |
| 3879 | |
| 3880 | ALIAS (show_ip_ospf_database, |
| 3881 | show_ip_ospf_database_type_id_cmd, |
| 3882 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 3883 | SHOW_STR |
| 3884 | IP_STR |
| 3885 | "OSPF information\n" |
| 3886 | "Database summary\n" |
| 3887 | OSPF_LSA_TYPES_DESC |
| 3888 | "Link State ID (as an IP address)\n") |
| 3889 | |
| 3890 | ALIAS (show_ip_ospf_database, |
| 3891 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 3892 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 3893 | SHOW_STR |
| 3894 | IP_STR |
| 3895 | "OSPF information\n" |
| 3896 | "Database summary\n" |
| 3897 | OSPF_LSA_TYPES_DESC |
| 3898 | "Link State ID (as an IP address)\n" |
| 3899 | "Advertising Router link states\n" |
| 3900 | "Advertising Router (as an IP address)\n") |
| 3901 | |
| 3902 | ALIAS (show_ip_ospf_database, |
| 3903 | show_ip_ospf_database_type_id_self_cmd, |
| 3904 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 3905 | SHOW_STR |
| 3906 | IP_STR |
| 3907 | "OSPF information\n" |
| 3908 | "Database summary\n" |
| 3909 | OSPF_LSA_TYPES_DESC |
| 3910 | "Link State ID (as an IP address)\n" |
| 3911 | "Self-originated link states\n" |
| 3912 | "\n") |
| 3913 | |
| 3914 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 3915 | show_ip_ospf_database_type_adv_router_cmd, |
| 3916 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 3917 | SHOW_STR |
| 3918 | IP_STR |
| 3919 | "OSPF information\n" |
| 3920 | "Database summary\n" |
| 3921 | OSPF_LSA_TYPES_DESC |
| 3922 | "Advertising Router link states\n" |
| 3923 | "Advertising Router (as an IP address)\n") |
| 3924 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3925 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3926 | int type, ret; |
| 3927 | struct in_addr adv_router; |
| 3928 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3929 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3930 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3931 | return CMD_SUCCESS; |
| 3932 | |
| 3933 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3934 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3935 | |
| 3936 | if (argc != 2) |
| 3937 | return CMD_WARNING; |
| 3938 | |
| 3939 | /* Set database type to show. */ |
| 3940 | if (strncmp (argv[0], "r", 1) == 0) |
| 3941 | type = OSPF_ROUTER_LSA; |
| 3942 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3943 | type = OSPF_NETWORK_LSA; |
| 3944 | #ifdef HAVE_NSSA |
| 3945 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3946 | type = OSPF_AS_NSSA_LSA; |
| 3947 | #endif /* HAVE_NSSA */ |
| 3948 | else if (strncmp (argv[0], "s", 1) == 0) |
| 3949 | type = OSPF_SUMMARY_LSA; |
| 3950 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3951 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3952 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3953 | type = OSPF_AS_EXTERNAL_LSA; |
| 3954 | #ifdef HAVE_OPAQUE_LSA |
| 3955 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3956 | type = OSPF_OPAQUE_LINK_LSA; |
| 3957 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3958 | type = OSPF_OPAQUE_AREA_LSA; |
| 3959 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3960 | type = OSPF_OPAQUE_AS_LSA; |
| 3961 | #endif /* HAVE_OPAQUE_LSA */ |
| 3962 | else |
| 3963 | return CMD_WARNING; |
| 3964 | |
| 3965 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 3966 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3967 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3968 | else |
| 3969 | { |
| 3970 | ret = inet_aton (argv[1], &adv_router); |
| 3971 | if (!ret) |
| 3972 | return CMD_WARNING; |
| 3973 | } |
| 3974 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3975 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3976 | |
| 3977 | return CMD_SUCCESS; |
| 3978 | } |
| 3979 | |
| 3980 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 3981 | show_ip_ospf_database_type_self_cmd, |
| 3982 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 3983 | SHOW_STR |
| 3984 | IP_STR |
| 3985 | "OSPF information\n" |
| 3986 | "Database summary\n" |
| 3987 | OSPF_LSA_TYPES_DESC |
| 3988 | "Self-originated link states\n") |
| 3989 | |
| 3990 | |
| 3991 | DEFUN (ip_ospf_authentication_args, |
| 3992 | ip_ospf_authentication_args_addr_cmd, |
| 3993 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 3994 | "IP Information\n" |
| 3995 | "OSPF interface commands\n" |
| 3996 | "Enable authentication on this interface\n" |
| 3997 | "Use null authentication\n" |
| 3998 | "Use message-digest authentication\n" |
| 3999 | "Address of interface") |
| 4000 | { |
| 4001 | struct interface *ifp; |
| 4002 | struct in_addr addr; |
| 4003 | int ret; |
| 4004 | struct ospf_if_params *params; |
| 4005 | |
| 4006 | ifp = vty->index; |
| 4007 | params = IF_DEF_PARAMS (ifp); |
| 4008 | |
| 4009 | if (argc == 2) |
| 4010 | { |
| 4011 | ret = inet_aton(argv[1], &addr); |
| 4012 | if (!ret) |
| 4013 | { |
| 4014 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4015 | VTY_NEWLINE); |
| 4016 | return CMD_WARNING; |
| 4017 | } |
| 4018 | |
| 4019 | params = ospf_get_if_params (ifp, addr); |
| 4020 | ospf_if_update_params (ifp, addr); |
| 4021 | } |
| 4022 | |
| 4023 | /* Handle null authentication */ |
| 4024 | if ( argv[0][0] == 'n' ) |
| 4025 | { |
| 4026 | SET_IF_PARAM (params, auth_type); |
| 4027 | params->auth_type = OSPF_AUTH_NULL; |
| 4028 | return CMD_SUCCESS; |
| 4029 | } |
| 4030 | |
| 4031 | /* Handle message-digest authentication */ |
| 4032 | if ( argv[0][0] == 'm' ) |
| 4033 | { |
| 4034 | SET_IF_PARAM (params, auth_type); |
| 4035 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4036 | return CMD_SUCCESS; |
| 4037 | } |
| 4038 | |
| 4039 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4040 | return CMD_WARNING; |
| 4041 | } |
| 4042 | |
| 4043 | ALIAS (ip_ospf_authentication_args, |
| 4044 | ip_ospf_authentication_args_cmd, |
| 4045 | "ip ospf authentication (null|message-digest)", |
| 4046 | "IP Information\n" |
| 4047 | "OSPF interface commands\n" |
| 4048 | "Enable authentication on this interface\n" |
| 4049 | "Use null authentication\n" |
| 4050 | "Use message-digest authentication\n") |
| 4051 | |
| 4052 | DEFUN (ip_ospf_authentication, |
| 4053 | ip_ospf_authentication_addr_cmd, |
| 4054 | "ip ospf authentication A.B.C.D", |
| 4055 | "IP Information\n" |
| 4056 | "OSPF interface commands\n" |
| 4057 | "Enable authentication on this interface\n" |
| 4058 | "Address of interface") |
| 4059 | { |
| 4060 | struct interface *ifp; |
| 4061 | struct in_addr addr; |
| 4062 | int ret; |
| 4063 | struct ospf_if_params *params; |
| 4064 | |
| 4065 | ifp = vty->index; |
| 4066 | params = IF_DEF_PARAMS (ifp); |
| 4067 | |
| 4068 | if (argc == 1) |
| 4069 | { |
| 4070 | ret = inet_aton(argv[1], &addr); |
| 4071 | if (!ret) |
| 4072 | { |
| 4073 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4074 | VTY_NEWLINE); |
| 4075 | return CMD_WARNING; |
| 4076 | } |
| 4077 | |
| 4078 | params = ospf_get_if_params (ifp, addr); |
| 4079 | ospf_if_update_params (ifp, addr); |
| 4080 | } |
| 4081 | |
| 4082 | SET_IF_PARAM (params, auth_type); |
| 4083 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4084 | |
| 4085 | return CMD_SUCCESS; |
| 4086 | } |
| 4087 | |
| 4088 | ALIAS (ip_ospf_authentication, |
| 4089 | ip_ospf_authentication_cmd, |
| 4090 | "ip ospf authentication", |
| 4091 | "IP Information\n" |
| 4092 | "OSPF interface commands\n" |
| 4093 | "Enable authentication on this interface\n") |
| 4094 | |
| 4095 | DEFUN (no_ip_ospf_authentication, |
| 4096 | no_ip_ospf_authentication_addr_cmd, |
| 4097 | "no ip ospf authentication A.B.C.D", |
| 4098 | NO_STR |
| 4099 | "IP Information\n" |
| 4100 | "OSPF interface commands\n" |
| 4101 | "Enable authentication on this interface\n" |
| 4102 | "Address of interface") |
| 4103 | { |
| 4104 | struct interface *ifp; |
| 4105 | struct in_addr addr; |
| 4106 | int ret; |
| 4107 | struct ospf_if_params *params; |
| 4108 | |
| 4109 | ifp = vty->index; |
| 4110 | params = IF_DEF_PARAMS (ifp); |
| 4111 | |
| 4112 | if (argc == 1) |
| 4113 | { |
| 4114 | ret = inet_aton(argv[1], &addr); |
| 4115 | if (!ret) |
| 4116 | { |
| 4117 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4118 | VTY_NEWLINE); |
| 4119 | return CMD_WARNING; |
| 4120 | } |
| 4121 | |
| 4122 | params = ospf_lookup_if_params (ifp, addr); |
| 4123 | if (params == NULL) |
| 4124 | return CMD_SUCCESS; |
| 4125 | } |
| 4126 | |
| 4127 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4128 | UNSET_IF_PARAM (params, auth_type); |
| 4129 | |
| 4130 | if (params != IF_DEF_PARAMS (ifp)) |
| 4131 | { |
| 4132 | ospf_free_if_params (ifp, addr); |
| 4133 | ospf_if_update_params (ifp, addr); |
| 4134 | } |
| 4135 | |
| 4136 | return CMD_SUCCESS; |
| 4137 | } |
| 4138 | |
| 4139 | ALIAS (no_ip_ospf_authentication, |
| 4140 | no_ip_ospf_authentication_cmd, |
| 4141 | "no ip ospf authentication", |
| 4142 | NO_STR |
| 4143 | "IP Information\n" |
| 4144 | "OSPF interface commands\n" |
| 4145 | "Enable authentication on this interface\n") |
| 4146 | |
| 4147 | DEFUN (ip_ospf_authentication_key, |
| 4148 | ip_ospf_authentication_key_addr_cmd, |
| 4149 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4150 | "IP Information\n" |
| 4151 | "OSPF interface commands\n" |
| 4152 | "Authentication password (key)\n" |
| 4153 | "The OSPF password (key)\n" |
| 4154 | "Address of interface") |
| 4155 | { |
| 4156 | struct interface *ifp; |
| 4157 | struct in_addr addr; |
| 4158 | int ret; |
| 4159 | struct ospf_if_params *params; |
| 4160 | |
| 4161 | ifp = vty->index; |
| 4162 | params = IF_DEF_PARAMS (ifp); |
| 4163 | |
| 4164 | if (argc == 2) |
| 4165 | { |
| 4166 | ret = inet_aton(argv[1], &addr); |
| 4167 | if (!ret) |
| 4168 | { |
| 4169 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4170 | VTY_NEWLINE); |
| 4171 | return CMD_WARNING; |
| 4172 | } |
| 4173 | |
| 4174 | params = ospf_get_if_params (ifp, addr); |
| 4175 | ospf_if_update_params (ifp, addr); |
| 4176 | } |
| 4177 | |
| 4178 | |
| 4179 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 4180 | strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
| 4181 | SET_IF_PARAM (params, auth_simple); |
| 4182 | |
| 4183 | return CMD_SUCCESS; |
| 4184 | } |
| 4185 | |
| 4186 | ALIAS (ip_ospf_authentication_key, |
| 4187 | ip_ospf_authentication_key_cmd, |
| 4188 | "ip ospf authentication-key AUTH_KEY", |
| 4189 | "IP Information\n" |
| 4190 | "OSPF interface commands\n" |
| 4191 | "Authentication password (key)\n" |
| 4192 | "The OSPF password (key)") |
| 4193 | |
| 4194 | ALIAS (ip_ospf_authentication_key, |
| 4195 | ospf_authentication_key_cmd, |
| 4196 | "ospf authentication-key AUTH_KEY", |
| 4197 | "OSPF interface commands\n" |
| 4198 | "Authentication password (key)\n" |
| 4199 | "The OSPF password (key)") |
| 4200 | |
| 4201 | DEFUN (no_ip_ospf_authentication_key, |
| 4202 | no_ip_ospf_authentication_key_addr_cmd, |
| 4203 | "no ip ospf authentication-key A.B.C.D", |
| 4204 | NO_STR |
| 4205 | "IP Information\n" |
| 4206 | "OSPF interface commands\n" |
| 4207 | "Authentication password (key)\n" |
| 4208 | "Address of interface") |
| 4209 | { |
| 4210 | struct interface *ifp; |
| 4211 | struct in_addr addr; |
| 4212 | int ret; |
| 4213 | struct ospf_if_params *params; |
| 4214 | |
| 4215 | ifp = vty->index; |
| 4216 | params = IF_DEF_PARAMS (ifp); |
| 4217 | |
| 4218 | if (argc == 2) |
| 4219 | { |
| 4220 | ret = inet_aton(argv[1], &addr); |
| 4221 | if (!ret) |
| 4222 | { |
| 4223 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4224 | VTY_NEWLINE); |
| 4225 | return CMD_WARNING; |
| 4226 | } |
| 4227 | |
| 4228 | params = ospf_lookup_if_params (ifp, addr); |
| 4229 | if (params == NULL) |
| 4230 | return CMD_SUCCESS; |
| 4231 | } |
| 4232 | |
| 4233 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4234 | UNSET_IF_PARAM (params, auth_simple); |
| 4235 | |
| 4236 | if (params != IF_DEF_PARAMS (ifp)) |
| 4237 | { |
| 4238 | ospf_free_if_params (ifp, addr); |
| 4239 | ospf_if_update_params (ifp, addr); |
| 4240 | } |
| 4241 | |
| 4242 | return CMD_SUCCESS; |
| 4243 | } |
| 4244 | |
| 4245 | ALIAS (no_ip_ospf_authentication_key, |
| 4246 | no_ip_ospf_authentication_key_cmd, |
| 4247 | "no ip ospf authentication-key", |
| 4248 | NO_STR |
| 4249 | "IP Information\n" |
| 4250 | "OSPF interface commands\n" |
| 4251 | "Authentication password (key)\n") |
| 4252 | |
| 4253 | ALIAS (no_ip_ospf_authentication_key, |
| 4254 | no_ospf_authentication_key_cmd, |
| 4255 | "no ospf authentication-key", |
| 4256 | NO_STR |
| 4257 | "OSPF interface commands\n" |
| 4258 | "Authentication password (key)\n") |
| 4259 | |
| 4260 | DEFUN (ip_ospf_message_digest_key, |
| 4261 | ip_ospf_message_digest_key_addr_cmd, |
| 4262 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4263 | "IP Information\n" |
| 4264 | "OSPF interface commands\n" |
| 4265 | "Message digest authentication password (key)\n" |
| 4266 | "Key ID\n" |
| 4267 | "Use MD5 algorithm\n" |
| 4268 | "The OSPF password (key)" |
| 4269 | "Address of interface") |
| 4270 | { |
| 4271 | struct interface *ifp; |
| 4272 | struct crypt_key *ck; |
| 4273 | u_char key_id; |
| 4274 | struct in_addr addr; |
| 4275 | int ret; |
| 4276 | struct ospf_if_params *params; |
| 4277 | |
| 4278 | ifp = vty->index; |
| 4279 | params = IF_DEF_PARAMS (ifp); |
| 4280 | |
| 4281 | if (argc == 3) |
| 4282 | { |
| 4283 | ret = inet_aton(argv[2], &addr); |
| 4284 | if (!ret) |
| 4285 | { |
| 4286 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4287 | VTY_NEWLINE); |
| 4288 | return CMD_WARNING; |
| 4289 | } |
| 4290 | |
| 4291 | params = ospf_get_if_params (ifp, addr); |
| 4292 | ospf_if_update_params (ifp, addr); |
| 4293 | } |
| 4294 | |
| 4295 | key_id = strtol (argv[0], NULL, 10); |
| 4296 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4297 | { |
| 4298 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4299 | return CMD_WARNING; |
| 4300 | } |
| 4301 | |
| 4302 | ck = ospf_crypt_key_new (); |
| 4303 | ck->key_id = (u_char) key_id; |
| 4304 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 4305 | strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
| 4306 | |
| 4307 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4308 | SET_IF_PARAM (params, auth_crypt); |
| 4309 | |
| 4310 | return CMD_SUCCESS; |
| 4311 | } |
| 4312 | |
| 4313 | ALIAS (ip_ospf_message_digest_key, |
| 4314 | ip_ospf_message_digest_key_cmd, |
| 4315 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4316 | "IP Information\n" |
| 4317 | "OSPF interface commands\n" |
| 4318 | "Message digest authentication password (key)\n" |
| 4319 | "Key ID\n" |
| 4320 | "Use MD5 algorithm\n" |
| 4321 | "The OSPF password (key)") |
| 4322 | |
| 4323 | ALIAS (ip_ospf_message_digest_key, |
| 4324 | ospf_message_digest_key_cmd, |
| 4325 | "ospf message-digest-key <1-255> md5 KEY", |
| 4326 | "OSPF interface commands\n" |
| 4327 | "Message digest authentication password (key)\n" |
| 4328 | "Key ID\n" |
| 4329 | "Use MD5 algorithm\n" |
| 4330 | "The OSPF password (key)") |
| 4331 | |
| 4332 | DEFUN (no_ip_ospf_message_digest_key, |
| 4333 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4334 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4335 | NO_STR |
| 4336 | "IP Information\n" |
| 4337 | "OSPF interface commands\n" |
| 4338 | "Message digest authentication password (key)\n" |
| 4339 | "Key ID\n" |
| 4340 | "Address of interface") |
| 4341 | { |
| 4342 | struct interface *ifp; |
| 4343 | struct crypt_key *ck; |
| 4344 | int key_id; |
| 4345 | struct in_addr addr; |
| 4346 | int ret; |
| 4347 | struct ospf_if_params *params; |
| 4348 | |
| 4349 | ifp = vty->index; |
| 4350 | params = IF_DEF_PARAMS (ifp); |
| 4351 | |
| 4352 | if (argc == 2) |
| 4353 | { |
| 4354 | ret = inet_aton(argv[1], &addr); |
| 4355 | if (!ret) |
| 4356 | { |
| 4357 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4358 | VTY_NEWLINE); |
| 4359 | return CMD_WARNING; |
| 4360 | } |
| 4361 | |
| 4362 | params = ospf_lookup_if_params (ifp, addr); |
| 4363 | if (params == NULL) |
| 4364 | return CMD_SUCCESS; |
| 4365 | } |
| 4366 | |
| 4367 | key_id = strtol (argv[0], NULL, 10); |
| 4368 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4369 | if (ck == NULL) |
| 4370 | { |
| 4371 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4372 | return CMD_WARNING; |
| 4373 | } |
| 4374 | |
| 4375 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4376 | |
| 4377 | if (params != IF_DEF_PARAMS (ifp)) |
| 4378 | { |
| 4379 | ospf_free_if_params (ifp, addr); |
| 4380 | ospf_if_update_params (ifp, addr); |
| 4381 | } |
| 4382 | |
| 4383 | return CMD_SUCCESS; |
| 4384 | } |
| 4385 | |
| 4386 | ALIAS (no_ip_ospf_message_digest_key, |
| 4387 | no_ip_ospf_message_digest_key_cmd, |
| 4388 | "no ip ospf message-digest-key <1-255>", |
| 4389 | NO_STR |
| 4390 | "IP Information\n" |
| 4391 | "OSPF interface commands\n" |
| 4392 | "Message digest authentication password (key)\n" |
| 4393 | "Key ID\n") |
| 4394 | |
| 4395 | ALIAS (no_ip_ospf_message_digest_key, |
| 4396 | no_ospf_message_digest_key_cmd, |
| 4397 | "no ospf message-digest-key <1-255>", |
| 4398 | NO_STR |
| 4399 | "OSPF interface commands\n" |
| 4400 | "Message digest authentication password (key)\n" |
| 4401 | "Key ID\n") |
| 4402 | |
| 4403 | DEFUN (ip_ospf_cost, |
| 4404 | ip_ospf_cost_addr_cmd, |
| 4405 | "ip ospf cost <1-65535> A.B.C.D", |
| 4406 | "IP Information\n" |
| 4407 | "OSPF interface commands\n" |
| 4408 | "Interface cost\n" |
| 4409 | "Cost\n" |
| 4410 | "Address of interface") |
| 4411 | { |
| 4412 | struct interface *ifp = vty->index; |
| 4413 | u_int32_t cost; |
| 4414 | struct in_addr addr; |
| 4415 | int ret; |
| 4416 | struct ospf_if_params *params; |
| 4417 | |
| 4418 | params = IF_DEF_PARAMS (ifp); |
| 4419 | |
| 4420 | cost = strtol (argv[0], NULL, 10); |
| 4421 | |
| 4422 | /* cost range is <1-65535>. */ |
| 4423 | if (cost < 1 || cost > 65535) |
| 4424 | { |
| 4425 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4426 | return CMD_WARNING; |
| 4427 | } |
| 4428 | |
| 4429 | if (argc == 2) |
| 4430 | { |
| 4431 | ret = inet_aton(argv[1], &addr); |
| 4432 | if (!ret) |
| 4433 | { |
| 4434 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4435 | VTY_NEWLINE); |
| 4436 | return CMD_WARNING; |
| 4437 | } |
| 4438 | |
| 4439 | params = ospf_get_if_params (ifp, addr); |
| 4440 | ospf_if_update_params (ifp, addr); |
| 4441 | } |
| 4442 | |
| 4443 | SET_IF_PARAM (params, output_cost_cmd); |
| 4444 | params->output_cost_cmd = cost; |
| 4445 | |
| 4446 | ospf_if_recalculate_output_cost (ifp); |
| 4447 | |
| 4448 | return CMD_SUCCESS; |
| 4449 | } |
| 4450 | |
| 4451 | ALIAS (ip_ospf_cost, |
| 4452 | ip_ospf_cost_cmd, |
| 4453 | "ip ospf cost <1-65535>", |
| 4454 | "IP Information\n" |
| 4455 | "OSPF interface commands\n" |
| 4456 | "Interface cost\n" |
| 4457 | "Cost") |
| 4458 | |
| 4459 | ALIAS (ip_ospf_cost, |
| 4460 | ospf_cost_cmd, |
| 4461 | "ospf cost <1-65535>", |
| 4462 | "OSPF interface commands\n" |
| 4463 | "Interface cost\n" |
| 4464 | "Cost") |
| 4465 | |
| 4466 | DEFUN (no_ip_ospf_cost, |
| 4467 | no_ip_ospf_cost_addr_cmd, |
| 4468 | "no ip ospf cost A.B.C.D", |
| 4469 | NO_STR |
| 4470 | "IP Information\n" |
| 4471 | "OSPF interface commands\n" |
| 4472 | "Interface cost\n" |
| 4473 | "Address of interface") |
| 4474 | { |
| 4475 | struct interface *ifp = vty->index; |
| 4476 | struct in_addr addr; |
| 4477 | int ret; |
| 4478 | struct ospf_if_params *params; |
| 4479 | |
| 4480 | ifp = vty->index; |
| 4481 | params = IF_DEF_PARAMS (ifp); |
| 4482 | |
| 4483 | if (argc == 1) |
| 4484 | { |
| 4485 | ret = inet_aton(argv[0], &addr); |
| 4486 | if (!ret) |
| 4487 | { |
| 4488 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4489 | VTY_NEWLINE); |
| 4490 | return CMD_WARNING; |
| 4491 | } |
| 4492 | |
| 4493 | params = ospf_lookup_if_params (ifp, addr); |
| 4494 | if (params == NULL) |
| 4495 | return CMD_SUCCESS; |
| 4496 | } |
| 4497 | |
| 4498 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4499 | |
| 4500 | if (params != IF_DEF_PARAMS (ifp)) |
| 4501 | { |
| 4502 | ospf_free_if_params (ifp, addr); |
| 4503 | ospf_if_update_params (ifp, addr); |
| 4504 | } |
| 4505 | |
| 4506 | ospf_if_recalculate_output_cost (ifp); |
| 4507 | |
| 4508 | return CMD_SUCCESS; |
| 4509 | } |
| 4510 | |
| 4511 | ALIAS (no_ip_ospf_cost, |
| 4512 | no_ip_ospf_cost_cmd, |
| 4513 | "no ip ospf cost", |
| 4514 | NO_STR |
| 4515 | "IP Information\n" |
| 4516 | "OSPF interface commands\n" |
| 4517 | "Interface cost\n") |
| 4518 | |
| 4519 | ALIAS (no_ip_ospf_cost, |
| 4520 | no_ospf_cost_cmd, |
| 4521 | "no ospf cost", |
| 4522 | NO_STR |
| 4523 | "OSPF interface commands\n" |
| 4524 | "Interface cost\n") |
| 4525 | |
| 4526 | void |
| 4527 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4528 | { |
| 4529 | struct route_node *rn; |
| 4530 | struct ospf_neighbor *nbr; |
| 4531 | |
| 4532 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4533 | if ((nbr = rn->info)) |
| 4534 | { |
| 4535 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4536 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4537 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4538 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4539 | } |
| 4540 | } |
| 4541 | |
| 4542 | DEFUN (ip_ospf_dead_interval, |
| 4543 | ip_ospf_dead_interval_addr_cmd, |
| 4544 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4545 | "IP Information\n" |
| 4546 | "OSPF interface commands\n" |
| 4547 | "Interval after which a neighbor is declared dead\n" |
| 4548 | "Seconds\n" |
| 4549 | "Address of interface") |
| 4550 | { |
| 4551 | struct interface *ifp = vty->index; |
| 4552 | u_int32_t seconds; |
| 4553 | struct in_addr addr; |
| 4554 | int ret; |
| 4555 | struct ospf_if_params *params; |
| 4556 | struct ospf_interface *oi; |
| 4557 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4558 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4559 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4560 | ospf = ospf_lookup (); |
| 4561 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4562 | params = IF_DEF_PARAMS (ifp); |
| 4563 | |
| 4564 | seconds = strtol (argv[0], NULL, 10); |
| 4565 | |
| 4566 | /* dead_interval range is <1-65535>. */ |
| 4567 | if (seconds < 1 || seconds > 65535) |
| 4568 | { |
| 4569 | vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE); |
| 4570 | return CMD_WARNING; |
| 4571 | } |
| 4572 | |
| 4573 | if (argc == 2) |
| 4574 | { |
| 4575 | ret = inet_aton(argv[1], &addr); |
| 4576 | if (!ret) |
| 4577 | { |
| 4578 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4579 | VTY_NEWLINE); |
| 4580 | return CMD_WARNING; |
| 4581 | } |
| 4582 | |
| 4583 | params = ospf_get_if_params (ifp, addr); |
| 4584 | ospf_if_update_params (ifp, addr); |
| 4585 | } |
| 4586 | |
| 4587 | SET_IF_PARAM (params, v_wait); |
| 4588 | params->v_wait = seconds; |
| 4589 | |
| 4590 | /* Update timer values in neighbor structure. */ |
| 4591 | if (argc == 2) |
| 4592 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4593 | if (ospf) |
| 4594 | { |
| 4595 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4596 | if (oi) |
| 4597 | ospf_nbr_timer_update (oi); |
| 4598 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4599 | } |
| 4600 | else |
| 4601 | { |
| 4602 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4603 | if ((oi = rn->info)) |
| 4604 | ospf_nbr_timer_update (oi); |
| 4605 | } |
| 4606 | |
| 4607 | return CMD_SUCCESS; |
| 4608 | } |
| 4609 | |
| 4610 | ALIAS (ip_ospf_dead_interval, |
| 4611 | ip_ospf_dead_interval_cmd, |
| 4612 | "ip ospf dead-interval <1-65535>", |
| 4613 | "IP Information\n" |
| 4614 | "OSPF interface commands\n" |
| 4615 | "Interval after which a neighbor is declared dead\n" |
| 4616 | "Seconds\n") |
| 4617 | |
| 4618 | ALIAS (ip_ospf_dead_interval, |
| 4619 | ospf_dead_interval_cmd, |
| 4620 | "ospf dead-interval <1-65535>", |
| 4621 | "OSPF interface commands\n" |
| 4622 | "Interval after which a neighbor is declared dead\n" |
| 4623 | "Seconds\n") |
| 4624 | |
| 4625 | DEFUN (no_ip_ospf_dead_interval, |
| 4626 | no_ip_ospf_dead_interval_addr_cmd, |
| 4627 | "no ip ospf dead-interval A.B.C.D", |
| 4628 | NO_STR |
| 4629 | "IP Information\n" |
| 4630 | "OSPF interface commands\n" |
| 4631 | "Interval after which a neighbor is declared dead\n" |
| 4632 | "Address of interface") |
| 4633 | { |
| 4634 | struct interface *ifp = vty->index; |
| 4635 | struct in_addr addr; |
| 4636 | int ret; |
| 4637 | struct ospf_if_params *params; |
| 4638 | struct ospf_interface *oi; |
| 4639 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4640 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4641 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4642 | ospf = ospf_lookup (); |
| 4643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4644 | ifp = vty->index; |
| 4645 | params = IF_DEF_PARAMS (ifp); |
| 4646 | |
| 4647 | if (argc == 1) |
| 4648 | { |
| 4649 | ret = inet_aton(argv[0], &addr); |
| 4650 | if (!ret) |
| 4651 | { |
| 4652 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4653 | VTY_NEWLINE); |
| 4654 | return CMD_WARNING; |
| 4655 | } |
| 4656 | |
| 4657 | params = ospf_lookup_if_params (ifp, addr); |
| 4658 | if (params == NULL) |
| 4659 | return CMD_SUCCESS; |
| 4660 | } |
| 4661 | |
| 4662 | UNSET_IF_PARAM (params, v_wait); |
| 4663 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4664 | |
| 4665 | if (params != IF_DEF_PARAMS (ifp)) |
| 4666 | { |
| 4667 | ospf_free_if_params (ifp, addr); |
| 4668 | ospf_if_update_params (ifp, addr); |
| 4669 | } |
| 4670 | |
| 4671 | /* Update timer values in neighbor structure. */ |
| 4672 | if (argc == 1) |
| 4673 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4674 | if (ospf) |
| 4675 | { |
| 4676 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4677 | if (oi) |
| 4678 | ospf_nbr_timer_update (oi); |
| 4679 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4680 | } |
| 4681 | else |
| 4682 | { |
| 4683 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4684 | if ((oi = rn->info)) |
| 4685 | ospf_nbr_timer_update (oi); |
| 4686 | } |
| 4687 | |
| 4688 | return CMD_SUCCESS; |
| 4689 | } |
| 4690 | |
| 4691 | ALIAS (no_ip_ospf_dead_interval, |
| 4692 | no_ip_ospf_dead_interval_cmd, |
| 4693 | "no ip ospf dead-interval", |
| 4694 | NO_STR |
| 4695 | "IP Information\n" |
| 4696 | "OSPF interface commands\n" |
| 4697 | "Interval after which a neighbor is declared dead\n") |
| 4698 | |
| 4699 | ALIAS (no_ip_ospf_dead_interval, |
| 4700 | no_ospf_dead_interval_cmd, |
| 4701 | "no ospf dead-interval", |
| 4702 | NO_STR |
| 4703 | "OSPF interface commands\n" |
| 4704 | "Interval after which a neighbor is declared dead\n") |
| 4705 | |
| 4706 | DEFUN (ip_ospf_hello_interval, |
| 4707 | ip_ospf_hello_interval_addr_cmd, |
| 4708 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4709 | "IP Information\n" |
| 4710 | "OSPF interface commands\n" |
| 4711 | "Time between HELLO packets\n" |
| 4712 | "Seconds\n" |
| 4713 | "Address of interface") |
| 4714 | { |
| 4715 | struct interface *ifp = vty->index; |
| 4716 | u_int32_t seconds; |
| 4717 | struct in_addr addr; |
| 4718 | int ret; |
| 4719 | struct ospf_if_params *params; |
| 4720 | |
| 4721 | params = IF_DEF_PARAMS (ifp); |
| 4722 | |
| 4723 | seconds = strtol (argv[0], NULL, 10); |
| 4724 | |
| 4725 | /* HelloInterval range is <1-65535>. */ |
| 4726 | if (seconds < 1 || seconds > 65535) |
| 4727 | { |
| 4728 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4729 | return CMD_WARNING; |
| 4730 | } |
| 4731 | |
| 4732 | if (argc == 2) |
| 4733 | { |
| 4734 | ret = inet_aton(argv[1], &addr); |
| 4735 | if (!ret) |
| 4736 | { |
| 4737 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4738 | VTY_NEWLINE); |
| 4739 | return CMD_WARNING; |
| 4740 | } |
| 4741 | |
| 4742 | params = ospf_get_if_params (ifp, addr); |
| 4743 | ospf_if_update_params (ifp, addr); |
| 4744 | } |
| 4745 | |
| 4746 | SET_IF_PARAM (params, v_hello); |
| 4747 | params->v_hello = seconds; |
| 4748 | |
| 4749 | return CMD_SUCCESS; |
| 4750 | } |
| 4751 | |
| 4752 | ALIAS (ip_ospf_hello_interval, |
| 4753 | ip_ospf_hello_interval_cmd, |
| 4754 | "ip ospf hello-interval <1-65535>", |
| 4755 | "IP Information\n" |
| 4756 | "OSPF interface commands\n" |
| 4757 | "Time between HELLO packets\n" |
| 4758 | "Seconds\n") |
| 4759 | |
| 4760 | ALIAS (ip_ospf_hello_interval, |
| 4761 | ospf_hello_interval_cmd, |
| 4762 | "ospf hello-interval <1-65535>", |
| 4763 | "OSPF interface commands\n" |
| 4764 | "Time between HELLO packets\n" |
| 4765 | "Seconds\n") |
| 4766 | |
| 4767 | DEFUN (no_ip_ospf_hello_interval, |
| 4768 | no_ip_ospf_hello_interval_addr_cmd, |
| 4769 | "no ip ospf hello-interval A.B.C.D", |
| 4770 | NO_STR |
| 4771 | "IP Information\n" |
| 4772 | "OSPF interface commands\n" |
| 4773 | "Time between HELLO packets\n" |
| 4774 | "Address of interface") |
| 4775 | { |
| 4776 | struct interface *ifp = vty->index; |
| 4777 | struct in_addr addr; |
| 4778 | int ret; |
| 4779 | struct ospf_if_params *params; |
| 4780 | |
| 4781 | ifp = vty->index; |
| 4782 | params = IF_DEF_PARAMS (ifp); |
| 4783 | |
| 4784 | if (argc == 1) |
| 4785 | { |
| 4786 | ret = inet_aton(argv[0], &addr); |
| 4787 | if (!ret) |
| 4788 | { |
| 4789 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4790 | VTY_NEWLINE); |
| 4791 | return CMD_WARNING; |
| 4792 | } |
| 4793 | |
| 4794 | params = ospf_lookup_if_params (ifp, addr); |
| 4795 | if (params == NULL) |
| 4796 | return CMD_SUCCESS; |
| 4797 | } |
| 4798 | |
| 4799 | UNSET_IF_PARAM (params, v_hello); |
| 4800 | params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4801 | |
| 4802 | if (params != IF_DEF_PARAMS (ifp)) |
| 4803 | { |
| 4804 | ospf_free_if_params (ifp, addr); |
| 4805 | ospf_if_update_params (ifp, addr); |
| 4806 | } |
| 4807 | |
| 4808 | return CMD_SUCCESS; |
| 4809 | } |
| 4810 | |
| 4811 | ALIAS (no_ip_ospf_hello_interval, |
| 4812 | no_ip_ospf_hello_interval_cmd, |
| 4813 | "no ip ospf hello-interval", |
| 4814 | NO_STR |
| 4815 | "IP Information\n" |
| 4816 | "OSPF interface commands\n" |
| 4817 | "Time between HELLO packets\n") |
| 4818 | |
| 4819 | ALIAS (no_ip_ospf_hello_interval, |
| 4820 | no_ospf_hello_interval_cmd, |
| 4821 | "no ospf hello-interval", |
| 4822 | NO_STR |
| 4823 | "OSPF interface commands\n" |
| 4824 | "Time between HELLO packets\n") |
| 4825 | |
| 4826 | DEFUN (ip_ospf_network, |
| 4827 | ip_ospf_network_cmd, |
| 4828 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4829 | "IP Information\n" |
| 4830 | "OSPF interface commands\n" |
| 4831 | "Network type\n" |
| 4832 | "Specify OSPF broadcast multi-access network\n" |
| 4833 | "Specify OSPF NBMA network\n" |
| 4834 | "Specify OSPF point-to-multipoint network\n" |
| 4835 | "Specify OSPF point-to-point network\n") |
| 4836 | { |
| 4837 | struct interface *ifp = vty->index; |
| 4838 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4839 | struct route_node *rn; |
| 4840 | |
| 4841 | if (strncmp (argv[0], "b", 1) == 0) |
| 4842 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 4843 | else if (strncmp (argv[0], "n", 1) == 0) |
| 4844 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 4845 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 4846 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 4847 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 4848 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 4849 | |
| 4850 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4851 | return CMD_SUCCESS; |
| 4852 | |
| 4853 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 4854 | |
| 4855 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4856 | { |
| 4857 | struct ospf_interface *oi = rn->info; |
| 4858 | |
| 4859 | if (!oi) |
| 4860 | continue; |
| 4861 | |
| 4862 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4863 | |
| 4864 | if (oi->state > ISM_Down) |
| 4865 | { |
| 4866 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4867 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4868 | } |
| 4869 | } |
| 4870 | |
| 4871 | return CMD_SUCCESS; |
| 4872 | } |
| 4873 | |
| 4874 | ALIAS (ip_ospf_network, |
| 4875 | ospf_network_cmd, |
| 4876 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4877 | "OSPF interface commands\n" |
| 4878 | "Network type\n" |
| 4879 | "Specify OSPF broadcast multi-access network\n" |
| 4880 | "Specify OSPF NBMA network\n" |
| 4881 | "Specify OSPF point-to-multipoint network\n" |
| 4882 | "Specify OSPF point-to-point network\n") |
| 4883 | |
| 4884 | DEFUN (no_ip_ospf_network, |
| 4885 | no_ip_ospf_network_cmd, |
| 4886 | "no ip ospf network", |
| 4887 | NO_STR |
| 4888 | "IP Information\n" |
| 4889 | "OSPF interface commands\n" |
| 4890 | "Network type\n") |
| 4891 | { |
| 4892 | struct interface *ifp = vty->index; |
| 4893 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4894 | struct route_node *rn; |
| 4895 | |
| 4896 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 4897 | |
| 4898 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4899 | return CMD_SUCCESS; |
| 4900 | |
| 4901 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4902 | { |
| 4903 | struct ospf_interface *oi = rn->info; |
| 4904 | |
| 4905 | if (!oi) |
| 4906 | continue; |
| 4907 | |
| 4908 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4909 | |
| 4910 | if (oi->state > ISM_Down) |
| 4911 | { |
| 4912 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4913 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4914 | } |
| 4915 | } |
| 4916 | |
| 4917 | return CMD_SUCCESS; |
| 4918 | } |
| 4919 | |
| 4920 | ALIAS (no_ip_ospf_network, |
| 4921 | no_ospf_network_cmd, |
| 4922 | "no ospf network", |
| 4923 | NO_STR |
| 4924 | "OSPF interface commands\n" |
| 4925 | "Network type\n") |
| 4926 | |
| 4927 | DEFUN (ip_ospf_priority, |
| 4928 | ip_ospf_priority_addr_cmd, |
| 4929 | "ip ospf priority <0-255> A.B.C.D", |
| 4930 | "IP Information\n" |
| 4931 | "OSPF interface commands\n" |
| 4932 | "Router priority\n" |
| 4933 | "Priority\n" |
| 4934 | "Address of interface") |
| 4935 | { |
| 4936 | struct interface *ifp = vty->index; |
| 4937 | u_int32_t priority; |
| 4938 | struct route_node *rn; |
| 4939 | struct in_addr addr; |
| 4940 | int ret; |
| 4941 | struct ospf_if_params *params; |
| 4942 | |
| 4943 | params = IF_DEF_PARAMS (ifp); |
| 4944 | |
| 4945 | priority = strtol (argv[0], NULL, 10); |
| 4946 | |
| 4947 | /* Router Priority range is <0-255>. */ |
| 4948 | if (priority < 0 || priority > 255) |
| 4949 | { |
| 4950 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 4951 | return CMD_WARNING; |
| 4952 | } |
| 4953 | |
| 4954 | if (argc == 2) |
| 4955 | { |
| 4956 | ret = inet_aton(argv[1], &addr); |
| 4957 | if (!ret) |
| 4958 | { |
| 4959 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4960 | VTY_NEWLINE); |
| 4961 | return CMD_WARNING; |
| 4962 | } |
| 4963 | |
| 4964 | params = ospf_get_if_params (ifp, addr); |
| 4965 | ospf_if_update_params (ifp, addr); |
| 4966 | } |
| 4967 | |
| 4968 | SET_IF_PARAM (params, priority); |
| 4969 | params->priority = priority; |
| 4970 | |
| 4971 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4972 | { |
| 4973 | struct ospf_interface *oi = rn->info; |
| 4974 | |
| 4975 | if (!oi) |
| 4976 | continue; |
| 4977 | |
| 4978 | |
| 4979 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 4980 | { |
| 4981 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 4982 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 4983 | } |
| 4984 | } |
| 4985 | |
| 4986 | return CMD_SUCCESS; |
| 4987 | } |
| 4988 | |
| 4989 | ALIAS (ip_ospf_priority, |
| 4990 | ip_ospf_priority_cmd, |
| 4991 | "ip ospf priority <0-255>", |
| 4992 | "IP Information\n" |
| 4993 | "OSPF interface commands\n" |
| 4994 | "Router priority\n" |
| 4995 | "Priority\n") |
| 4996 | |
| 4997 | ALIAS (ip_ospf_priority, |
| 4998 | ospf_priority_cmd, |
| 4999 | "ospf priority <0-255>", |
| 5000 | "OSPF interface commands\n" |
| 5001 | "Router priority\n" |
| 5002 | "Priority\n") |
| 5003 | |
| 5004 | DEFUN (no_ip_ospf_priority, |
| 5005 | no_ip_ospf_priority_addr_cmd, |
| 5006 | "no ip ospf priority A.B.C.D", |
| 5007 | NO_STR |
| 5008 | "IP Information\n" |
| 5009 | "OSPF interface commands\n" |
| 5010 | "Router priority\n" |
| 5011 | "Address of interface") |
| 5012 | { |
| 5013 | struct interface *ifp = vty->index; |
| 5014 | struct route_node *rn; |
| 5015 | struct in_addr addr; |
| 5016 | int ret; |
| 5017 | struct ospf_if_params *params; |
| 5018 | |
| 5019 | ifp = vty->index; |
| 5020 | params = IF_DEF_PARAMS (ifp); |
| 5021 | |
| 5022 | if (argc == 1) |
| 5023 | { |
| 5024 | ret = inet_aton(argv[0], &addr); |
| 5025 | if (!ret) |
| 5026 | { |
| 5027 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5028 | VTY_NEWLINE); |
| 5029 | return CMD_WARNING; |
| 5030 | } |
| 5031 | |
| 5032 | params = ospf_lookup_if_params (ifp, addr); |
| 5033 | if (params == NULL) |
| 5034 | return CMD_SUCCESS; |
| 5035 | } |
| 5036 | |
| 5037 | UNSET_IF_PARAM (params, priority); |
| 5038 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5039 | |
| 5040 | if (params != IF_DEF_PARAMS (ifp)) |
| 5041 | { |
| 5042 | ospf_free_if_params (ifp, addr); |
| 5043 | ospf_if_update_params (ifp, addr); |
| 5044 | } |
| 5045 | |
| 5046 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5047 | { |
| 5048 | struct ospf_interface *oi = rn->info; |
| 5049 | |
| 5050 | if (!oi) |
| 5051 | continue; |
| 5052 | |
| 5053 | |
| 5054 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5055 | { |
| 5056 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5057 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5058 | } |
| 5059 | } |
| 5060 | |
| 5061 | return CMD_SUCCESS; |
| 5062 | } |
| 5063 | |
| 5064 | ALIAS (no_ip_ospf_priority, |
| 5065 | no_ip_ospf_priority_cmd, |
| 5066 | "no ip ospf priority", |
| 5067 | NO_STR |
| 5068 | "IP Information\n" |
| 5069 | "OSPF interface commands\n" |
| 5070 | "Router priority\n") |
| 5071 | |
| 5072 | ALIAS (no_ip_ospf_priority, |
| 5073 | no_ospf_priority_cmd, |
| 5074 | "no ospf priority", |
| 5075 | NO_STR |
| 5076 | "OSPF interface commands\n" |
| 5077 | "Router priority\n") |
| 5078 | |
| 5079 | DEFUN (ip_ospf_retransmit_interval, |
| 5080 | ip_ospf_retransmit_interval_addr_cmd, |
| 5081 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5082 | "IP Information\n" |
| 5083 | "OSPF interface commands\n" |
| 5084 | "Time between retransmitting lost link state advertisements\n" |
| 5085 | "Seconds\n" |
| 5086 | "Address of interface") |
| 5087 | { |
| 5088 | struct interface *ifp = vty->index; |
| 5089 | u_int32_t seconds; |
| 5090 | struct in_addr addr; |
| 5091 | int ret; |
| 5092 | struct ospf_if_params *params; |
| 5093 | |
| 5094 | params = IF_DEF_PARAMS (ifp); |
| 5095 | seconds = strtol (argv[0], NULL, 10); |
| 5096 | |
| 5097 | /* Retransmit Interval range is <3-65535>. */ |
| 5098 | if (seconds < 3 || seconds > 65535) |
| 5099 | { |
| 5100 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5101 | return CMD_WARNING; |
| 5102 | } |
| 5103 | |
| 5104 | |
| 5105 | if (argc == 2) |
| 5106 | { |
| 5107 | ret = inet_aton(argv[1], &addr); |
| 5108 | if (!ret) |
| 5109 | { |
| 5110 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5111 | VTY_NEWLINE); |
| 5112 | return CMD_WARNING; |
| 5113 | } |
| 5114 | |
| 5115 | params = ospf_get_if_params (ifp, addr); |
| 5116 | ospf_if_update_params (ifp, addr); |
| 5117 | } |
| 5118 | |
| 5119 | SET_IF_PARAM (params, retransmit_interval); |
| 5120 | params->retransmit_interval = seconds; |
| 5121 | |
| 5122 | return CMD_SUCCESS; |
| 5123 | } |
| 5124 | |
| 5125 | ALIAS (ip_ospf_retransmit_interval, |
| 5126 | ip_ospf_retransmit_interval_cmd, |
| 5127 | "ip ospf retransmit-interval <3-65535>", |
| 5128 | "IP Information\n" |
| 5129 | "OSPF interface commands\n" |
| 5130 | "Time between retransmitting lost link state advertisements\n" |
| 5131 | "Seconds\n") |
| 5132 | |
| 5133 | ALIAS (ip_ospf_retransmit_interval, |
| 5134 | ospf_retransmit_interval_cmd, |
| 5135 | "ospf retransmit-interval <3-65535>", |
| 5136 | "OSPF interface commands\n" |
| 5137 | "Time between retransmitting lost link state advertisements\n" |
| 5138 | "Seconds\n") |
| 5139 | |
| 5140 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5141 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5142 | "no ip ospf retransmit-interval A.B.C.D", |
| 5143 | NO_STR |
| 5144 | "IP Information\n" |
| 5145 | "OSPF interface commands\n" |
| 5146 | "Time between retransmitting lost link state advertisements\n" |
| 5147 | "Address of interface") |
| 5148 | { |
| 5149 | struct interface *ifp = vty->index; |
| 5150 | struct in_addr addr; |
| 5151 | int ret; |
| 5152 | struct ospf_if_params *params; |
| 5153 | |
| 5154 | ifp = vty->index; |
| 5155 | params = IF_DEF_PARAMS (ifp); |
| 5156 | |
| 5157 | if (argc == 1) |
| 5158 | { |
| 5159 | ret = inet_aton(argv[0], &addr); |
| 5160 | if (!ret) |
| 5161 | { |
| 5162 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5163 | VTY_NEWLINE); |
| 5164 | return CMD_WARNING; |
| 5165 | } |
| 5166 | |
| 5167 | params = ospf_lookup_if_params (ifp, addr); |
| 5168 | if (params == NULL) |
| 5169 | return CMD_SUCCESS; |
| 5170 | } |
| 5171 | |
| 5172 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5173 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5174 | |
| 5175 | if (params != IF_DEF_PARAMS (ifp)) |
| 5176 | { |
| 5177 | ospf_free_if_params (ifp, addr); |
| 5178 | ospf_if_update_params (ifp, addr); |
| 5179 | } |
| 5180 | |
| 5181 | return CMD_SUCCESS; |
| 5182 | } |
| 5183 | |
| 5184 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5185 | no_ip_ospf_retransmit_interval_cmd, |
| 5186 | "no ip ospf retransmit-interval", |
| 5187 | NO_STR |
| 5188 | "IP Information\n" |
| 5189 | "OSPF interface commands\n" |
| 5190 | "Time between retransmitting lost link state advertisements\n") |
| 5191 | |
| 5192 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5193 | no_ospf_retransmit_interval_cmd, |
| 5194 | "no ospf retransmit-interval", |
| 5195 | NO_STR |
| 5196 | "OSPF interface commands\n" |
| 5197 | "Time between retransmitting lost link state advertisements\n") |
| 5198 | |
| 5199 | DEFUN (ip_ospf_transmit_delay, |
| 5200 | ip_ospf_transmit_delay_addr_cmd, |
| 5201 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5202 | "IP Information\n" |
| 5203 | "OSPF interface commands\n" |
| 5204 | "Link state transmit delay\n" |
| 5205 | "Seconds\n" |
| 5206 | "Address of interface") |
| 5207 | { |
| 5208 | struct interface *ifp = vty->index; |
| 5209 | u_int32_t seconds; |
| 5210 | struct in_addr addr; |
| 5211 | int ret; |
| 5212 | struct ospf_if_params *params; |
| 5213 | |
| 5214 | params = IF_DEF_PARAMS (ifp); |
| 5215 | seconds = strtol (argv[0], NULL, 10); |
| 5216 | |
| 5217 | /* Transmit Delay range is <1-65535>. */ |
| 5218 | if (seconds < 1 || seconds > 65535) |
| 5219 | { |
| 5220 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5221 | return CMD_WARNING; |
| 5222 | } |
| 5223 | |
| 5224 | if (argc == 2) |
| 5225 | { |
| 5226 | ret = inet_aton(argv[1], &addr); |
| 5227 | if (!ret) |
| 5228 | { |
| 5229 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5230 | VTY_NEWLINE); |
| 5231 | return CMD_WARNING; |
| 5232 | } |
| 5233 | |
| 5234 | params = ospf_get_if_params (ifp, addr); |
| 5235 | ospf_if_update_params (ifp, addr); |
| 5236 | } |
| 5237 | |
| 5238 | SET_IF_PARAM (params, transmit_delay); |
| 5239 | params->transmit_delay = seconds; |
| 5240 | |
| 5241 | return CMD_SUCCESS; |
| 5242 | } |
| 5243 | |
| 5244 | ALIAS (ip_ospf_transmit_delay, |
| 5245 | ip_ospf_transmit_delay_cmd, |
| 5246 | "ip ospf transmit-delay <1-65535>", |
| 5247 | "IP Information\n" |
| 5248 | "OSPF interface commands\n" |
| 5249 | "Link state transmit delay\n" |
| 5250 | "Seconds\n") |
| 5251 | |
| 5252 | ALIAS (ip_ospf_transmit_delay, |
| 5253 | ospf_transmit_delay_cmd, |
| 5254 | "ospf transmit-delay <1-65535>", |
| 5255 | "OSPF interface commands\n" |
| 5256 | "Link state transmit delay\n" |
| 5257 | "Seconds\n") |
| 5258 | |
| 5259 | DEFUN (no_ip_ospf_transmit_delay, |
| 5260 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5261 | "no ip ospf transmit-delay A.B.C.D", |
| 5262 | NO_STR |
| 5263 | "IP Information\n" |
| 5264 | "OSPF interface commands\n" |
| 5265 | "Link state transmit delay\n" |
| 5266 | "Address of interface") |
| 5267 | { |
| 5268 | struct interface *ifp = vty->index; |
| 5269 | struct in_addr addr; |
| 5270 | int ret; |
| 5271 | struct ospf_if_params *params; |
| 5272 | |
| 5273 | ifp = vty->index; |
| 5274 | params = IF_DEF_PARAMS (ifp); |
| 5275 | |
| 5276 | if (argc == 1) |
| 5277 | { |
| 5278 | ret = inet_aton(argv[0], &addr); |
| 5279 | if (!ret) |
| 5280 | { |
| 5281 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5282 | VTY_NEWLINE); |
| 5283 | return CMD_WARNING; |
| 5284 | } |
| 5285 | |
| 5286 | params = ospf_lookup_if_params (ifp, addr); |
| 5287 | if (params == NULL) |
| 5288 | return CMD_SUCCESS; |
| 5289 | } |
| 5290 | |
| 5291 | UNSET_IF_PARAM (params, transmit_delay); |
| 5292 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5293 | |
| 5294 | if (params != IF_DEF_PARAMS (ifp)) |
| 5295 | { |
| 5296 | ospf_free_if_params (ifp, addr); |
| 5297 | ospf_if_update_params (ifp, addr); |
| 5298 | } |
| 5299 | |
| 5300 | return CMD_SUCCESS; |
| 5301 | } |
| 5302 | |
| 5303 | ALIAS (no_ip_ospf_transmit_delay, |
| 5304 | no_ip_ospf_transmit_delay_cmd, |
| 5305 | "no ip ospf transmit-delay", |
| 5306 | NO_STR |
| 5307 | "IP Information\n" |
| 5308 | "OSPF interface commands\n" |
| 5309 | "Link state transmit delay\n") |
| 5310 | |
| 5311 | ALIAS (no_ip_ospf_transmit_delay, |
| 5312 | no_ospf_transmit_delay_cmd, |
| 5313 | "no ospf transmit-delay", |
| 5314 | NO_STR |
| 5315 | "OSPF interface commands\n" |
| 5316 | "Link state transmit delay\n") |
| 5317 | |
| 5318 | |
| 5319 | DEFUN (ospf_redistribute_source_metric_type, |
| 5320 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5321 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5322 | "Redistribute information from another routing protocol\n" |
| 5323 | "Kernel routes\n" |
| 5324 | "Connected\n" |
| 5325 | "Static routes\n" |
| 5326 | "Routing Information Protocol (RIP)\n" |
| 5327 | "Border Gateway Protocol (BGP)\n" |
| 5328 | "Metric for redistributed routes\n" |
| 5329 | "OSPF default metric\n" |
| 5330 | "OSPF exterior metric type for redistributed routes\n" |
| 5331 | "Set OSPF External Type 1 metrics\n" |
| 5332 | "Set OSPF External Type 2 metrics\n" |
| 5333 | "Route map reference\n" |
| 5334 | "Pointer to route-map entries\n") |
| 5335 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5336 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5337 | int source; |
| 5338 | int type = -1; |
| 5339 | int metric = -1; |
| 5340 | |
| 5341 | /* Get distribute source. */ |
| 5342 | if (!str2distribute_source (argv[0], &source)) |
| 5343 | return CMD_WARNING; |
| 5344 | |
| 5345 | /* Get metric value. */ |
| 5346 | if (argc >= 2) |
| 5347 | if (!str2metric (argv[1], &metric)) |
| 5348 | return CMD_WARNING; |
| 5349 | |
| 5350 | /* Get metric type. */ |
| 5351 | if (argc >= 3) |
| 5352 | if (!str2metric_type (argv[2], &type)) |
| 5353 | return CMD_WARNING; |
| 5354 | |
| 5355 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5356 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5357 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5358 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5359 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5360 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5361 | } |
| 5362 | |
| 5363 | ALIAS (ospf_redistribute_source_metric_type, |
| 5364 | ospf_redistribute_source_metric_type_cmd, |
| 5365 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5366 | "Redistribute information from another routing protocol\n" |
| 5367 | "Kernel routes\n" |
| 5368 | "Connected\n" |
| 5369 | "Static routes\n" |
| 5370 | "Routing Information Protocol (RIP)\n" |
| 5371 | "Border Gateway Protocol (BGP)\n" |
| 5372 | "Metric for redistributed routes\n" |
| 5373 | "OSPF default metric\n" |
| 5374 | "OSPF exterior metric type for redistributed routes\n" |
| 5375 | "Set OSPF External Type 1 metrics\n" |
| 5376 | "Set OSPF External Type 2 metrics\n") |
| 5377 | |
| 5378 | ALIAS (ospf_redistribute_source_metric_type, |
| 5379 | ospf_redistribute_source_metric_cmd, |
| 5380 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5381 | "Redistribute information from another routing protocol\n" |
| 5382 | "Kernel routes\n" |
| 5383 | "Connected\n" |
| 5384 | "Static routes\n" |
| 5385 | "Routing Information Protocol (RIP)\n" |
| 5386 | "Border Gateway Protocol (BGP)\n" |
| 5387 | "Metric for redistributed routes\n" |
| 5388 | "OSPF default metric\n") |
| 5389 | |
| 5390 | DEFUN (ospf_redistribute_source_type_metric, |
| 5391 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5392 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5393 | "Redistribute information from another routing protocol\n" |
| 5394 | "Kernel routes\n" |
| 5395 | "Connected\n" |
| 5396 | "Static routes\n" |
| 5397 | "Routing Information Protocol (RIP)\n" |
| 5398 | "Border Gateway Protocol (BGP)\n" |
| 5399 | "OSPF exterior metric type for redistributed routes\n" |
| 5400 | "Set OSPF External Type 1 metrics\n" |
| 5401 | "Set OSPF External Type 2 metrics\n" |
| 5402 | "Metric for redistributed routes\n" |
| 5403 | "OSPF default metric\n" |
| 5404 | "Route map reference\n" |
| 5405 | "Pointer to route-map entries\n") |
| 5406 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5407 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5408 | int source; |
| 5409 | int type = -1; |
| 5410 | int metric = -1; |
| 5411 | |
| 5412 | /* Get distribute source. */ |
| 5413 | if (!str2distribute_source (argv[0], &source)) |
| 5414 | return CMD_WARNING; |
| 5415 | |
| 5416 | /* Get metric value. */ |
| 5417 | if (argc >= 2) |
| 5418 | if (!str2metric_type (argv[1], &type)) |
| 5419 | return CMD_WARNING; |
| 5420 | |
| 5421 | /* Get metric type. */ |
| 5422 | if (argc >= 3) |
| 5423 | if (!str2metric (argv[2], &metric)) |
| 5424 | return CMD_WARNING; |
| 5425 | |
| 5426 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5427 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5428 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5429 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5430 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5431 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5432 | } |
| 5433 | |
| 5434 | ALIAS (ospf_redistribute_source_type_metric, |
| 5435 | ospf_redistribute_source_type_metric_cmd, |
| 5436 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5437 | "Redistribute information from another routing protocol\n" |
| 5438 | "Kernel routes\n" |
| 5439 | "Connected\n" |
| 5440 | "Static routes\n" |
| 5441 | "Routing Information Protocol (RIP)\n" |
| 5442 | "Border Gateway Protocol (BGP)\n" |
| 5443 | "OSPF exterior metric type for redistributed routes\n" |
| 5444 | "Set OSPF External Type 1 metrics\n" |
| 5445 | "Set OSPF External Type 2 metrics\n" |
| 5446 | "Metric for redistributed routes\n" |
| 5447 | "OSPF default metric\n") |
| 5448 | |
| 5449 | ALIAS (ospf_redistribute_source_type_metric, |
| 5450 | ospf_redistribute_source_type_cmd, |
| 5451 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5452 | "Redistribute information from another routing protocol\n" |
| 5453 | "Kernel routes\n" |
| 5454 | "Connected\n" |
| 5455 | "Static routes\n" |
| 5456 | "Routing Information Protocol (RIP)\n" |
| 5457 | "Border Gateway Protocol (BGP)\n" |
| 5458 | "OSPF exterior metric type for redistributed routes\n" |
| 5459 | "Set OSPF External Type 1 metrics\n" |
| 5460 | "Set OSPF External Type 2 metrics\n") |
| 5461 | |
| 5462 | ALIAS (ospf_redistribute_source_type_metric, |
| 5463 | ospf_redistribute_source_cmd, |
| 5464 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5465 | "Redistribute information from another routing protocol\n" |
| 5466 | "Kernel routes\n" |
| 5467 | "Connected\n" |
| 5468 | "Static routes\n" |
| 5469 | "Routing Information Protocol (RIP)\n" |
| 5470 | "Border Gateway Protocol (BGP)\n") |
| 5471 | |
| 5472 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5473 | ospf_redistribute_source_metric_routemap_cmd, |
| 5474 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5475 | "Redistribute information from another routing protocol\n" |
| 5476 | "Kernel routes\n" |
| 5477 | "Connected\n" |
| 5478 | "Static routes\n" |
| 5479 | "Routing Information Protocol (RIP)\n" |
| 5480 | "Border Gateway Protocol (BGP)\n" |
| 5481 | "Metric for redistributed routes\n" |
| 5482 | "OSPF default metric\n" |
| 5483 | "Route map reference\n" |
| 5484 | "Pointer to route-map entries\n") |
| 5485 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5486 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5487 | int source; |
| 5488 | int metric = -1; |
| 5489 | |
| 5490 | /* Get distribute source. */ |
| 5491 | if (!str2distribute_source (argv[0], &source)) |
| 5492 | return CMD_WARNING; |
| 5493 | |
| 5494 | /* Get metric value. */ |
| 5495 | if (argc >= 2) |
| 5496 | if (!str2metric (argv[1], &metric)) |
| 5497 | return CMD_WARNING; |
| 5498 | |
| 5499 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5500 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5501 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5502 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5503 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5504 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5505 | } |
| 5506 | |
| 5507 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5508 | ospf_redistribute_source_type_routemap_cmd, |
| 5509 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5510 | "Redistribute information from another routing protocol\n" |
| 5511 | "Kernel routes\n" |
| 5512 | "Connected\n" |
| 5513 | "Static routes\n" |
| 5514 | "Routing Information Protocol (RIP)\n" |
| 5515 | "Border Gateway Protocol (BGP)\n" |
| 5516 | "OSPF exterior metric type for redistributed routes\n" |
| 5517 | "Set OSPF External Type 1 metrics\n" |
| 5518 | "Set OSPF External Type 2 metrics\n" |
| 5519 | "Route map reference\n" |
| 5520 | "Pointer to route-map entries\n") |
| 5521 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5522 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5523 | int source; |
| 5524 | int type = -1; |
| 5525 | |
| 5526 | /* Get distribute source. */ |
| 5527 | if (!str2distribute_source (argv[0], &source)) |
| 5528 | return CMD_WARNING; |
| 5529 | |
| 5530 | /* Get metric value. */ |
| 5531 | if (argc >= 2) |
| 5532 | if (!str2metric_type (argv[1], &type)) |
| 5533 | return CMD_WARNING; |
| 5534 | |
| 5535 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5536 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5537 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5538 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5539 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5540 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5541 | } |
| 5542 | |
| 5543 | DEFUN (ospf_redistribute_source_routemap, |
| 5544 | ospf_redistribute_source_routemap_cmd, |
| 5545 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5546 | "Redistribute information from another routing protocol\n" |
| 5547 | "Kernel routes\n" |
| 5548 | "Connected\n" |
| 5549 | "Static routes\n" |
| 5550 | "Routing Information Protocol (RIP)\n" |
| 5551 | "Border Gateway Protocol (BGP)\n" |
| 5552 | "Route map reference\n" |
| 5553 | "Pointer to route-map entries\n") |
| 5554 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5555 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5556 | int source; |
| 5557 | |
| 5558 | /* Get distribute source. */ |
| 5559 | if (!str2distribute_source (argv[0], &source)) |
| 5560 | return CMD_WARNING; |
| 5561 | |
| 5562 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5563 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5564 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5565 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5566 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5567 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5568 | } |
| 5569 | |
| 5570 | DEFUN (no_ospf_redistribute_source, |
| 5571 | no_ospf_redistribute_source_cmd, |
| 5572 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5573 | NO_STR |
| 5574 | "Redistribute information from another routing protocol\n" |
| 5575 | "Kernel routes\n" |
| 5576 | "Connected\n" |
| 5577 | "Static routes\n" |
| 5578 | "Routing Information Protocol (RIP)\n" |
| 5579 | "Border Gateway Protocol (BGP)\n") |
| 5580 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5581 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5582 | int source; |
| 5583 | |
| 5584 | if (!str2distribute_source (argv[0], &source)) |
| 5585 | return CMD_WARNING; |
| 5586 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5587 | ospf_routemap_unset (ospf, source); |
| 5588 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5589 | } |
| 5590 | |
| 5591 | DEFUN (ospf_distribute_list_out, |
| 5592 | ospf_distribute_list_out_cmd, |
| 5593 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5594 | "Filter networks in routing updates\n" |
| 5595 | "Access-list name\n" |
| 5596 | OUT_STR |
| 5597 | "Kernel routes\n" |
| 5598 | "Connected\n" |
| 5599 | "Static routes\n" |
| 5600 | "Routing Information Protocol (RIP)\n" |
| 5601 | "Border Gateway Protocol (BGP)\n") |
| 5602 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5603 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5604 | int source; |
| 5605 | |
| 5606 | /* Get distribute source. */ |
| 5607 | if (!str2distribute_source (argv[1], &source)) |
| 5608 | return CMD_WARNING; |
| 5609 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5610 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5611 | } |
| 5612 | |
| 5613 | DEFUN (no_ospf_distribute_list_out, |
| 5614 | no_ospf_distribute_list_out_cmd, |
| 5615 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5616 | NO_STR |
| 5617 | "Filter networks in routing updates\n" |
| 5618 | "Access-list name\n" |
| 5619 | OUT_STR |
| 5620 | "Kernel routes\n" |
| 5621 | "Connected\n" |
| 5622 | "Static routes\n" |
| 5623 | "Routing Information Protocol (RIP)\n" |
| 5624 | "Border Gateway Protocol (BGP)\n") |
| 5625 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5626 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5627 | int source; |
| 5628 | |
| 5629 | if (!str2distribute_source (argv[1], &source)) |
| 5630 | return CMD_WARNING; |
| 5631 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5632 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5633 | } |
| 5634 | |
| 5635 | /* Default information originate. */ |
| 5636 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5637 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5638 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5639 | "Control distribution of default information\n" |
| 5640 | "Distribute a default route\n" |
| 5641 | "OSPF default metric\n" |
| 5642 | "OSPF metric\n" |
| 5643 | "OSPF metric type for default routes\n" |
| 5644 | "Set OSPF External Type 1 metrics\n" |
| 5645 | "Set OSPF External Type 2 metrics\n" |
| 5646 | "Route map reference\n" |
| 5647 | "Pointer to route-map entries\n") |
| 5648 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5649 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5650 | int type = -1; |
| 5651 | int metric = -1; |
| 5652 | |
| 5653 | /* Get metric value. */ |
| 5654 | if (argc >= 1) |
| 5655 | if (!str2metric (argv[0], &metric)) |
| 5656 | return CMD_WARNING; |
| 5657 | |
| 5658 | /* Get metric type. */ |
| 5659 | if (argc >= 2) |
| 5660 | if (!str2metric_type (argv[1], &type)) |
| 5661 | return CMD_WARNING; |
| 5662 | |
| 5663 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5664 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5665 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5666 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5667 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5668 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5669 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5670 | } |
| 5671 | |
| 5672 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5673 | ospf_default_information_originate_metric_type_cmd, |
| 5674 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5675 | "Control distribution of default information\n" |
| 5676 | "Distribute a default route\n" |
| 5677 | "OSPF default metric\n" |
| 5678 | "OSPF metric\n" |
| 5679 | "OSPF metric type for default routes\n" |
| 5680 | "Set OSPF External Type 1 metrics\n" |
| 5681 | "Set OSPF External Type 2 metrics\n") |
| 5682 | |
| 5683 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5684 | ospf_default_information_originate_metric_cmd, |
| 5685 | "default-information originate metric <0-16777214>", |
| 5686 | "Control distribution of default information\n" |
| 5687 | "Distribute a default route\n" |
| 5688 | "OSPF default metric\n" |
| 5689 | "OSPF metric\n") |
| 5690 | |
| 5691 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5692 | ospf_default_information_originate_cmd, |
| 5693 | "default-information originate", |
| 5694 | "Control distribution of default information\n" |
| 5695 | "Distribute a default route\n") |
| 5696 | |
| 5697 | /* Default information originate. */ |
| 5698 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5699 | ospf_default_information_originate_metric_routemap_cmd, |
| 5700 | "default-information originate metric <0-16777214> route-map WORD", |
| 5701 | "Control distribution of default information\n" |
| 5702 | "Distribute a default route\n" |
| 5703 | "OSPF default metric\n" |
| 5704 | "OSPF metric\n" |
| 5705 | "Route map reference\n" |
| 5706 | "Pointer to route-map entries\n") |
| 5707 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5708 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | int metric = -1; |
| 5710 | |
| 5711 | /* Get metric value. */ |
| 5712 | if (argc >= 1) |
| 5713 | if (!str2metric (argv[0], &metric)) |
| 5714 | return CMD_WARNING; |
| 5715 | |
| 5716 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5717 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5718 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5719 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5720 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5721 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5722 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5723 | } |
| 5724 | |
| 5725 | /* Default information originate. */ |
| 5726 | DEFUN (ospf_default_information_originate_routemap, |
| 5727 | ospf_default_information_originate_routemap_cmd, |
| 5728 | "default-information originate route-map WORD", |
| 5729 | "Control distribution of default information\n" |
| 5730 | "Distribute a default route\n" |
| 5731 | "Route map reference\n" |
| 5732 | "Pointer to route-map entries\n") |
| 5733 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5734 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5735 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5736 | if (argc == 1) |
| 5737 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5738 | else |
| 5739 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5740 | |
| 5741 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5742 | } |
| 5743 | |
| 5744 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 5745 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 5746 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5747 | "Control distribution of default information\n" |
| 5748 | "Distribute a default route\n" |
| 5749 | "OSPF metric type for default routes\n" |
| 5750 | "Set OSPF External Type 1 metrics\n" |
| 5751 | "Set OSPF External Type 2 metrics\n" |
| 5752 | "OSPF default metric\n" |
| 5753 | "OSPF metric\n" |
| 5754 | "Route map reference\n" |
| 5755 | "Pointer to route-map entries\n") |
| 5756 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5757 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | int type = -1; |
| 5759 | int metric = -1; |
| 5760 | |
| 5761 | /* Get metric type. */ |
| 5762 | if (argc >= 1) |
| 5763 | if (!str2metric_type (argv[0], &type)) |
| 5764 | return CMD_WARNING; |
| 5765 | |
| 5766 | /* Get metric value. */ |
| 5767 | if (argc >= 2) |
| 5768 | if (!str2metric (argv[1], &metric)) |
| 5769 | return CMD_WARNING; |
| 5770 | |
| 5771 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5772 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5773 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5774 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5775 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5776 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5777 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5778 | } |
| 5779 | |
| 5780 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5781 | ospf_default_information_originate_type_metric_cmd, |
| 5782 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 5783 | "Control distribution of default information\n" |
| 5784 | "Distribute a default route\n" |
| 5785 | "OSPF metric type for default routes\n" |
| 5786 | "Set OSPF External Type 1 metrics\n" |
| 5787 | "Set OSPF External Type 2 metrics\n" |
| 5788 | "OSPF default metric\n" |
| 5789 | "OSPF metric\n") |
| 5790 | |
| 5791 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5792 | ospf_default_information_originate_type_cmd, |
| 5793 | "default-information originate metric-type (1|2)", |
| 5794 | "Control distribution of default information\n" |
| 5795 | "Distribute a default route\n" |
| 5796 | "OSPF metric type for default routes\n" |
| 5797 | "Set OSPF External Type 1 metrics\n" |
| 5798 | "Set OSPF External Type 2 metrics\n") |
| 5799 | |
| 5800 | DEFUN (ospf_default_information_originate_type_routemap, |
| 5801 | ospf_default_information_originate_type_routemap_cmd, |
| 5802 | "default-information originate metric-type (1|2) route-map WORD", |
| 5803 | "Control distribution of default information\n" |
| 5804 | "Distribute a default route\n" |
| 5805 | "OSPF metric type for default routes\n" |
| 5806 | "Set OSPF External Type 1 metrics\n" |
| 5807 | "Set OSPF External Type 2 metrics\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 type = -1; |
| 5813 | |
| 5814 | /* Get metric type. */ |
| 5815 | if (argc >= 1) |
| 5816 | if (!str2metric_type (argv[0], &type)) |
| 5817 | return CMD_WARNING; |
| 5818 | |
| 5819 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5820 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5821 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5822 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5823 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5824 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5825 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5826 | } |
| 5827 | |
| 5828 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 5829 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 5830 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5831 | "Control distribution of default information\n" |
| 5832 | "Distribute a default route\n" |
| 5833 | "Always advertise default route\n" |
| 5834 | "OSPF default metric\n" |
| 5835 | "OSPF metric\n" |
| 5836 | "OSPF metric type for default routes\n" |
| 5837 | "Set OSPF External Type 1 metrics\n" |
| 5838 | "Set OSPF External Type 2 metrics\n" |
| 5839 | "Route map reference\n" |
| 5840 | "Pointer to route-map entries\n") |
| 5841 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5842 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5843 | int type = -1; |
| 5844 | int metric = -1; |
| 5845 | |
| 5846 | /* Get metric value. */ |
| 5847 | if (argc >= 1) |
| 5848 | if (!str2metric (argv[0], &metric)) |
| 5849 | return CMD_WARNING; |
| 5850 | |
| 5851 | /* Get metric type. */ |
| 5852 | if (argc >= 2) |
| 5853 | if (!str2metric_type (argv[1], &type)) |
| 5854 | return CMD_WARNING; |
| 5855 | |
| 5856 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5857 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5858 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5859 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5860 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5861 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5862 | type, metric); |
| 5863 | } |
| 5864 | |
| 5865 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5866 | ospf_default_information_originate_always_metric_type_cmd, |
| 5867 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 5868 | "Control distribution of default information\n" |
| 5869 | "Distribute a default route\n" |
| 5870 | "Always advertise default route\n" |
| 5871 | "OSPF default metric\n" |
| 5872 | "OSPF metric\n" |
| 5873 | "OSPF metric type for default routes\n" |
| 5874 | "Set OSPF External Type 1 metrics\n" |
| 5875 | "Set OSPF External Type 2 metrics\n") |
| 5876 | |
| 5877 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5878 | ospf_default_information_originate_always_metric_cmd, |
| 5879 | "default-information originate always metric <0-16777214>", |
| 5880 | "Control distribution of default information\n" |
| 5881 | "Distribute a default route\n" |
| 5882 | "Always advertise default route\n" |
| 5883 | "OSPF default metric\n" |
| 5884 | "OSPF metric\n" |
| 5885 | "OSPF metric type for default routes\n") |
| 5886 | |
| 5887 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5888 | ospf_default_information_originate_always_cmd, |
| 5889 | "default-information originate always", |
| 5890 | "Control distribution of default information\n" |
| 5891 | "Distribute a default route\n" |
| 5892 | "Always advertise default route\n") |
| 5893 | |
| 5894 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 5895 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 5896 | "default-information originate always metric <0-16777214> route-map WORD", |
| 5897 | "Control distribution of default information\n" |
| 5898 | "Distribute a default route\n" |
| 5899 | "Always advertise default route\n" |
| 5900 | "OSPF default metric\n" |
| 5901 | "OSPF metric\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 metric = -1; |
| 5907 | |
| 5908 | /* Get metric value. */ |
| 5909 | if (argc >= 1) |
| 5910 | if (!str2metric (argv[0], &metric)) |
| 5911 | return CMD_WARNING; |
| 5912 | |
| 5913 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5914 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5915 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5916 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5917 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5918 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 5919 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5920 | } |
| 5921 | |
| 5922 | DEFUN (ospf_default_information_originate_always_routemap, |
| 5923 | ospf_default_information_originate_always_routemap_cmd, |
| 5924 | "default-information originate always route-map WORD", |
| 5925 | "Control distribution of default information\n" |
| 5926 | "Distribute a default route\n" |
| 5927 | "Always advertise default route\n" |
| 5928 | "Route map reference\n" |
| 5929 | "Pointer to route-map entries\n") |
| 5930 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5931 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5932 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5933 | if (argc == 1) |
| 5934 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5935 | else |
| 5936 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5937 | |
| 5938 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5939 | } |
| 5940 | |
| 5941 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 5942 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 5943 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5944 | "Control distribution of default information\n" |
| 5945 | "Distribute a default route\n" |
| 5946 | "Always advertise default route\n" |
| 5947 | "OSPF metric type for default routes\n" |
| 5948 | "Set OSPF External Type 1 metrics\n" |
| 5949 | "Set OSPF External Type 2 metrics\n" |
| 5950 | "OSPF default metric\n" |
| 5951 | "OSPF metric\n" |
| 5952 | "Route map reference\n" |
| 5953 | "Pointer to route-map entries\n") |
| 5954 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5955 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5956 | int type = -1; |
| 5957 | int metric = -1; |
| 5958 | |
| 5959 | /* Get metric type. */ |
| 5960 | if (argc >= 1) |
| 5961 | if (!str2metric_type (argv[0], &type)) |
| 5962 | return CMD_WARNING; |
| 5963 | |
| 5964 | /* Get metric value. */ |
| 5965 | if (argc >= 2) |
| 5966 | if (!str2metric (argv[1], &metric)) |
| 5967 | return CMD_WARNING; |
| 5968 | |
| 5969 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5970 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5971 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5972 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5973 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5974 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5975 | type, metric); |
| 5976 | } |
| 5977 | |
| 5978 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 5979 | ospf_default_information_originate_always_type_metric_cmd, |
| 5980 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 5981 | "Control distribution of default information\n" |
| 5982 | "Distribute a default route\n" |
| 5983 | "Always advertise default route\n" |
| 5984 | "OSPF metric type for default routes\n" |
| 5985 | "Set OSPF External Type 1 metrics\n" |
| 5986 | "Set OSPF External Type 2 metrics\n" |
| 5987 | "OSPF default metric\n" |
| 5988 | "OSPF metric\n") |
| 5989 | |
| 5990 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 5991 | ospf_default_information_originate_always_type_cmd, |
| 5992 | "default-information originate always metric-type (1|2)", |
| 5993 | "Control distribution of default information\n" |
| 5994 | "Distribute a default route\n" |
| 5995 | "Always advertise default route\n" |
| 5996 | "OSPF metric type for default routes\n" |
| 5997 | "Set OSPF External Type 1 metrics\n" |
| 5998 | "Set OSPF External Type 2 metrics\n") |
| 5999 | |
| 6000 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 6001 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6002 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6003 | "Control distribution of default information\n" |
| 6004 | "Distribute a default route\n" |
| 6005 | "Always advertise default route\n" |
| 6006 | "OSPF metric type for default routes\n" |
| 6007 | "Set OSPF External Type 1 metrics\n" |
| 6008 | "Set OSPF External Type 2 metrics\n" |
| 6009 | "Route map reference\n" |
| 6010 | "Pointer to route-map entries\n") |
| 6011 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6012 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6013 | int type = -1; |
| 6014 | |
| 6015 | /* Get metric type. */ |
| 6016 | if (argc >= 1) |
| 6017 | if (!str2metric_type (argv[0], &type)) |
| 6018 | return CMD_WARNING; |
| 6019 | |
| 6020 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6021 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6022 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6023 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6024 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6025 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6026 | type, -1); |
| 6027 | } |
| 6028 | |
| 6029 | DEFUN (no_ospf_default_information_originate, |
| 6030 | no_ospf_default_information_originate_cmd, |
| 6031 | "no default-information originate", |
| 6032 | NO_STR |
| 6033 | "Control distribution of default information\n" |
| 6034 | "Distribute a default route\n") |
| 6035 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6036 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | struct prefix_ipv4 p; |
| 6038 | struct in_addr nexthop; |
| 6039 | |
| 6040 | p.family = AF_INET; |
| 6041 | p.prefix.s_addr = 0; |
| 6042 | p.prefixlen = 0; |
| 6043 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6044 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6045 | |
| 6046 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6047 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6048 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6049 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6050 | } |
| 6051 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6052 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6053 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6054 | } |
| 6055 | |
| 6056 | DEFUN (ospf_default_metric, |
| 6057 | ospf_default_metric_cmd, |
| 6058 | "default-metric <0-16777214>", |
| 6059 | "Set metric of redistributed routes\n" |
| 6060 | "Default metric\n") |
| 6061 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6062 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6063 | int metric = -1; |
| 6064 | |
| 6065 | if (!str2metric (argv[0], &metric)) |
| 6066 | return CMD_WARNING; |
| 6067 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6068 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6069 | |
| 6070 | return CMD_SUCCESS; |
| 6071 | } |
| 6072 | |
| 6073 | DEFUN (no_ospf_default_metric, |
| 6074 | no_ospf_default_metric_cmd, |
| 6075 | "no default-metric", |
| 6076 | NO_STR |
| 6077 | "Set metric of redistributed routes\n") |
| 6078 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6079 | struct ospf *ospf = vty->index; |
| 6080 | |
| 6081 | ospf->default_metric = -1; |
| 6082 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6083 | return CMD_SUCCESS; |
| 6084 | } |
| 6085 | |
| 6086 | ALIAS (no_ospf_default_metric, |
| 6087 | no_ospf_default_metric_val_cmd, |
| 6088 | "no default-metric <0-16777214>", |
| 6089 | NO_STR |
| 6090 | "Set metric of redistributed routes\n" |
| 6091 | "Default metric\n") |
| 6092 | |
| 6093 | DEFUN (ospf_distance, |
| 6094 | ospf_distance_cmd, |
| 6095 | "distance <1-255>", |
| 6096 | "Define an administrative distance\n" |
| 6097 | "OSPF Administrative distance\n") |
| 6098 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6099 | struct ospf *ospf = vty->index; |
| 6100 | |
| 6101 | ospf->distance_all = atoi (argv[0]); |
| 6102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6103 | return CMD_SUCCESS; |
| 6104 | } |
| 6105 | |
| 6106 | DEFUN (no_ospf_distance, |
| 6107 | no_ospf_distance_cmd, |
| 6108 | "no distance <1-255>", |
| 6109 | NO_STR |
| 6110 | "Define an administrative distance\n" |
| 6111 | "OSPF Administrative distance\n") |
| 6112 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6113 | struct ospf *ospf = vty->index; |
| 6114 | |
| 6115 | ospf->distance_all = 0; |
| 6116 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6117 | return CMD_SUCCESS; |
| 6118 | } |
| 6119 | |
| 6120 | DEFUN (no_ospf_distance_ospf, |
| 6121 | no_ospf_distance_ospf_cmd, |
| 6122 | "no distance ospf", |
| 6123 | NO_STR |
| 6124 | "Define an administrative distance\n" |
| 6125 | "OSPF Administrative distance\n" |
| 6126 | "OSPF Distance\n") |
| 6127 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6128 | struct ospf *ospf = vty->index; |
| 6129 | |
| 6130 | ospf->distance_intra = 0; |
| 6131 | ospf->distance_inter = 0; |
| 6132 | ospf->distance_external = 0; |
| 6133 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6134 | return CMD_SUCCESS; |
| 6135 | } |
| 6136 | |
| 6137 | DEFUN (ospf_distance_ospf_intra, |
| 6138 | ospf_distance_ospf_intra_cmd, |
| 6139 | "distance ospf intra-area <1-255>", |
| 6140 | "Define an administrative distance\n" |
| 6141 | "OSPF Administrative distance\n" |
| 6142 | "Intra-area routes\n" |
| 6143 | "Distance for intra-area routes\n") |
| 6144 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6145 | struct ospf *ospf = vty->index; |
| 6146 | |
| 6147 | ospf->distance_intra = atoi (argv[0]); |
| 6148 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6149 | return CMD_SUCCESS; |
| 6150 | } |
| 6151 | |
| 6152 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6153 | ospf_distance_ospf_intra_inter_cmd, |
| 6154 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6155 | "Define an administrative distance\n" |
| 6156 | "OSPF Administrative distance\n" |
| 6157 | "Intra-area routes\n" |
| 6158 | "Distance for intra-area routes\n" |
| 6159 | "Inter-area routes\n" |
| 6160 | "Distance for inter-area routes\n") |
| 6161 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6162 | struct ospf *ospf = vty->index; |
| 6163 | |
| 6164 | ospf->distance_intra = atoi (argv[0]); |
| 6165 | ospf->distance_inter = atoi (argv[1]); |
| 6166 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6167 | return CMD_SUCCESS; |
| 6168 | } |
| 6169 | |
| 6170 | DEFUN (ospf_distance_ospf_intra_external, |
| 6171 | ospf_distance_ospf_intra_external_cmd, |
| 6172 | "distance ospf intra-area <1-255> external <1-255>", |
| 6173 | "Define an administrative distance\n" |
| 6174 | "OSPF Administrative distance\n" |
| 6175 | "Intra-area routes\n" |
| 6176 | "Distance for intra-area routes\n" |
| 6177 | "External routes\n" |
| 6178 | "Distance for external routes\n") |
| 6179 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6180 | struct ospf *ospf = vty->index; |
| 6181 | |
| 6182 | ospf->distance_intra = atoi (argv[0]); |
| 6183 | ospf->distance_external = atoi (argv[1]); |
| 6184 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6185 | return CMD_SUCCESS; |
| 6186 | } |
| 6187 | |
| 6188 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6189 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6190 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6191 | "Define an administrative distance\n" |
| 6192 | "OSPF Administrative distance\n" |
| 6193 | "Intra-area routes\n" |
| 6194 | "Distance for intra-area routes\n" |
| 6195 | "Inter-area routes\n" |
| 6196 | "Distance for inter-area routes\n" |
| 6197 | "External routes\n" |
| 6198 | "Distance for external routes\n") |
| 6199 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6200 | struct ospf *ospf = vty->index; |
| 6201 | |
| 6202 | ospf->distance_intra = atoi (argv[0]); |
| 6203 | ospf->distance_inter = atoi (argv[1]); |
| 6204 | ospf->distance_external = atoi (argv[2]); |
| 6205 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6206 | return CMD_SUCCESS; |
| 6207 | } |
| 6208 | |
| 6209 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6210 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6211 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6212 | "Define an administrative distance\n" |
| 6213 | "OSPF Administrative distance\n" |
| 6214 | "Intra-area routes\n" |
| 6215 | "Distance for intra-area routes\n" |
| 6216 | "External routes\n" |
| 6217 | "Distance for external routes\n" |
| 6218 | "Inter-area routes\n" |
| 6219 | "Distance for inter-area routes\n") |
| 6220 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6221 | struct ospf *ospf = vty->index; |
| 6222 | |
| 6223 | ospf->distance_intra = atoi (argv[0]); |
| 6224 | ospf->distance_external = atoi (argv[1]); |
| 6225 | ospf->distance_inter = atoi (argv[2]); |
| 6226 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6227 | return CMD_SUCCESS; |
| 6228 | } |
| 6229 | |
| 6230 | DEFUN (ospf_distance_ospf_inter, |
| 6231 | ospf_distance_ospf_inter_cmd, |
| 6232 | "distance ospf inter-area <1-255>", |
| 6233 | "Define an administrative distance\n" |
| 6234 | "OSPF Administrative distance\n" |
| 6235 | "Inter-area routes\n" |
| 6236 | "Distance for inter-area routes\n") |
| 6237 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6238 | struct ospf *ospf = vty->index; |
| 6239 | |
| 6240 | ospf->distance_inter = atoi (argv[0]); |
| 6241 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6242 | return CMD_SUCCESS; |
| 6243 | } |
| 6244 | |
| 6245 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6246 | ospf_distance_ospf_inter_intra_cmd, |
| 6247 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6248 | "Define an administrative distance\n" |
| 6249 | "OSPF Administrative distance\n" |
| 6250 | "Inter-area routes\n" |
| 6251 | "Distance for inter-area routes\n" |
| 6252 | "Intra-area routes\n" |
| 6253 | "Distance for intra-area routes\n") |
| 6254 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6255 | struct ospf *ospf = vty->index; |
| 6256 | |
| 6257 | ospf->distance_inter = atoi (argv[0]); |
| 6258 | ospf->distance_intra = atoi (argv[1]); |
| 6259 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6260 | return CMD_SUCCESS; |
| 6261 | } |
| 6262 | |
| 6263 | DEFUN (ospf_distance_ospf_inter_external, |
| 6264 | ospf_distance_ospf_inter_external_cmd, |
| 6265 | "distance ospf inter-area <1-255> external <1-255>", |
| 6266 | "Define an administrative distance\n" |
| 6267 | "OSPF Administrative distance\n" |
| 6268 | "Inter-area routes\n" |
| 6269 | "Distance for inter-area routes\n" |
| 6270 | "External routes\n" |
| 6271 | "Distance for external routes\n") |
| 6272 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6273 | struct ospf *ospf = vty->index; |
| 6274 | |
| 6275 | ospf->distance_inter = atoi (argv[0]); |
| 6276 | ospf->distance_external = atoi (argv[1]); |
| 6277 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6278 | return CMD_SUCCESS; |
| 6279 | } |
| 6280 | |
| 6281 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6282 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6283 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6284 | "Define an administrative distance\n" |
| 6285 | "OSPF Administrative distance\n" |
| 6286 | "Inter-area routes\n" |
| 6287 | "Distance for inter-area routes\n" |
| 6288 | "Intra-area routes\n" |
| 6289 | "Distance for intra-area routes\n" |
| 6290 | "External routes\n" |
| 6291 | "Distance for external routes\n") |
| 6292 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6293 | struct ospf *ospf = vty->index; |
| 6294 | |
| 6295 | ospf->distance_inter = atoi (argv[0]); |
| 6296 | ospf->distance_intra = atoi (argv[1]); |
| 6297 | ospf->distance_external = atoi (argv[2]); |
| 6298 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6299 | return CMD_SUCCESS; |
| 6300 | } |
| 6301 | |
| 6302 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6303 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6304 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6305 | "Define an administrative distance\n" |
| 6306 | "OSPF Administrative distance\n" |
| 6307 | "Inter-area routes\n" |
| 6308 | "Distance for inter-area routes\n" |
| 6309 | "External routes\n" |
| 6310 | "Distance for external routes\n" |
| 6311 | "Intra-area routes\n" |
| 6312 | "Distance for intra-area routes\n") |
| 6313 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6314 | struct ospf *ospf = vty->index; |
| 6315 | |
| 6316 | ospf->distance_inter = atoi (argv[0]); |
| 6317 | ospf->distance_external = atoi (argv[1]); |
| 6318 | ospf->distance_intra = atoi (argv[2]); |
| 6319 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6320 | return CMD_SUCCESS; |
| 6321 | } |
| 6322 | |
| 6323 | DEFUN (ospf_distance_ospf_external, |
| 6324 | ospf_distance_ospf_external_cmd, |
| 6325 | "distance ospf external <1-255>", |
| 6326 | "Define an administrative distance\n" |
| 6327 | "OSPF Administrative distance\n" |
| 6328 | "External routes\n" |
| 6329 | "Distance for external routes\n") |
| 6330 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6331 | struct ospf *ospf = vty->index; |
| 6332 | |
| 6333 | ospf->distance_external = atoi (argv[0]); |
| 6334 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6335 | return CMD_SUCCESS; |
| 6336 | } |
| 6337 | |
| 6338 | DEFUN (ospf_distance_ospf_external_intra, |
| 6339 | ospf_distance_ospf_external_intra_cmd, |
| 6340 | "distance ospf external <1-255> intra-area <1-255>", |
| 6341 | "Define an administrative distance\n" |
| 6342 | "OSPF Administrative distance\n" |
| 6343 | "External routes\n" |
| 6344 | "Distance for external routes\n" |
| 6345 | "Intra-area routes\n" |
| 6346 | "Distance for intra-area routes\n") |
| 6347 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6348 | struct ospf *ospf = vty->index; |
| 6349 | |
| 6350 | ospf->distance_external = atoi (argv[0]); |
| 6351 | ospf->distance_intra = atoi (argv[1]); |
| 6352 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6353 | return CMD_SUCCESS; |
| 6354 | } |
| 6355 | |
| 6356 | DEFUN (ospf_distance_ospf_external_inter, |
| 6357 | ospf_distance_ospf_external_inter_cmd, |
| 6358 | "distance ospf external <1-255> inter-area <1-255>", |
| 6359 | "Define an administrative distance\n" |
| 6360 | "OSPF Administrative distance\n" |
| 6361 | "External routes\n" |
| 6362 | "Distance for external routes\n" |
| 6363 | "Inter-area routes\n" |
| 6364 | "Distance for inter-area routes\n") |
| 6365 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6366 | struct ospf *ospf = vty->index; |
| 6367 | |
| 6368 | ospf->distance_external = atoi (argv[0]); |
| 6369 | ospf->distance_inter = atoi (argv[1]); |
| 6370 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6371 | return CMD_SUCCESS; |
| 6372 | } |
| 6373 | |
| 6374 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6375 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6376 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6377 | "Define an administrative distance\n" |
| 6378 | "OSPF Administrative distance\n" |
| 6379 | "External routes\n" |
| 6380 | "Distance for external routes\n" |
| 6381 | "Intra-area routes\n" |
| 6382 | "Distance for intra-area routes\n" |
| 6383 | "Inter-area routes\n" |
| 6384 | "Distance for inter-area routes\n") |
| 6385 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6386 | struct ospf *ospf = vty->index; |
| 6387 | |
| 6388 | ospf->distance_external = atoi (argv[0]); |
| 6389 | ospf->distance_intra = atoi (argv[1]); |
| 6390 | ospf->distance_inter = atoi (argv[2]); |
| 6391 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6392 | return CMD_SUCCESS; |
| 6393 | } |
| 6394 | |
| 6395 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6396 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6397 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6398 | "Define an administrative distance\n" |
| 6399 | "OSPF Administrative distance\n" |
| 6400 | "External routes\n" |
| 6401 | "Distance for external routes\n" |
| 6402 | "Inter-area routes\n" |
| 6403 | "Distance for inter-area routes\n" |
| 6404 | "Intra-area routes\n" |
| 6405 | "Distance for intra-area routes\n") |
| 6406 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6407 | struct ospf *ospf = vty->index; |
| 6408 | |
| 6409 | ospf->distance_external = atoi (argv[0]); |
| 6410 | ospf->distance_inter = atoi (argv[1]); |
| 6411 | ospf->distance_intra = atoi (argv[2]); |
| 6412 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6413 | return CMD_SUCCESS; |
| 6414 | } |
| 6415 | |
| 6416 | DEFUN (ospf_distance_source, |
| 6417 | ospf_distance_source_cmd, |
| 6418 | "distance <1-255> A.B.C.D/M", |
| 6419 | "Administrative distance\n" |
| 6420 | "Distance value\n" |
| 6421 | "IP source prefix\n") |
| 6422 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6423 | struct ospf *ospf = vty->index; |
| 6424 | |
| 6425 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6426 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6427 | return CMD_SUCCESS; |
| 6428 | } |
| 6429 | |
| 6430 | DEFUN (no_ospf_distance_source, |
| 6431 | no_ospf_distance_source_cmd, |
| 6432 | "no distance <1-255> A.B.C.D/M", |
| 6433 | NO_STR |
| 6434 | "Administrative distance\n" |
| 6435 | "Distance value\n" |
| 6436 | "IP source prefix\n") |
| 6437 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6438 | struct ospf *ospf = vty->index; |
| 6439 | |
| 6440 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6441 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6442 | return CMD_SUCCESS; |
| 6443 | } |
| 6444 | |
| 6445 | DEFUN (ospf_distance_source_access_list, |
| 6446 | ospf_distance_source_access_list_cmd, |
| 6447 | "distance <1-255> A.B.C.D/M WORD", |
| 6448 | "Administrative distance\n" |
| 6449 | "Distance value\n" |
| 6450 | "IP source prefix\n" |
| 6451 | "Access list name\n") |
| 6452 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6453 | struct ospf *ospf = vty->index; |
| 6454 | |
| 6455 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6456 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6457 | return CMD_SUCCESS; |
| 6458 | } |
| 6459 | |
| 6460 | DEFUN (no_ospf_distance_source_access_list, |
| 6461 | no_ospf_distance_source_access_list_cmd, |
| 6462 | "no distance <1-255> A.B.C.D/M WORD", |
| 6463 | NO_STR |
| 6464 | "Administrative distance\n" |
| 6465 | "Distance value\n" |
| 6466 | "IP source prefix\n" |
| 6467 | "Access list name\n") |
| 6468 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6469 | struct ospf *ospf = vty->index; |
| 6470 | |
| 6471 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6472 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6473 | return CMD_SUCCESS; |
| 6474 | } |
| 6475 | |
| 6476 | void |
| 6477 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6478 | { |
| 6479 | struct route_node *rn; |
| 6480 | struct ospf_route *or; |
| 6481 | listnode pnode; |
| 6482 | struct ospf_path *path; |
| 6483 | |
| 6484 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6485 | VTY_NEWLINE); |
| 6486 | |
| 6487 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6488 | if ((or = rn->info) != NULL) |
| 6489 | { |
| 6490 | char buf1[19]; |
| 6491 | snprintf (buf1, 19, "%s/%d", |
| 6492 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6493 | |
| 6494 | switch (or->path_type) |
| 6495 | { |
| 6496 | case OSPF_PATH_INTER_AREA: |
| 6497 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6498 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6499 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6500 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6501 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6502 | break; |
| 6503 | case OSPF_PATH_INTRA_AREA: |
| 6504 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6505 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6506 | break; |
| 6507 | default: |
| 6508 | break; |
| 6509 | } |
| 6510 | |
| 6511 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6512 | for (pnode = listhead (or->path); pnode; nextnode (pnode)) |
| 6513 | { |
| 6514 | path = getdata (pnode); |
| 6515 | if (path->oi != NULL) |
| 6516 | { |
| 6517 | if (path->nexthop.s_addr == 0) |
| 6518 | vty_out (vty, "%24s directly attached to %s%s", |
| 6519 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6520 | else |
| 6521 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6522 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6523 | VTY_NEWLINE); |
| 6524 | } |
| 6525 | } |
| 6526 | } |
| 6527 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6528 | } |
| 6529 | |
| 6530 | void |
| 6531 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6532 | { |
| 6533 | struct route_node *rn; |
| 6534 | struct ospf_route *or; |
| 6535 | listnode pn, nn; |
| 6536 | struct ospf_path *path; |
| 6537 | |
| 6538 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6539 | VTY_NEWLINE); |
| 6540 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6541 | if (rn->info) |
| 6542 | { |
| 6543 | int flag = 0; |
| 6544 | |
| 6545 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6546 | |
| 6547 | for (nn = listhead ((list) rn->info); nn; nextnode (nn)) |
| 6548 | if ((or = getdata (nn)) != NULL) |
| 6549 | { |
| 6550 | if (flag++) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 6551 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6552 | |
| 6553 | /* Show path. */ |
| 6554 | vty_out (vty, "%s [%d] area: %s", |
| 6555 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6556 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6557 | /* Show flags. */ |
| 6558 | vty_out (vty, "%s%s%s", |
| 6559 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6560 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6561 | VTY_NEWLINE); |
| 6562 | |
| 6563 | for (pn = listhead (or->path); pn; nextnode (pn)) |
| 6564 | { |
| 6565 | path = getdata (pn); |
| 6566 | if (path->nexthop.s_addr == 0) |
| 6567 | vty_out (vty, "%24s directly attached to %s%s", |
| 6568 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6569 | else |
| 6570 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6571 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6572 | VTY_NEWLINE); |
| 6573 | } |
| 6574 | } |
| 6575 | } |
| 6576 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6577 | } |
| 6578 | |
| 6579 | void |
| 6580 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6581 | { |
| 6582 | struct route_node *rn; |
| 6583 | struct ospf_route *er; |
| 6584 | listnode pnode; |
| 6585 | struct ospf_path *path; |
| 6586 | |
| 6587 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6588 | VTY_NEWLINE); |
| 6589 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6590 | if ((er = rn->info) != NULL) |
| 6591 | { |
| 6592 | char buf1[19]; |
| 6593 | snprintf (buf1, 19, "%s/%d", |
| 6594 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6595 | |
| 6596 | switch (er->path_type) |
| 6597 | { |
| 6598 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6599 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6600 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6601 | break; |
| 6602 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6603 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6604 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6605 | break; |
| 6606 | } |
| 6607 | |
| 6608 | for (pnode = listhead (er->path); pnode; nextnode (pnode)) |
| 6609 | { |
| 6610 | path = getdata (pnode); |
| 6611 | if (path->oi != NULL) |
| 6612 | { |
| 6613 | if (path->nexthop.s_addr == 0) |
| 6614 | vty_out (vty, "%24s directly attached to %s%s", |
| 6615 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6616 | else |
| 6617 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6618 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6619 | VTY_NEWLINE); |
| 6620 | } |
| 6621 | } |
| 6622 | } |
| 6623 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6624 | } |
| 6625 | |
| 6626 | #ifdef HAVE_NSSA |
| 6627 | DEFUN (show_ip_ospf_border_routers, |
| 6628 | show_ip_ospf_border_routers_cmd, |
| 6629 | "show ip ospf border-routers", |
| 6630 | SHOW_STR |
| 6631 | IP_STR |
| 6632 | "show all the ABR's and ASBR's\n" |
| 6633 | "for this area\n") |
| 6634 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6635 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6636 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6637 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6638 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6639 | { |
| 6640 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6641 | return CMD_SUCCESS; |
| 6642 | } |
| 6643 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6644 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6645 | { |
| 6646 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6647 | return CMD_SUCCESS; |
| 6648 | } |
| 6649 | |
| 6650 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6651 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6652 | |
| 6653 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6654 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6655 | |
| 6656 | return CMD_SUCCESS; |
| 6657 | } |
| 6658 | #endif /* HAVE_NSSA */ |
| 6659 | |
| 6660 | DEFUN (show_ip_ospf_route, |
| 6661 | show_ip_ospf_route_cmd, |
| 6662 | "show ip ospf route", |
| 6663 | SHOW_STR |
| 6664 | IP_STR |
| 6665 | "OSPF information\n" |
| 6666 | "OSPF routing table\n") |
| 6667 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6668 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6669 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6670 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6671 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6672 | { |
| 6673 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6674 | return CMD_SUCCESS; |
| 6675 | } |
| 6676 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6677 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6678 | { |
| 6679 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6680 | return CMD_SUCCESS; |
| 6681 | } |
| 6682 | |
| 6683 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6684 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6685 | |
| 6686 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6687 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6688 | |
| 6689 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6690 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6691 | |
| 6692 | return CMD_SUCCESS; |
| 6693 | } |
| 6694 | |
| 6695 | |
| 6696 | char *ospf_abr_type_str[] = |
| 6697 | { |
| 6698 | "unknown", |
| 6699 | "standard", |
| 6700 | "ibm", |
| 6701 | "cisco", |
| 6702 | "shortcut" |
| 6703 | }; |
| 6704 | |
| 6705 | char *ospf_shortcut_mode_str[] = |
| 6706 | { |
| 6707 | "default", |
| 6708 | "enable", |
| 6709 | "disable" |
| 6710 | }; |
| 6711 | |
| 6712 | |
| 6713 | void |
| 6714 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6715 | { |
| 6716 | memset (buf, 0, length); |
| 6717 | |
| 6718 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6719 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6720 | else |
| 6721 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6722 | } |
| 6723 | |
| 6724 | |
| 6725 | char *ospf_int_type_str[] = |
| 6726 | { |
| 6727 | "unknown", /* should never be used. */ |
| 6728 | "point-to-point", |
| 6729 | "broadcast", |
| 6730 | "non-broadcast", |
| 6731 | "point-to-multipoint", |
| 6732 | "virtual-link", /* should never be used. */ |
| 6733 | "loopback" |
| 6734 | }; |
| 6735 | |
| 6736 | /* Configuration write function for ospfd. */ |
| 6737 | int |
| 6738 | config_write_interface (struct vty *vty) |
| 6739 | { |
| 6740 | listnode n1, n2; |
| 6741 | struct interface *ifp; |
| 6742 | struct crypt_key *ck; |
| 6743 | int write = 0; |
| 6744 | struct route_node *rn = NULL; |
| 6745 | struct ospf_if_params *params; |
| 6746 | |
| 6747 | for (n1 = listhead (iflist); n1; nextnode (n1)) |
| 6748 | { |
| 6749 | ifp = getdata (n1); |
| 6750 | |
| 6751 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6752 | continue; |
| 6753 | |
| 6754 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6755 | vty_out (vty, "interface %s%s", ifp->name, |
| 6756 | VTY_NEWLINE); |
| 6757 | if (ifp->desc) |
| 6758 | vty_out (vty, " description %s%s", ifp->desc, |
| 6759 | VTY_NEWLINE); |
| 6760 | |
| 6761 | write++; |
| 6762 | |
| 6763 | params = IF_DEF_PARAMS (ifp); |
| 6764 | |
| 6765 | do { |
| 6766 | /* Interface Network print. */ |
| 6767 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
| 6768 | params->type != OSPF_IFTYPE_BROADCAST && |
| 6769 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6770 | { |
| 6771 | vty_out (vty, " ip ospf network %s", |
| 6772 | ospf_int_type_str[params->type]); |
| 6773 | if (params != IF_DEF_PARAMS (ifp)) |
| 6774 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6775 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6776 | } |
| 6777 | |
| 6778 | /* OSPF interface authentication print */ |
| 6779 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6780 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6781 | { |
| 6782 | char *auth_str; |
| 6783 | |
| 6784 | /* Translation tables are not that much help here due to syntax |
| 6785 | of the simple option */ |
| 6786 | switch (params->auth_type) |
| 6787 | { |
| 6788 | |
| 6789 | case OSPF_AUTH_NULL: |
| 6790 | auth_str = " null"; |
| 6791 | break; |
| 6792 | |
| 6793 | case OSPF_AUTH_SIMPLE: |
| 6794 | auth_str = ""; |
| 6795 | break; |
| 6796 | |
| 6797 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6798 | auth_str = " message-digest"; |
| 6799 | break; |
| 6800 | |
| 6801 | default: |
| 6802 | auth_str = ""; |
| 6803 | break; |
| 6804 | } |
| 6805 | |
| 6806 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6807 | if (params != IF_DEF_PARAMS (ifp)) |
| 6808 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6809 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6810 | } |
| 6811 | |
| 6812 | /* Simple Authentication Password print. */ |
| 6813 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6814 | params->auth_simple[0] != '\0') |
| 6815 | { |
| 6816 | vty_out (vty, " ip ospf authentication-key %s", |
| 6817 | params->auth_simple); |
| 6818 | if (params != IF_DEF_PARAMS (ifp)) |
| 6819 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6820 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6821 | } |
| 6822 | |
| 6823 | /* Cryptographic Authentication Key print. */ |
| 6824 | for (n2 = listhead (params->auth_crypt); n2; nextnode (n2)) |
| 6825 | { |
| 6826 | ck = getdata (n2); |
| 6827 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6828 | ck->key_id, ck->auth_key); |
| 6829 | if (params != IF_DEF_PARAMS (ifp)) |
| 6830 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6831 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6832 | } |
| 6833 | |
| 6834 | /* Interface Output Cost print. */ |
| 6835 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6836 | { |
| 6837 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6838 | if (params != IF_DEF_PARAMS (ifp)) |
| 6839 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6840 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6841 | } |
| 6842 | |
| 6843 | /* Hello Interval print. */ |
| 6844 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6845 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6846 | { |
| 6847 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6848 | if (params != IF_DEF_PARAMS (ifp)) |
| 6849 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6850 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6851 | } |
| 6852 | |
| 6853 | |
| 6854 | /* Router Dead Interval print. */ |
| 6855 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6856 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6857 | { |
| 6858 | vty_out (vty, " ip ospf dead-interval %u", params->v_wait); |
| 6859 | if (params != IF_DEF_PARAMS (ifp)) |
| 6860 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6861 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6862 | } |
| 6863 | |
| 6864 | /* Router Priority print. */ |
| 6865 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 6866 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 6867 | { |
| 6868 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 6869 | if (params != IF_DEF_PARAMS (ifp)) |
| 6870 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6871 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6872 | } |
| 6873 | |
| 6874 | /* Retransmit Interval print. */ |
| 6875 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 6876 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 6877 | { |
| 6878 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 6879 | params->retransmit_interval); |
| 6880 | if (params != IF_DEF_PARAMS (ifp)) |
| 6881 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6882 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6883 | } |
| 6884 | |
| 6885 | /* Transmit Delay print. */ |
| 6886 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 6887 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 6888 | { |
| 6889 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 6890 | if (params != IF_DEF_PARAMS (ifp)) |
| 6891 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6892 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6893 | } |
| 6894 | |
| 6895 | while (1) |
| 6896 | { |
| 6897 | if (rn == NULL) |
| 6898 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 6899 | else |
| 6900 | rn = route_next (rn); |
| 6901 | |
| 6902 | if (rn == NULL) |
| 6903 | break; |
| 6904 | params = rn->info; |
| 6905 | if (params != NULL) |
| 6906 | break; |
| 6907 | } |
| 6908 | } while (rn); |
| 6909 | |
| 6910 | #ifdef HAVE_OPAQUE_LSA |
| 6911 | ospf_opaque_config_write_if (vty, ifp); |
| 6912 | #endif /* HAVE_OPAQUE_LSA */ |
| 6913 | } |
| 6914 | |
| 6915 | return write; |
| 6916 | } |
| 6917 | |
| 6918 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6919 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6920 | { |
| 6921 | struct route_node *rn; |
| 6922 | u_char buf[INET_ADDRSTRLEN]; |
| 6923 | |
| 6924 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6925 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6926 | if (rn->info) |
| 6927 | { |
| 6928 | struct ospf_network *n = rn->info; |
| 6929 | |
| 6930 | memset (buf, 0, INET_ADDRSTRLEN); |
| 6931 | |
| 6932 | /* Create Area ID string by specified Area ID format. */ |
| 6933 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6934 | strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
| 6935 | else |
| 6936 | sprintf (buf, "%lu", |
| 6937 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 6938 | |
| 6939 | /* Network print. */ |
| 6940 | vty_out (vty, " network %s/%d area %s%s", |
| 6941 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 6942 | buf, VTY_NEWLINE); |
| 6943 | } |
| 6944 | |
| 6945 | return 0; |
| 6946 | } |
| 6947 | |
| 6948 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6949 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6950 | { |
| 6951 | listnode node; |
| 6952 | u_char buf[INET_ADDRSTRLEN]; |
| 6953 | |
| 6954 | /* Area configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6955 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6956 | { |
| 6957 | struct ospf_area *area = getdata (node); |
| 6958 | struct route_node *rn1; |
| 6959 | |
| 6960 | area_id2str (buf, INET_ADDRSTRLEN, area); |
| 6961 | |
| 6962 | if (area->auth_type != OSPF_AUTH_NULL) |
| 6963 | { |
| 6964 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 6965 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 6966 | else |
| 6967 | vty_out (vty, " area %s authentication message-digest%s", |
| 6968 | buf, VTY_NEWLINE); |
| 6969 | } |
| 6970 | |
| 6971 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 6972 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 6973 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 6974 | VTY_NEWLINE); |
| 6975 | |
| 6976 | if ((area->external_routing == OSPF_AREA_STUB) |
| 6977 | #ifdef HAVE_NSSA |
| 6978 | || (area->external_routing == OSPF_AREA_NSSA) |
| 6979 | #endif /* HAVE_NSSA */ |
| 6980 | ) |
| 6981 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 6982 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6983 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 6984 | #ifdef HAVE_NSSA |
| 6985 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 6986 | { |
| 6987 | vty_out (vty, " area %s nssa", buf); |
| 6988 | switch (area->NSSATranslatorRole) |
| 6989 | { |
| 6990 | case OSPF_NSSA_ROLE_NEVER: |
| 6991 | vty_out (vty, " translate-never"); |
| 6992 | break; |
| 6993 | case OSPF_NSSA_ROLE_ALWAYS: |
| 6994 | vty_out (vty, " translate-always"); |
| 6995 | break; |
| 6996 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 6997 | default: |
| 6998 | vty_out (vty, " translate-candidate"); |
| 6999 | } |
| 7000 | } |
| 7001 | #endif /* HAVE_NSSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7002 | |
| 7003 | if (area->no_summary) |
| 7004 | vty_out (vty, " no-summary"); |
| 7005 | |
| 7006 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7007 | |
| 7008 | if (area->default_cost != 1) |
| 7009 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7010 | area->default_cost, VTY_NEWLINE); |
| 7011 | } |
| 7012 | |
| 7013 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7014 | if (rn1->info) |
| 7015 | { |
| 7016 | struct ospf_area_range *range = rn1->info; |
| 7017 | |
| 7018 | vty_out (vty, " area %s range %s/%d", buf, |
| 7019 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7020 | |
| 7021 | if (range->cost_config != -1) |
| 7022 | vty_out (vty, " cost %d", range->cost_config); |
| 7023 | |
| 7024 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7025 | vty_out (vty, " not-advertise"); |
| 7026 | |
| 7027 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7028 | vty_out (vty, " substitute %s/%d", |
| 7029 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7030 | |
| 7031 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7032 | } |
| 7033 | |
| 7034 | if (EXPORT_NAME (area)) |
| 7035 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7036 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7037 | |
| 7038 | if (IMPORT_NAME (area)) |
| 7039 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7040 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7041 | |
| 7042 | if (PREFIX_NAME_IN (area)) |
| 7043 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7044 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7045 | |
| 7046 | if (PREFIX_NAME_OUT (area)) |
| 7047 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7048 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7049 | } |
| 7050 | |
| 7051 | return 0; |
| 7052 | } |
| 7053 | |
| 7054 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7055 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7056 | { |
| 7057 | struct ospf_nbr_nbma *nbr_nbma; |
| 7058 | struct route_node *rn; |
| 7059 | |
| 7060 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7061 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7062 | if ((nbr_nbma = rn->info)) |
| 7063 | { |
| 7064 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7065 | |
| 7066 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7067 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7068 | |
| 7069 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7070 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7071 | |
| 7072 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7073 | } |
| 7074 | |
| 7075 | return 0; |
| 7076 | } |
| 7077 | |
| 7078 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7079 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7080 | { |
| 7081 | listnode node; |
| 7082 | u_char buf[INET_ADDRSTRLEN]; |
| 7083 | |
| 7084 | /* Virtual-Link print */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7085 | for (node = listhead (ospf->vlinks); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7086 | { |
| 7087 | listnode n2; |
| 7088 | struct crypt_key *ck; |
| 7089 | struct ospf_vl_data *vl_data = getdata (node); |
| 7090 | struct ospf_interface *oi; |
| 7091 | |
| 7092 | if (vl_data != NULL) |
| 7093 | { |
| 7094 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7095 | |
| 7096 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 7097 | strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
| 7098 | else |
| 7099 | sprintf (buf, "%lu", |
| 7100 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7101 | oi = vl_data->vl_oi; |
| 7102 | |
| 7103 | /* timers */ |
| 7104 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7105 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7106 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7107 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7108 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7109 | buf, |
| 7110 | inet_ntoa (vl_data->vl_peer), |
| 7111 | OSPF_IF_PARAM (oi, v_hello), |
| 7112 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7113 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7114 | OSPF_IF_PARAM (oi, v_wait), |
| 7115 | VTY_NEWLINE); |
| 7116 | else |
| 7117 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7118 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7119 | /* Auth key */ |
| 7120 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7121 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7122 | buf, |
| 7123 | inet_ntoa (vl_data->vl_peer), |
| 7124 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7125 | VTY_NEWLINE); |
| 7126 | /* md5 keys */ |
| 7127 | for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2)) |
| 7128 | { |
| 7129 | ck = getdata (n2); |
| 7130 | vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s", |
| 7131 | buf, |
| 7132 | inet_ntoa (vl_data->vl_peer), |
| 7133 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
| 7134 | } |
| 7135 | |
| 7136 | } |
| 7137 | } |
| 7138 | |
| 7139 | return 0; |
| 7140 | } |
| 7141 | |
| 7142 | |
| 7143 | char *distribute_str[] = { "system", "kernel", "connected", "static", "rip", |
| 7144 | "ripng", "ospf", "ospf6", "bgp"}; |
| 7145 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7146 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7147 | { |
| 7148 | int type; |
| 7149 | |
| 7150 | /* redistribute print. */ |
| 7151 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7152 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7153 | { |
| 7154 | vty_out (vty, " redistribute %s", distribute_str[type]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7155 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7156 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7157 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7158 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7159 | vty_out (vty, " metric-type 1"); |
| 7160 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7161 | if (ROUTEMAP_NAME (ospf, type)) |
| 7162 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7163 | |
| 7164 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7165 | } |
| 7166 | |
| 7167 | return 0; |
| 7168 | } |
| 7169 | |
| 7170 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7171 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7172 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7173 | if (ospf->default_metric != -1) |
| 7174 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7175 | VTY_NEWLINE); |
| 7176 | return 0; |
| 7177 | } |
| 7178 | |
| 7179 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7180 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7181 | { |
| 7182 | int type; |
| 7183 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7184 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7185 | { |
| 7186 | /* distribute-list print. */ |
| 7187 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7188 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7189 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7190 | ospf->dlist[type].name, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7191 | distribute_str[type], VTY_NEWLINE); |
| 7192 | |
| 7193 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7194 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7195 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7196 | if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7197 | vty_out (vty, " default-information originate"); |
| 7198 | else |
| 7199 | vty_out (vty, " default-information originate always"); |
| 7200 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7201 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7202 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7203 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7204 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7205 | vty_out (vty, " metric-type 1"); |
| 7206 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7207 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7208 | vty_out (vty, " route-map %s", |
| 7209 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7210 | |
| 7211 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7212 | } |
| 7213 | |
| 7214 | } |
| 7215 | |
| 7216 | return 0; |
| 7217 | } |
| 7218 | |
| 7219 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7220 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7221 | { |
| 7222 | struct route_node *rn; |
| 7223 | struct ospf_distance *odistance; |
| 7224 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7225 | if (ospf->distance_all) |
| 7226 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7227 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7228 | if (ospf->distance_intra |
| 7229 | || ospf->distance_inter |
| 7230 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7231 | { |
| 7232 | vty_out (vty, " distance ospf"); |
| 7233 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7234 | if (ospf->distance_intra) |
| 7235 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7236 | if (ospf->distance_inter) |
| 7237 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7238 | if (ospf->distance_external) |
| 7239 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7240 | |
| 7241 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7242 | } |
| 7243 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7244 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | if ((odistance = rn->info) != NULL) |
| 7246 | { |
| 7247 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7248 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7249 | odistance->access_list ? odistance->access_list : "", |
| 7250 | VTY_NEWLINE); |
| 7251 | } |
| 7252 | return 0; |
| 7253 | } |
| 7254 | |
| 7255 | /* OSPF configuration write function. */ |
| 7256 | int |
| 7257 | ospf_config_write (struct vty *vty) |
| 7258 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7259 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7260 | listnode node; |
| 7261 | int write = 0; |
| 7262 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7263 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7264 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7265 | { |
| 7266 | /* `router ospf' print. */ |
| 7267 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7268 | |
| 7269 | write++; |
| 7270 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7271 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7272 | return write; |
| 7273 | |
| 7274 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7275 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7276 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7277 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7278 | |
| 7279 | /* ABR type print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7280 | if (ospf->abr_type != OSPF_ABR_STAND) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7281 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7282 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7283 | |
| 7284 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7285 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7286 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7287 | |
| 7288 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7289 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7290 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7291 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7292 | |
| 7293 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7294 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
| 7295 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7296 | vty_out (vty, " timers spf %d %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7297 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7298 | |
| 7299 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7300 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7301 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7302 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7303 | |
| 7304 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7305 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7306 | |
| 7307 | /* passive-interface print. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7308 | for (node = listhead (om->iflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7309 | { |
| 7310 | struct interface *ifp = getdata (node); |
| 7311 | |
| 7312 | if (!ifp) |
| 7313 | continue; |
| 7314 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7315 | vty_out (vty, " passive-interface %s%s", |
| 7316 | ifp->name, VTY_NEWLINE); |
| 7317 | } |
| 7318 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7319 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7320 | { |
| 7321 | struct ospf_interface *oi = getdata (node); |
| 7322 | |
| 7323 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7324 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
| 7325 | vty_out (vty, " passive-interface %s%s", |
| 7326 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
| 7327 | } |
| 7328 | |
| 7329 | |
| 7330 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7331 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7332 | |
| 7333 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7334 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7335 | |
| 7336 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7337 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7338 | |
| 7339 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7340 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7341 | |
| 7342 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7343 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7344 | |
| 7345 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7346 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7347 | |
| 7348 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7349 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7350 | |
| 7351 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7352 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7353 | #endif /* HAVE_OPAQUE_LSA */ |
| 7354 | } |
| 7355 | |
| 7356 | return write; |
| 7357 | } |
| 7358 | |
| 7359 | void |
| 7360 | ospf_vty_show_init () |
| 7361 | { |
| 7362 | /* "show ip ospf" commands. */ |
| 7363 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7364 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7365 | |
| 7366 | /* "show ip ospf database" commands. */ |
| 7367 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7368 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7369 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7370 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7371 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7372 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7373 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7374 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7375 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7376 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7377 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7378 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7379 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7380 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7381 | |
| 7382 | /* "show ip ospf interface" commands. */ |
| 7383 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7384 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7385 | |
| 7386 | /* "show ip ospf neighbor" commands. */ |
| 7387 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7388 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7389 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7390 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7391 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7392 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7393 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7394 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7395 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7396 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7397 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7398 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7399 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7400 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7401 | |
| 7402 | /* "show ip ospf route" commands. */ |
| 7403 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7404 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
| 7405 | #ifdef HAVE_NSSA |
| 7406 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7407 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
| 7408 | #endif /* HAVE_NSSA */ |
| 7409 | } |
| 7410 | |
| 7411 | |
| 7412 | /* ospfd's interface node. */ |
| 7413 | struct cmd_node interface_node = |
| 7414 | { |
| 7415 | INTERFACE_NODE, |
| 7416 | "%s(config-if)# ", |
| 7417 | 1 |
| 7418 | }; |
| 7419 | |
| 7420 | /* Initialization of OSPF interface. */ |
| 7421 | void |
| 7422 | ospf_vty_if_init () |
| 7423 | { |
| 7424 | /* Install interface node. */ |
| 7425 | install_node (&interface_node, config_write_interface); |
| 7426 | |
| 7427 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7428 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7429 | install_default (INTERFACE_NODE); |
| 7430 | |
| 7431 | /* "description" commands. */ |
| 7432 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7433 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7434 | |
| 7435 | /* "ip ospf authentication" commands. */ |
| 7436 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7437 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7438 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7439 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7440 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7441 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7442 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7443 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7444 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7445 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7446 | |
| 7447 | /* "ip ospf message-digest-key" commands. */ |
| 7448 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7449 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7450 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7451 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7452 | |
| 7453 | /* "ip ospf cost" commands. */ |
| 7454 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7455 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7456 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7457 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7458 | |
| 7459 | /* "ip ospf dead-interval" commands. */ |
| 7460 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7461 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
| 7462 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7463 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
| 7464 | |
| 7465 | /* "ip ospf hello-interval" commands. */ |
| 7466 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7467 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7468 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7469 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7470 | |
| 7471 | /* "ip ospf network" commands. */ |
| 7472 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7473 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7474 | |
| 7475 | /* "ip ospf priority" commands. */ |
| 7476 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7477 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7478 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7479 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7480 | |
| 7481 | /* "ip ospf retransmit-interval" commands. */ |
| 7482 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7483 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7484 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7485 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7486 | |
| 7487 | /* "ip ospf transmit-delay" commands. */ |
| 7488 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7489 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7490 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7491 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7492 | |
| 7493 | /* These commands are compatibitliy for previous version. */ |
| 7494 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7495 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7496 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7497 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 7498 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 7499 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 7500 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7501 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7502 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7503 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7504 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7505 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7506 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7507 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7508 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7509 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7510 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7511 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7512 | } |
| 7513 | |
| 7514 | /* Zebra node structure. */ |
| 7515 | struct cmd_node zebra_node = |
| 7516 | { |
| 7517 | ZEBRA_NODE, |
| 7518 | "%s(config-router)#", |
| 7519 | }; |
| 7520 | |
| 7521 | void |
| 7522 | ospf_vty_zebra_init () |
| 7523 | { |
| 7524 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 7525 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 7526 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 7527 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 7528 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 7529 | install_element (OSPF_NODE, |
| 7530 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 7531 | install_element (OSPF_NODE, |
| 7532 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 7533 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 7534 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 7535 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 7536 | |
| 7537 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7538 | |
| 7539 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7540 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7541 | |
| 7542 | install_element (OSPF_NODE, |
| 7543 | &ospf_default_information_originate_metric_type_cmd); |
| 7544 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 7545 | install_element (OSPF_NODE, |
| 7546 | &ospf_default_information_originate_type_metric_cmd); |
| 7547 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 7548 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 7549 | install_element (OSPF_NODE, |
| 7550 | &ospf_default_information_originate_always_metric_type_cmd); |
| 7551 | install_element (OSPF_NODE, |
| 7552 | &ospf_default_information_originate_always_metric_cmd); |
| 7553 | install_element (OSPF_NODE, |
| 7554 | &ospf_default_information_originate_always_cmd); |
| 7555 | install_element (OSPF_NODE, |
| 7556 | &ospf_default_information_originate_always_type_metric_cmd); |
| 7557 | install_element (OSPF_NODE, |
| 7558 | &ospf_default_information_originate_always_type_cmd); |
| 7559 | |
| 7560 | install_element (OSPF_NODE, |
| 7561 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 7562 | install_element (OSPF_NODE, |
| 7563 | &ospf_default_information_originate_metric_routemap_cmd); |
| 7564 | install_element (OSPF_NODE, |
| 7565 | &ospf_default_information_originate_routemap_cmd); |
| 7566 | install_element (OSPF_NODE, |
| 7567 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 7568 | install_element (OSPF_NODE, |
| 7569 | &ospf_default_information_originate_type_routemap_cmd); |
| 7570 | install_element (OSPF_NODE, |
| 7571 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 7572 | install_element (OSPF_NODE, |
| 7573 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 7574 | install_element (OSPF_NODE, |
| 7575 | &ospf_default_information_originate_always_routemap_cmd); |
| 7576 | install_element (OSPF_NODE, |
| 7577 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 7578 | install_element (OSPF_NODE, |
| 7579 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 7580 | |
| 7581 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7582 | |
| 7583 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7584 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7585 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7586 | |
| 7587 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7588 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7589 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 7590 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 7591 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 7592 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 7593 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 7594 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 7595 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 7596 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 7597 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 7598 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 7599 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 7600 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 7601 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 7602 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 7603 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 7604 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 7605 | #if 0 |
| 7606 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7607 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7608 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7609 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7610 | #endif /* 0 */ |
| 7611 | } |
| 7612 | |
| 7613 | struct cmd_node ospf_node = |
| 7614 | { |
| 7615 | OSPF_NODE, |
| 7616 | "%s(config-router)# ", |
| 7617 | 1 |
| 7618 | }; |
| 7619 | |
| 7620 | |
| 7621 | /* Install OSPF related vty commands. */ |
| 7622 | void |
| 7623 | ospf_vty_init () |
| 7624 | { |
| 7625 | /* Install ospf top node. */ |
| 7626 | install_node (&ospf_node, ospf_config_write); |
| 7627 | |
| 7628 | /* "router ospf" commands. */ |
| 7629 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7630 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7631 | |
| 7632 | install_default (OSPF_NODE); |
| 7633 | |
| 7634 | /* "ospf router-id" commands. */ |
| 7635 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7636 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7637 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7638 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7639 | |
| 7640 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7641 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7642 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 7643 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7644 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7645 | |
| 7646 | /* "ospf abr-type" commands. */ |
| 7647 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7648 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7649 | |
| 7650 | /* "ospf rfc1583-compatible" commands. */ |
| 7651 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7652 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7653 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7654 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7655 | |
| 7656 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7657 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7658 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7659 | |
| 7660 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7661 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7662 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7663 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7664 | |
| 7665 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7666 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7667 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7668 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7669 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7670 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7671 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7672 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7673 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7674 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7675 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7676 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7677 | |
| 7678 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7679 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7680 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7681 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7682 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7683 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7684 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7685 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7686 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7687 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7688 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7689 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7690 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7691 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7692 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7693 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7694 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7695 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7696 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7697 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7698 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7699 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7700 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7701 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7702 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7703 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7704 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7705 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7706 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7707 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7708 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7709 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7710 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7711 | |
| 7712 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7713 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7714 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7715 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7716 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7717 | |
| 7718 | #ifdef HAVE_NSSA |
| 7719 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7720 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7721 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7722 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7723 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7724 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7725 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7726 | #endif /* HAVE_NSSA */ |
| 7727 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7728 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7729 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7730 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7731 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7732 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7733 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7734 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 7735 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7736 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7737 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 7738 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7739 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7740 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 7741 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7742 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7743 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 7744 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7745 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7746 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 7747 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7748 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7749 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7750 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 7751 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7752 | |
| 7753 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7754 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7755 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7756 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7757 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7758 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7759 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7760 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7761 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7762 | |
| 7763 | /* Init interface related vty commands. */ |
| 7764 | ospf_vty_if_init (); |
| 7765 | |
| 7766 | /* Init zebra related vty commands. */ |
| 7767 | ospf_vty_zebra_init (); |
| 7768 | } |