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 | { |
| 1430 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 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 | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1482 | DEFUN (ospf_area_nssa, |
| 1483 | ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1484 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1485 | "OSPF area parameters\n" |
| 1486 | "OSPF area ID in IP address format\n" |
| 1487 | "OSPF area ID as a decimal value\n" |
| 1488 | "Configure OSPF area as nssa\n") |
| 1489 | { |
| 1490 | struct ospf *ospf = vty->index; |
| 1491 | struct in_addr area_id; |
| 1492 | int ret, format; |
| 1493 | |
| 1494 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1495 | |
| 1496 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1497 | if (ret == 0) |
| 1498 | { |
| 1499 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1500 | VTY_NEWLINE); |
| 1501 | return CMD_WARNING; |
| 1502 | } |
| 1503 | |
| 1504 | if (argc > 1) |
| 1505 | { |
| 1506 | if (strncmp (argv[1], "translate-c", 11) == 0) |
| 1507 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1508 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1509 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
| 1510 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1511 | OSPF_NSSA_ROLE_NEVER); |
| 1512 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
| 1513 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1514 | OSPF_NSSA_ROLE_ALWAYS); |
| 1515 | } |
| 1516 | |
| 1517 | if (argc > 2) |
| 1518 | ospf_area_no_summary_set (ospf, area_id); |
| 1519 | |
| 1520 | return CMD_SUCCESS; |
| 1521 | } |
| 1522 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1523 | ALIAS (ospf_area_nssa, |
| 1524 | ospf_area_nssa_translate_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1525 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) (no-summary|)", |
| 1526 | "OSPF area parameters\n" |
| 1527 | "OSPF area ID in IP address format\n" |
| 1528 | "OSPF area ID as a decimal value\n" |
| 1529 | "Configure OSPF area as nssa\n" |
| 1530 | "Configure NSSA-ABR for translate election (default)\n" |
| 1531 | "Configure NSSA-ABR to never translate\n" |
| 1532 | "Configure NSSA-ABR to always translate\n" |
| 1533 | "Do not inject inter-area routes into nssa\n" |
| 1534 | "dummy\n") |
| 1535 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1536 | ALIAS (ospf_area_nssa, |
| 1537 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1538 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1539 | "OSPF area parameters\n" |
| 1540 | "OSPF area ID in IP address format\n" |
| 1541 | "OSPF area ID as a decimal value\n" |
| 1542 | "Configure OSPF area as nssa\n" |
| 1543 | "Configure NSSA-ABR for translate election (default)\n" |
| 1544 | "Configure NSSA-ABR to never translate\n" |
| 1545 | "Configure NSSA-ABR to always translate\n") |
| 1546 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1547 | DEFUN (ospf_area_nssa_no_summary, |
| 1548 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1549 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1550 | "OSPF area parameters\n" |
| 1551 | "OSPF area ID in IP address format\n" |
| 1552 | "OSPF area ID as a decimal value\n" |
| 1553 | "Configure OSPF area as nssa\n" |
| 1554 | "Do not inject inter-area routes into nssa\n") |
| 1555 | { |
| 1556 | struct ospf *ospf = vty->index; |
| 1557 | struct in_addr area_id; |
| 1558 | int ret, format; |
| 1559 | |
| 1560 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1561 | |
| 1562 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1563 | if (ret == 0) |
| 1564 | { |
| 1565 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1566 | VTY_NEWLINE); |
| 1567 | return CMD_WARNING; |
| 1568 | } |
| 1569 | |
| 1570 | ospf_area_no_summary_set (ospf, area_id); |
| 1571 | |
| 1572 | return CMD_SUCCESS; |
| 1573 | } |
| 1574 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1575 | DEFUN (no_ospf_area_nssa, |
| 1576 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1577 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1578 | NO_STR |
| 1579 | "OSPF area parameters\n" |
| 1580 | "OSPF area ID in IP address format\n" |
| 1581 | "OSPF area ID as a decimal value\n" |
| 1582 | "Configure OSPF area as nssa\n") |
| 1583 | { |
| 1584 | struct ospf *ospf = vty->index; |
| 1585 | struct in_addr area_id; |
| 1586 | int format; |
| 1587 | |
| 1588 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1589 | |
| 1590 | ospf_area_nssa_unset (ospf, area_id); |
| 1591 | ospf_area_no_summary_unset (ospf, area_id); |
| 1592 | |
| 1593 | return CMD_SUCCESS; |
| 1594 | } |
| 1595 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1596 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1597 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1599 | NO_STR |
| 1600 | "OSPF area parameters\n" |
| 1601 | "OSPF area ID in IP address format\n" |
| 1602 | "OSPF area ID as a decimal value\n" |
| 1603 | "Configure OSPF area as nssa\n" |
| 1604 | "Do not inject inter-area routes into nssa\n") |
| 1605 | { |
| 1606 | struct ospf *ospf = vty->index; |
| 1607 | struct in_addr area_id; |
| 1608 | int format; |
| 1609 | |
| 1610 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1611 | ospf_area_no_summary_unset (ospf, area_id); |
| 1612 | |
| 1613 | return CMD_SUCCESS; |
| 1614 | } |
| 1615 | |
| 1616 | #endif /* HAVE_NSSA */ |
| 1617 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1618 | DEFUN (ospf_area_default_cost, |
| 1619 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1620 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1621 | "OSPF area parameters\n" |
| 1622 | "OSPF area ID in IP address format\n" |
| 1623 | "OSPF area ID as a decimal value\n" |
| 1624 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1625 | "Stub's advertised default summary cost\n") |
| 1626 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1627 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1628 | struct ospf_area *area; |
| 1629 | struct in_addr area_id; |
| 1630 | u_int32_t cost; |
| 1631 | int format; |
| 1632 | |
| 1633 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1634 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1635 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1636 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | |
| 1638 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1639 | { |
| 1640 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1641 | return CMD_WARNING; |
| 1642 | } |
| 1643 | |
| 1644 | area->default_cost = cost; |
| 1645 | |
| 1646 | return CMD_SUCCESS; |
| 1647 | } |
| 1648 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1649 | DEFUN (no_ospf_area_default_cost, |
| 1650 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1651 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1652 | NO_STR |
| 1653 | "OSPF area parameters\n" |
| 1654 | "OSPF area ID in IP address format\n" |
| 1655 | "OSPF area ID as a decimal value\n" |
| 1656 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1657 | "Stub's advertised default summary cost\n") |
| 1658 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1659 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1660 | struct ospf_area *area; |
| 1661 | struct in_addr area_id; |
| 1662 | u_int32_t cost; |
| 1663 | int format; |
| 1664 | |
| 1665 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1666 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1667 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1668 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1669 | if (area == NULL) |
| 1670 | return CMD_SUCCESS; |
| 1671 | |
| 1672 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1673 | { |
| 1674 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1675 | return CMD_WARNING; |
| 1676 | } |
| 1677 | |
| 1678 | area->default_cost = 1; |
| 1679 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1680 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1681 | |
| 1682 | return CMD_SUCCESS; |
| 1683 | } |
| 1684 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1685 | DEFUN (ospf_area_export_list, |
| 1686 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1687 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1688 | "OSPF area parameters\n" |
| 1689 | "OSPF area ID in IP address format\n" |
| 1690 | "OSPF area ID as a decimal value\n" |
| 1691 | "Set the filter for networks announced to other areas\n" |
| 1692 | "Name of the access-list\n") |
| 1693 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1694 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1695 | struct ospf_area *area; |
| 1696 | struct in_addr area_id; |
| 1697 | int format; |
| 1698 | |
| 1699 | VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]); |
| 1700 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1701 | area = ospf_area_get (ospf, area_id, format); |
| 1702 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1703 | |
| 1704 | return CMD_SUCCESS; |
| 1705 | } |
| 1706 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1707 | DEFUN (no_ospf_area_export_list, |
| 1708 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1709 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1710 | NO_STR |
| 1711 | "OSPF area parameters\n" |
| 1712 | "OSPF area ID in IP address format\n" |
| 1713 | "OSPF area ID as a decimal value\n" |
| 1714 | "Unset the filter for networks announced to other areas\n" |
| 1715 | "Name of the access-list\n") |
| 1716 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1717 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1718 | struct ospf_area *area; |
| 1719 | struct in_addr area_id; |
| 1720 | int format; |
| 1721 | |
| 1722 | VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]); |
| 1723 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1724 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1725 | if (area == NULL) |
| 1726 | return CMD_SUCCESS; |
| 1727 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1728 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1729 | |
| 1730 | return CMD_SUCCESS; |
| 1731 | } |
| 1732 | |
| 1733 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1734 | DEFUN (ospf_area_import_list, |
| 1735 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1736 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1737 | "OSPF area parameters\n" |
| 1738 | "OSPF area ID in IP address format\n" |
| 1739 | "OSPF area ID as a decimal value\n" |
| 1740 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1741 | "Name of the access-list\n") |
| 1742 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1743 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1744 | struct ospf_area *area; |
| 1745 | struct in_addr area_id; |
| 1746 | int format; |
| 1747 | |
| 1748 | VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]); |
| 1749 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1750 | area = ospf_area_get (ospf, area_id, format); |
| 1751 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1752 | |
| 1753 | return CMD_SUCCESS; |
| 1754 | } |
| 1755 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1756 | DEFUN (no_ospf_area_import_list, |
| 1757 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1758 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1759 | NO_STR |
| 1760 | "OSPF area parameters\n" |
| 1761 | "OSPF area ID in IP address format\n" |
| 1762 | "OSPF area ID as a decimal value\n" |
| 1763 | "Unset the filter for networks announced to other areas\n" |
| 1764 | "Name of the access-list\n") |
| 1765 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1766 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1767 | struct ospf_area *area; |
| 1768 | struct in_addr area_id; |
| 1769 | int format; |
| 1770 | |
| 1771 | 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] | 1772 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1773 | if (area == NULL) |
| 1774 | return CMD_SUCCESS; |
| 1775 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1776 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1777 | |
| 1778 | return CMD_SUCCESS; |
| 1779 | } |
| 1780 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1781 | DEFUN (ospf_area_filter_list, |
| 1782 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1783 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1784 | "OSPF area parameters\n" |
| 1785 | "OSPF area ID in IP address format\n" |
| 1786 | "OSPF area ID as a decimal value\n" |
| 1787 | "Filter networks between OSPF areas\n" |
| 1788 | "Filter prefixes between OSPF areas\n" |
| 1789 | "Name of an IP prefix-list\n" |
| 1790 | "Filter networks sent to this area\n" |
| 1791 | "Filter networks sent from this area\n") |
| 1792 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1793 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1794 | struct ospf_area *area; |
| 1795 | struct in_addr area_id; |
| 1796 | struct prefix_list *plist; |
| 1797 | int format; |
| 1798 | |
| 1799 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1800 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1801 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1802 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1803 | if (strncmp (argv[2], "in", 2) == 0) |
| 1804 | { |
| 1805 | PREFIX_LIST_IN (area) = plist; |
| 1806 | if (PREFIX_NAME_IN (area)) |
| 1807 | free (PREFIX_NAME_IN (area)); |
| 1808 | |
| 1809 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1810 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1811 | } |
| 1812 | else |
| 1813 | { |
| 1814 | PREFIX_LIST_OUT (area) = plist; |
| 1815 | if (PREFIX_NAME_OUT (area)) |
| 1816 | free (PREFIX_NAME_OUT (area)); |
| 1817 | |
| 1818 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1819 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1820 | } |
| 1821 | |
| 1822 | return CMD_SUCCESS; |
| 1823 | } |
| 1824 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1825 | DEFUN (no_ospf_area_filter_list, |
| 1826 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1827 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1828 | NO_STR |
| 1829 | "OSPF area parameters\n" |
| 1830 | "OSPF area ID in IP address format\n" |
| 1831 | "OSPF area ID as a decimal value\n" |
| 1832 | "Filter networks between OSPF areas\n" |
| 1833 | "Filter prefixes between OSPF areas\n" |
| 1834 | "Name of an IP prefix-list\n" |
| 1835 | "Filter networks sent to this area\n" |
| 1836 | "Filter networks sent from this area\n") |
| 1837 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1838 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1839 | struct ospf_area *area; |
| 1840 | struct in_addr area_id; |
| 1841 | struct prefix_list *plist; |
| 1842 | int format; |
| 1843 | |
| 1844 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1845 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1846 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1847 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1848 | if (strncmp (argv[2], "in", 2) == 0) |
| 1849 | { |
| 1850 | if (PREFIX_NAME_IN (area)) |
| 1851 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1852 | return CMD_SUCCESS; |
| 1853 | |
| 1854 | PREFIX_LIST_IN (area) = NULL; |
| 1855 | if (PREFIX_NAME_IN (area)) |
| 1856 | free (PREFIX_NAME_IN (area)); |
| 1857 | |
| 1858 | PREFIX_NAME_IN (area) = NULL; |
| 1859 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1860 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1861 | } |
| 1862 | else |
| 1863 | { |
| 1864 | if (PREFIX_NAME_OUT (area)) |
| 1865 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1866 | return CMD_SUCCESS; |
| 1867 | |
| 1868 | PREFIX_LIST_OUT (area) = NULL; |
| 1869 | if (PREFIX_NAME_OUT (area)) |
| 1870 | free (PREFIX_NAME_OUT (area)); |
| 1871 | |
| 1872 | PREFIX_NAME_OUT (area) = NULL; |
| 1873 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1874 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1875 | } |
| 1876 | |
| 1877 | return CMD_SUCCESS; |
| 1878 | } |
| 1879 | |
| 1880 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1881 | DEFUN (ospf_area_authentication_message_digest, |
| 1882 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1883 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1884 | "OSPF area parameters\n" |
| 1885 | "Enable authentication\n" |
| 1886 | "Use message-digest authentication\n") |
| 1887 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1888 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1889 | struct ospf_area *area; |
| 1890 | struct in_addr area_id; |
| 1891 | int format; |
| 1892 | |
| 1893 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1894 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1895 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1896 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1897 | |
| 1898 | return CMD_SUCCESS; |
| 1899 | } |
| 1900 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1901 | DEFUN (ospf_area_authentication, |
| 1902 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1903 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1904 | "OSPF area parameters\n" |
| 1905 | "OSPF area ID in IP address format\n" |
| 1906 | "OSPF area ID as a decimal value\n" |
| 1907 | "Enable authentication\n") |
| 1908 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1909 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1910 | struct ospf_area *area; |
| 1911 | struct in_addr area_id; |
| 1912 | int format; |
| 1913 | |
| 1914 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1915 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1916 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1917 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1918 | |
| 1919 | return CMD_SUCCESS; |
| 1920 | } |
| 1921 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 1922 | DEFUN (no_ospf_area_authentication, |
| 1923 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1924 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1925 | NO_STR |
| 1926 | "OSPF area parameters\n" |
| 1927 | "OSPF area ID in IP address format\n" |
| 1928 | "OSPF area ID as a decimal value\n" |
| 1929 | "Enable authentication\n") |
| 1930 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1931 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1932 | struct ospf_area *area; |
| 1933 | struct in_addr area_id; |
| 1934 | int format; |
| 1935 | |
| 1936 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1937 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1938 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1939 | if (area == NULL) |
| 1940 | return CMD_SUCCESS; |
| 1941 | |
| 1942 | area->auth_type = OSPF_AUTH_NULL; |
| 1943 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1944 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1945 | |
| 1946 | return CMD_SUCCESS; |
| 1947 | } |
| 1948 | |
| 1949 | |
| 1950 | DEFUN (ospf_abr_type, |
| 1951 | ospf_abr_type_cmd, |
| 1952 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 1953 | "OSPF specific commands\n" |
| 1954 | "Set OSPF ABR type\n" |
| 1955 | "Alternative ABR, cisco implementation\n" |
| 1956 | "Alternative ABR, IBM implementation\n" |
| 1957 | "Shortcut ABR\n" |
| 1958 | "Standard behavior (RFC2328)\n") |
| 1959 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1960 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1961 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 1962 | |
| 1963 | if (strncmp (argv[0], "c", 1) == 0) |
| 1964 | abr_type = OSPF_ABR_CISCO; |
| 1965 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1966 | abr_type = OSPF_ABR_IBM; |
| 1967 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 1968 | abr_type = OSPF_ABR_SHORTCUT; |
| 1969 | else if (strncmp (argv[0], "st", 2) == 0) |
| 1970 | abr_type = OSPF_ABR_STAND; |
| 1971 | else |
| 1972 | return CMD_WARNING; |
| 1973 | |
| 1974 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1975 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1976 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1977 | ospf->abr_type = abr_type; |
| 1978 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1979 | } |
| 1980 | |
| 1981 | return CMD_SUCCESS; |
| 1982 | } |
| 1983 | |
| 1984 | DEFUN (no_ospf_abr_type, |
| 1985 | no_ospf_abr_type_cmd, |
| 1986 | "no ospf abr-type (cisco|ibm|shortcut)", |
| 1987 | NO_STR |
| 1988 | "OSPF specific commands\n" |
| 1989 | "Set OSPF ABR type\n" |
| 1990 | "Alternative ABR, cisco implementation\n" |
| 1991 | "Alternative ABR, IBM implementation\n" |
| 1992 | "Shortcut ABR\n") |
| 1993 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1994 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1995 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 1996 | |
| 1997 | if (strncmp (argv[0], "c", 1) == 0) |
| 1998 | abr_type = OSPF_ABR_CISCO; |
| 1999 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2000 | abr_type = OSPF_ABR_IBM; |
| 2001 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2002 | abr_type = OSPF_ABR_SHORTCUT; |
| 2003 | else |
| 2004 | return CMD_WARNING; |
| 2005 | |
| 2006 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2007 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2008 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2009 | ospf->abr_type = OSPF_ABR_STAND; |
| 2010 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | return CMD_SUCCESS; |
| 2014 | } |
| 2015 | |
| 2016 | DEFUN (ospf_compatible_rfc1583, |
| 2017 | ospf_compatible_rfc1583_cmd, |
| 2018 | "compatible rfc1583", |
| 2019 | "OSPF compatibility list\n" |
| 2020 | "compatible with RFC 1583\n") |
| 2021 | { |
| 2022 | struct ospf *ospf = vty->index; |
| 2023 | |
| 2024 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2025 | { |
| 2026 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2027 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2028 | } |
| 2029 | return CMD_SUCCESS; |
| 2030 | } |
| 2031 | |
| 2032 | DEFUN (no_ospf_compatible_rfc1583, |
| 2033 | no_ospf_compatible_rfc1583_cmd, |
| 2034 | "no compatible rfc1583", |
| 2035 | NO_STR |
| 2036 | "OSPF compatibility list\n" |
| 2037 | "compatible with RFC 1583\n") |
| 2038 | { |
| 2039 | struct ospf *ospf = vty->index; |
| 2040 | |
| 2041 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2042 | { |
| 2043 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2044 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2045 | } |
| 2046 | return CMD_SUCCESS; |
| 2047 | } |
| 2048 | |
| 2049 | ALIAS (ospf_compatible_rfc1583, |
| 2050 | ospf_rfc1583_flag_cmd, |
| 2051 | "ospf rfc1583compatibility", |
| 2052 | "OSPF specific commands\n" |
| 2053 | "Enable the RFC1583Compatibility flag\n") |
| 2054 | |
| 2055 | ALIAS (no_ospf_compatible_rfc1583, |
| 2056 | no_ospf_rfc1583_flag_cmd, |
| 2057 | "no ospf rfc1583compatibility", |
| 2058 | NO_STR |
| 2059 | "OSPF specific commands\n" |
| 2060 | "Disable the RFC1583Compatibility flag\n") |
| 2061 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2062 | DEFUN (ospf_timers_spf, |
| 2063 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2064 | "timers spf <0-4294967295> <0-4294967295>", |
| 2065 | "Adjust routing timers\n" |
| 2066 | "OSPF SPF timers\n" |
| 2067 | "Delay between receiving a change to SPF calculation\n" |
| 2068 | "Hold time between consecutive SPF calculations\n") |
| 2069 | { |
| 2070 | struct ospf *ospf = vty->index; |
| 2071 | u_int32_t delay, hold; |
| 2072 | |
| 2073 | VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]); |
| 2074 | VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]); |
| 2075 | |
| 2076 | ospf_timers_spf_set (ospf, delay, hold); |
| 2077 | |
| 2078 | return CMD_SUCCESS; |
| 2079 | } |
| 2080 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2081 | DEFUN (no_ospf_timers_spf, |
| 2082 | no_ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2083 | "no timers spf", |
| 2084 | NO_STR |
| 2085 | "Adjust routing timers\n" |
| 2086 | "OSPF SPF timers\n") |
| 2087 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2088 | struct ospf *ospf = vty->index; |
| 2089 | |
| 2090 | ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT; |
| 2091 | ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2092 | |
| 2093 | return CMD_SUCCESS; |
| 2094 | } |
| 2095 | |
| 2096 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2097 | DEFUN (ospf_neighbor, |
| 2098 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2099 | "neighbor A.B.C.D", |
| 2100 | NEIGHBOR_STR |
| 2101 | "Neighbor IP address\n") |
| 2102 | { |
| 2103 | struct ospf *ospf = vty->index; |
| 2104 | struct in_addr nbr_addr; |
| 2105 | int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2106 | int interval = OSPF_POLL_INTERVAL_DEFAULT; |
| 2107 | |
| 2108 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2109 | |
| 2110 | if (argc > 1) |
| 2111 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2112 | |
| 2113 | if (argc > 2) |
| 2114 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2115 | |
| 2116 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2117 | if (argc > 1) |
| 2118 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2119 | if (argc > 2) |
| 2120 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2121 | |
| 2122 | return CMD_SUCCESS; |
| 2123 | } |
| 2124 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2125 | ALIAS (ospf_neighbor, |
| 2126 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2127 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2128 | NEIGHBOR_STR |
| 2129 | "Neighbor IP address\n" |
| 2130 | "Neighbor Priority\n" |
| 2131 | "Priority\n" |
| 2132 | "Dead Neighbor Polling interval\n" |
| 2133 | "Seconds\n") |
| 2134 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2135 | ALIAS (ospf_neighbor, |
| 2136 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2137 | "neighbor A.B.C.D priority <0-255>", |
| 2138 | NEIGHBOR_STR |
| 2139 | "Neighbor IP address\n" |
| 2140 | "Neighbor Priority\n" |
| 2141 | "Seconds\n") |
| 2142 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2143 | DEFUN (ospf_neighbor_poll_interval, |
| 2144 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2145 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2146 | NEIGHBOR_STR |
| 2147 | "Neighbor IP address\n" |
| 2148 | "Dead Neighbor Polling interval\n" |
| 2149 | "Seconds\n") |
| 2150 | { |
| 2151 | struct ospf *ospf = vty->index; |
| 2152 | struct in_addr nbr_addr; |
| 2153 | int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2154 | int interval = OSPF_POLL_INTERVAL_DEFAULT; |
| 2155 | |
| 2156 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2157 | |
| 2158 | if (argc > 1) |
| 2159 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2160 | |
| 2161 | if (argc > 2) |
| 2162 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2163 | |
| 2164 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2165 | if (argc > 1) |
| 2166 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2167 | if (argc > 2) |
| 2168 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2169 | |
| 2170 | return CMD_SUCCESS; |
| 2171 | } |
| 2172 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2173 | ALIAS (ospf_neighbor_poll_interval, |
| 2174 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2175 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2176 | NEIGHBOR_STR |
| 2177 | "Neighbor address\n" |
| 2178 | "OSPF dead-router polling interval\n" |
| 2179 | "Seconds\n" |
| 2180 | "OSPF priority of non-broadcast neighbor\n" |
| 2181 | "Priority\n") |
| 2182 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2183 | DEFUN (no_ospf_neighbor, |
| 2184 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2185 | "no neighbor A.B.C.D", |
| 2186 | NO_STR |
| 2187 | NEIGHBOR_STR |
| 2188 | "Neighbor IP address\n") |
| 2189 | { |
| 2190 | struct ospf *ospf = vty->index; |
| 2191 | struct in_addr nbr_addr; |
| 2192 | int ret; |
| 2193 | |
| 2194 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2195 | |
| 2196 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2197 | |
| 2198 | return CMD_SUCCESS; |
| 2199 | } |
| 2200 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2201 | ALIAS (no_ospf_neighbor, |
| 2202 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2203 | "no neighbor A.B.C.D priority <0-255>", |
| 2204 | NO_STR |
| 2205 | NEIGHBOR_STR |
| 2206 | "Neighbor IP address\n" |
| 2207 | "Neighbor Priority\n" |
| 2208 | "Priority\n") |
| 2209 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2210 | ALIAS (no_ospf_neighbor, |
| 2211 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2212 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2213 | NO_STR |
| 2214 | NEIGHBOR_STR |
| 2215 | "Neighbor IP address\n" |
| 2216 | "Dead Neighbor Polling interval\n" |
| 2217 | "Seconds\n") |
| 2218 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2219 | ALIAS (no_ospf_neighbor, |
| 2220 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2221 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2222 | NO_STR |
| 2223 | NEIGHBOR_STR |
| 2224 | "Neighbor IP address\n" |
| 2225 | "Neighbor Priority\n" |
| 2226 | "Priority\n" |
| 2227 | "Dead Neighbor Polling interval\n" |
| 2228 | "Seconds\n") |
| 2229 | |
| 2230 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2231 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | "refresh timer <10-1800>", |
| 2233 | "Adjust refresh parameters\n" |
| 2234 | "Set refresh timer\n" |
| 2235 | "Timer value in seconds\n") |
| 2236 | { |
| 2237 | struct ospf *ospf = vty->index; |
| 2238 | int interval; |
| 2239 | |
| 2240 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2241 | interval = (interval / 10) * 10; |
| 2242 | |
| 2243 | ospf_timers_refresh_set (ospf, interval); |
| 2244 | |
| 2245 | return CMD_SUCCESS; |
| 2246 | } |
| 2247 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2248 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2249 | "no refresh timer <10-1800>", |
| 2250 | "Adjust refresh parameters\n" |
| 2251 | "Unset refresh timer\n" |
| 2252 | "Timer value in seconds\n") |
| 2253 | { |
| 2254 | struct ospf *ospf = vty->index; |
| 2255 | int interval; |
| 2256 | |
| 2257 | if (argc == 1) |
| 2258 | { |
| 2259 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2260 | |
| 2261 | if (ospf->lsa_refresh_interval != interval || |
| 2262 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2263 | return CMD_SUCCESS; |
| 2264 | } |
| 2265 | |
| 2266 | ospf_timers_refresh_unset (ospf); |
| 2267 | |
| 2268 | return CMD_SUCCESS; |
| 2269 | } |
| 2270 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2271 | ALIAS (no_ospf_refresh_timer, |
| 2272 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2273 | "no refresh timer", |
| 2274 | "Adjust refresh parameters\n" |
| 2275 | "Unset refresh timer\n") |
| 2276 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2277 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2278 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2279 | "auto-cost reference-bandwidth <1-4294967>", |
| 2280 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2281 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2282 | "The reference bandwidth in terms of Mbits per second\n") |
| 2283 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2284 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2285 | u_int32_t refbw; |
| 2286 | listnode node; |
| 2287 | |
| 2288 | refbw = strtol (argv[0], NULL, 10); |
| 2289 | if (refbw < 1 || refbw > 4294967) |
| 2290 | { |
| 2291 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2292 | return CMD_WARNING; |
| 2293 | } |
| 2294 | |
| 2295 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2296 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | return CMD_SUCCESS; |
| 2298 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2299 | ospf->ref_bandwidth = refbw * 1000; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2300 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2301 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2302 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2303 | for (node = listhead (om->iflist); node; nextnode (node)) |
| 2304 | ospf_if_recalculate_output_cost (getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | |
| 2306 | return CMD_SUCCESS; |
| 2307 | } |
| 2308 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 2309 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2310 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | "no auto-cost reference-bandwidth", |
| 2312 | NO_STR |
| 2313 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2314 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2315 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2316 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2317 | listnode node; |
| 2318 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2319 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | return CMD_SUCCESS; |
| 2321 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2322 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2323 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2324 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2325 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2326 | for (node = listhead (om->iflist); node; nextnode (node)) |
| 2327 | ospf_if_recalculate_output_cost (getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | |
| 2329 | return CMD_SUCCESS; |
| 2330 | } |
| 2331 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2332 | char *ospf_abr_type_descr_str[] = |
| 2333 | { |
| 2334 | "Unknown", |
| 2335 | "Standard (RFC2328)", |
| 2336 | "Alternative IBM", |
| 2337 | "Alternative Cisco", |
| 2338 | "Alternative Shortcut" |
| 2339 | }; |
| 2340 | |
| 2341 | char *ospf_shortcut_mode_descr_str[] = |
| 2342 | { |
| 2343 | "Default", |
| 2344 | "Enabled", |
| 2345 | "Disabled" |
| 2346 | }; |
| 2347 | |
| 2348 | |
| 2349 | |
| 2350 | void |
| 2351 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2352 | { |
| 2353 | /* Show Area ID. */ |
| 2354 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2355 | |
| 2356 | /* Show Area type/mode. */ |
| 2357 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2358 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2359 | else |
| 2360 | { |
| 2361 | if (area->external_routing == OSPF_AREA_STUB) |
| 2362 | vty_out (vty, " (Stub%s%s)", |
| 2363 | area->no_summary ? ", no summary" : "", |
| 2364 | area->shortcut_configured ? "; " : ""); |
| 2365 | |
| 2366 | #ifdef HAVE_NSSA |
| 2367 | |
| 2368 | else |
| 2369 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2370 | vty_out (vty, " (NSSA%s%s)", |
| 2371 | area->no_summary ? ", no summary" : "", |
| 2372 | area->shortcut_configured ? "; " : ""); |
| 2373 | #endif /* HAVE_NSSA */ |
| 2374 | |
| 2375 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2376 | vty_out (vty, " Shortcutting mode: %s", |
| 2377 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
| 2378 | vty_out (vty, ", S-bit consensus: %s%s", |
| 2379 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
| 2380 | } |
| 2381 | |
| 2382 | /* Show number of interfaces. */ |
| 2383 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2384 | "Active: %d%s", listcount (area->oiflist), |
| 2385 | area->act_ints, VTY_NEWLINE); |
| 2386 | |
| 2387 | #ifdef HAVE_NSSA |
| 2388 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2389 | { |
| 2390 | 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] | 2391 | if (! IS_OSPF_ABR (area->ospf)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2392 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2393 | VTY_NEWLINE); |
| 2394 | else |
| 2395 | { |
| 2396 | if (area->NSSATranslator) |
| 2397 | vty_out (vty, " We are an ABR and the NSSA Elected Translator. %s", VTY_NEWLINE); |
| 2398 | else |
| 2399 | vty_out (vty, " We are an ABR, but not the NSSA Elected Translator. %s", VTY_NEWLINE); |
| 2400 | } |
| 2401 | } |
| 2402 | #endif /* HAVE_NSSA */ |
| 2403 | |
| 2404 | /* Show number of fully adjacent neighbors. */ |
| 2405 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
| 2406 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
| 2407 | |
| 2408 | /* Show authentication type. */ |
| 2409 | vty_out (vty, " Area has "); |
| 2410 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2411 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2412 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2413 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2414 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2415 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2416 | |
| 2417 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2418 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2419 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2420 | |
| 2421 | /* Show SPF calculation times. */ |
| 2422 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2423 | area->spf_calculation, VTY_NEWLINE); |
| 2424 | |
| 2425 | /* Show number of LSA. */ |
| 2426 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
| 2427 | |
| 2428 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2429 | } |
| 2430 | |
| 2431 | DEFUN (show_ip_ospf, |
| 2432 | show_ip_ospf_cmd, |
| 2433 | "show ip ospf", |
| 2434 | SHOW_STR |
| 2435 | IP_STR |
| 2436 | "OSPF information\n") |
| 2437 | { |
| 2438 | listnode node; |
| 2439 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2440 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2441 | |
| 2442 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2443 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2444 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2445 | { |
| 2446 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2447 | return CMD_SUCCESS; |
| 2448 | } |
| 2449 | |
| 2450 | /* Show Router ID. */ |
| 2451 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2452 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2453 | VTY_NEWLINE); |
| 2454 | |
| 2455 | /* Show capability. */ |
| 2456 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2457 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2458 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2459 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2460 | "enabled" : "disabled", VTY_NEWLINE); |
| 2461 | #ifdef HAVE_OPAQUE_LSA |
| 2462 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2463 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2464 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2465 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2466 | " (origination blocked)" : "", |
| 2467 | VTY_NEWLINE); |
| 2468 | #endif /* HAVE_OPAQUE_LSA */ |
| 2469 | |
| 2470 | /* Show SPF timers. */ |
| 2471 | 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] | 2472 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2473 | |
| 2474 | /* Show refresh parameters. */ |
| 2475 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2476 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2477 | |
| 2478 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2479 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2480 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2481 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2483 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2484 | vty_out (vty, " This router is an ASBR " |
| 2485 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2486 | |
| 2487 | /* Show Number of AS-external-LSAs. */ |
| 2488 | vty_out (vty, " Number of external LSA %ld%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2489 | ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2490 | |
| 2491 | /* Show number of areas attached. */ |
| 2492 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2493 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2494 | |
| 2495 | /* Show each area status. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2496 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2497 | if ((area = getdata (node)) != NULL) |
| 2498 | show_ip_ospf_area (vty, area); |
| 2499 | |
| 2500 | return CMD_SUCCESS; |
| 2501 | } |
| 2502 | |
| 2503 | |
| 2504 | void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2505 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2506 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2507 | { |
| 2508 | struct ospf_neighbor *nbr; |
| 2509 | int oi_count; |
| 2510 | struct route_node *rn; |
| 2511 | char buf[9]; |
| 2512 | |
| 2513 | oi_count = ospf_oi_count (ifp); |
| 2514 | |
| 2515 | /* Is interface up? */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 2516 | if (if_is_operative (ifp)) { |
| 2517 | vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE); |
| 2518 | } else |
| 2519 | { |
| 2520 | vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2521 | |
| 2522 | |
| 2523 | if (oi_count == 0) |
| 2524 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2525 | else |
| 2526 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2527 | VTY_NEWLINE); |
| 2528 | return; |
| 2529 | } |
| 2530 | |
| 2531 | /* Is interface OSPF enabled? */ |
| 2532 | if (oi_count == 0) |
| 2533 | { |
| 2534 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2535 | return; |
| 2536 | } |
| 2537 | |
| 2538 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2539 | { |
| 2540 | struct ospf_interface *oi = rn->info; |
| 2541 | |
| 2542 | if (oi == NULL) |
| 2543 | continue; |
| 2544 | |
| 2545 | /* Show OSPF interface information. */ |
| 2546 | vty_out (vty, " Internet Address %s/%d,", |
| 2547 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2548 | |
| 2549 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2550 | VTY_NEWLINE); |
| 2551 | |
| 2552 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2553 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2554 | oi->output_cost, VTY_NEWLINE); |
| 2555 | |
| 2556 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2557 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2558 | PRIORITY (oi), VTY_NEWLINE); |
| 2559 | |
| 2560 | /* Show DR information. */ |
| 2561 | if (DR (oi).s_addr == 0) |
| 2562 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2563 | else |
| 2564 | { |
| 2565 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2566 | if (nbr == NULL) |
| 2567 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2568 | else |
| 2569 | { |
| 2570 | vty_out (vty, " Designated Router (ID) %s,", |
| 2571 | inet_ntoa (nbr->router_id)); |
| 2572 | vty_out (vty, " Interface Address %s%s", |
| 2573 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2574 | } |
| 2575 | } |
| 2576 | |
| 2577 | /* Show BDR information. */ |
| 2578 | if (BDR (oi).s_addr == 0) |
| 2579 | vty_out (vty, " No backup designated router on this network%s", |
| 2580 | VTY_NEWLINE); |
| 2581 | else |
| 2582 | { |
| 2583 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2584 | if (nbr == NULL) |
| 2585 | vty_out (vty, " No backup designated router on this network%s", |
| 2586 | VTY_NEWLINE); |
| 2587 | else |
| 2588 | { |
| 2589 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2590 | inet_ntoa (nbr->router_id)); |
| 2591 | vty_out (vty, " Interface Address %s%s", |
| 2592 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2593 | } |
| 2594 | } |
| 2595 | vty_out (vty, " Timer intervals configured,"); |
| 2596 | vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s", |
| 2597 | OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait), |
| 2598 | OSPF_IF_PARAM (oi, v_wait), |
| 2599 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2600 | VTY_NEWLINE); |
| 2601 | |
| 2602 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
| 2603 | vty_out (vty, " Hello due in %s%s", |
| 2604 | ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE); |
| 2605 | else /* OSPF_IF_PASSIVE is set */ |
| 2606 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2607 | |
| 2608 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2609 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2610 | VTY_NEWLINE); |
| 2611 | } |
| 2612 | } |
| 2613 | |
| 2614 | DEFUN (show_ip_ospf_interface, |
| 2615 | show_ip_ospf_interface_cmd, |
| 2616 | "show ip ospf interface [INTERFACE]", |
| 2617 | SHOW_STR |
| 2618 | IP_STR |
| 2619 | "OSPF information\n" |
| 2620 | "Interface information\n" |
| 2621 | "Interface name\n") |
| 2622 | { |
| 2623 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2624 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2625 | listnode node; |
| 2626 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2627 | ospf = ospf_lookup (); |
| 2628 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2629 | /* Show All Interfaces. */ |
| 2630 | if (argc == 0) |
| 2631 | for (node = listhead (iflist); node; nextnode (node)) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2632 | show_ip_ospf_interface_sub (vty, ospf, node->data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2633 | /* Interface name is specified. */ |
| 2634 | else |
| 2635 | { |
| 2636 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2637 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2638 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2639 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2640 | } |
| 2641 | |
| 2642 | return CMD_SUCCESS; |
| 2643 | } |
| 2644 | |
| 2645 | void |
| 2646 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2647 | { |
| 2648 | struct route_node *rn; |
| 2649 | struct ospf_neighbor *nbr; |
| 2650 | char msgbuf[16]; |
| 2651 | char timebuf[9]; |
| 2652 | |
| 2653 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2654 | if ((nbr = rn->info)) |
| 2655 | /* Do not show myself. */ |
| 2656 | if (nbr != oi->nbr_self) |
| 2657 | /* Down state is not shown. */ |
| 2658 | if (nbr->state != NSM_Down) |
| 2659 | { |
| 2660 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2661 | |
| 2662 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2663 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2664 | "-", nbr->priority, |
| 2665 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2666 | else |
| 2667 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2668 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2669 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2670 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
| 2671 | vty_out (vty, "%-15s %5ld %5ld %5d%s", |
| 2672 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2673 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2674 | VTY_NEWLINE); |
| 2675 | } |
| 2676 | } |
| 2677 | |
| 2678 | DEFUN (show_ip_ospf_neighbor, |
| 2679 | show_ip_ospf_neighbor_cmd, |
| 2680 | "show ip ospf neighbor", |
| 2681 | SHOW_STR |
| 2682 | IP_STR |
| 2683 | "OSPF information\n" |
| 2684 | "Neighbor list\n") |
| 2685 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2686 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2687 | listnode node; |
| 2688 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2689 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2690 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2691 | { |
| 2692 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2693 | return CMD_SUCCESS; |
| 2694 | } |
| 2695 | |
| 2696 | /* Show All neighbors. */ |
| 2697 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2698 | "Time Address Interface RXmtL " |
| 2699 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2700 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2701 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2702 | show_ip_ospf_neighbor_sub (vty, getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2703 | |
| 2704 | return CMD_SUCCESS; |
| 2705 | } |
| 2706 | |
| 2707 | DEFUN (show_ip_ospf_neighbor_all, |
| 2708 | show_ip_ospf_neighbor_all_cmd, |
| 2709 | "show ip ospf neighbor all", |
| 2710 | SHOW_STR |
| 2711 | IP_STR |
| 2712 | "OSPF information\n" |
| 2713 | "Neighbor list\n" |
| 2714 | "include down status neighbor\n") |
| 2715 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2716 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2717 | listnode node; |
| 2718 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2719 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2720 | { |
| 2721 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2722 | return CMD_SUCCESS; |
| 2723 | } |
| 2724 | |
| 2725 | /* Show All neighbors. */ |
| 2726 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2727 | "Time Address Interface RXmtL " |
| 2728 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2729 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2730 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2731 | { |
| 2732 | struct ospf_interface *oi = getdata (node); |
| 2733 | listnode nbr_node; |
| 2734 | |
| 2735 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2736 | |
| 2737 | /* print Down neighbor status */ |
| 2738 | for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node)) |
| 2739 | { |
| 2740 | struct ospf_nbr_nbma *nbr_nbma; |
| 2741 | |
| 2742 | nbr_nbma = getdata (nbr_node); |
| 2743 | |
| 2744 | if (nbr_nbma->nbr == NULL |
| 2745 | || nbr_nbma->nbr->state == NSM_Down) |
| 2746 | { |
| 2747 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2748 | "-", nbr_nbma->priority, "Down", "-"); |
| 2749 | vty_out (vty, "%-15s %-15s %5d %5d %5d%s", |
| 2750 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 2751 | 0, 0, 0, VTY_NEWLINE); |
| 2752 | } |
| 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | return CMD_SUCCESS; |
| 2757 | } |
| 2758 | |
| 2759 | DEFUN (show_ip_ospf_neighbor_int, |
| 2760 | show_ip_ospf_neighbor_int_cmd, |
| 2761 | "show ip ospf neighbor A.B.C.D", |
| 2762 | SHOW_STR |
| 2763 | IP_STR |
| 2764 | "OSPF information\n" |
| 2765 | "Neighbor list\n" |
| 2766 | "Interface name\n") |
| 2767 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2768 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2769 | struct ospf_interface *oi; |
| 2770 | struct in_addr addr; |
| 2771 | int ret; |
| 2772 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2773 | ret = inet_aton (argv[0], &addr); |
| 2774 | if (!ret) |
| 2775 | { |
| 2776 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 2777 | VTY_NEWLINE); |
| 2778 | return CMD_WARNING; |
| 2779 | } |
| 2780 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2781 | ospf = ospf_lookup (); |
| 2782 | if (ospf == NULL) |
| 2783 | { |
| 2784 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2785 | return CMD_SUCCESS; |
| 2786 | } |
| 2787 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2788 | if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2789 | vty_out (vty, "No such interface address%s", VTY_NEWLINE); |
| 2790 | else |
| 2791 | { |
| 2792 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2793 | "Time Address Interface RXmtL " |
| 2794 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2795 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2796 | } |
| 2797 | |
| 2798 | return CMD_SUCCESS; |
| 2799 | } |
| 2800 | |
| 2801 | void |
| 2802 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2803 | struct ospf_nbr_nbma *nbr_nbma) |
| 2804 | { |
| 2805 | char timebuf[9]; |
| 2806 | |
| 2807 | /* Show neighbor ID. */ |
| 2808 | vty_out (vty, " Neighbor %s,", "-"); |
| 2809 | |
| 2810 | /* Show interface address. */ |
| 2811 | vty_out (vty, " interface address %s%s", |
| 2812 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 2813 | /* Show Area ID. */ |
| 2814 | vty_out (vty, " In the area %s via interface %s%s", |
| 2815 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 2816 | /* Show neighbor priority and state. */ |
| 2817 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2818 | nbr_nbma->priority, "Down"); |
| 2819 | /* Show state changes. */ |
| 2820 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 2821 | |
| 2822 | /* Show PollInterval */ |
| 2823 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 2824 | |
| 2825 | /* Show poll-interval timer. */ |
| 2826 | vty_out (vty, " Poll timer due in %s%s", |
| 2827 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE); |
| 2828 | |
| 2829 | /* Show poll-interval timer thread. */ |
| 2830 | vty_out (vty, " Thread Poll Timer %s%s", |
| 2831 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 2832 | } |
| 2833 | |
| 2834 | void |
| 2835 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2836 | struct ospf_neighbor *nbr) |
| 2837 | { |
| 2838 | char timebuf[9]; |
| 2839 | |
| 2840 | /* Show neighbor ID. */ |
| 2841 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2842 | vty_out (vty, " Neighbor %s,", "-"); |
| 2843 | else |
| 2844 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 2845 | |
| 2846 | /* Show interface address. */ |
| 2847 | vty_out (vty, " interface address %s%s", |
| 2848 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2849 | /* Show Area ID. */ |
| 2850 | vty_out (vty, " In the area %s via interface %s%s", |
| 2851 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 2852 | /* Show neighbor priority and state. */ |
| 2853 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2854 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 2855 | /* Show state changes. */ |
| 2856 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 2857 | |
| 2858 | /* Show Designated Rotuer ID. */ |
| 2859 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 2860 | /* Show Backup Designated Rotuer ID. */ |
| 2861 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 2862 | /* Show options. */ |
| 2863 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 2864 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 2865 | /* Show Router Dead interval timer. */ |
| 2866 | vty_out (vty, " Dead timer due in %s%s", |
| 2867 | ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE); |
| 2868 | /* Show Database Summary list. */ |
| 2869 | vty_out (vty, " Database Summary List %d%s", |
| 2870 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 2871 | /* Show Link State Request list. */ |
| 2872 | vty_out (vty, " Link State Request List %ld%s", |
| 2873 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 2874 | /* Show Link State Retransmission list. */ |
| 2875 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 2876 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 2877 | /* Show inactivity timer thread. */ |
| 2878 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 2879 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 2880 | /* Show Database Description retransmission thread. */ |
| 2881 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 2882 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 2883 | /* Show Link State Request Retransmission thread. */ |
| 2884 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 2885 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 2886 | /* Show Link State Update Retransmission thread. */ |
| 2887 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 2888 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 2889 | } |
| 2890 | |
| 2891 | DEFUN (show_ip_ospf_neighbor_id, |
| 2892 | show_ip_ospf_neighbor_id_cmd, |
| 2893 | "show ip ospf neighbor A.B.C.D", |
| 2894 | SHOW_STR |
| 2895 | IP_STR |
| 2896 | "OSPF information\n" |
| 2897 | "Neighbor list\n" |
| 2898 | "Neighbor ID\n") |
| 2899 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2900 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2901 | listnode node; |
| 2902 | struct ospf_neighbor *nbr; |
| 2903 | struct in_addr router_id; |
| 2904 | int ret; |
| 2905 | |
| 2906 | ret = inet_aton (argv[0], &router_id); |
| 2907 | if (!ret) |
| 2908 | { |
| 2909 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 2910 | return CMD_WARNING; |
| 2911 | } |
| 2912 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2913 | ospf = ospf_lookup (); |
| 2914 | if (ospf == NULL) |
| 2915 | { |
| 2916 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2917 | return CMD_SUCCESS; |
| 2918 | } |
| 2919 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2920 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2921 | { |
| 2922 | struct ospf_interface *oi = getdata (node); |
| 2923 | |
| 2924 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 2925 | { |
| 2926 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 2927 | return CMD_SUCCESS; |
| 2928 | } |
| 2929 | } |
| 2930 | |
| 2931 | /* Nothing to show. */ |
| 2932 | return CMD_SUCCESS; |
| 2933 | } |
| 2934 | |
| 2935 | DEFUN (show_ip_ospf_neighbor_detail, |
| 2936 | show_ip_ospf_neighbor_detail_cmd, |
| 2937 | "show ip ospf neighbor detail", |
| 2938 | SHOW_STR |
| 2939 | IP_STR |
| 2940 | "OSPF information\n" |
| 2941 | "Neighbor list\n" |
| 2942 | "detail of all neighbors\n") |
| 2943 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2944 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2945 | listnode node; |
| 2946 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2947 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2948 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2949 | { |
| 2950 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2951 | return CMD_SUCCESS; |
| 2952 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2953 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2954 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2955 | { |
| 2956 | struct ospf_interface *oi = getdata (node); |
| 2957 | struct route_node *rn; |
| 2958 | struct ospf_neighbor *nbr; |
| 2959 | |
| 2960 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2961 | if ((nbr = rn->info)) |
| 2962 | if (nbr != oi->nbr_self) |
| 2963 | if (nbr->state != NSM_Down) |
| 2964 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 2965 | } |
| 2966 | |
| 2967 | return CMD_SUCCESS; |
| 2968 | } |
| 2969 | |
| 2970 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 2971 | show_ip_ospf_neighbor_detail_all_cmd, |
| 2972 | "show ip ospf neighbor detail all", |
| 2973 | SHOW_STR |
| 2974 | IP_STR |
| 2975 | "OSPF information\n" |
| 2976 | "Neighbor list\n" |
| 2977 | "detail of all neighbors\n" |
| 2978 | "include down status neighbor\n") |
| 2979 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2980 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2981 | listnode node; |
| 2982 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2983 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2984 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2985 | { |
| 2986 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2987 | return CMD_SUCCESS; |
| 2988 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2989 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2990 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2991 | { |
| 2992 | struct ospf_interface *oi = getdata (node); |
| 2993 | struct route_node *rn; |
| 2994 | struct ospf_neighbor *nbr; |
| 2995 | |
| 2996 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2997 | if ((nbr = rn->info)) |
| 2998 | if (nbr != oi->nbr_self) |
| 2999 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3000 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3001 | |
| 3002 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3003 | { |
| 3004 | listnode nd; |
| 3005 | |
| 3006 | for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd)) |
| 3007 | { |
| 3008 | struct ospf_nbr_nbma *nbr_nbma = getdata (nd); |
| 3009 | if (nbr_nbma->nbr == NULL |
| 3010 | || nbr_nbma->nbr->state == NSM_Down) |
| 3011 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
| 3012 | } |
| 3013 | } |
| 3014 | } |
| 3015 | |
| 3016 | return CMD_SUCCESS; |
| 3017 | } |
| 3018 | |
| 3019 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3020 | show_ip_ospf_neighbor_int_detail_cmd, |
| 3021 | "show ip ospf neighbor A.B.C.D detail", |
| 3022 | SHOW_STR |
| 3023 | IP_STR |
| 3024 | "OSPF information\n" |
| 3025 | "Neighbor list\n" |
| 3026 | "Interface address\n" |
| 3027 | "detail of all neighbors") |
| 3028 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3029 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3030 | struct ospf_interface *oi; |
| 3031 | struct in_addr addr; |
| 3032 | int ret; |
| 3033 | |
| 3034 | ret = inet_aton (argv[0], &addr); |
| 3035 | if (!ret) |
| 3036 | { |
| 3037 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 3038 | VTY_NEWLINE); |
| 3039 | return CMD_WARNING; |
| 3040 | } |
| 3041 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3042 | ospf = ospf_lookup (); |
| 3043 | if (ospf == NULL) |
| 3044 | { |
| 3045 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3046 | return CMD_SUCCESS; |
| 3047 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3048 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3049 | if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3050 | vty_out (vty, "No such interface address%s", VTY_NEWLINE); |
| 3051 | else |
| 3052 | { |
| 3053 | struct route_node *rn; |
| 3054 | struct ospf_neighbor *nbr; |
| 3055 | |
| 3056 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3057 | if ((nbr = rn->info)) |
| 3058 | if (nbr != oi->nbr_self) |
| 3059 | if (nbr->state != NSM_Down) |
| 3060 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3061 | } |
| 3062 | |
| 3063 | return CMD_SUCCESS; |
| 3064 | } |
| 3065 | |
| 3066 | |
| 3067 | /* Show functions */ |
| 3068 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3069 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3070 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3071 | struct router_lsa *rl; |
| 3072 | struct summary_lsa *sl; |
| 3073 | struct as_external_lsa *asel; |
| 3074 | struct prefix_ipv4 p; |
| 3075 | |
| 3076 | if (lsa != NULL) |
| 3077 | /* If self option is set, check LSA self flag. */ |
| 3078 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3079 | { |
| 3080 | /* LSA common part show. */ |
| 3081 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3082 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3083 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3084 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3085 | /* LSA specific part show. */ |
| 3086 | switch (lsa->data->type) |
| 3087 | { |
| 3088 | case OSPF_ROUTER_LSA: |
| 3089 | rl = (struct router_lsa *) lsa->data; |
| 3090 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3091 | break; |
| 3092 | case OSPF_SUMMARY_LSA: |
| 3093 | sl = (struct summary_lsa *) lsa->data; |
| 3094 | |
| 3095 | p.family = AF_INET; |
| 3096 | p.prefix = sl->header.id; |
| 3097 | p.prefixlen = ip_masklen (sl->mask); |
| 3098 | apply_mask_ipv4 (&p); |
| 3099 | |
| 3100 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3101 | break; |
| 3102 | case OSPF_AS_EXTERNAL_LSA: |
| 3103 | asel = (struct as_external_lsa *) lsa->data; |
| 3104 | |
| 3105 | p.family = AF_INET; |
| 3106 | p.prefix = asel->header.id; |
| 3107 | p.prefixlen = ip_masklen (asel->mask); |
| 3108 | apply_mask_ipv4 (&p); |
| 3109 | |
| 3110 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3111 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3112 | inet_ntoa (p.prefix), p.prefixlen, |
| 3113 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3114 | break; |
| 3115 | case OSPF_NETWORK_LSA: |
| 3116 | case OSPF_ASBR_SUMMARY_LSA: |
| 3117 | #ifdef HAVE_OPAQUE_LSA |
| 3118 | case OSPF_OPAQUE_LINK_LSA: |
| 3119 | case OSPF_OPAQUE_AREA_LSA: |
| 3120 | case OSPF_OPAQUE_AS_LSA: |
| 3121 | #endif /* HAVE_OPAQUE_LSA */ |
| 3122 | default: |
| 3123 | break; |
| 3124 | } |
| 3125 | vty_out (vty, VTY_NEWLINE); |
| 3126 | } |
| 3127 | |
| 3128 | return 0; |
| 3129 | } |
| 3130 | |
| 3131 | char *show_database_desc[] = |
| 3132 | { |
| 3133 | "unknown", |
| 3134 | "Router Link States", |
| 3135 | "Net Link States", |
| 3136 | "Summary Link States", |
| 3137 | "ASBR-Summary Link States", |
| 3138 | "AS External Link States", |
| 3139 | #if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA) |
| 3140 | "Group Membership LSA", |
| 3141 | "NSSA-external Link States", |
| 3142 | #endif /* HAVE_NSSA */ |
| 3143 | #ifdef HAVE_OPAQUE_LSA |
| 3144 | "Type-8 LSA", |
| 3145 | "Link-Local Opaque-LSA", |
| 3146 | "Area-Local Opaque-LSA", |
| 3147 | "AS-external Opaque-LSA", |
| 3148 | #endif /* HAVE_OPAQUE_LSA */ |
| 3149 | }; |
| 3150 | |
| 3151 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3152 | "Link ID ADV Router Age Seq# CkSum" |
| 3153 | |
| 3154 | char *show_database_header[] = |
| 3155 | { |
| 3156 | "", |
| 3157 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3158 | "Link ID ADV Router Age Seq# CkSum", |
| 3159 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3160 | "Link ID ADV Router Age Seq# CkSum", |
| 3161 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3162 | #ifdef HAVE_NSSA |
| 3163 | " --- header for Group Member ----", |
| 3164 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3165 | #endif /* HAVE_NSSA */ |
| 3166 | #ifdef HAVE_OPAQUE_LSA |
| 3167 | #ifndef HAVE_NSSA |
| 3168 | " --- type-6 ---", |
| 3169 | " --- type-7 ---", |
| 3170 | #endif /* HAVE_NSSA */ |
| 3171 | " --- type-8 ---", |
| 3172 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3173 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3174 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3175 | #endif /* HAVE_OPAQUE_LSA */ |
| 3176 | }; |
| 3177 | |
| 3178 | void |
| 3179 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3180 | { |
| 3181 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
| 3182 | |
| 3183 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
| 3184 | vty_out (vty, " Options: %d%s", lsa->data->options, VTY_NEWLINE); |
| 3185 | |
| 3186 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3187 | { |
| 3188 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3189 | |
| 3190 | if (rlsa->flags) |
| 3191 | vty_out (vty, " :%s%s%s%s", |
| 3192 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3193 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3194 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3195 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3196 | |
| 3197 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3198 | } |
| 3199 | vty_out (vty, " LS Type: %s%s", |
| 3200 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3201 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3202 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3203 | vty_out (vty, " Advertising Router: %s%s", |
| 3204 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3205 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3206 | VTY_NEWLINE); |
| 3207 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3208 | VTY_NEWLINE); |
| 3209 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3210 | } |
| 3211 | |
| 3212 | char *link_type_desc[] = |
| 3213 | { |
| 3214 | "(null)", |
| 3215 | "another Router (point-to-point)", |
| 3216 | "a Transit Network", |
| 3217 | "Stub Network", |
| 3218 | "a Virtual Link", |
| 3219 | }; |
| 3220 | |
| 3221 | char *link_id_desc[] = |
| 3222 | { |
| 3223 | "(null)", |
| 3224 | "Neighboring Router ID", |
| 3225 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3226 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3227 | "Neighboring Router ID", |
| 3228 | }; |
| 3229 | |
| 3230 | char *link_data_desc[] = |
| 3231 | { |
| 3232 | "(null)", |
| 3233 | "Router Interface address", |
| 3234 | "Router Interface address", |
| 3235 | "Network Mask", |
| 3236 | "Router Interface address", |
| 3237 | }; |
| 3238 | |
| 3239 | /* Show router-LSA each Link information. */ |
| 3240 | void |
| 3241 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3242 | struct router_lsa *rl) |
| 3243 | { |
| 3244 | int len, i, type; |
| 3245 | |
| 3246 | len = ntohs (rl->header.length) - 4; |
| 3247 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3248 | { |
| 3249 | type = rl->link[i].type; |
| 3250 | |
| 3251 | vty_out (vty, " Link connected to: %s%s", |
| 3252 | link_type_desc[type], VTY_NEWLINE); |
| 3253 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3254 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3255 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3256 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3257 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3258 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3259 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3260 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3261 | } |
| 3262 | } |
| 3263 | |
| 3264 | /* Show router-LSA detail information. */ |
| 3265 | int |
| 3266 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3267 | { |
| 3268 | if (lsa != NULL) |
| 3269 | { |
| 3270 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3271 | |
| 3272 | show_ip_ospf_database_header (vty, lsa); |
| 3273 | |
| 3274 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3275 | VTY_NEWLINE, VTY_NEWLINE); |
| 3276 | |
| 3277 | show_ip_ospf_database_router_links (vty, rl); |
| 3278 | } |
| 3279 | |
| 3280 | return 0; |
| 3281 | } |
| 3282 | |
| 3283 | /* Show network-LSA detail information. */ |
| 3284 | int |
| 3285 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3286 | { |
| 3287 | int length, i; |
| 3288 | |
| 3289 | if (lsa != NULL) |
| 3290 | { |
| 3291 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3292 | |
| 3293 | show_ip_ospf_database_header (vty, lsa); |
| 3294 | |
| 3295 | vty_out (vty, " Network Mask: /%d%s", |
| 3296 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3297 | |
| 3298 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3299 | |
| 3300 | for (i = 0; length > 0; i++, length -= 4) |
| 3301 | vty_out (vty, " Attached Router: %s%s", |
| 3302 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3303 | |
| 3304 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3305 | } |
| 3306 | |
| 3307 | return 0; |
| 3308 | } |
| 3309 | |
| 3310 | /* Show summary-LSA detail information. */ |
| 3311 | int |
| 3312 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3313 | { |
| 3314 | if (lsa != NULL) |
| 3315 | { |
| 3316 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3317 | |
| 3318 | show_ip_ospf_database_header (vty, lsa); |
| 3319 | |
| 3320 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3321 | VTY_NEWLINE); |
| 3322 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3323 | VTY_NEWLINE); |
| 3324 | } |
| 3325 | |
| 3326 | return 0; |
| 3327 | } |
| 3328 | |
| 3329 | /* Show summary-ASBR-LSA detail information. */ |
| 3330 | int |
| 3331 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3332 | { |
| 3333 | if (lsa != NULL) |
| 3334 | { |
| 3335 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3336 | |
| 3337 | show_ip_ospf_database_header (vty, lsa); |
| 3338 | |
| 3339 | vty_out (vty, " Network Mask: /%d%s", |
| 3340 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3341 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3342 | VTY_NEWLINE); |
| 3343 | } |
| 3344 | |
| 3345 | return 0; |
| 3346 | } |
| 3347 | |
| 3348 | /* Show AS-external-LSA detail information. */ |
| 3349 | int |
| 3350 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3351 | { |
| 3352 | if (lsa != NULL) |
| 3353 | { |
| 3354 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3355 | |
| 3356 | show_ip_ospf_database_header (vty, lsa); |
| 3357 | |
| 3358 | vty_out (vty, " Network Mask: /%d%s", |
| 3359 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3360 | vty_out (vty, " Metric Type: %s%s", |
| 3361 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3362 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3363 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3364 | vty_out (vty, " Metric: %d%s", |
| 3365 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3366 | vty_out (vty, " Forward Address: %s%s", |
| 3367 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3368 | |
| 3369 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3370 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3371 | } |
| 3372 | |
| 3373 | return 0; |
| 3374 | } |
| 3375 | |
| 3376 | #ifdef HAVE_NSSA |
| 3377 | int |
| 3378 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3379 | { |
| 3380 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3381 | |
| 3382 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3383 | |
| 3384 | zlog_info( " Network Mask: /%d%s", |
| 3385 | ip_masklen (al->mask), "\n"); |
| 3386 | zlog_info( " Metric Type: %s%s", |
| 3387 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3388 | "2 (Larger than any link state path)" : "1", "\n"); |
| 3389 | zlog_info( " TOS: 0%s", "\n"); |
| 3390 | zlog_info( " Metric: %d%s", |
| 3391 | GET_METRIC (al->e[0].metric), "\n"); |
| 3392 | zlog_info( " Forward Address: %s%s", |
| 3393 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3394 | |
| 3395 | zlog_info( " External Route Tag: %u%s%s", |
| 3396 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3397 | |
| 3398 | return 0; |
| 3399 | } |
| 3400 | |
| 3401 | /* Show AS-NSSA-LSA detail information. */ |
| 3402 | int |
| 3403 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3404 | { |
| 3405 | if (lsa != NULL) |
| 3406 | { |
| 3407 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3408 | |
| 3409 | show_ip_ospf_database_header (vty, lsa); |
| 3410 | |
| 3411 | vty_out (vty, " Network Mask: /%d%s", |
| 3412 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3413 | vty_out (vty, " Metric Type: %s%s", |
| 3414 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3415 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3416 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3417 | vty_out (vty, " Metric: %d%s", |
| 3418 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3419 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3420 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3421 | |
| 3422 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3423 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3424 | } |
| 3425 | |
| 3426 | return 0; |
| 3427 | } |
| 3428 | |
| 3429 | #endif /* HAVE_NSSA */ |
| 3430 | |
| 3431 | int |
| 3432 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3433 | { |
| 3434 | return 0; |
| 3435 | } |
| 3436 | |
| 3437 | #ifdef HAVE_OPAQUE_LSA |
| 3438 | int |
| 3439 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3440 | { |
| 3441 | if (lsa != NULL) |
| 3442 | { |
| 3443 | show_ip_ospf_database_header (vty, lsa); |
| 3444 | show_opaque_info_detail (vty, lsa); |
| 3445 | |
| 3446 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3447 | } |
| 3448 | return 0; |
| 3449 | } |
| 3450 | #endif /* HAVE_OPAQUE_LSA */ |
| 3451 | |
| 3452 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3453 | { |
| 3454 | NULL, |
| 3455 | show_router_lsa_detail, |
| 3456 | show_network_lsa_detail, |
| 3457 | show_summary_lsa_detail, |
| 3458 | show_summary_asbr_lsa_detail, |
| 3459 | show_as_external_lsa_detail, |
| 3460 | #ifdef HAVE_NSSA |
| 3461 | show_func_dummy, |
| 3462 | show_as_nssa_lsa_detail, /* almost same as external */ |
| 3463 | #endif /* HAVE_NSSA */ |
| 3464 | #ifdef HAVE_OPAQUE_LSA |
| 3465 | #ifndef HAVE_NSSA |
| 3466 | show_func_dummy, |
| 3467 | show_func_dummy, |
| 3468 | #endif /* HAVE_NSSA */ |
| 3469 | NULL, /* type-8 */ |
| 3470 | show_opaque_lsa_detail, |
| 3471 | show_opaque_lsa_detail, |
| 3472 | show_opaque_lsa_detail, |
| 3473 | #endif /* HAVE_OPAQUE_LSA */ |
| 3474 | }; |
| 3475 | |
| 3476 | void |
| 3477 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3478 | struct in_addr *adv_router) |
| 3479 | { |
| 3480 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3481 | lp->family = 0; |
| 3482 | if (id == NULL) |
| 3483 | lp->prefixlen = 0; |
| 3484 | else if (adv_router == NULL) |
| 3485 | { |
| 3486 | lp->prefixlen = 32; |
| 3487 | lp->id = *id; |
| 3488 | } |
| 3489 | else |
| 3490 | { |
| 3491 | lp->prefixlen = 64; |
| 3492 | lp->id = *id; |
| 3493 | lp->adv_router = *adv_router; |
| 3494 | } |
| 3495 | } |
| 3496 | |
| 3497 | void |
| 3498 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3499 | struct in_addr *id, struct in_addr *adv_router) |
| 3500 | { |
| 3501 | struct prefix_ls lp; |
| 3502 | struct route_node *rn, *start; |
| 3503 | struct ospf_lsa *lsa; |
| 3504 | |
| 3505 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3506 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3507 | if (start) |
| 3508 | { |
| 3509 | route_lock_node (start); |
| 3510 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3511 | if ((lsa = rn->info)) |
| 3512 | { |
| 3513 | #ifdef HAVE_NSSA |
| 3514 | /* Stay away from any Local Translated Type-7 LSAs */ |
| 3515 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3516 | continue; |
| 3517 | #endif /* HAVE_NSSA */ |
| 3518 | |
| 3519 | if (show_function[lsa->data->type] != NULL) |
| 3520 | show_function[lsa->data->type] (vty, lsa); |
| 3521 | } |
| 3522 | route_unlock_node (start); |
| 3523 | } |
| 3524 | } |
| 3525 | |
| 3526 | /* Show detail LSA information |
| 3527 | -- if id is NULL then show all LSAs. */ |
| 3528 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3529 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3530 | struct in_addr *id, struct in_addr *adv_router) |
| 3531 | { |
| 3532 | listnode node; |
| 3533 | |
| 3534 | switch (type) |
| 3535 | { |
| 3536 | case OSPF_AS_EXTERNAL_LSA: |
| 3537 | #ifdef HAVE_OPAQUE_LSA |
| 3538 | case OSPF_OPAQUE_AS_LSA: |
| 3539 | #endif /* HAVE_OPAQUE_LSA */ |
| 3540 | vty_out (vty, " %s %s%s", |
| 3541 | show_database_desc[type], |
| 3542 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3543 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3544 | break; |
| 3545 | default: |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3546 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3547 | { |
| 3548 | struct ospf_area *area = node->data; |
| 3549 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3550 | VTY_NEWLINE, show_database_desc[type], |
| 3551 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3552 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3553 | } |
| 3554 | break; |
| 3555 | } |
| 3556 | } |
| 3557 | |
| 3558 | void |
| 3559 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3560 | struct in_addr *adv_router) |
| 3561 | { |
| 3562 | struct route_node *rn; |
| 3563 | struct ospf_lsa *lsa; |
| 3564 | |
| 3565 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3566 | if ((lsa = rn->info)) |
| 3567 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3568 | { |
| 3569 | #ifdef HAVE_NSSA |
| 3570 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3571 | continue; |
| 3572 | #endif /* HAVE_NSSA */ |
| 3573 | if (show_function[lsa->data->type] != NULL) |
| 3574 | show_function[lsa->data->type] (vty, lsa); |
| 3575 | } |
| 3576 | } |
| 3577 | |
| 3578 | /* Show detail LSA information. */ |
| 3579 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3580 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3581 | struct in_addr *adv_router) |
| 3582 | { |
| 3583 | listnode node; |
| 3584 | |
| 3585 | switch (type) |
| 3586 | { |
| 3587 | case OSPF_AS_EXTERNAL_LSA: |
| 3588 | #ifdef HAVE_OPAQUE_LSA |
| 3589 | case OSPF_OPAQUE_AS_LSA: |
| 3590 | #endif /* HAVE_OPAQUE_LSA */ |
| 3591 | vty_out (vty, " %s %s%s", |
| 3592 | show_database_desc[type], |
| 3593 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3594 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3595 | adv_router); |
| 3596 | break; |
| 3597 | default: |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3598 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3599 | { |
| 3600 | struct ospf_area *area = node->data; |
| 3601 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3602 | VTY_NEWLINE, show_database_desc[type], |
| 3603 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3604 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3605 | adv_router); |
| 3606 | } |
| 3607 | break; |
| 3608 | } |
| 3609 | } |
| 3610 | |
| 3611 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3612 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3613 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3614 | struct ospf_lsa *lsa; |
| 3615 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3616 | listnode node; |
| 3617 | int type; |
| 3618 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3619 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3620 | { |
| 3621 | struct ospf_area *area = node->data; |
| 3622 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3623 | { |
| 3624 | switch (type) |
| 3625 | { |
| 3626 | case OSPF_AS_EXTERNAL_LSA: |
| 3627 | #ifdef HAVE_OPAQUE_LSA |
| 3628 | case OSPF_OPAQUE_AS_LSA: |
| 3629 | #endif /* HAVE_OPAQUE_LSA */ |
| 3630 | continue; |
| 3631 | default: |
| 3632 | break; |
| 3633 | } |
| 3634 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3635 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3636 | { |
| 3637 | vty_out (vty, " %s (Area %s)%s%s", |
| 3638 | show_database_desc[type], |
| 3639 | ospf_area_desc_string (area), |
| 3640 | VTY_NEWLINE, VTY_NEWLINE); |
| 3641 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3642 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3643 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3644 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3645 | |
| 3646 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3647 | } |
| 3648 | } |
| 3649 | } |
| 3650 | |
| 3651 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3652 | { |
| 3653 | switch (type) |
| 3654 | { |
| 3655 | case OSPF_AS_EXTERNAL_LSA: |
| 3656 | #ifdef HAVE_OPAQUE_LSA |
| 3657 | case OSPF_OPAQUE_AS_LSA: |
| 3658 | #endif /* HAVE_OPAQUE_LSA */ |
| 3659 | break;; |
| 3660 | default: |
| 3661 | continue; |
| 3662 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3663 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3664 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3665 | { |
| 3666 | vty_out (vty, " %s%s%s", |
| 3667 | show_database_desc[type], |
| 3668 | VTY_NEWLINE, VTY_NEWLINE); |
| 3669 | vty_out (vty, "%s%s", show_database_header[type], |
| 3670 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3671 | |
| 3672 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3673 | show_lsa_summary (vty, lsa, self); |
| 3674 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3675 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3676 | } |
| 3677 | } |
| 3678 | |
| 3679 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3680 | } |
| 3681 | |
| 3682 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3683 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3684 | { |
| 3685 | listnode node; |
| 3686 | struct ospf_lsa *lsa; |
| 3687 | |
| 3688 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3689 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3690 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3691 | for (node = listhead (ospf->maxage_lsa); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3692 | if ((lsa = node->data) != NULL) |
| 3693 | { |
| 3694 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3695 | vty_out (vty, "Link State ID: %s%s", |
| 3696 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3697 | vty_out (vty, "Advertising Router: %s%s", |
| 3698 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3699 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3700 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3701 | } |
| 3702 | } |
| 3703 | |
| 3704 | #ifdef HAVE_NSSA |
| 3705 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3706 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
| 3707 | #else /* HAVE_NSSA */ |
| 3708 | #define OSPF_LSA_TYPE_NSSA_DESC "" |
| 3709 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "" |
| 3710 | #endif /* HAVE_NSSA */ |
| 3711 | |
| 3712 | #ifdef HAVE_OPAQUE_LSA |
| 3713 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3714 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3715 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3716 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3717 | #else /* HAVE_OPAQUE_LSA */ |
| 3718 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3719 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3720 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3721 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3722 | #endif /* HAVE_OPAQUE_LSA */ |
| 3723 | |
| 3724 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3725 | "asbr-summary|external|network|router|summary" \ |
| 3726 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3727 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3728 | |
| 3729 | #define OSPF_LSA_TYPES_DESC \ |
| 3730 | "ASBR summary link states\n" \ |
| 3731 | "External link states\n" \ |
| 3732 | "Network link states\n" \ |
| 3733 | "Router link states\n" \ |
| 3734 | "Network summary link states\n" \ |
| 3735 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3736 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3737 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3738 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3739 | |
| 3740 | DEFUN (show_ip_ospf_database, |
| 3741 | show_ip_ospf_database_cmd, |
| 3742 | "show ip ospf database", |
| 3743 | SHOW_STR |
| 3744 | IP_STR |
| 3745 | "OSPF information\n" |
| 3746 | "Database summary\n") |
| 3747 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3748 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3749 | int type, ret; |
| 3750 | struct in_addr id, adv_router; |
| 3751 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3752 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3753 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3754 | return CMD_SUCCESS; |
| 3755 | |
| 3756 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3757 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3758 | |
| 3759 | /* Show all LSA. */ |
| 3760 | if (argc == 0) |
| 3761 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3762 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3763 | return CMD_SUCCESS; |
| 3764 | } |
| 3765 | |
| 3766 | /* Set database type to show. */ |
| 3767 | if (strncmp (argv[0], "r", 1) == 0) |
| 3768 | type = OSPF_ROUTER_LSA; |
| 3769 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3770 | type = OSPF_NETWORK_LSA; |
| 3771 | #ifdef HAVE_NSSA |
| 3772 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3773 | type = OSPF_AS_NSSA_LSA; |
| 3774 | #endif /* HAVE_NSSA */ |
| 3775 | else if (strncmp (argv[0], "su", 2) == 0) |
| 3776 | type = OSPF_SUMMARY_LSA; |
| 3777 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3778 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3779 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3780 | type = OSPF_AS_EXTERNAL_LSA; |
| 3781 | else if (strncmp (argv[0], "se", 2) == 0) |
| 3782 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3783 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3784 | return CMD_SUCCESS; |
| 3785 | } |
| 3786 | else if (strncmp (argv[0], "m", 1) == 0) |
| 3787 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3788 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3789 | return CMD_SUCCESS; |
| 3790 | } |
| 3791 | #ifdef HAVE_OPAQUE_LSA |
| 3792 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3793 | type = OSPF_OPAQUE_LINK_LSA; |
| 3794 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3795 | type = OSPF_OPAQUE_AREA_LSA; |
| 3796 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3797 | type = OSPF_OPAQUE_AS_LSA; |
| 3798 | #endif /* HAVE_OPAQUE_LSA */ |
| 3799 | else |
| 3800 | return CMD_WARNING; |
| 3801 | |
| 3802 | /* `show ip ospf database LSA'. */ |
| 3803 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3804 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3805 | else if (argc >= 2) |
| 3806 | { |
| 3807 | ret = inet_aton (argv[1], &id); |
| 3808 | if (!ret) |
| 3809 | return CMD_WARNING; |
| 3810 | |
| 3811 | /* `show ip ospf database LSA ID'. */ |
| 3812 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3813 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3814 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 3815 | else if (argc == 3) |
| 3816 | { |
| 3817 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3818 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3819 | else |
| 3820 | { |
| 3821 | ret = inet_aton (argv[2], &adv_router); |
| 3822 | if (!ret) |
| 3823 | return CMD_WARNING; |
| 3824 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3825 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3826 | } |
| 3827 | } |
| 3828 | |
| 3829 | return CMD_SUCCESS; |
| 3830 | } |
| 3831 | |
| 3832 | ALIAS (show_ip_ospf_database, |
| 3833 | show_ip_ospf_database_type_cmd, |
| 3834 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 3835 | SHOW_STR |
| 3836 | IP_STR |
| 3837 | "OSPF information\n" |
| 3838 | "Database summary\n" |
| 3839 | OSPF_LSA_TYPES_DESC |
| 3840 | "LSAs in MaxAge list\n" |
| 3841 | "Self-originated link states\n") |
| 3842 | |
| 3843 | ALIAS (show_ip_ospf_database, |
| 3844 | show_ip_ospf_database_type_id_cmd, |
| 3845 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 3846 | SHOW_STR |
| 3847 | IP_STR |
| 3848 | "OSPF information\n" |
| 3849 | "Database summary\n" |
| 3850 | OSPF_LSA_TYPES_DESC |
| 3851 | "Link State ID (as an IP address)\n") |
| 3852 | |
| 3853 | ALIAS (show_ip_ospf_database, |
| 3854 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 3855 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 3856 | SHOW_STR |
| 3857 | IP_STR |
| 3858 | "OSPF information\n" |
| 3859 | "Database summary\n" |
| 3860 | OSPF_LSA_TYPES_DESC |
| 3861 | "Link State ID (as an IP address)\n" |
| 3862 | "Advertising Router link states\n" |
| 3863 | "Advertising Router (as an IP address)\n") |
| 3864 | |
| 3865 | ALIAS (show_ip_ospf_database, |
| 3866 | show_ip_ospf_database_type_id_self_cmd, |
| 3867 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 3868 | SHOW_STR |
| 3869 | IP_STR |
| 3870 | "OSPF information\n" |
| 3871 | "Database summary\n" |
| 3872 | OSPF_LSA_TYPES_DESC |
| 3873 | "Link State ID (as an IP address)\n" |
| 3874 | "Self-originated link states\n" |
| 3875 | "\n") |
| 3876 | |
| 3877 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 3878 | show_ip_ospf_database_type_adv_router_cmd, |
| 3879 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 3880 | SHOW_STR |
| 3881 | IP_STR |
| 3882 | "OSPF information\n" |
| 3883 | "Database summary\n" |
| 3884 | OSPF_LSA_TYPES_DESC |
| 3885 | "Advertising Router link states\n" |
| 3886 | "Advertising Router (as an IP address)\n") |
| 3887 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3888 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3889 | int type, ret; |
| 3890 | struct in_addr adv_router; |
| 3891 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3892 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3893 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3894 | return CMD_SUCCESS; |
| 3895 | |
| 3896 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3897 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3898 | |
| 3899 | if (argc != 2) |
| 3900 | return CMD_WARNING; |
| 3901 | |
| 3902 | /* Set database type to show. */ |
| 3903 | if (strncmp (argv[0], "r", 1) == 0) |
| 3904 | type = OSPF_ROUTER_LSA; |
| 3905 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3906 | type = OSPF_NETWORK_LSA; |
| 3907 | #ifdef HAVE_NSSA |
| 3908 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3909 | type = OSPF_AS_NSSA_LSA; |
| 3910 | #endif /* HAVE_NSSA */ |
| 3911 | else if (strncmp (argv[0], "s", 1) == 0) |
| 3912 | type = OSPF_SUMMARY_LSA; |
| 3913 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3914 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3915 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3916 | type = OSPF_AS_EXTERNAL_LSA; |
| 3917 | #ifdef HAVE_OPAQUE_LSA |
| 3918 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3919 | type = OSPF_OPAQUE_LINK_LSA; |
| 3920 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3921 | type = OSPF_OPAQUE_AREA_LSA; |
| 3922 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3923 | type = OSPF_OPAQUE_AS_LSA; |
| 3924 | #endif /* HAVE_OPAQUE_LSA */ |
| 3925 | else |
| 3926 | return CMD_WARNING; |
| 3927 | |
| 3928 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 3929 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3930 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3931 | else |
| 3932 | { |
| 3933 | ret = inet_aton (argv[1], &adv_router); |
| 3934 | if (!ret) |
| 3935 | return CMD_WARNING; |
| 3936 | } |
| 3937 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3938 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3939 | |
| 3940 | return CMD_SUCCESS; |
| 3941 | } |
| 3942 | |
| 3943 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 3944 | show_ip_ospf_database_type_self_cmd, |
| 3945 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 3946 | SHOW_STR |
| 3947 | IP_STR |
| 3948 | "OSPF information\n" |
| 3949 | "Database summary\n" |
| 3950 | OSPF_LSA_TYPES_DESC |
| 3951 | "Self-originated link states\n") |
| 3952 | |
| 3953 | |
| 3954 | DEFUN (ip_ospf_authentication_args, |
| 3955 | ip_ospf_authentication_args_addr_cmd, |
| 3956 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 3957 | "IP Information\n" |
| 3958 | "OSPF interface commands\n" |
| 3959 | "Enable authentication on this interface\n" |
| 3960 | "Use null authentication\n" |
| 3961 | "Use message-digest authentication\n" |
| 3962 | "Address of interface") |
| 3963 | { |
| 3964 | struct interface *ifp; |
| 3965 | struct in_addr addr; |
| 3966 | int ret; |
| 3967 | struct ospf_if_params *params; |
| 3968 | |
| 3969 | ifp = vty->index; |
| 3970 | params = IF_DEF_PARAMS (ifp); |
| 3971 | |
| 3972 | if (argc == 2) |
| 3973 | { |
| 3974 | ret = inet_aton(argv[1], &addr); |
| 3975 | if (!ret) |
| 3976 | { |
| 3977 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 3978 | VTY_NEWLINE); |
| 3979 | return CMD_WARNING; |
| 3980 | } |
| 3981 | |
| 3982 | params = ospf_get_if_params (ifp, addr); |
| 3983 | ospf_if_update_params (ifp, addr); |
| 3984 | } |
| 3985 | |
| 3986 | /* Handle null authentication */ |
| 3987 | if ( argv[0][0] == 'n' ) |
| 3988 | { |
| 3989 | SET_IF_PARAM (params, auth_type); |
| 3990 | params->auth_type = OSPF_AUTH_NULL; |
| 3991 | return CMD_SUCCESS; |
| 3992 | } |
| 3993 | |
| 3994 | /* Handle message-digest authentication */ |
| 3995 | if ( argv[0][0] == 'm' ) |
| 3996 | { |
| 3997 | SET_IF_PARAM (params, auth_type); |
| 3998 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 3999 | return CMD_SUCCESS; |
| 4000 | } |
| 4001 | |
| 4002 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4003 | return CMD_WARNING; |
| 4004 | } |
| 4005 | |
| 4006 | ALIAS (ip_ospf_authentication_args, |
| 4007 | ip_ospf_authentication_args_cmd, |
| 4008 | "ip ospf authentication (null|message-digest)", |
| 4009 | "IP Information\n" |
| 4010 | "OSPF interface commands\n" |
| 4011 | "Enable authentication on this interface\n" |
| 4012 | "Use null authentication\n" |
| 4013 | "Use message-digest authentication\n") |
| 4014 | |
| 4015 | DEFUN (ip_ospf_authentication, |
| 4016 | ip_ospf_authentication_addr_cmd, |
| 4017 | "ip ospf authentication A.B.C.D", |
| 4018 | "IP Information\n" |
| 4019 | "OSPF interface commands\n" |
| 4020 | "Enable authentication on this interface\n" |
| 4021 | "Address of interface") |
| 4022 | { |
| 4023 | struct interface *ifp; |
| 4024 | struct in_addr addr; |
| 4025 | int ret; |
| 4026 | struct ospf_if_params *params; |
| 4027 | |
| 4028 | ifp = vty->index; |
| 4029 | params = IF_DEF_PARAMS (ifp); |
| 4030 | |
| 4031 | if (argc == 1) |
| 4032 | { |
| 4033 | ret = inet_aton(argv[1], &addr); |
| 4034 | if (!ret) |
| 4035 | { |
| 4036 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4037 | VTY_NEWLINE); |
| 4038 | return CMD_WARNING; |
| 4039 | } |
| 4040 | |
| 4041 | params = ospf_get_if_params (ifp, addr); |
| 4042 | ospf_if_update_params (ifp, addr); |
| 4043 | } |
| 4044 | |
| 4045 | SET_IF_PARAM (params, auth_type); |
| 4046 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4047 | |
| 4048 | return CMD_SUCCESS; |
| 4049 | } |
| 4050 | |
| 4051 | ALIAS (ip_ospf_authentication, |
| 4052 | ip_ospf_authentication_cmd, |
| 4053 | "ip ospf authentication", |
| 4054 | "IP Information\n" |
| 4055 | "OSPF interface commands\n" |
| 4056 | "Enable authentication on this interface\n") |
| 4057 | |
| 4058 | DEFUN (no_ip_ospf_authentication, |
| 4059 | no_ip_ospf_authentication_addr_cmd, |
| 4060 | "no ip ospf authentication A.B.C.D", |
| 4061 | NO_STR |
| 4062 | "IP Information\n" |
| 4063 | "OSPF interface commands\n" |
| 4064 | "Enable authentication on this interface\n" |
| 4065 | "Address of interface") |
| 4066 | { |
| 4067 | struct interface *ifp; |
| 4068 | struct in_addr addr; |
| 4069 | int ret; |
| 4070 | struct ospf_if_params *params; |
| 4071 | |
| 4072 | ifp = vty->index; |
| 4073 | params = IF_DEF_PARAMS (ifp); |
| 4074 | |
| 4075 | if (argc == 1) |
| 4076 | { |
| 4077 | ret = inet_aton(argv[1], &addr); |
| 4078 | if (!ret) |
| 4079 | { |
| 4080 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4081 | VTY_NEWLINE); |
| 4082 | return CMD_WARNING; |
| 4083 | } |
| 4084 | |
| 4085 | params = ospf_lookup_if_params (ifp, addr); |
| 4086 | if (params == NULL) |
| 4087 | return CMD_SUCCESS; |
| 4088 | } |
| 4089 | |
| 4090 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4091 | UNSET_IF_PARAM (params, auth_type); |
| 4092 | |
| 4093 | if (params != IF_DEF_PARAMS (ifp)) |
| 4094 | { |
| 4095 | ospf_free_if_params (ifp, addr); |
| 4096 | ospf_if_update_params (ifp, addr); |
| 4097 | } |
| 4098 | |
| 4099 | return CMD_SUCCESS; |
| 4100 | } |
| 4101 | |
| 4102 | ALIAS (no_ip_ospf_authentication, |
| 4103 | no_ip_ospf_authentication_cmd, |
| 4104 | "no ip ospf authentication", |
| 4105 | NO_STR |
| 4106 | "IP Information\n" |
| 4107 | "OSPF interface commands\n" |
| 4108 | "Enable authentication on this interface\n") |
| 4109 | |
| 4110 | DEFUN (ip_ospf_authentication_key, |
| 4111 | ip_ospf_authentication_key_addr_cmd, |
| 4112 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4113 | "IP Information\n" |
| 4114 | "OSPF interface commands\n" |
| 4115 | "Authentication password (key)\n" |
| 4116 | "The OSPF password (key)\n" |
| 4117 | "Address of interface") |
| 4118 | { |
| 4119 | struct interface *ifp; |
| 4120 | struct in_addr addr; |
| 4121 | int ret; |
| 4122 | struct ospf_if_params *params; |
| 4123 | |
| 4124 | ifp = vty->index; |
| 4125 | params = IF_DEF_PARAMS (ifp); |
| 4126 | |
| 4127 | if (argc == 2) |
| 4128 | { |
| 4129 | ret = inet_aton(argv[1], &addr); |
| 4130 | if (!ret) |
| 4131 | { |
| 4132 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4133 | VTY_NEWLINE); |
| 4134 | return CMD_WARNING; |
| 4135 | } |
| 4136 | |
| 4137 | params = ospf_get_if_params (ifp, addr); |
| 4138 | ospf_if_update_params (ifp, addr); |
| 4139 | } |
| 4140 | |
| 4141 | |
| 4142 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 4143 | strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
| 4144 | SET_IF_PARAM (params, auth_simple); |
| 4145 | |
| 4146 | return CMD_SUCCESS; |
| 4147 | } |
| 4148 | |
| 4149 | ALIAS (ip_ospf_authentication_key, |
| 4150 | ip_ospf_authentication_key_cmd, |
| 4151 | "ip ospf authentication-key AUTH_KEY", |
| 4152 | "IP Information\n" |
| 4153 | "OSPF interface commands\n" |
| 4154 | "Authentication password (key)\n" |
| 4155 | "The OSPF password (key)") |
| 4156 | |
| 4157 | ALIAS (ip_ospf_authentication_key, |
| 4158 | ospf_authentication_key_cmd, |
| 4159 | "ospf authentication-key AUTH_KEY", |
| 4160 | "OSPF interface commands\n" |
| 4161 | "Authentication password (key)\n" |
| 4162 | "The OSPF password (key)") |
| 4163 | |
| 4164 | DEFUN (no_ip_ospf_authentication_key, |
| 4165 | no_ip_ospf_authentication_key_addr_cmd, |
| 4166 | "no ip ospf authentication-key A.B.C.D", |
| 4167 | NO_STR |
| 4168 | "IP Information\n" |
| 4169 | "OSPF interface commands\n" |
| 4170 | "Authentication password (key)\n" |
| 4171 | "Address of interface") |
| 4172 | { |
| 4173 | struct interface *ifp; |
| 4174 | struct in_addr addr; |
| 4175 | int ret; |
| 4176 | struct ospf_if_params *params; |
| 4177 | |
| 4178 | ifp = vty->index; |
| 4179 | params = IF_DEF_PARAMS (ifp); |
| 4180 | |
| 4181 | if (argc == 2) |
| 4182 | { |
| 4183 | ret = inet_aton(argv[1], &addr); |
| 4184 | if (!ret) |
| 4185 | { |
| 4186 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4187 | VTY_NEWLINE); |
| 4188 | return CMD_WARNING; |
| 4189 | } |
| 4190 | |
| 4191 | params = ospf_lookup_if_params (ifp, addr); |
| 4192 | if (params == NULL) |
| 4193 | return CMD_SUCCESS; |
| 4194 | } |
| 4195 | |
| 4196 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4197 | UNSET_IF_PARAM (params, auth_simple); |
| 4198 | |
| 4199 | if (params != IF_DEF_PARAMS (ifp)) |
| 4200 | { |
| 4201 | ospf_free_if_params (ifp, addr); |
| 4202 | ospf_if_update_params (ifp, addr); |
| 4203 | } |
| 4204 | |
| 4205 | return CMD_SUCCESS; |
| 4206 | } |
| 4207 | |
| 4208 | ALIAS (no_ip_ospf_authentication_key, |
| 4209 | no_ip_ospf_authentication_key_cmd, |
| 4210 | "no ip ospf authentication-key", |
| 4211 | NO_STR |
| 4212 | "IP Information\n" |
| 4213 | "OSPF interface commands\n" |
| 4214 | "Authentication password (key)\n") |
| 4215 | |
| 4216 | ALIAS (no_ip_ospf_authentication_key, |
| 4217 | no_ospf_authentication_key_cmd, |
| 4218 | "no ospf authentication-key", |
| 4219 | NO_STR |
| 4220 | "OSPF interface commands\n" |
| 4221 | "Authentication password (key)\n") |
| 4222 | |
| 4223 | DEFUN (ip_ospf_message_digest_key, |
| 4224 | ip_ospf_message_digest_key_addr_cmd, |
| 4225 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4226 | "IP Information\n" |
| 4227 | "OSPF interface commands\n" |
| 4228 | "Message digest authentication password (key)\n" |
| 4229 | "Key ID\n" |
| 4230 | "Use MD5 algorithm\n" |
| 4231 | "The OSPF password (key)" |
| 4232 | "Address of interface") |
| 4233 | { |
| 4234 | struct interface *ifp; |
| 4235 | struct crypt_key *ck; |
| 4236 | u_char key_id; |
| 4237 | struct in_addr addr; |
| 4238 | int ret; |
| 4239 | struct ospf_if_params *params; |
| 4240 | |
| 4241 | ifp = vty->index; |
| 4242 | params = IF_DEF_PARAMS (ifp); |
| 4243 | |
| 4244 | if (argc == 3) |
| 4245 | { |
| 4246 | ret = inet_aton(argv[2], &addr); |
| 4247 | if (!ret) |
| 4248 | { |
| 4249 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4250 | VTY_NEWLINE); |
| 4251 | return CMD_WARNING; |
| 4252 | } |
| 4253 | |
| 4254 | params = ospf_get_if_params (ifp, addr); |
| 4255 | ospf_if_update_params (ifp, addr); |
| 4256 | } |
| 4257 | |
| 4258 | key_id = strtol (argv[0], NULL, 10); |
| 4259 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4260 | { |
| 4261 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4262 | return CMD_WARNING; |
| 4263 | } |
| 4264 | |
| 4265 | ck = ospf_crypt_key_new (); |
| 4266 | ck->key_id = (u_char) key_id; |
| 4267 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 4268 | strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
| 4269 | |
| 4270 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4271 | SET_IF_PARAM (params, auth_crypt); |
| 4272 | |
| 4273 | return CMD_SUCCESS; |
| 4274 | } |
| 4275 | |
| 4276 | ALIAS (ip_ospf_message_digest_key, |
| 4277 | ip_ospf_message_digest_key_cmd, |
| 4278 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4279 | "IP Information\n" |
| 4280 | "OSPF interface commands\n" |
| 4281 | "Message digest authentication password (key)\n" |
| 4282 | "Key ID\n" |
| 4283 | "Use MD5 algorithm\n" |
| 4284 | "The OSPF password (key)") |
| 4285 | |
| 4286 | ALIAS (ip_ospf_message_digest_key, |
| 4287 | ospf_message_digest_key_cmd, |
| 4288 | "ospf message-digest-key <1-255> md5 KEY", |
| 4289 | "OSPF interface commands\n" |
| 4290 | "Message digest authentication password (key)\n" |
| 4291 | "Key ID\n" |
| 4292 | "Use MD5 algorithm\n" |
| 4293 | "The OSPF password (key)") |
| 4294 | |
| 4295 | DEFUN (no_ip_ospf_message_digest_key, |
| 4296 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4297 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4298 | NO_STR |
| 4299 | "IP Information\n" |
| 4300 | "OSPF interface commands\n" |
| 4301 | "Message digest authentication password (key)\n" |
| 4302 | "Key ID\n" |
| 4303 | "Address of interface") |
| 4304 | { |
| 4305 | struct interface *ifp; |
| 4306 | struct crypt_key *ck; |
| 4307 | int key_id; |
| 4308 | struct in_addr addr; |
| 4309 | int ret; |
| 4310 | struct ospf_if_params *params; |
| 4311 | |
| 4312 | ifp = vty->index; |
| 4313 | params = IF_DEF_PARAMS (ifp); |
| 4314 | |
| 4315 | if (argc == 2) |
| 4316 | { |
| 4317 | ret = inet_aton(argv[1], &addr); |
| 4318 | if (!ret) |
| 4319 | { |
| 4320 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4321 | VTY_NEWLINE); |
| 4322 | return CMD_WARNING; |
| 4323 | } |
| 4324 | |
| 4325 | params = ospf_lookup_if_params (ifp, addr); |
| 4326 | if (params == NULL) |
| 4327 | return CMD_SUCCESS; |
| 4328 | } |
| 4329 | |
| 4330 | key_id = strtol (argv[0], NULL, 10); |
| 4331 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4332 | if (ck == NULL) |
| 4333 | { |
| 4334 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4335 | return CMD_WARNING; |
| 4336 | } |
| 4337 | |
| 4338 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4339 | |
| 4340 | if (params != IF_DEF_PARAMS (ifp)) |
| 4341 | { |
| 4342 | ospf_free_if_params (ifp, addr); |
| 4343 | ospf_if_update_params (ifp, addr); |
| 4344 | } |
| 4345 | |
| 4346 | return CMD_SUCCESS; |
| 4347 | } |
| 4348 | |
| 4349 | ALIAS (no_ip_ospf_message_digest_key, |
| 4350 | no_ip_ospf_message_digest_key_cmd, |
| 4351 | "no ip ospf message-digest-key <1-255>", |
| 4352 | NO_STR |
| 4353 | "IP Information\n" |
| 4354 | "OSPF interface commands\n" |
| 4355 | "Message digest authentication password (key)\n" |
| 4356 | "Key ID\n") |
| 4357 | |
| 4358 | ALIAS (no_ip_ospf_message_digest_key, |
| 4359 | no_ospf_message_digest_key_cmd, |
| 4360 | "no ospf message-digest-key <1-255>", |
| 4361 | NO_STR |
| 4362 | "OSPF interface commands\n" |
| 4363 | "Message digest authentication password (key)\n" |
| 4364 | "Key ID\n") |
| 4365 | |
| 4366 | DEFUN (ip_ospf_cost, |
| 4367 | ip_ospf_cost_addr_cmd, |
| 4368 | "ip ospf cost <1-65535> A.B.C.D", |
| 4369 | "IP Information\n" |
| 4370 | "OSPF interface commands\n" |
| 4371 | "Interface cost\n" |
| 4372 | "Cost\n" |
| 4373 | "Address of interface") |
| 4374 | { |
| 4375 | struct interface *ifp = vty->index; |
| 4376 | u_int32_t cost; |
| 4377 | struct in_addr addr; |
| 4378 | int ret; |
| 4379 | struct ospf_if_params *params; |
| 4380 | |
| 4381 | params = IF_DEF_PARAMS (ifp); |
| 4382 | |
| 4383 | cost = strtol (argv[0], NULL, 10); |
| 4384 | |
| 4385 | /* cost range is <1-65535>. */ |
| 4386 | if (cost < 1 || cost > 65535) |
| 4387 | { |
| 4388 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4389 | return CMD_WARNING; |
| 4390 | } |
| 4391 | |
| 4392 | if (argc == 2) |
| 4393 | { |
| 4394 | ret = inet_aton(argv[1], &addr); |
| 4395 | if (!ret) |
| 4396 | { |
| 4397 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4398 | VTY_NEWLINE); |
| 4399 | return CMD_WARNING; |
| 4400 | } |
| 4401 | |
| 4402 | params = ospf_get_if_params (ifp, addr); |
| 4403 | ospf_if_update_params (ifp, addr); |
| 4404 | } |
| 4405 | |
| 4406 | SET_IF_PARAM (params, output_cost_cmd); |
| 4407 | params->output_cost_cmd = cost; |
| 4408 | |
| 4409 | ospf_if_recalculate_output_cost (ifp); |
| 4410 | |
| 4411 | return CMD_SUCCESS; |
| 4412 | } |
| 4413 | |
| 4414 | ALIAS (ip_ospf_cost, |
| 4415 | ip_ospf_cost_cmd, |
| 4416 | "ip ospf cost <1-65535>", |
| 4417 | "IP Information\n" |
| 4418 | "OSPF interface commands\n" |
| 4419 | "Interface cost\n" |
| 4420 | "Cost") |
| 4421 | |
| 4422 | ALIAS (ip_ospf_cost, |
| 4423 | ospf_cost_cmd, |
| 4424 | "ospf cost <1-65535>", |
| 4425 | "OSPF interface commands\n" |
| 4426 | "Interface cost\n" |
| 4427 | "Cost") |
| 4428 | |
| 4429 | DEFUN (no_ip_ospf_cost, |
| 4430 | no_ip_ospf_cost_addr_cmd, |
| 4431 | "no ip ospf cost A.B.C.D", |
| 4432 | NO_STR |
| 4433 | "IP Information\n" |
| 4434 | "OSPF interface commands\n" |
| 4435 | "Interface cost\n" |
| 4436 | "Address of interface") |
| 4437 | { |
| 4438 | struct interface *ifp = vty->index; |
| 4439 | struct in_addr addr; |
| 4440 | int ret; |
| 4441 | struct ospf_if_params *params; |
| 4442 | |
| 4443 | ifp = vty->index; |
| 4444 | params = IF_DEF_PARAMS (ifp); |
| 4445 | |
| 4446 | if (argc == 1) |
| 4447 | { |
| 4448 | ret = inet_aton(argv[0], &addr); |
| 4449 | if (!ret) |
| 4450 | { |
| 4451 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4452 | VTY_NEWLINE); |
| 4453 | return CMD_WARNING; |
| 4454 | } |
| 4455 | |
| 4456 | params = ospf_lookup_if_params (ifp, addr); |
| 4457 | if (params == NULL) |
| 4458 | return CMD_SUCCESS; |
| 4459 | } |
| 4460 | |
| 4461 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4462 | |
| 4463 | if (params != IF_DEF_PARAMS (ifp)) |
| 4464 | { |
| 4465 | ospf_free_if_params (ifp, addr); |
| 4466 | ospf_if_update_params (ifp, addr); |
| 4467 | } |
| 4468 | |
| 4469 | ospf_if_recalculate_output_cost (ifp); |
| 4470 | |
| 4471 | return CMD_SUCCESS; |
| 4472 | } |
| 4473 | |
| 4474 | ALIAS (no_ip_ospf_cost, |
| 4475 | no_ip_ospf_cost_cmd, |
| 4476 | "no ip ospf cost", |
| 4477 | NO_STR |
| 4478 | "IP Information\n" |
| 4479 | "OSPF interface commands\n" |
| 4480 | "Interface cost\n") |
| 4481 | |
| 4482 | ALIAS (no_ip_ospf_cost, |
| 4483 | no_ospf_cost_cmd, |
| 4484 | "no ospf cost", |
| 4485 | NO_STR |
| 4486 | "OSPF interface commands\n" |
| 4487 | "Interface cost\n") |
| 4488 | |
| 4489 | void |
| 4490 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4491 | { |
| 4492 | struct route_node *rn; |
| 4493 | struct ospf_neighbor *nbr; |
| 4494 | |
| 4495 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4496 | if ((nbr = rn->info)) |
| 4497 | { |
| 4498 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4499 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4500 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4501 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4502 | } |
| 4503 | } |
| 4504 | |
| 4505 | DEFUN (ip_ospf_dead_interval, |
| 4506 | ip_ospf_dead_interval_addr_cmd, |
| 4507 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4508 | "IP Information\n" |
| 4509 | "OSPF interface commands\n" |
| 4510 | "Interval after which a neighbor is declared dead\n" |
| 4511 | "Seconds\n" |
| 4512 | "Address of interface") |
| 4513 | { |
| 4514 | struct interface *ifp = vty->index; |
| 4515 | u_int32_t seconds; |
| 4516 | struct in_addr addr; |
| 4517 | int ret; |
| 4518 | struct ospf_if_params *params; |
| 4519 | struct ospf_interface *oi; |
| 4520 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4521 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4522 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4523 | ospf = ospf_lookup (); |
| 4524 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4525 | params = IF_DEF_PARAMS (ifp); |
| 4526 | |
| 4527 | seconds = strtol (argv[0], NULL, 10); |
| 4528 | |
| 4529 | /* dead_interval range is <1-65535>. */ |
| 4530 | if (seconds < 1 || seconds > 65535) |
| 4531 | { |
| 4532 | vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE); |
| 4533 | return CMD_WARNING; |
| 4534 | } |
| 4535 | |
| 4536 | if (argc == 2) |
| 4537 | { |
| 4538 | ret = inet_aton(argv[1], &addr); |
| 4539 | if (!ret) |
| 4540 | { |
| 4541 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4542 | VTY_NEWLINE); |
| 4543 | return CMD_WARNING; |
| 4544 | } |
| 4545 | |
| 4546 | params = ospf_get_if_params (ifp, addr); |
| 4547 | ospf_if_update_params (ifp, addr); |
| 4548 | } |
| 4549 | |
| 4550 | SET_IF_PARAM (params, v_wait); |
| 4551 | params->v_wait = seconds; |
| 4552 | |
| 4553 | /* Update timer values in neighbor structure. */ |
| 4554 | if (argc == 2) |
| 4555 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4556 | if (ospf) |
| 4557 | { |
| 4558 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4559 | if (oi) |
| 4560 | ospf_nbr_timer_update (oi); |
| 4561 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4562 | } |
| 4563 | else |
| 4564 | { |
| 4565 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4566 | if ((oi = rn->info)) |
| 4567 | ospf_nbr_timer_update (oi); |
| 4568 | } |
| 4569 | |
| 4570 | return CMD_SUCCESS; |
| 4571 | } |
| 4572 | |
| 4573 | ALIAS (ip_ospf_dead_interval, |
| 4574 | ip_ospf_dead_interval_cmd, |
| 4575 | "ip ospf dead-interval <1-65535>", |
| 4576 | "IP Information\n" |
| 4577 | "OSPF interface commands\n" |
| 4578 | "Interval after which a neighbor is declared dead\n" |
| 4579 | "Seconds\n") |
| 4580 | |
| 4581 | ALIAS (ip_ospf_dead_interval, |
| 4582 | ospf_dead_interval_cmd, |
| 4583 | "ospf dead-interval <1-65535>", |
| 4584 | "OSPF interface commands\n" |
| 4585 | "Interval after which a neighbor is declared dead\n" |
| 4586 | "Seconds\n") |
| 4587 | |
| 4588 | DEFUN (no_ip_ospf_dead_interval, |
| 4589 | no_ip_ospf_dead_interval_addr_cmd, |
| 4590 | "no ip ospf dead-interval A.B.C.D", |
| 4591 | NO_STR |
| 4592 | "IP Information\n" |
| 4593 | "OSPF interface commands\n" |
| 4594 | "Interval after which a neighbor is declared dead\n" |
| 4595 | "Address of interface") |
| 4596 | { |
| 4597 | struct interface *ifp = vty->index; |
| 4598 | struct in_addr addr; |
| 4599 | int ret; |
| 4600 | struct ospf_if_params *params; |
| 4601 | struct ospf_interface *oi; |
| 4602 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4603 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4604 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4605 | ospf = ospf_lookup (); |
| 4606 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4607 | ifp = vty->index; |
| 4608 | params = IF_DEF_PARAMS (ifp); |
| 4609 | |
| 4610 | if (argc == 1) |
| 4611 | { |
| 4612 | ret = inet_aton(argv[0], &addr); |
| 4613 | if (!ret) |
| 4614 | { |
| 4615 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4616 | VTY_NEWLINE); |
| 4617 | return CMD_WARNING; |
| 4618 | } |
| 4619 | |
| 4620 | params = ospf_lookup_if_params (ifp, addr); |
| 4621 | if (params == NULL) |
| 4622 | return CMD_SUCCESS; |
| 4623 | } |
| 4624 | |
| 4625 | UNSET_IF_PARAM (params, v_wait); |
| 4626 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4627 | |
| 4628 | if (params != IF_DEF_PARAMS (ifp)) |
| 4629 | { |
| 4630 | ospf_free_if_params (ifp, addr); |
| 4631 | ospf_if_update_params (ifp, addr); |
| 4632 | } |
| 4633 | |
| 4634 | /* Update timer values in neighbor structure. */ |
| 4635 | if (argc == 1) |
| 4636 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4637 | if (ospf) |
| 4638 | { |
| 4639 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4640 | if (oi) |
| 4641 | ospf_nbr_timer_update (oi); |
| 4642 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4643 | } |
| 4644 | else |
| 4645 | { |
| 4646 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4647 | if ((oi = rn->info)) |
| 4648 | ospf_nbr_timer_update (oi); |
| 4649 | } |
| 4650 | |
| 4651 | return CMD_SUCCESS; |
| 4652 | } |
| 4653 | |
| 4654 | ALIAS (no_ip_ospf_dead_interval, |
| 4655 | no_ip_ospf_dead_interval_cmd, |
| 4656 | "no ip ospf dead-interval", |
| 4657 | NO_STR |
| 4658 | "IP Information\n" |
| 4659 | "OSPF interface commands\n" |
| 4660 | "Interval after which a neighbor is declared dead\n") |
| 4661 | |
| 4662 | ALIAS (no_ip_ospf_dead_interval, |
| 4663 | no_ospf_dead_interval_cmd, |
| 4664 | "no ospf dead-interval", |
| 4665 | NO_STR |
| 4666 | "OSPF interface commands\n" |
| 4667 | "Interval after which a neighbor is declared dead\n") |
| 4668 | |
| 4669 | DEFUN (ip_ospf_hello_interval, |
| 4670 | ip_ospf_hello_interval_addr_cmd, |
| 4671 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4672 | "IP Information\n" |
| 4673 | "OSPF interface commands\n" |
| 4674 | "Time between HELLO packets\n" |
| 4675 | "Seconds\n" |
| 4676 | "Address of interface") |
| 4677 | { |
| 4678 | struct interface *ifp = vty->index; |
| 4679 | u_int32_t seconds; |
| 4680 | struct in_addr addr; |
| 4681 | int ret; |
| 4682 | struct ospf_if_params *params; |
| 4683 | |
| 4684 | params = IF_DEF_PARAMS (ifp); |
| 4685 | |
| 4686 | seconds = strtol (argv[0], NULL, 10); |
| 4687 | |
| 4688 | /* HelloInterval range is <1-65535>. */ |
| 4689 | if (seconds < 1 || seconds > 65535) |
| 4690 | { |
| 4691 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4692 | return CMD_WARNING; |
| 4693 | } |
| 4694 | |
| 4695 | if (argc == 2) |
| 4696 | { |
| 4697 | ret = inet_aton(argv[1], &addr); |
| 4698 | if (!ret) |
| 4699 | { |
| 4700 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4701 | VTY_NEWLINE); |
| 4702 | return CMD_WARNING; |
| 4703 | } |
| 4704 | |
| 4705 | params = ospf_get_if_params (ifp, addr); |
| 4706 | ospf_if_update_params (ifp, addr); |
| 4707 | } |
| 4708 | |
| 4709 | SET_IF_PARAM (params, v_hello); |
| 4710 | params->v_hello = seconds; |
| 4711 | |
| 4712 | return CMD_SUCCESS; |
| 4713 | } |
| 4714 | |
| 4715 | ALIAS (ip_ospf_hello_interval, |
| 4716 | ip_ospf_hello_interval_cmd, |
| 4717 | "ip ospf hello-interval <1-65535>", |
| 4718 | "IP Information\n" |
| 4719 | "OSPF interface commands\n" |
| 4720 | "Time between HELLO packets\n" |
| 4721 | "Seconds\n") |
| 4722 | |
| 4723 | ALIAS (ip_ospf_hello_interval, |
| 4724 | ospf_hello_interval_cmd, |
| 4725 | "ospf hello-interval <1-65535>", |
| 4726 | "OSPF interface commands\n" |
| 4727 | "Time between HELLO packets\n" |
| 4728 | "Seconds\n") |
| 4729 | |
| 4730 | DEFUN (no_ip_ospf_hello_interval, |
| 4731 | no_ip_ospf_hello_interval_addr_cmd, |
| 4732 | "no ip ospf hello-interval A.B.C.D", |
| 4733 | NO_STR |
| 4734 | "IP Information\n" |
| 4735 | "OSPF interface commands\n" |
| 4736 | "Time between HELLO packets\n" |
| 4737 | "Address of interface") |
| 4738 | { |
| 4739 | struct interface *ifp = vty->index; |
| 4740 | struct in_addr addr; |
| 4741 | int ret; |
| 4742 | struct ospf_if_params *params; |
| 4743 | |
| 4744 | ifp = vty->index; |
| 4745 | params = IF_DEF_PARAMS (ifp); |
| 4746 | |
| 4747 | if (argc == 1) |
| 4748 | { |
| 4749 | ret = inet_aton(argv[0], &addr); |
| 4750 | if (!ret) |
| 4751 | { |
| 4752 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4753 | VTY_NEWLINE); |
| 4754 | return CMD_WARNING; |
| 4755 | } |
| 4756 | |
| 4757 | params = ospf_lookup_if_params (ifp, addr); |
| 4758 | if (params == NULL) |
| 4759 | return CMD_SUCCESS; |
| 4760 | } |
| 4761 | |
| 4762 | UNSET_IF_PARAM (params, v_hello); |
| 4763 | params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4764 | |
| 4765 | if (params != IF_DEF_PARAMS (ifp)) |
| 4766 | { |
| 4767 | ospf_free_if_params (ifp, addr); |
| 4768 | ospf_if_update_params (ifp, addr); |
| 4769 | } |
| 4770 | |
| 4771 | return CMD_SUCCESS; |
| 4772 | } |
| 4773 | |
| 4774 | ALIAS (no_ip_ospf_hello_interval, |
| 4775 | no_ip_ospf_hello_interval_cmd, |
| 4776 | "no ip ospf hello-interval", |
| 4777 | NO_STR |
| 4778 | "IP Information\n" |
| 4779 | "OSPF interface commands\n" |
| 4780 | "Time between HELLO packets\n") |
| 4781 | |
| 4782 | ALIAS (no_ip_ospf_hello_interval, |
| 4783 | no_ospf_hello_interval_cmd, |
| 4784 | "no ospf hello-interval", |
| 4785 | NO_STR |
| 4786 | "OSPF interface commands\n" |
| 4787 | "Time between HELLO packets\n") |
| 4788 | |
| 4789 | DEFUN (ip_ospf_network, |
| 4790 | ip_ospf_network_cmd, |
| 4791 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4792 | "IP Information\n" |
| 4793 | "OSPF interface commands\n" |
| 4794 | "Network type\n" |
| 4795 | "Specify OSPF broadcast multi-access network\n" |
| 4796 | "Specify OSPF NBMA network\n" |
| 4797 | "Specify OSPF point-to-multipoint network\n" |
| 4798 | "Specify OSPF point-to-point network\n") |
| 4799 | { |
| 4800 | struct interface *ifp = vty->index; |
| 4801 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4802 | struct route_node *rn; |
| 4803 | |
| 4804 | if (strncmp (argv[0], "b", 1) == 0) |
| 4805 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 4806 | else if (strncmp (argv[0], "n", 1) == 0) |
| 4807 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 4808 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 4809 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 4810 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 4811 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 4812 | |
| 4813 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4814 | return CMD_SUCCESS; |
| 4815 | |
| 4816 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 4817 | |
| 4818 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4819 | { |
| 4820 | struct ospf_interface *oi = rn->info; |
| 4821 | |
| 4822 | if (!oi) |
| 4823 | continue; |
| 4824 | |
| 4825 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4826 | |
| 4827 | if (oi->state > ISM_Down) |
| 4828 | { |
| 4829 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4830 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4831 | } |
| 4832 | } |
| 4833 | |
| 4834 | return CMD_SUCCESS; |
| 4835 | } |
| 4836 | |
| 4837 | ALIAS (ip_ospf_network, |
| 4838 | ospf_network_cmd, |
| 4839 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4840 | "OSPF interface commands\n" |
| 4841 | "Network type\n" |
| 4842 | "Specify OSPF broadcast multi-access network\n" |
| 4843 | "Specify OSPF NBMA network\n" |
| 4844 | "Specify OSPF point-to-multipoint network\n" |
| 4845 | "Specify OSPF point-to-point network\n") |
| 4846 | |
| 4847 | DEFUN (no_ip_ospf_network, |
| 4848 | no_ip_ospf_network_cmd, |
| 4849 | "no ip ospf network", |
| 4850 | NO_STR |
| 4851 | "IP Information\n" |
| 4852 | "OSPF interface commands\n" |
| 4853 | "Network type\n") |
| 4854 | { |
| 4855 | struct interface *ifp = vty->index; |
| 4856 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4857 | struct route_node *rn; |
| 4858 | |
| 4859 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 4860 | |
| 4861 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4862 | return CMD_SUCCESS; |
| 4863 | |
| 4864 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4865 | { |
| 4866 | struct ospf_interface *oi = rn->info; |
| 4867 | |
| 4868 | if (!oi) |
| 4869 | continue; |
| 4870 | |
| 4871 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4872 | |
| 4873 | if (oi->state > ISM_Down) |
| 4874 | { |
| 4875 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4876 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4877 | } |
| 4878 | } |
| 4879 | |
| 4880 | return CMD_SUCCESS; |
| 4881 | } |
| 4882 | |
| 4883 | ALIAS (no_ip_ospf_network, |
| 4884 | no_ospf_network_cmd, |
| 4885 | "no ospf network", |
| 4886 | NO_STR |
| 4887 | "OSPF interface commands\n" |
| 4888 | "Network type\n") |
| 4889 | |
| 4890 | DEFUN (ip_ospf_priority, |
| 4891 | ip_ospf_priority_addr_cmd, |
| 4892 | "ip ospf priority <0-255> A.B.C.D", |
| 4893 | "IP Information\n" |
| 4894 | "OSPF interface commands\n" |
| 4895 | "Router priority\n" |
| 4896 | "Priority\n" |
| 4897 | "Address of interface") |
| 4898 | { |
| 4899 | struct interface *ifp = vty->index; |
| 4900 | u_int32_t priority; |
| 4901 | struct route_node *rn; |
| 4902 | struct in_addr addr; |
| 4903 | int ret; |
| 4904 | struct ospf_if_params *params; |
| 4905 | |
| 4906 | params = IF_DEF_PARAMS (ifp); |
| 4907 | |
| 4908 | priority = strtol (argv[0], NULL, 10); |
| 4909 | |
| 4910 | /* Router Priority range is <0-255>. */ |
| 4911 | if (priority < 0 || priority > 255) |
| 4912 | { |
| 4913 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 4914 | return CMD_WARNING; |
| 4915 | } |
| 4916 | |
| 4917 | if (argc == 2) |
| 4918 | { |
| 4919 | ret = inet_aton(argv[1], &addr); |
| 4920 | if (!ret) |
| 4921 | { |
| 4922 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4923 | VTY_NEWLINE); |
| 4924 | return CMD_WARNING; |
| 4925 | } |
| 4926 | |
| 4927 | params = ospf_get_if_params (ifp, addr); |
| 4928 | ospf_if_update_params (ifp, addr); |
| 4929 | } |
| 4930 | |
| 4931 | SET_IF_PARAM (params, priority); |
| 4932 | params->priority = priority; |
| 4933 | |
| 4934 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4935 | { |
| 4936 | struct ospf_interface *oi = rn->info; |
| 4937 | |
| 4938 | if (!oi) |
| 4939 | continue; |
| 4940 | |
| 4941 | |
| 4942 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 4943 | { |
| 4944 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 4945 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 4946 | } |
| 4947 | } |
| 4948 | |
| 4949 | return CMD_SUCCESS; |
| 4950 | } |
| 4951 | |
| 4952 | ALIAS (ip_ospf_priority, |
| 4953 | ip_ospf_priority_cmd, |
| 4954 | "ip ospf priority <0-255>", |
| 4955 | "IP Information\n" |
| 4956 | "OSPF interface commands\n" |
| 4957 | "Router priority\n" |
| 4958 | "Priority\n") |
| 4959 | |
| 4960 | ALIAS (ip_ospf_priority, |
| 4961 | ospf_priority_cmd, |
| 4962 | "ospf priority <0-255>", |
| 4963 | "OSPF interface commands\n" |
| 4964 | "Router priority\n" |
| 4965 | "Priority\n") |
| 4966 | |
| 4967 | DEFUN (no_ip_ospf_priority, |
| 4968 | no_ip_ospf_priority_addr_cmd, |
| 4969 | "no ip ospf priority A.B.C.D", |
| 4970 | NO_STR |
| 4971 | "IP Information\n" |
| 4972 | "OSPF interface commands\n" |
| 4973 | "Router priority\n" |
| 4974 | "Address of interface") |
| 4975 | { |
| 4976 | struct interface *ifp = vty->index; |
| 4977 | struct route_node *rn; |
| 4978 | struct in_addr addr; |
| 4979 | int ret; |
| 4980 | struct ospf_if_params *params; |
| 4981 | |
| 4982 | ifp = vty->index; |
| 4983 | params = IF_DEF_PARAMS (ifp); |
| 4984 | |
| 4985 | if (argc == 1) |
| 4986 | { |
| 4987 | ret = inet_aton(argv[0], &addr); |
| 4988 | if (!ret) |
| 4989 | { |
| 4990 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4991 | VTY_NEWLINE); |
| 4992 | return CMD_WARNING; |
| 4993 | } |
| 4994 | |
| 4995 | params = ospf_lookup_if_params (ifp, addr); |
| 4996 | if (params == NULL) |
| 4997 | return CMD_SUCCESS; |
| 4998 | } |
| 4999 | |
| 5000 | UNSET_IF_PARAM (params, priority); |
| 5001 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5002 | |
| 5003 | if (params != IF_DEF_PARAMS (ifp)) |
| 5004 | { |
| 5005 | ospf_free_if_params (ifp, addr); |
| 5006 | ospf_if_update_params (ifp, addr); |
| 5007 | } |
| 5008 | |
| 5009 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5010 | { |
| 5011 | struct ospf_interface *oi = rn->info; |
| 5012 | |
| 5013 | if (!oi) |
| 5014 | continue; |
| 5015 | |
| 5016 | |
| 5017 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5018 | { |
| 5019 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5020 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5021 | } |
| 5022 | } |
| 5023 | |
| 5024 | return CMD_SUCCESS; |
| 5025 | } |
| 5026 | |
| 5027 | ALIAS (no_ip_ospf_priority, |
| 5028 | no_ip_ospf_priority_cmd, |
| 5029 | "no ip ospf priority", |
| 5030 | NO_STR |
| 5031 | "IP Information\n" |
| 5032 | "OSPF interface commands\n" |
| 5033 | "Router priority\n") |
| 5034 | |
| 5035 | ALIAS (no_ip_ospf_priority, |
| 5036 | no_ospf_priority_cmd, |
| 5037 | "no ospf priority", |
| 5038 | NO_STR |
| 5039 | "OSPF interface commands\n" |
| 5040 | "Router priority\n") |
| 5041 | |
| 5042 | DEFUN (ip_ospf_retransmit_interval, |
| 5043 | ip_ospf_retransmit_interval_addr_cmd, |
| 5044 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5045 | "IP Information\n" |
| 5046 | "OSPF interface commands\n" |
| 5047 | "Time between retransmitting lost link state advertisements\n" |
| 5048 | "Seconds\n" |
| 5049 | "Address of interface") |
| 5050 | { |
| 5051 | struct interface *ifp = vty->index; |
| 5052 | u_int32_t seconds; |
| 5053 | struct in_addr addr; |
| 5054 | int ret; |
| 5055 | struct ospf_if_params *params; |
| 5056 | |
| 5057 | params = IF_DEF_PARAMS (ifp); |
| 5058 | seconds = strtol (argv[0], NULL, 10); |
| 5059 | |
| 5060 | /* Retransmit Interval range is <3-65535>. */ |
| 5061 | if (seconds < 3 || seconds > 65535) |
| 5062 | { |
| 5063 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5064 | return CMD_WARNING; |
| 5065 | } |
| 5066 | |
| 5067 | |
| 5068 | if (argc == 2) |
| 5069 | { |
| 5070 | ret = inet_aton(argv[1], &addr); |
| 5071 | if (!ret) |
| 5072 | { |
| 5073 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5074 | VTY_NEWLINE); |
| 5075 | return CMD_WARNING; |
| 5076 | } |
| 5077 | |
| 5078 | params = ospf_get_if_params (ifp, addr); |
| 5079 | ospf_if_update_params (ifp, addr); |
| 5080 | } |
| 5081 | |
| 5082 | SET_IF_PARAM (params, retransmit_interval); |
| 5083 | params->retransmit_interval = seconds; |
| 5084 | |
| 5085 | return CMD_SUCCESS; |
| 5086 | } |
| 5087 | |
| 5088 | ALIAS (ip_ospf_retransmit_interval, |
| 5089 | ip_ospf_retransmit_interval_cmd, |
| 5090 | "ip ospf retransmit-interval <3-65535>", |
| 5091 | "IP Information\n" |
| 5092 | "OSPF interface commands\n" |
| 5093 | "Time between retransmitting lost link state advertisements\n" |
| 5094 | "Seconds\n") |
| 5095 | |
| 5096 | ALIAS (ip_ospf_retransmit_interval, |
| 5097 | ospf_retransmit_interval_cmd, |
| 5098 | "ospf retransmit-interval <3-65535>", |
| 5099 | "OSPF interface commands\n" |
| 5100 | "Time between retransmitting lost link state advertisements\n" |
| 5101 | "Seconds\n") |
| 5102 | |
| 5103 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5104 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5105 | "no ip ospf retransmit-interval A.B.C.D", |
| 5106 | NO_STR |
| 5107 | "IP Information\n" |
| 5108 | "OSPF interface commands\n" |
| 5109 | "Time between retransmitting lost link state advertisements\n" |
| 5110 | "Address of interface") |
| 5111 | { |
| 5112 | struct interface *ifp = vty->index; |
| 5113 | struct in_addr addr; |
| 5114 | int ret; |
| 5115 | struct ospf_if_params *params; |
| 5116 | |
| 5117 | ifp = vty->index; |
| 5118 | params = IF_DEF_PARAMS (ifp); |
| 5119 | |
| 5120 | if (argc == 1) |
| 5121 | { |
| 5122 | ret = inet_aton(argv[0], &addr); |
| 5123 | if (!ret) |
| 5124 | { |
| 5125 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5126 | VTY_NEWLINE); |
| 5127 | return CMD_WARNING; |
| 5128 | } |
| 5129 | |
| 5130 | params = ospf_lookup_if_params (ifp, addr); |
| 5131 | if (params == NULL) |
| 5132 | return CMD_SUCCESS; |
| 5133 | } |
| 5134 | |
| 5135 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5136 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5137 | |
| 5138 | if (params != IF_DEF_PARAMS (ifp)) |
| 5139 | { |
| 5140 | ospf_free_if_params (ifp, addr); |
| 5141 | ospf_if_update_params (ifp, addr); |
| 5142 | } |
| 5143 | |
| 5144 | return CMD_SUCCESS; |
| 5145 | } |
| 5146 | |
| 5147 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5148 | no_ip_ospf_retransmit_interval_cmd, |
| 5149 | "no ip ospf retransmit-interval", |
| 5150 | NO_STR |
| 5151 | "IP Information\n" |
| 5152 | "OSPF interface commands\n" |
| 5153 | "Time between retransmitting lost link state advertisements\n") |
| 5154 | |
| 5155 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5156 | no_ospf_retransmit_interval_cmd, |
| 5157 | "no ospf retransmit-interval", |
| 5158 | NO_STR |
| 5159 | "OSPF interface commands\n" |
| 5160 | "Time between retransmitting lost link state advertisements\n") |
| 5161 | |
| 5162 | DEFUN (ip_ospf_transmit_delay, |
| 5163 | ip_ospf_transmit_delay_addr_cmd, |
| 5164 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5165 | "IP Information\n" |
| 5166 | "OSPF interface commands\n" |
| 5167 | "Link state transmit delay\n" |
| 5168 | "Seconds\n" |
| 5169 | "Address of interface") |
| 5170 | { |
| 5171 | struct interface *ifp = vty->index; |
| 5172 | u_int32_t seconds; |
| 5173 | struct in_addr addr; |
| 5174 | int ret; |
| 5175 | struct ospf_if_params *params; |
| 5176 | |
| 5177 | params = IF_DEF_PARAMS (ifp); |
| 5178 | seconds = strtol (argv[0], NULL, 10); |
| 5179 | |
| 5180 | /* Transmit Delay range is <1-65535>. */ |
| 5181 | if (seconds < 1 || seconds > 65535) |
| 5182 | { |
| 5183 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5184 | return CMD_WARNING; |
| 5185 | } |
| 5186 | |
| 5187 | if (argc == 2) |
| 5188 | { |
| 5189 | ret = inet_aton(argv[1], &addr); |
| 5190 | if (!ret) |
| 5191 | { |
| 5192 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5193 | VTY_NEWLINE); |
| 5194 | return CMD_WARNING; |
| 5195 | } |
| 5196 | |
| 5197 | params = ospf_get_if_params (ifp, addr); |
| 5198 | ospf_if_update_params (ifp, addr); |
| 5199 | } |
| 5200 | |
| 5201 | SET_IF_PARAM (params, transmit_delay); |
| 5202 | params->transmit_delay = seconds; |
| 5203 | |
| 5204 | return CMD_SUCCESS; |
| 5205 | } |
| 5206 | |
| 5207 | ALIAS (ip_ospf_transmit_delay, |
| 5208 | ip_ospf_transmit_delay_cmd, |
| 5209 | "ip ospf transmit-delay <1-65535>", |
| 5210 | "IP Information\n" |
| 5211 | "OSPF interface commands\n" |
| 5212 | "Link state transmit delay\n" |
| 5213 | "Seconds\n") |
| 5214 | |
| 5215 | ALIAS (ip_ospf_transmit_delay, |
| 5216 | ospf_transmit_delay_cmd, |
| 5217 | "ospf transmit-delay <1-65535>", |
| 5218 | "OSPF interface commands\n" |
| 5219 | "Link state transmit delay\n" |
| 5220 | "Seconds\n") |
| 5221 | |
| 5222 | DEFUN (no_ip_ospf_transmit_delay, |
| 5223 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5224 | "no ip ospf transmit-delay A.B.C.D", |
| 5225 | NO_STR |
| 5226 | "IP Information\n" |
| 5227 | "OSPF interface commands\n" |
| 5228 | "Link state transmit delay\n" |
| 5229 | "Address of interface") |
| 5230 | { |
| 5231 | struct interface *ifp = vty->index; |
| 5232 | struct in_addr addr; |
| 5233 | int ret; |
| 5234 | struct ospf_if_params *params; |
| 5235 | |
| 5236 | ifp = vty->index; |
| 5237 | params = IF_DEF_PARAMS (ifp); |
| 5238 | |
| 5239 | if (argc == 1) |
| 5240 | { |
| 5241 | ret = inet_aton(argv[0], &addr); |
| 5242 | if (!ret) |
| 5243 | { |
| 5244 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5245 | VTY_NEWLINE); |
| 5246 | return CMD_WARNING; |
| 5247 | } |
| 5248 | |
| 5249 | params = ospf_lookup_if_params (ifp, addr); |
| 5250 | if (params == NULL) |
| 5251 | return CMD_SUCCESS; |
| 5252 | } |
| 5253 | |
| 5254 | UNSET_IF_PARAM (params, transmit_delay); |
| 5255 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5256 | |
| 5257 | if (params != IF_DEF_PARAMS (ifp)) |
| 5258 | { |
| 5259 | ospf_free_if_params (ifp, addr); |
| 5260 | ospf_if_update_params (ifp, addr); |
| 5261 | } |
| 5262 | |
| 5263 | return CMD_SUCCESS; |
| 5264 | } |
| 5265 | |
| 5266 | ALIAS (no_ip_ospf_transmit_delay, |
| 5267 | no_ip_ospf_transmit_delay_cmd, |
| 5268 | "no ip ospf transmit-delay", |
| 5269 | NO_STR |
| 5270 | "IP Information\n" |
| 5271 | "OSPF interface commands\n" |
| 5272 | "Link state transmit delay\n") |
| 5273 | |
| 5274 | ALIAS (no_ip_ospf_transmit_delay, |
| 5275 | no_ospf_transmit_delay_cmd, |
| 5276 | "no ospf transmit-delay", |
| 5277 | NO_STR |
| 5278 | "OSPF interface commands\n" |
| 5279 | "Link state transmit delay\n") |
| 5280 | |
| 5281 | |
| 5282 | DEFUN (ospf_redistribute_source_metric_type, |
| 5283 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5284 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5285 | "Redistribute information from another routing protocol\n" |
| 5286 | "Kernel routes\n" |
| 5287 | "Connected\n" |
| 5288 | "Static routes\n" |
| 5289 | "Routing Information Protocol (RIP)\n" |
| 5290 | "Border Gateway Protocol (BGP)\n" |
| 5291 | "Metric for redistributed routes\n" |
| 5292 | "OSPF default metric\n" |
| 5293 | "OSPF exterior metric type for redistributed routes\n" |
| 5294 | "Set OSPF External Type 1 metrics\n" |
| 5295 | "Set OSPF External Type 2 metrics\n" |
| 5296 | "Route map reference\n" |
| 5297 | "Pointer to route-map entries\n") |
| 5298 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5299 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5300 | int source; |
| 5301 | int type = -1; |
| 5302 | int metric = -1; |
| 5303 | |
| 5304 | /* Get distribute source. */ |
| 5305 | if (!str2distribute_source (argv[0], &source)) |
| 5306 | return CMD_WARNING; |
| 5307 | |
| 5308 | /* Get metric value. */ |
| 5309 | if (argc >= 2) |
| 5310 | if (!str2metric (argv[1], &metric)) |
| 5311 | return CMD_WARNING; |
| 5312 | |
| 5313 | /* Get metric type. */ |
| 5314 | if (argc >= 3) |
| 5315 | if (!str2metric_type (argv[2], &type)) |
| 5316 | return CMD_WARNING; |
| 5317 | |
| 5318 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5319 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5320 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5321 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5322 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5323 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5324 | } |
| 5325 | |
| 5326 | ALIAS (ospf_redistribute_source_metric_type, |
| 5327 | ospf_redistribute_source_metric_type_cmd, |
| 5328 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5329 | "Redistribute information from another routing protocol\n" |
| 5330 | "Kernel routes\n" |
| 5331 | "Connected\n" |
| 5332 | "Static routes\n" |
| 5333 | "Routing Information Protocol (RIP)\n" |
| 5334 | "Border Gateway Protocol (BGP)\n" |
| 5335 | "Metric for redistributed routes\n" |
| 5336 | "OSPF default metric\n" |
| 5337 | "OSPF exterior metric type for redistributed routes\n" |
| 5338 | "Set OSPF External Type 1 metrics\n" |
| 5339 | "Set OSPF External Type 2 metrics\n") |
| 5340 | |
| 5341 | ALIAS (ospf_redistribute_source_metric_type, |
| 5342 | ospf_redistribute_source_metric_cmd, |
| 5343 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5344 | "Redistribute information from another routing protocol\n" |
| 5345 | "Kernel routes\n" |
| 5346 | "Connected\n" |
| 5347 | "Static routes\n" |
| 5348 | "Routing Information Protocol (RIP)\n" |
| 5349 | "Border Gateway Protocol (BGP)\n" |
| 5350 | "Metric for redistributed routes\n" |
| 5351 | "OSPF default metric\n") |
| 5352 | |
| 5353 | DEFUN (ospf_redistribute_source_type_metric, |
| 5354 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5355 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5356 | "Redistribute information from another routing protocol\n" |
| 5357 | "Kernel routes\n" |
| 5358 | "Connected\n" |
| 5359 | "Static routes\n" |
| 5360 | "Routing Information Protocol (RIP)\n" |
| 5361 | "Border Gateway Protocol (BGP)\n" |
| 5362 | "OSPF exterior metric type for redistributed routes\n" |
| 5363 | "Set OSPF External Type 1 metrics\n" |
| 5364 | "Set OSPF External Type 2 metrics\n" |
| 5365 | "Metric for redistributed routes\n" |
| 5366 | "OSPF default metric\n" |
| 5367 | "Route map reference\n" |
| 5368 | "Pointer to route-map entries\n") |
| 5369 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5370 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5371 | int source; |
| 5372 | int type = -1; |
| 5373 | int metric = -1; |
| 5374 | |
| 5375 | /* Get distribute source. */ |
| 5376 | if (!str2distribute_source (argv[0], &source)) |
| 5377 | return CMD_WARNING; |
| 5378 | |
| 5379 | /* Get metric value. */ |
| 5380 | if (argc >= 2) |
| 5381 | if (!str2metric_type (argv[1], &type)) |
| 5382 | return CMD_WARNING; |
| 5383 | |
| 5384 | /* Get metric type. */ |
| 5385 | if (argc >= 3) |
| 5386 | if (!str2metric (argv[2], &metric)) |
| 5387 | return CMD_WARNING; |
| 5388 | |
| 5389 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5390 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5391 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5392 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5393 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5394 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5395 | } |
| 5396 | |
| 5397 | ALIAS (ospf_redistribute_source_type_metric, |
| 5398 | ospf_redistribute_source_type_metric_cmd, |
| 5399 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5400 | "Redistribute information from another routing protocol\n" |
| 5401 | "Kernel routes\n" |
| 5402 | "Connected\n" |
| 5403 | "Static routes\n" |
| 5404 | "Routing Information Protocol (RIP)\n" |
| 5405 | "Border Gateway Protocol (BGP)\n" |
| 5406 | "OSPF exterior metric type for redistributed routes\n" |
| 5407 | "Set OSPF External Type 1 metrics\n" |
| 5408 | "Set OSPF External Type 2 metrics\n" |
| 5409 | "Metric for redistributed routes\n" |
| 5410 | "OSPF default metric\n") |
| 5411 | |
| 5412 | ALIAS (ospf_redistribute_source_type_metric, |
| 5413 | ospf_redistribute_source_type_cmd, |
| 5414 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5415 | "Redistribute information from another routing protocol\n" |
| 5416 | "Kernel routes\n" |
| 5417 | "Connected\n" |
| 5418 | "Static routes\n" |
| 5419 | "Routing Information Protocol (RIP)\n" |
| 5420 | "Border Gateway Protocol (BGP)\n" |
| 5421 | "OSPF exterior metric type for redistributed routes\n" |
| 5422 | "Set OSPF External Type 1 metrics\n" |
| 5423 | "Set OSPF External Type 2 metrics\n") |
| 5424 | |
| 5425 | ALIAS (ospf_redistribute_source_type_metric, |
| 5426 | ospf_redistribute_source_cmd, |
| 5427 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5428 | "Redistribute information from another routing protocol\n" |
| 5429 | "Kernel routes\n" |
| 5430 | "Connected\n" |
| 5431 | "Static routes\n" |
| 5432 | "Routing Information Protocol (RIP)\n" |
| 5433 | "Border Gateway Protocol (BGP)\n") |
| 5434 | |
| 5435 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5436 | ospf_redistribute_source_metric_routemap_cmd, |
| 5437 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5438 | "Redistribute information from another routing protocol\n" |
| 5439 | "Kernel routes\n" |
| 5440 | "Connected\n" |
| 5441 | "Static routes\n" |
| 5442 | "Routing Information Protocol (RIP)\n" |
| 5443 | "Border Gateway Protocol (BGP)\n" |
| 5444 | "Metric for redistributed routes\n" |
| 5445 | "OSPF default metric\n" |
| 5446 | "Route map reference\n" |
| 5447 | "Pointer to route-map entries\n") |
| 5448 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5449 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5450 | int source; |
| 5451 | int metric = -1; |
| 5452 | |
| 5453 | /* Get distribute source. */ |
| 5454 | if (!str2distribute_source (argv[0], &source)) |
| 5455 | return CMD_WARNING; |
| 5456 | |
| 5457 | /* Get metric value. */ |
| 5458 | if (argc >= 2) |
| 5459 | if (!str2metric (argv[1], &metric)) |
| 5460 | return CMD_WARNING; |
| 5461 | |
| 5462 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5463 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5464 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5465 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5466 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5467 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5468 | } |
| 5469 | |
| 5470 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5471 | ospf_redistribute_source_type_routemap_cmd, |
| 5472 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5473 | "Redistribute information from another routing protocol\n" |
| 5474 | "Kernel routes\n" |
| 5475 | "Connected\n" |
| 5476 | "Static routes\n" |
| 5477 | "Routing Information Protocol (RIP)\n" |
| 5478 | "Border Gateway Protocol (BGP)\n" |
| 5479 | "OSPF exterior metric type for redistributed routes\n" |
| 5480 | "Set OSPF External Type 1 metrics\n" |
| 5481 | "Set OSPF External Type 2 metrics\n" |
| 5482 | "Route map reference\n" |
| 5483 | "Pointer to route-map entries\n") |
| 5484 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5485 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5486 | int source; |
| 5487 | int type = -1; |
| 5488 | |
| 5489 | /* Get distribute source. */ |
| 5490 | if (!str2distribute_source (argv[0], &source)) |
| 5491 | return CMD_WARNING; |
| 5492 | |
| 5493 | /* Get metric value. */ |
| 5494 | if (argc >= 2) |
| 5495 | if (!str2metric_type (argv[1], &type)) |
| 5496 | return CMD_WARNING; |
| 5497 | |
| 5498 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5499 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5500 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5501 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5502 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5503 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5504 | } |
| 5505 | |
| 5506 | DEFUN (ospf_redistribute_source_routemap, |
| 5507 | ospf_redistribute_source_routemap_cmd, |
| 5508 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5509 | "Redistribute information from another routing protocol\n" |
| 5510 | "Kernel routes\n" |
| 5511 | "Connected\n" |
| 5512 | "Static routes\n" |
| 5513 | "Routing Information Protocol (RIP)\n" |
| 5514 | "Border Gateway Protocol (BGP)\n" |
| 5515 | "Route map reference\n" |
| 5516 | "Pointer to route-map entries\n") |
| 5517 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5518 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5519 | int source; |
| 5520 | |
| 5521 | /* Get distribute source. */ |
| 5522 | if (!str2distribute_source (argv[0], &source)) |
| 5523 | return CMD_WARNING; |
| 5524 | |
| 5525 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5526 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5527 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5528 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5529 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5530 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5531 | } |
| 5532 | |
| 5533 | DEFUN (no_ospf_redistribute_source, |
| 5534 | no_ospf_redistribute_source_cmd, |
| 5535 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5536 | NO_STR |
| 5537 | "Redistribute information from another routing protocol\n" |
| 5538 | "Kernel routes\n" |
| 5539 | "Connected\n" |
| 5540 | "Static routes\n" |
| 5541 | "Routing Information Protocol (RIP)\n" |
| 5542 | "Border Gateway Protocol (BGP)\n") |
| 5543 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5544 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5545 | int source; |
| 5546 | |
| 5547 | if (!str2distribute_source (argv[0], &source)) |
| 5548 | return CMD_WARNING; |
| 5549 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5550 | ospf_routemap_unset (ospf, source); |
| 5551 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5552 | } |
| 5553 | |
| 5554 | DEFUN (ospf_distribute_list_out, |
| 5555 | ospf_distribute_list_out_cmd, |
| 5556 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5557 | "Filter networks in routing updates\n" |
| 5558 | "Access-list name\n" |
| 5559 | OUT_STR |
| 5560 | "Kernel routes\n" |
| 5561 | "Connected\n" |
| 5562 | "Static routes\n" |
| 5563 | "Routing Information Protocol (RIP)\n" |
| 5564 | "Border Gateway Protocol (BGP)\n") |
| 5565 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5566 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5567 | int source; |
| 5568 | |
| 5569 | /* Get distribute source. */ |
| 5570 | if (!str2distribute_source (argv[1], &source)) |
| 5571 | return CMD_WARNING; |
| 5572 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5573 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5574 | } |
| 5575 | |
| 5576 | DEFUN (no_ospf_distribute_list_out, |
| 5577 | no_ospf_distribute_list_out_cmd, |
| 5578 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5579 | NO_STR |
| 5580 | "Filter networks in routing updates\n" |
| 5581 | "Access-list name\n" |
| 5582 | OUT_STR |
| 5583 | "Kernel routes\n" |
| 5584 | "Connected\n" |
| 5585 | "Static routes\n" |
| 5586 | "Routing Information Protocol (RIP)\n" |
| 5587 | "Border Gateway Protocol (BGP)\n") |
| 5588 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5589 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5590 | int source; |
| 5591 | |
| 5592 | if (!str2distribute_source (argv[1], &source)) |
| 5593 | return CMD_WARNING; |
| 5594 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5595 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5596 | } |
| 5597 | |
| 5598 | /* Default information originate. */ |
| 5599 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5600 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5601 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5602 | "Control distribution of default information\n" |
| 5603 | "Distribute a default route\n" |
| 5604 | "OSPF default metric\n" |
| 5605 | "OSPF metric\n" |
| 5606 | "OSPF metric type for default routes\n" |
| 5607 | "Set OSPF External Type 1 metrics\n" |
| 5608 | "Set OSPF External Type 2 metrics\n" |
| 5609 | "Route map reference\n" |
| 5610 | "Pointer to route-map entries\n") |
| 5611 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5612 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5613 | int type = -1; |
| 5614 | int metric = -1; |
| 5615 | |
| 5616 | /* Get metric value. */ |
| 5617 | if (argc >= 1) |
| 5618 | if (!str2metric (argv[0], &metric)) |
| 5619 | return CMD_WARNING; |
| 5620 | |
| 5621 | /* Get metric type. */ |
| 5622 | if (argc >= 2) |
| 5623 | if (!str2metric_type (argv[1], &type)) |
| 5624 | return CMD_WARNING; |
| 5625 | |
| 5626 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5627 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5628 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5629 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5630 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5631 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5632 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5633 | } |
| 5634 | |
| 5635 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5636 | ospf_default_information_originate_metric_type_cmd, |
| 5637 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5638 | "Control distribution of default information\n" |
| 5639 | "Distribute a default route\n" |
| 5640 | "OSPF default metric\n" |
| 5641 | "OSPF metric\n" |
| 5642 | "OSPF metric type for default routes\n" |
| 5643 | "Set OSPF External Type 1 metrics\n" |
| 5644 | "Set OSPF External Type 2 metrics\n") |
| 5645 | |
| 5646 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5647 | ospf_default_information_originate_metric_cmd, |
| 5648 | "default-information originate metric <0-16777214>", |
| 5649 | "Control distribution of default information\n" |
| 5650 | "Distribute a default route\n" |
| 5651 | "OSPF default metric\n" |
| 5652 | "OSPF metric\n") |
| 5653 | |
| 5654 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5655 | ospf_default_information_originate_cmd, |
| 5656 | "default-information originate", |
| 5657 | "Control distribution of default information\n" |
| 5658 | "Distribute a default route\n") |
| 5659 | |
| 5660 | /* Default information originate. */ |
| 5661 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5662 | ospf_default_information_originate_metric_routemap_cmd, |
| 5663 | "default-information originate metric <0-16777214> route-map WORD", |
| 5664 | "Control distribution of default information\n" |
| 5665 | "Distribute a default route\n" |
| 5666 | "OSPF default metric\n" |
| 5667 | "OSPF metric\n" |
| 5668 | "Route map reference\n" |
| 5669 | "Pointer to route-map entries\n") |
| 5670 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5671 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5672 | int metric = -1; |
| 5673 | |
| 5674 | /* Get metric value. */ |
| 5675 | if (argc >= 1) |
| 5676 | if (!str2metric (argv[0], &metric)) |
| 5677 | return CMD_WARNING; |
| 5678 | |
| 5679 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5680 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5681 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5682 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5683 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5684 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5685 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5686 | } |
| 5687 | |
| 5688 | /* Default information originate. */ |
| 5689 | DEFUN (ospf_default_information_originate_routemap, |
| 5690 | ospf_default_information_originate_routemap_cmd, |
| 5691 | "default-information originate route-map WORD", |
| 5692 | "Control distribution of default information\n" |
| 5693 | "Distribute a default route\n" |
| 5694 | "Route map reference\n" |
| 5695 | "Pointer to route-map entries\n") |
| 5696 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5697 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5698 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5699 | if (argc == 1) |
| 5700 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5701 | else |
| 5702 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5703 | |
| 5704 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5705 | } |
| 5706 | |
| 5707 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 5708 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 5709 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5710 | "Control distribution of default information\n" |
| 5711 | "Distribute a default route\n" |
| 5712 | "OSPF metric type for default routes\n" |
| 5713 | "Set OSPF External Type 1 metrics\n" |
| 5714 | "Set OSPF External Type 2 metrics\n" |
| 5715 | "OSPF default metric\n" |
| 5716 | "OSPF metric\n" |
| 5717 | "Route map reference\n" |
| 5718 | "Pointer to route-map entries\n") |
| 5719 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5720 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5721 | int type = -1; |
| 5722 | int metric = -1; |
| 5723 | |
| 5724 | /* Get metric type. */ |
| 5725 | if (argc >= 1) |
| 5726 | if (!str2metric_type (argv[0], &type)) |
| 5727 | return CMD_WARNING; |
| 5728 | |
| 5729 | /* Get metric value. */ |
| 5730 | if (argc >= 2) |
| 5731 | if (!str2metric (argv[1], &metric)) |
| 5732 | return CMD_WARNING; |
| 5733 | |
| 5734 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5735 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5736 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5737 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5738 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5739 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5740 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5741 | } |
| 5742 | |
| 5743 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5744 | ospf_default_information_originate_type_metric_cmd, |
| 5745 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 5746 | "Control distribution of default information\n" |
| 5747 | "Distribute a default route\n" |
| 5748 | "OSPF metric type for default routes\n" |
| 5749 | "Set OSPF External Type 1 metrics\n" |
| 5750 | "Set OSPF External Type 2 metrics\n" |
| 5751 | "OSPF default metric\n" |
| 5752 | "OSPF metric\n") |
| 5753 | |
| 5754 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5755 | ospf_default_information_originate_type_cmd, |
| 5756 | "default-information originate metric-type (1|2)", |
| 5757 | "Control distribution of default information\n" |
| 5758 | "Distribute a default route\n" |
| 5759 | "OSPF metric type for default routes\n" |
| 5760 | "Set OSPF External Type 1 metrics\n" |
| 5761 | "Set OSPF External Type 2 metrics\n") |
| 5762 | |
| 5763 | DEFUN (ospf_default_information_originate_type_routemap, |
| 5764 | ospf_default_information_originate_type_routemap_cmd, |
| 5765 | "default-information originate metric-type (1|2) route-map WORD", |
| 5766 | "Control distribution of default information\n" |
| 5767 | "Distribute a default route\n" |
| 5768 | "OSPF metric type for default routes\n" |
| 5769 | "Set OSPF External Type 1 metrics\n" |
| 5770 | "Set OSPF External Type 2 metrics\n" |
| 5771 | "Route map reference\n" |
| 5772 | "Pointer to route-map entries\n") |
| 5773 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5774 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5775 | int type = -1; |
| 5776 | |
| 5777 | /* Get metric type. */ |
| 5778 | if (argc >= 1) |
| 5779 | if (!str2metric_type (argv[0], &type)) |
| 5780 | return CMD_WARNING; |
| 5781 | |
| 5782 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5783 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5784 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5785 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5786 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5787 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5788 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5789 | } |
| 5790 | |
| 5791 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 5792 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 5793 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5794 | "Control distribution of default information\n" |
| 5795 | "Distribute a default route\n" |
| 5796 | "Always advertise default route\n" |
| 5797 | "OSPF default metric\n" |
| 5798 | "OSPF metric\n" |
| 5799 | "OSPF metric type for default routes\n" |
| 5800 | "Set OSPF External Type 1 metrics\n" |
| 5801 | "Set OSPF External Type 2 metrics\n" |
| 5802 | "Route map reference\n" |
| 5803 | "Pointer to route-map entries\n") |
| 5804 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5805 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5806 | int type = -1; |
| 5807 | int metric = -1; |
| 5808 | |
| 5809 | /* Get metric value. */ |
| 5810 | if (argc >= 1) |
| 5811 | if (!str2metric (argv[0], &metric)) |
| 5812 | return CMD_WARNING; |
| 5813 | |
| 5814 | /* Get metric type. */ |
| 5815 | if (argc >= 2) |
| 5816 | if (!str2metric_type (argv[1], &type)) |
| 5817 | return CMD_WARNING; |
| 5818 | |
| 5819 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5820 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
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_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5825 | type, metric); |
| 5826 | } |
| 5827 | |
| 5828 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5829 | ospf_default_information_originate_always_metric_type_cmd, |
| 5830 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 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 | |
| 5840 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5841 | ospf_default_information_originate_always_metric_cmd, |
| 5842 | "default-information originate always metric <0-16777214>", |
| 5843 | "Control distribution of default information\n" |
| 5844 | "Distribute a default route\n" |
| 5845 | "Always advertise default route\n" |
| 5846 | "OSPF default metric\n" |
| 5847 | "OSPF metric\n" |
| 5848 | "OSPF metric type for default routes\n") |
| 5849 | |
| 5850 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5851 | ospf_default_information_originate_always_cmd, |
| 5852 | "default-information originate always", |
| 5853 | "Control distribution of default information\n" |
| 5854 | "Distribute a default route\n" |
| 5855 | "Always advertise default route\n") |
| 5856 | |
| 5857 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 5858 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 5859 | "default-information originate always metric <0-16777214> route-map WORD", |
| 5860 | "Control distribution of default information\n" |
| 5861 | "Distribute a default route\n" |
| 5862 | "Always advertise default route\n" |
| 5863 | "OSPF default metric\n" |
| 5864 | "OSPF metric\n" |
| 5865 | "Route map reference\n" |
| 5866 | "Pointer to route-map entries\n") |
| 5867 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5868 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5869 | int metric = -1; |
| 5870 | |
| 5871 | /* Get metric value. */ |
| 5872 | if (argc >= 1) |
| 5873 | if (!str2metric (argv[0], &metric)) |
| 5874 | return CMD_WARNING; |
| 5875 | |
| 5876 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5877 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5878 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5879 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5880 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5881 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 5882 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5883 | } |
| 5884 | |
| 5885 | DEFUN (ospf_default_information_originate_always_routemap, |
| 5886 | ospf_default_information_originate_always_routemap_cmd, |
| 5887 | "default-information originate always route-map WORD", |
| 5888 | "Control distribution of default information\n" |
| 5889 | "Distribute a default route\n" |
| 5890 | "Always advertise default route\n" |
| 5891 | "Route map reference\n" |
| 5892 | "Pointer to route-map entries\n") |
| 5893 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5894 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5895 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5896 | if (argc == 1) |
| 5897 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5898 | else |
| 5899 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5900 | |
| 5901 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5902 | } |
| 5903 | |
| 5904 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 5905 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 5906 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5907 | "Control distribution of default information\n" |
| 5908 | "Distribute a default route\n" |
| 5909 | "Always advertise default route\n" |
| 5910 | "OSPF metric type for default routes\n" |
| 5911 | "Set OSPF External Type 1 metrics\n" |
| 5912 | "Set OSPF External Type 2 metrics\n" |
| 5913 | "OSPF default metric\n" |
| 5914 | "OSPF metric\n" |
| 5915 | "Route map reference\n" |
| 5916 | "Pointer to route-map entries\n") |
| 5917 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5918 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5919 | int type = -1; |
| 5920 | int metric = -1; |
| 5921 | |
| 5922 | /* Get metric type. */ |
| 5923 | if (argc >= 1) |
| 5924 | if (!str2metric_type (argv[0], &type)) |
| 5925 | return CMD_WARNING; |
| 5926 | |
| 5927 | /* Get metric value. */ |
| 5928 | if (argc >= 2) |
| 5929 | if (!str2metric (argv[1], &metric)) |
| 5930 | return CMD_WARNING; |
| 5931 | |
| 5932 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5933 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5934 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5935 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5936 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5937 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5938 | type, metric); |
| 5939 | } |
| 5940 | |
| 5941 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 5942 | ospf_default_information_originate_always_type_metric_cmd, |
| 5943 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 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 | |
| 5953 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 5954 | ospf_default_information_originate_always_type_cmd, |
| 5955 | "default-information originate always metric-type (1|2)", |
| 5956 | "Control distribution of default information\n" |
| 5957 | "Distribute a default route\n" |
| 5958 | "Always advertise default route\n" |
| 5959 | "OSPF metric type for default routes\n" |
| 5960 | "Set OSPF External Type 1 metrics\n" |
| 5961 | "Set OSPF External Type 2 metrics\n") |
| 5962 | |
| 5963 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 5964 | ospf_default_information_originate_always_type_routemap_cmd, |
| 5965 | "default-information originate always metric-type (1|2) route-map WORD", |
| 5966 | "Control distribution of default information\n" |
| 5967 | "Distribute a default route\n" |
| 5968 | "Always advertise default route\n" |
| 5969 | "OSPF metric type for default routes\n" |
| 5970 | "Set OSPF External Type 1 metrics\n" |
| 5971 | "Set OSPF External Type 2 metrics\n" |
| 5972 | "Route map reference\n" |
| 5973 | "Pointer to route-map entries\n") |
| 5974 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5975 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | int type = -1; |
| 5977 | |
| 5978 | /* Get metric type. */ |
| 5979 | if (argc >= 1) |
| 5980 | if (!str2metric_type (argv[0], &type)) |
| 5981 | return CMD_WARNING; |
| 5982 | |
| 5983 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5984 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5985 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5986 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5987 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5988 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5989 | type, -1); |
| 5990 | } |
| 5991 | |
| 5992 | DEFUN (no_ospf_default_information_originate, |
| 5993 | no_ospf_default_information_originate_cmd, |
| 5994 | "no default-information originate", |
| 5995 | NO_STR |
| 5996 | "Control distribution of default information\n" |
| 5997 | "Distribute a default route\n") |
| 5998 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5999 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6000 | struct prefix_ipv4 p; |
| 6001 | struct in_addr nexthop; |
| 6002 | |
| 6003 | p.family = AF_INET; |
| 6004 | p.prefix.s_addr = 0; |
| 6005 | p.prefixlen = 0; |
| 6006 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6007 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6008 | |
| 6009 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6010 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6011 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6012 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6013 | } |
| 6014 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6015 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6016 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | } |
| 6018 | |
| 6019 | DEFUN (ospf_default_metric, |
| 6020 | ospf_default_metric_cmd, |
| 6021 | "default-metric <0-16777214>", |
| 6022 | "Set metric of redistributed routes\n" |
| 6023 | "Default metric\n") |
| 6024 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6025 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6026 | int metric = -1; |
| 6027 | |
| 6028 | if (!str2metric (argv[0], &metric)) |
| 6029 | return CMD_WARNING; |
| 6030 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6031 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6032 | |
| 6033 | return CMD_SUCCESS; |
| 6034 | } |
| 6035 | |
| 6036 | DEFUN (no_ospf_default_metric, |
| 6037 | no_ospf_default_metric_cmd, |
| 6038 | "no default-metric", |
| 6039 | NO_STR |
| 6040 | "Set metric of redistributed routes\n") |
| 6041 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6042 | struct ospf *ospf = vty->index; |
| 6043 | |
| 6044 | ospf->default_metric = -1; |
| 6045 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6046 | return CMD_SUCCESS; |
| 6047 | } |
| 6048 | |
| 6049 | ALIAS (no_ospf_default_metric, |
| 6050 | no_ospf_default_metric_val_cmd, |
| 6051 | "no default-metric <0-16777214>", |
| 6052 | NO_STR |
| 6053 | "Set metric of redistributed routes\n" |
| 6054 | "Default metric\n") |
| 6055 | |
| 6056 | DEFUN (ospf_distance, |
| 6057 | ospf_distance_cmd, |
| 6058 | "distance <1-255>", |
| 6059 | "Define an administrative distance\n" |
| 6060 | "OSPF Administrative distance\n") |
| 6061 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6062 | struct ospf *ospf = vty->index; |
| 6063 | |
| 6064 | ospf->distance_all = atoi (argv[0]); |
| 6065 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6066 | return CMD_SUCCESS; |
| 6067 | } |
| 6068 | |
| 6069 | DEFUN (no_ospf_distance, |
| 6070 | no_ospf_distance_cmd, |
| 6071 | "no distance <1-255>", |
| 6072 | NO_STR |
| 6073 | "Define an administrative distance\n" |
| 6074 | "OSPF Administrative distance\n") |
| 6075 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6076 | struct ospf *ospf = vty->index; |
| 6077 | |
| 6078 | ospf->distance_all = 0; |
| 6079 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6080 | return CMD_SUCCESS; |
| 6081 | } |
| 6082 | |
| 6083 | DEFUN (no_ospf_distance_ospf, |
| 6084 | no_ospf_distance_ospf_cmd, |
| 6085 | "no distance ospf", |
| 6086 | NO_STR |
| 6087 | "Define an administrative distance\n" |
| 6088 | "OSPF Administrative distance\n" |
| 6089 | "OSPF Distance\n") |
| 6090 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6091 | struct ospf *ospf = vty->index; |
| 6092 | |
| 6093 | ospf->distance_intra = 0; |
| 6094 | ospf->distance_inter = 0; |
| 6095 | ospf->distance_external = 0; |
| 6096 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6097 | return CMD_SUCCESS; |
| 6098 | } |
| 6099 | |
| 6100 | DEFUN (ospf_distance_ospf_intra, |
| 6101 | ospf_distance_ospf_intra_cmd, |
| 6102 | "distance ospf intra-area <1-255>", |
| 6103 | "Define an administrative distance\n" |
| 6104 | "OSPF Administrative distance\n" |
| 6105 | "Intra-area routes\n" |
| 6106 | "Distance for intra-area routes\n") |
| 6107 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6108 | struct ospf *ospf = vty->index; |
| 6109 | |
| 6110 | ospf->distance_intra = atoi (argv[0]); |
| 6111 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6112 | return CMD_SUCCESS; |
| 6113 | } |
| 6114 | |
| 6115 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6116 | ospf_distance_ospf_intra_inter_cmd, |
| 6117 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6118 | "Define an administrative distance\n" |
| 6119 | "OSPF Administrative distance\n" |
| 6120 | "Intra-area routes\n" |
| 6121 | "Distance for intra-area routes\n" |
| 6122 | "Inter-area routes\n" |
| 6123 | "Distance for inter-area routes\n") |
| 6124 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6125 | struct ospf *ospf = vty->index; |
| 6126 | |
| 6127 | ospf->distance_intra = atoi (argv[0]); |
| 6128 | ospf->distance_inter = atoi (argv[1]); |
| 6129 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6130 | return CMD_SUCCESS; |
| 6131 | } |
| 6132 | |
| 6133 | DEFUN (ospf_distance_ospf_intra_external, |
| 6134 | ospf_distance_ospf_intra_external_cmd, |
| 6135 | "distance ospf intra-area <1-255> external <1-255>", |
| 6136 | "Define an administrative distance\n" |
| 6137 | "OSPF Administrative distance\n" |
| 6138 | "Intra-area routes\n" |
| 6139 | "Distance for intra-area routes\n" |
| 6140 | "External routes\n" |
| 6141 | "Distance for external routes\n") |
| 6142 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6143 | struct ospf *ospf = vty->index; |
| 6144 | |
| 6145 | ospf->distance_intra = atoi (argv[0]); |
| 6146 | ospf->distance_external = atoi (argv[1]); |
| 6147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6148 | return CMD_SUCCESS; |
| 6149 | } |
| 6150 | |
| 6151 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6152 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6153 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6154 | "Define an administrative distance\n" |
| 6155 | "OSPF Administrative distance\n" |
| 6156 | "Intra-area routes\n" |
| 6157 | "Distance for intra-area routes\n" |
| 6158 | "Inter-area routes\n" |
| 6159 | "Distance for inter-area routes\n" |
| 6160 | "External routes\n" |
| 6161 | "Distance for external routes\n") |
| 6162 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6163 | struct ospf *ospf = vty->index; |
| 6164 | |
| 6165 | ospf->distance_intra = atoi (argv[0]); |
| 6166 | ospf->distance_inter = atoi (argv[1]); |
| 6167 | ospf->distance_external = atoi (argv[2]); |
| 6168 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6169 | return CMD_SUCCESS; |
| 6170 | } |
| 6171 | |
| 6172 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6173 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6174 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6175 | "Define an administrative distance\n" |
| 6176 | "OSPF Administrative distance\n" |
| 6177 | "Intra-area routes\n" |
| 6178 | "Distance for intra-area routes\n" |
| 6179 | "External routes\n" |
| 6180 | "Distance for external routes\n" |
| 6181 | "Inter-area routes\n" |
| 6182 | "Distance for inter-area routes\n") |
| 6183 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6184 | struct ospf *ospf = vty->index; |
| 6185 | |
| 6186 | ospf->distance_intra = atoi (argv[0]); |
| 6187 | ospf->distance_external = atoi (argv[1]); |
| 6188 | ospf->distance_inter = atoi (argv[2]); |
| 6189 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6190 | return CMD_SUCCESS; |
| 6191 | } |
| 6192 | |
| 6193 | DEFUN (ospf_distance_ospf_inter, |
| 6194 | ospf_distance_ospf_inter_cmd, |
| 6195 | "distance ospf inter-area <1-255>", |
| 6196 | "Define an administrative distance\n" |
| 6197 | "OSPF Administrative distance\n" |
| 6198 | "Inter-area routes\n" |
| 6199 | "Distance for inter-area routes\n") |
| 6200 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6201 | struct ospf *ospf = vty->index; |
| 6202 | |
| 6203 | ospf->distance_inter = atoi (argv[0]); |
| 6204 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6205 | return CMD_SUCCESS; |
| 6206 | } |
| 6207 | |
| 6208 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6209 | ospf_distance_ospf_inter_intra_cmd, |
| 6210 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6211 | "Define an administrative distance\n" |
| 6212 | "OSPF Administrative distance\n" |
| 6213 | "Inter-area routes\n" |
| 6214 | "Distance for inter-area routes\n" |
| 6215 | "Intra-area routes\n" |
| 6216 | "Distance for intra-area routes\n") |
| 6217 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6218 | struct ospf *ospf = vty->index; |
| 6219 | |
| 6220 | ospf->distance_inter = atoi (argv[0]); |
| 6221 | ospf->distance_intra = atoi (argv[1]); |
| 6222 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6223 | return CMD_SUCCESS; |
| 6224 | } |
| 6225 | |
| 6226 | DEFUN (ospf_distance_ospf_inter_external, |
| 6227 | ospf_distance_ospf_inter_external_cmd, |
| 6228 | "distance ospf inter-area <1-255> external <1-255>", |
| 6229 | "Define an administrative distance\n" |
| 6230 | "OSPF Administrative distance\n" |
| 6231 | "Inter-area routes\n" |
| 6232 | "Distance for inter-area routes\n" |
| 6233 | "External routes\n" |
| 6234 | "Distance for external routes\n") |
| 6235 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6236 | struct ospf *ospf = vty->index; |
| 6237 | |
| 6238 | ospf->distance_inter = atoi (argv[0]); |
| 6239 | ospf->distance_external = atoi (argv[1]); |
| 6240 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6241 | return CMD_SUCCESS; |
| 6242 | } |
| 6243 | |
| 6244 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6245 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6246 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6247 | "Define an administrative distance\n" |
| 6248 | "OSPF Administrative distance\n" |
| 6249 | "Inter-area routes\n" |
| 6250 | "Distance for inter-area routes\n" |
| 6251 | "Intra-area routes\n" |
| 6252 | "Distance for intra-area routes\n" |
| 6253 | "External routes\n" |
| 6254 | "Distance for external routes\n") |
| 6255 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6256 | struct ospf *ospf = vty->index; |
| 6257 | |
| 6258 | ospf->distance_inter = atoi (argv[0]); |
| 6259 | ospf->distance_intra = atoi (argv[1]); |
| 6260 | ospf->distance_external = atoi (argv[2]); |
| 6261 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6262 | return CMD_SUCCESS; |
| 6263 | } |
| 6264 | |
| 6265 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6266 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6267 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6268 | "Define an administrative distance\n" |
| 6269 | "OSPF Administrative distance\n" |
| 6270 | "Inter-area routes\n" |
| 6271 | "Distance for inter-area routes\n" |
| 6272 | "External routes\n" |
| 6273 | "Distance for external routes\n" |
| 6274 | "Intra-area routes\n" |
| 6275 | "Distance for intra-area routes\n") |
| 6276 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6277 | struct ospf *ospf = vty->index; |
| 6278 | |
| 6279 | ospf->distance_inter = atoi (argv[0]); |
| 6280 | ospf->distance_external = atoi (argv[1]); |
| 6281 | ospf->distance_intra = atoi (argv[2]); |
| 6282 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6283 | return CMD_SUCCESS; |
| 6284 | } |
| 6285 | |
| 6286 | DEFUN (ospf_distance_ospf_external, |
| 6287 | ospf_distance_ospf_external_cmd, |
| 6288 | "distance ospf external <1-255>", |
| 6289 | "Define an administrative distance\n" |
| 6290 | "OSPF Administrative distance\n" |
| 6291 | "External routes\n" |
| 6292 | "Distance for external routes\n") |
| 6293 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6294 | struct ospf *ospf = vty->index; |
| 6295 | |
| 6296 | ospf->distance_external = atoi (argv[0]); |
| 6297 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6298 | return CMD_SUCCESS; |
| 6299 | } |
| 6300 | |
| 6301 | DEFUN (ospf_distance_ospf_external_intra, |
| 6302 | ospf_distance_ospf_external_intra_cmd, |
| 6303 | "distance ospf external <1-255> intra-area <1-255>", |
| 6304 | "Define an administrative distance\n" |
| 6305 | "OSPF Administrative distance\n" |
| 6306 | "External routes\n" |
| 6307 | "Distance for external routes\n" |
| 6308 | "Intra-area routes\n" |
| 6309 | "Distance for intra-area routes\n") |
| 6310 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6311 | struct ospf *ospf = vty->index; |
| 6312 | |
| 6313 | ospf->distance_external = atoi (argv[0]); |
| 6314 | ospf->distance_intra = atoi (argv[1]); |
| 6315 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6316 | return CMD_SUCCESS; |
| 6317 | } |
| 6318 | |
| 6319 | DEFUN (ospf_distance_ospf_external_inter, |
| 6320 | ospf_distance_ospf_external_inter_cmd, |
| 6321 | "distance ospf external <1-255> inter-area <1-255>", |
| 6322 | "Define an administrative distance\n" |
| 6323 | "OSPF Administrative distance\n" |
| 6324 | "External routes\n" |
| 6325 | "Distance for external routes\n" |
| 6326 | "Inter-area routes\n" |
| 6327 | "Distance for inter-area routes\n") |
| 6328 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6329 | struct ospf *ospf = vty->index; |
| 6330 | |
| 6331 | ospf->distance_external = atoi (argv[0]); |
| 6332 | ospf->distance_inter = atoi (argv[1]); |
| 6333 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6334 | return CMD_SUCCESS; |
| 6335 | } |
| 6336 | |
| 6337 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6338 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6339 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6340 | "Define an administrative distance\n" |
| 6341 | "OSPF Administrative distance\n" |
| 6342 | "External routes\n" |
| 6343 | "Distance for external routes\n" |
| 6344 | "Intra-area routes\n" |
| 6345 | "Distance for intra-area routes\n" |
| 6346 | "Inter-area routes\n" |
| 6347 | "Distance for inter-area routes\n") |
| 6348 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6349 | struct ospf *ospf = vty->index; |
| 6350 | |
| 6351 | ospf->distance_external = atoi (argv[0]); |
| 6352 | ospf->distance_intra = atoi (argv[1]); |
| 6353 | ospf->distance_inter = atoi (argv[2]); |
| 6354 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6355 | return CMD_SUCCESS; |
| 6356 | } |
| 6357 | |
| 6358 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6359 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6360 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6361 | "Define an administrative distance\n" |
| 6362 | "OSPF Administrative distance\n" |
| 6363 | "External routes\n" |
| 6364 | "Distance for external routes\n" |
| 6365 | "Inter-area routes\n" |
| 6366 | "Distance for inter-area routes\n" |
| 6367 | "Intra-area routes\n" |
| 6368 | "Distance for intra-area routes\n") |
| 6369 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6370 | struct ospf *ospf = vty->index; |
| 6371 | |
| 6372 | ospf->distance_external = atoi (argv[0]); |
| 6373 | ospf->distance_inter = atoi (argv[1]); |
| 6374 | ospf->distance_intra = atoi (argv[2]); |
| 6375 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6376 | return CMD_SUCCESS; |
| 6377 | } |
| 6378 | |
| 6379 | DEFUN (ospf_distance_source, |
| 6380 | ospf_distance_source_cmd, |
| 6381 | "distance <1-255> A.B.C.D/M", |
| 6382 | "Administrative distance\n" |
| 6383 | "Distance value\n" |
| 6384 | "IP source prefix\n") |
| 6385 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6386 | struct ospf *ospf = vty->index; |
| 6387 | |
| 6388 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6389 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6390 | return CMD_SUCCESS; |
| 6391 | } |
| 6392 | |
| 6393 | DEFUN (no_ospf_distance_source, |
| 6394 | no_ospf_distance_source_cmd, |
| 6395 | "no distance <1-255> A.B.C.D/M", |
| 6396 | NO_STR |
| 6397 | "Administrative distance\n" |
| 6398 | "Distance value\n" |
| 6399 | "IP source prefix\n") |
| 6400 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6401 | struct ospf *ospf = vty->index; |
| 6402 | |
| 6403 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6404 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6405 | return CMD_SUCCESS; |
| 6406 | } |
| 6407 | |
| 6408 | DEFUN (ospf_distance_source_access_list, |
| 6409 | ospf_distance_source_access_list_cmd, |
| 6410 | "distance <1-255> A.B.C.D/M WORD", |
| 6411 | "Administrative distance\n" |
| 6412 | "Distance value\n" |
| 6413 | "IP source prefix\n" |
| 6414 | "Access list name\n") |
| 6415 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6416 | struct ospf *ospf = vty->index; |
| 6417 | |
| 6418 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6419 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6420 | return CMD_SUCCESS; |
| 6421 | } |
| 6422 | |
| 6423 | DEFUN (no_ospf_distance_source_access_list, |
| 6424 | no_ospf_distance_source_access_list_cmd, |
| 6425 | "no distance <1-255> A.B.C.D/M WORD", |
| 6426 | NO_STR |
| 6427 | "Administrative distance\n" |
| 6428 | "Distance value\n" |
| 6429 | "IP source prefix\n" |
| 6430 | "Access list name\n") |
| 6431 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6432 | struct ospf *ospf = vty->index; |
| 6433 | |
| 6434 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6435 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6436 | return CMD_SUCCESS; |
| 6437 | } |
| 6438 | |
| 6439 | void |
| 6440 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6441 | { |
| 6442 | struct route_node *rn; |
| 6443 | struct ospf_route *or; |
| 6444 | listnode pnode; |
| 6445 | struct ospf_path *path; |
| 6446 | |
| 6447 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6448 | VTY_NEWLINE); |
| 6449 | |
| 6450 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6451 | if ((or = rn->info) != NULL) |
| 6452 | { |
| 6453 | char buf1[19]; |
| 6454 | snprintf (buf1, 19, "%s/%d", |
| 6455 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6456 | |
| 6457 | switch (or->path_type) |
| 6458 | { |
| 6459 | case OSPF_PATH_INTER_AREA: |
| 6460 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6461 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6462 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6463 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6464 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6465 | break; |
| 6466 | case OSPF_PATH_INTRA_AREA: |
| 6467 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6468 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6469 | break; |
| 6470 | default: |
| 6471 | break; |
| 6472 | } |
| 6473 | |
| 6474 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6475 | for (pnode = listhead (or->path); pnode; nextnode (pnode)) |
| 6476 | { |
| 6477 | path = getdata (pnode); |
| 6478 | if (path->oi != NULL) |
| 6479 | { |
| 6480 | if (path->nexthop.s_addr == 0) |
| 6481 | vty_out (vty, "%24s directly attached to %s%s", |
| 6482 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6483 | else |
| 6484 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6485 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6486 | VTY_NEWLINE); |
| 6487 | } |
| 6488 | } |
| 6489 | } |
| 6490 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6491 | } |
| 6492 | |
| 6493 | void |
| 6494 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6495 | { |
| 6496 | struct route_node *rn; |
| 6497 | struct ospf_route *or; |
| 6498 | listnode pn, nn; |
| 6499 | struct ospf_path *path; |
| 6500 | |
| 6501 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6502 | VTY_NEWLINE); |
| 6503 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6504 | if (rn->info) |
| 6505 | { |
| 6506 | int flag = 0; |
| 6507 | |
| 6508 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6509 | |
| 6510 | for (nn = listhead ((list) rn->info); nn; nextnode (nn)) |
| 6511 | if ((or = getdata (nn)) != NULL) |
| 6512 | { |
| 6513 | if (flag++) |
| 6514 | vty_out(vty," " ); |
| 6515 | |
| 6516 | /* Show path. */ |
| 6517 | vty_out (vty, "%s [%d] area: %s", |
| 6518 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6519 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6520 | /* Show flags. */ |
| 6521 | vty_out (vty, "%s%s%s", |
| 6522 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6523 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6524 | VTY_NEWLINE); |
| 6525 | |
| 6526 | for (pn = listhead (or->path); pn; nextnode (pn)) |
| 6527 | { |
| 6528 | path = getdata (pn); |
| 6529 | if (path->nexthop.s_addr == 0) |
| 6530 | vty_out (vty, "%24s directly attached to %s%s", |
| 6531 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6532 | else |
| 6533 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6534 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6535 | VTY_NEWLINE); |
| 6536 | } |
| 6537 | } |
| 6538 | } |
| 6539 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6540 | } |
| 6541 | |
| 6542 | void |
| 6543 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6544 | { |
| 6545 | struct route_node *rn; |
| 6546 | struct ospf_route *er; |
| 6547 | listnode pnode; |
| 6548 | struct ospf_path *path; |
| 6549 | |
| 6550 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6551 | VTY_NEWLINE); |
| 6552 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6553 | if ((er = rn->info) != NULL) |
| 6554 | { |
| 6555 | char buf1[19]; |
| 6556 | snprintf (buf1, 19, "%s/%d", |
| 6557 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6558 | |
| 6559 | switch (er->path_type) |
| 6560 | { |
| 6561 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6562 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6563 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6564 | break; |
| 6565 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6566 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6567 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6568 | break; |
| 6569 | } |
| 6570 | |
| 6571 | for (pnode = listhead (er->path); pnode; nextnode (pnode)) |
| 6572 | { |
| 6573 | path = getdata (pnode); |
| 6574 | if (path->oi != NULL) |
| 6575 | { |
| 6576 | if (path->nexthop.s_addr == 0) |
| 6577 | vty_out (vty, "%24s directly attached to %s%s", |
| 6578 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6579 | else |
| 6580 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6581 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6582 | VTY_NEWLINE); |
| 6583 | } |
| 6584 | } |
| 6585 | } |
| 6586 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6587 | } |
| 6588 | |
| 6589 | #ifdef HAVE_NSSA |
| 6590 | DEFUN (show_ip_ospf_border_routers, |
| 6591 | show_ip_ospf_border_routers_cmd, |
| 6592 | "show ip ospf border-routers", |
| 6593 | SHOW_STR |
| 6594 | IP_STR |
| 6595 | "show all the ABR's and ASBR's\n" |
| 6596 | "for this area\n") |
| 6597 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6598 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6599 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6600 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6601 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6602 | { |
| 6603 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6604 | return CMD_SUCCESS; |
| 6605 | } |
| 6606 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6607 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6608 | { |
| 6609 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6610 | return CMD_SUCCESS; |
| 6611 | } |
| 6612 | |
| 6613 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6614 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6615 | |
| 6616 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6617 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6618 | |
| 6619 | return CMD_SUCCESS; |
| 6620 | } |
| 6621 | #endif /* HAVE_NSSA */ |
| 6622 | |
| 6623 | DEFUN (show_ip_ospf_route, |
| 6624 | show_ip_ospf_route_cmd, |
| 6625 | "show ip ospf route", |
| 6626 | SHOW_STR |
| 6627 | IP_STR |
| 6628 | "OSPF information\n" |
| 6629 | "OSPF routing table\n") |
| 6630 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6631 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6632 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6633 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6634 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6635 | { |
| 6636 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6637 | return CMD_SUCCESS; |
| 6638 | } |
| 6639 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6640 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6641 | { |
| 6642 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6643 | return CMD_SUCCESS; |
| 6644 | } |
| 6645 | |
| 6646 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6647 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6648 | |
| 6649 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6650 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6651 | |
| 6652 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6653 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6654 | |
| 6655 | return CMD_SUCCESS; |
| 6656 | } |
| 6657 | |
| 6658 | |
| 6659 | char *ospf_abr_type_str[] = |
| 6660 | { |
| 6661 | "unknown", |
| 6662 | "standard", |
| 6663 | "ibm", |
| 6664 | "cisco", |
| 6665 | "shortcut" |
| 6666 | }; |
| 6667 | |
| 6668 | char *ospf_shortcut_mode_str[] = |
| 6669 | { |
| 6670 | "default", |
| 6671 | "enable", |
| 6672 | "disable" |
| 6673 | }; |
| 6674 | |
| 6675 | |
| 6676 | void |
| 6677 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6678 | { |
| 6679 | memset (buf, 0, length); |
| 6680 | |
| 6681 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6682 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6683 | else |
| 6684 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6685 | } |
| 6686 | |
| 6687 | |
| 6688 | char *ospf_int_type_str[] = |
| 6689 | { |
| 6690 | "unknown", /* should never be used. */ |
| 6691 | "point-to-point", |
| 6692 | "broadcast", |
| 6693 | "non-broadcast", |
| 6694 | "point-to-multipoint", |
| 6695 | "virtual-link", /* should never be used. */ |
| 6696 | "loopback" |
| 6697 | }; |
| 6698 | |
| 6699 | /* Configuration write function for ospfd. */ |
| 6700 | int |
| 6701 | config_write_interface (struct vty *vty) |
| 6702 | { |
| 6703 | listnode n1, n2; |
| 6704 | struct interface *ifp; |
| 6705 | struct crypt_key *ck; |
| 6706 | int write = 0; |
| 6707 | struct route_node *rn = NULL; |
| 6708 | struct ospf_if_params *params; |
| 6709 | |
| 6710 | for (n1 = listhead (iflist); n1; nextnode (n1)) |
| 6711 | { |
| 6712 | ifp = getdata (n1); |
| 6713 | |
| 6714 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6715 | continue; |
| 6716 | |
| 6717 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6718 | vty_out (vty, "interface %s%s", ifp->name, |
| 6719 | VTY_NEWLINE); |
| 6720 | if (ifp->desc) |
| 6721 | vty_out (vty, " description %s%s", ifp->desc, |
| 6722 | VTY_NEWLINE); |
| 6723 | |
| 6724 | write++; |
| 6725 | |
| 6726 | params = IF_DEF_PARAMS (ifp); |
| 6727 | |
| 6728 | do { |
| 6729 | /* Interface Network print. */ |
| 6730 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
| 6731 | params->type != OSPF_IFTYPE_BROADCAST && |
| 6732 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6733 | { |
| 6734 | vty_out (vty, " ip ospf network %s", |
| 6735 | ospf_int_type_str[params->type]); |
| 6736 | if (params != IF_DEF_PARAMS (ifp)) |
| 6737 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6738 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6739 | } |
| 6740 | |
| 6741 | /* OSPF interface authentication print */ |
| 6742 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6743 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6744 | { |
| 6745 | char *auth_str; |
| 6746 | |
| 6747 | /* Translation tables are not that much help here due to syntax |
| 6748 | of the simple option */ |
| 6749 | switch (params->auth_type) |
| 6750 | { |
| 6751 | |
| 6752 | case OSPF_AUTH_NULL: |
| 6753 | auth_str = " null"; |
| 6754 | break; |
| 6755 | |
| 6756 | case OSPF_AUTH_SIMPLE: |
| 6757 | auth_str = ""; |
| 6758 | break; |
| 6759 | |
| 6760 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6761 | auth_str = " message-digest"; |
| 6762 | break; |
| 6763 | |
| 6764 | default: |
| 6765 | auth_str = ""; |
| 6766 | break; |
| 6767 | } |
| 6768 | |
| 6769 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6770 | if (params != IF_DEF_PARAMS (ifp)) |
| 6771 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6772 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6773 | } |
| 6774 | |
| 6775 | /* Simple Authentication Password print. */ |
| 6776 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6777 | params->auth_simple[0] != '\0') |
| 6778 | { |
| 6779 | vty_out (vty, " ip ospf authentication-key %s", |
| 6780 | params->auth_simple); |
| 6781 | if (params != IF_DEF_PARAMS (ifp)) |
| 6782 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6783 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6784 | } |
| 6785 | |
| 6786 | /* Cryptographic Authentication Key print. */ |
| 6787 | for (n2 = listhead (params->auth_crypt); n2; nextnode (n2)) |
| 6788 | { |
| 6789 | ck = getdata (n2); |
| 6790 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6791 | ck->key_id, ck->auth_key); |
| 6792 | if (params != IF_DEF_PARAMS (ifp)) |
| 6793 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6794 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6795 | } |
| 6796 | |
| 6797 | /* Interface Output Cost print. */ |
| 6798 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6799 | { |
| 6800 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6801 | if (params != IF_DEF_PARAMS (ifp)) |
| 6802 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6803 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6804 | } |
| 6805 | |
| 6806 | /* Hello Interval print. */ |
| 6807 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6808 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6809 | { |
| 6810 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6811 | if (params != IF_DEF_PARAMS (ifp)) |
| 6812 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6813 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6814 | } |
| 6815 | |
| 6816 | |
| 6817 | /* Router Dead Interval print. */ |
| 6818 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6819 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6820 | { |
| 6821 | vty_out (vty, " ip ospf dead-interval %u", params->v_wait); |
| 6822 | if (params != IF_DEF_PARAMS (ifp)) |
| 6823 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6824 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6825 | } |
| 6826 | |
| 6827 | /* Router Priority print. */ |
| 6828 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 6829 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 6830 | { |
| 6831 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 6832 | if (params != IF_DEF_PARAMS (ifp)) |
| 6833 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6834 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6835 | } |
| 6836 | |
| 6837 | /* Retransmit Interval print. */ |
| 6838 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 6839 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 6840 | { |
| 6841 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 6842 | params->retransmit_interval); |
| 6843 | if (params != IF_DEF_PARAMS (ifp)) |
| 6844 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6845 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6846 | } |
| 6847 | |
| 6848 | /* Transmit Delay print. */ |
| 6849 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 6850 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 6851 | { |
| 6852 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 6853 | if (params != IF_DEF_PARAMS (ifp)) |
| 6854 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6855 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6856 | } |
| 6857 | |
| 6858 | while (1) |
| 6859 | { |
| 6860 | if (rn == NULL) |
| 6861 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 6862 | else |
| 6863 | rn = route_next (rn); |
| 6864 | |
| 6865 | if (rn == NULL) |
| 6866 | break; |
| 6867 | params = rn->info; |
| 6868 | if (params != NULL) |
| 6869 | break; |
| 6870 | } |
| 6871 | } while (rn); |
| 6872 | |
| 6873 | #ifdef HAVE_OPAQUE_LSA |
| 6874 | ospf_opaque_config_write_if (vty, ifp); |
| 6875 | #endif /* HAVE_OPAQUE_LSA */ |
| 6876 | } |
| 6877 | |
| 6878 | return write; |
| 6879 | } |
| 6880 | |
| 6881 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6882 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6883 | { |
| 6884 | struct route_node *rn; |
| 6885 | u_char buf[INET_ADDRSTRLEN]; |
| 6886 | |
| 6887 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6888 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6889 | if (rn->info) |
| 6890 | { |
| 6891 | struct ospf_network *n = rn->info; |
| 6892 | |
| 6893 | memset (buf, 0, INET_ADDRSTRLEN); |
| 6894 | |
| 6895 | /* Create Area ID string by specified Area ID format. */ |
| 6896 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6897 | strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
| 6898 | else |
| 6899 | sprintf (buf, "%lu", |
| 6900 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 6901 | |
| 6902 | /* Network print. */ |
| 6903 | vty_out (vty, " network %s/%d area %s%s", |
| 6904 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 6905 | buf, VTY_NEWLINE); |
| 6906 | } |
| 6907 | |
| 6908 | return 0; |
| 6909 | } |
| 6910 | |
| 6911 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6912 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6913 | { |
| 6914 | listnode node; |
| 6915 | u_char buf[INET_ADDRSTRLEN]; |
| 6916 | |
| 6917 | /* Area configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6918 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6919 | { |
| 6920 | struct ospf_area *area = getdata (node); |
| 6921 | struct route_node *rn1; |
| 6922 | |
| 6923 | area_id2str (buf, INET_ADDRSTRLEN, area); |
| 6924 | |
| 6925 | if (area->auth_type != OSPF_AUTH_NULL) |
| 6926 | { |
| 6927 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 6928 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 6929 | else |
| 6930 | vty_out (vty, " area %s authentication message-digest%s", |
| 6931 | buf, VTY_NEWLINE); |
| 6932 | } |
| 6933 | |
| 6934 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 6935 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 6936 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 6937 | VTY_NEWLINE); |
| 6938 | |
| 6939 | if ((area->external_routing == OSPF_AREA_STUB) |
| 6940 | #ifdef HAVE_NSSA |
| 6941 | || (area->external_routing == OSPF_AREA_NSSA) |
| 6942 | #endif /* HAVE_NSSA */ |
| 6943 | ) |
| 6944 | { |
| 6945 | #ifdef HAVE_NSSA |
| 6946 | if (area->external_routing == OSPF_AREA_NSSA) |
| 6947 | vty_out (vty, " area %s nssa", buf); |
| 6948 | else |
| 6949 | #endif /* HAVE_NSSA */ |
| 6950 | vty_out (vty, " area %s stub", buf); |
| 6951 | |
| 6952 | if (area->no_summary) |
| 6953 | vty_out (vty, " no-summary"); |
| 6954 | |
| 6955 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6956 | |
| 6957 | if (area->default_cost != 1) |
| 6958 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 6959 | area->default_cost, VTY_NEWLINE); |
| 6960 | } |
| 6961 | |
| 6962 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 6963 | if (rn1->info) |
| 6964 | { |
| 6965 | struct ospf_area_range *range = rn1->info; |
| 6966 | |
| 6967 | vty_out (vty, " area %s range %s/%d", buf, |
| 6968 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 6969 | |
| 6970 | if (range->cost_config != -1) |
| 6971 | vty_out (vty, " cost %d", range->cost_config); |
| 6972 | |
| 6973 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 6974 | vty_out (vty, " not-advertise"); |
| 6975 | |
| 6976 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 6977 | vty_out (vty, " substitute %s/%d", |
| 6978 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 6979 | |
| 6980 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6981 | } |
| 6982 | |
| 6983 | if (EXPORT_NAME (area)) |
| 6984 | vty_out (vty, " area %s export-list %s%s", buf, |
| 6985 | EXPORT_NAME (area), VTY_NEWLINE); |
| 6986 | |
| 6987 | if (IMPORT_NAME (area)) |
| 6988 | vty_out (vty, " area %s import-list %s%s", buf, |
| 6989 | IMPORT_NAME (area), VTY_NEWLINE); |
| 6990 | |
| 6991 | if (PREFIX_NAME_IN (area)) |
| 6992 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 6993 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 6994 | |
| 6995 | if (PREFIX_NAME_OUT (area)) |
| 6996 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 6997 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 6998 | } |
| 6999 | |
| 7000 | return 0; |
| 7001 | } |
| 7002 | |
| 7003 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7004 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7005 | { |
| 7006 | struct ospf_nbr_nbma *nbr_nbma; |
| 7007 | struct route_node *rn; |
| 7008 | |
| 7009 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7010 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7011 | if ((nbr_nbma = rn->info)) |
| 7012 | { |
| 7013 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7014 | |
| 7015 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7016 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7017 | |
| 7018 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7019 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7020 | |
| 7021 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7022 | } |
| 7023 | |
| 7024 | return 0; |
| 7025 | } |
| 7026 | |
| 7027 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7028 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7029 | { |
| 7030 | listnode node; |
| 7031 | u_char buf[INET_ADDRSTRLEN]; |
| 7032 | |
| 7033 | /* Virtual-Link print */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7034 | for (node = listhead (ospf->vlinks); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7035 | { |
| 7036 | listnode n2; |
| 7037 | struct crypt_key *ck; |
| 7038 | struct ospf_vl_data *vl_data = getdata (node); |
| 7039 | struct ospf_interface *oi; |
| 7040 | |
| 7041 | if (vl_data != NULL) |
| 7042 | { |
| 7043 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7044 | |
| 7045 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 7046 | strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
| 7047 | else |
| 7048 | sprintf (buf, "%lu", |
| 7049 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7050 | oi = vl_data->vl_oi; |
| 7051 | |
| 7052 | /* timers */ |
| 7053 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7054 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7055 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7056 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7057 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7058 | buf, |
| 7059 | inet_ntoa (vl_data->vl_peer), |
| 7060 | OSPF_IF_PARAM (oi, v_hello), |
| 7061 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7062 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7063 | OSPF_IF_PARAM (oi, v_wait), |
| 7064 | VTY_NEWLINE); |
| 7065 | else |
| 7066 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7067 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7068 | /* Auth key */ |
| 7069 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7070 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7071 | buf, |
| 7072 | inet_ntoa (vl_data->vl_peer), |
| 7073 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7074 | VTY_NEWLINE); |
| 7075 | /* md5 keys */ |
| 7076 | for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2)) |
| 7077 | { |
| 7078 | ck = getdata (n2); |
| 7079 | vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s", |
| 7080 | buf, |
| 7081 | inet_ntoa (vl_data->vl_peer), |
| 7082 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
| 7083 | } |
| 7084 | |
| 7085 | } |
| 7086 | } |
| 7087 | |
| 7088 | return 0; |
| 7089 | } |
| 7090 | |
| 7091 | |
| 7092 | char *distribute_str[] = { "system", "kernel", "connected", "static", "rip", |
| 7093 | "ripng", "ospf", "ospf6", "bgp"}; |
| 7094 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7095 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7096 | { |
| 7097 | int type; |
| 7098 | |
| 7099 | /* redistribute print. */ |
| 7100 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7101 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7102 | { |
| 7103 | vty_out (vty, " redistribute %s", distribute_str[type]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7104 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7105 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7106 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7107 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7108 | vty_out (vty, " metric-type 1"); |
| 7109 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7110 | if (ROUTEMAP_NAME (ospf, type)) |
| 7111 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7112 | |
| 7113 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7114 | } |
| 7115 | |
| 7116 | return 0; |
| 7117 | } |
| 7118 | |
| 7119 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7120 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7121 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7122 | if (ospf->default_metric != -1) |
| 7123 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7124 | VTY_NEWLINE); |
| 7125 | return 0; |
| 7126 | } |
| 7127 | |
| 7128 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7129 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7130 | { |
| 7131 | int type; |
| 7132 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7133 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7134 | { |
| 7135 | /* distribute-list print. */ |
| 7136 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7137 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7138 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7139 | ospf->dlist[type].name, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7140 | distribute_str[type], VTY_NEWLINE); |
| 7141 | |
| 7142 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7143 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7144 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7145 | if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7146 | vty_out (vty, " default-information originate"); |
| 7147 | else |
| 7148 | vty_out (vty, " default-information originate always"); |
| 7149 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7150 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7151 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7152 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7153 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7154 | vty_out (vty, " metric-type 1"); |
| 7155 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7156 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7157 | vty_out (vty, " route-map %s", |
| 7158 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7159 | |
| 7160 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7161 | } |
| 7162 | |
| 7163 | } |
| 7164 | |
| 7165 | return 0; |
| 7166 | } |
| 7167 | |
| 7168 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7169 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7170 | { |
| 7171 | struct route_node *rn; |
| 7172 | struct ospf_distance *odistance; |
| 7173 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7174 | if (ospf->distance_all) |
| 7175 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7176 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7177 | if (ospf->distance_intra |
| 7178 | || ospf->distance_inter |
| 7179 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7180 | { |
| 7181 | vty_out (vty, " distance ospf"); |
| 7182 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7183 | if (ospf->distance_intra) |
| 7184 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7185 | if (ospf->distance_inter) |
| 7186 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7187 | if (ospf->distance_external) |
| 7188 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7189 | |
| 7190 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7191 | } |
| 7192 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7193 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7194 | if ((odistance = rn->info) != NULL) |
| 7195 | { |
| 7196 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7197 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7198 | odistance->access_list ? odistance->access_list : "", |
| 7199 | VTY_NEWLINE); |
| 7200 | } |
| 7201 | return 0; |
| 7202 | } |
| 7203 | |
| 7204 | /* OSPF configuration write function. */ |
| 7205 | int |
| 7206 | ospf_config_write (struct vty *vty) |
| 7207 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7208 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7209 | listnode node; |
| 7210 | int write = 0; |
| 7211 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7212 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7213 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7214 | { |
| 7215 | /* `router ospf' print. */ |
| 7216 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7217 | |
| 7218 | write++; |
| 7219 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7220 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7221 | return write; |
| 7222 | |
| 7223 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7224 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7225 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7226 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7227 | |
| 7228 | /* ABR type print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7229 | if (ospf->abr_type != OSPF_ABR_STAND) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7230 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7231 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7232 | |
| 7233 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7234 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7235 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7236 | |
| 7237 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7238 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7239 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7240 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7241 | |
| 7242 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7243 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
| 7244 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | vty_out (vty, " timers spf %d %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7246 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7247 | |
| 7248 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7249 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7250 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7251 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7252 | |
| 7253 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7254 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7255 | |
| 7256 | /* passive-interface print. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7257 | for (node = listhead (om->iflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7258 | { |
| 7259 | struct interface *ifp = getdata (node); |
| 7260 | |
| 7261 | if (!ifp) |
| 7262 | continue; |
| 7263 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7264 | vty_out (vty, " passive-interface %s%s", |
| 7265 | ifp->name, VTY_NEWLINE); |
| 7266 | } |
| 7267 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7268 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7269 | { |
| 7270 | struct ospf_interface *oi = getdata (node); |
| 7271 | |
| 7272 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7273 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
| 7274 | vty_out (vty, " passive-interface %s%s", |
| 7275 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
| 7276 | } |
| 7277 | |
| 7278 | |
| 7279 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7280 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7281 | |
| 7282 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7283 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7284 | |
| 7285 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7286 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7287 | |
| 7288 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7289 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7290 | |
| 7291 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7292 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7293 | |
| 7294 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7295 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7296 | |
| 7297 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7298 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7299 | |
| 7300 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7301 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7302 | #endif /* HAVE_OPAQUE_LSA */ |
| 7303 | } |
| 7304 | |
| 7305 | return write; |
| 7306 | } |
| 7307 | |
| 7308 | void |
| 7309 | ospf_vty_show_init () |
| 7310 | { |
| 7311 | /* "show ip ospf" commands. */ |
| 7312 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7313 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7314 | |
| 7315 | /* "show ip ospf database" commands. */ |
| 7316 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7317 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7318 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7319 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7320 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7321 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7322 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7323 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7324 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7325 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7326 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7327 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7328 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7329 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7330 | |
| 7331 | /* "show ip ospf interface" commands. */ |
| 7332 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7333 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7334 | |
| 7335 | /* "show ip ospf neighbor" commands. */ |
| 7336 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7337 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7338 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7339 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7340 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7341 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7342 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7343 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7344 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7345 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7346 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7347 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7348 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7349 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7350 | |
| 7351 | /* "show ip ospf route" commands. */ |
| 7352 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7353 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
| 7354 | #ifdef HAVE_NSSA |
| 7355 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7356 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
| 7357 | #endif /* HAVE_NSSA */ |
| 7358 | } |
| 7359 | |
| 7360 | |
| 7361 | /* ospfd's interface node. */ |
| 7362 | struct cmd_node interface_node = |
| 7363 | { |
| 7364 | INTERFACE_NODE, |
| 7365 | "%s(config-if)# ", |
| 7366 | 1 |
| 7367 | }; |
| 7368 | |
| 7369 | /* Initialization of OSPF interface. */ |
| 7370 | void |
| 7371 | ospf_vty_if_init () |
| 7372 | { |
| 7373 | /* Install interface node. */ |
| 7374 | install_node (&interface_node, config_write_interface); |
| 7375 | |
| 7376 | install_element (CONFIG_NODE, &interface_cmd); |
| 7377 | install_default (INTERFACE_NODE); |
| 7378 | |
| 7379 | /* "description" commands. */ |
| 7380 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7381 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7382 | |
| 7383 | /* "ip ospf authentication" commands. */ |
| 7384 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7385 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7386 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7387 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7388 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7389 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7390 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7391 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7392 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7393 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7394 | |
| 7395 | /* "ip ospf message-digest-key" commands. */ |
| 7396 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7397 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7398 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7399 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7400 | |
| 7401 | /* "ip ospf cost" commands. */ |
| 7402 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7403 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7404 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7405 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7406 | |
| 7407 | /* "ip ospf dead-interval" commands. */ |
| 7408 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7409 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
| 7410 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7411 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
| 7412 | |
| 7413 | /* "ip ospf hello-interval" commands. */ |
| 7414 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7415 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7416 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7417 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7418 | |
| 7419 | /* "ip ospf network" commands. */ |
| 7420 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7421 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7422 | |
| 7423 | /* "ip ospf priority" commands. */ |
| 7424 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7425 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7426 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7427 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7428 | |
| 7429 | /* "ip ospf retransmit-interval" commands. */ |
| 7430 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7431 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7432 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7433 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7434 | |
| 7435 | /* "ip ospf transmit-delay" commands. */ |
| 7436 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7437 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7438 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7439 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7440 | |
| 7441 | /* These commands are compatibitliy for previous version. */ |
| 7442 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7443 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7444 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7445 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 7446 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 7447 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 7448 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7449 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7450 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7451 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7452 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7453 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7454 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7455 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7456 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7457 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7458 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7459 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7460 | } |
| 7461 | |
| 7462 | /* Zebra node structure. */ |
| 7463 | struct cmd_node zebra_node = |
| 7464 | { |
| 7465 | ZEBRA_NODE, |
| 7466 | "%s(config-router)#", |
| 7467 | }; |
| 7468 | |
| 7469 | void |
| 7470 | ospf_vty_zebra_init () |
| 7471 | { |
| 7472 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 7473 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 7474 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 7475 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 7476 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 7477 | install_element (OSPF_NODE, |
| 7478 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 7479 | install_element (OSPF_NODE, |
| 7480 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 7481 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 7482 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 7483 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 7484 | |
| 7485 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7486 | |
| 7487 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7488 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7489 | |
| 7490 | install_element (OSPF_NODE, |
| 7491 | &ospf_default_information_originate_metric_type_cmd); |
| 7492 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 7493 | install_element (OSPF_NODE, |
| 7494 | &ospf_default_information_originate_type_metric_cmd); |
| 7495 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 7496 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 7497 | install_element (OSPF_NODE, |
| 7498 | &ospf_default_information_originate_always_metric_type_cmd); |
| 7499 | install_element (OSPF_NODE, |
| 7500 | &ospf_default_information_originate_always_metric_cmd); |
| 7501 | install_element (OSPF_NODE, |
| 7502 | &ospf_default_information_originate_always_cmd); |
| 7503 | install_element (OSPF_NODE, |
| 7504 | &ospf_default_information_originate_always_type_metric_cmd); |
| 7505 | install_element (OSPF_NODE, |
| 7506 | &ospf_default_information_originate_always_type_cmd); |
| 7507 | |
| 7508 | install_element (OSPF_NODE, |
| 7509 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 7510 | install_element (OSPF_NODE, |
| 7511 | &ospf_default_information_originate_metric_routemap_cmd); |
| 7512 | install_element (OSPF_NODE, |
| 7513 | &ospf_default_information_originate_routemap_cmd); |
| 7514 | install_element (OSPF_NODE, |
| 7515 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 7516 | install_element (OSPF_NODE, |
| 7517 | &ospf_default_information_originate_type_routemap_cmd); |
| 7518 | install_element (OSPF_NODE, |
| 7519 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 7520 | install_element (OSPF_NODE, |
| 7521 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 7522 | install_element (OSPF_NODE, |
| 7523 | &ospf_default_information_originate_always_routemap_cmd); |
| 7524 | install_element (OSPF_NODE, |
| 7525 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 7526 | install_element (OSPF_NODE, |
| 7527 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 7528 | |
| 7529 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7530 | |
| 7531 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7532 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7533 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7534 | |
| 7535 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7536 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7537 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 7538 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 7539 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 7540 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 7541 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 7542 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 7543 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 7544 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 7545 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 7546 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 7547 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 7548 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 7549 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 7550 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 7551 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 7552 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 7553 | #if 0 |
| 7554 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7555 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7556 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7557 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7558 | #endif /* 0 */ |
| 7559 | } |
| 7560 | |
| 7561 | struct cmd_node ospf_node = |
| 7562 | { |
| 7563 | OSPF_NODE, |
| 7564 | "%s(config-router)# ", |
| 7565 | 1 |
| 7566 | }; |
| 7567 | |
| 7568 | |
| 7569 | /* Install OSPF related vty commands. */ |
| 7570 | void |
| 7571 | ospf_vty_init () |
| 7572 | { |
| 7573 | /* Install ospf top node. */ |
| 7574 | install_node (&ospf_node, ospf_config_write); |
| 7575 | |
| 7576 | /* "router ospf" commands. */ |
| 7577 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7578 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7579 | |
| 7580 | install_default (OSPF_NODE); |
| 7581 | |
| 7582 | /* "ospf router-id" commands. */ |
| 7583 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7584 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7585 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7586 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7587 | |
| 7588 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7589 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7590 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 7591 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7592 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7593 | |
| 7594 | /* "ospf abr-type" commands. */ |
| 7595 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7596 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7597 | |
| 7598 | /* "ospf rfc1583-compatible" commands. */ |
| 7599 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7600 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7601 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7602 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7603 | |
| 7604 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7605 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7606 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7607 | |
| 7608 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7609 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7610 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7611 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7612 | |
| 7613 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7614 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7615 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7616 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7617 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7618 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7619 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7620 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7621 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7622 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7623 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7624 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7625 | |
| 7626 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7627 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7628 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7629 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7630 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7631 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7632 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7633 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7634 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7635 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7636 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7637 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7638 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7639 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7640 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7641 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7642 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7643 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7644 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7645 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7646 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7647 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7648 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7649 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7650 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7651 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7652 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7653 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7654 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7655 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7656 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7657 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7658 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7659 | |
| 7660 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7661 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7662 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7663 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7664 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7665 | |
| 7666 | #ifdef HAVE_NSSA |
| 7667 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7668 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7669 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7670 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7671 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7672 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7673 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7674 | #endif /* HAVE_NSSA */ |
| 7675 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7676 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7677 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7678 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7679 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7680 | install_element (OSPF_NODE, &no_ospf_area_shortcut_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_export_list_cmd); |
| 7683 | install_element (OSPF_NODE, &no_ospf_area_export_list_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_filter_list_cmd); |
| 7686 | install_element (OSPF_NODE, &no_ospf_area_filter_list_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_import_list_cmd); |
| 7689 | install_element (OSPF_NODE, &no_ospf_area_import_list_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_timers_spf_cmd); |
| 7692 | install_element (OSPF_NODE, &no_ospf_timers_spf_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_refresh_timer_cmd); |
| 7695 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7696 | install_element (OSPF_NODE, &no_ospf_refresh_timer_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_auto_cost_reference_bandwidth_cmd); |
| 7699 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7700 | |
| 7701 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame^] | 7702 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7703 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7704 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7705 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7706 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7707 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7708 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7709 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7710 | |
| 7711 | /* Init interface related vty commands. */ |
| 7712 | ospf_vty_if_init (); |
| 7713 | |
| 7714 | /* Init zebra related vty commands. */ |
| 7715 | ospf_vty_zebra_init (); |
| 7716 | } |