paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* OSPF VTY interface. |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * Copyright (C) 2000 Toshiaki Takada |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "memory.h" |
| 26 | #include "thread.h" |
| 27 | #include "prefix.h" |
| 28 | #include "table.h" |
| 29 | #include "vty.h" |
| 30 | #include "command.h" |
| 31 | #include "plist.h" |
| 32 | #include "log.h" |
| 33 | #include "zclient.h" |
| 34 | |
| 35 | #include "ospfd/ospfd.h" |
| 36 | #include "ospfd/ospf_asbr.h" |
| 37 | #include "ospfd/ospf_lsa.h" |
| 38 | #include "ospfd/ospf_lsdb.h" |
| 39 | #include "ospfd/ospf_ism.h" |
| 40 | #include "ospfd/ospf_interface.h" |
| 41 | #include "ospfd/ospf_nsm.h" |
| 42 | #include "ospfd/ospf_neighbor.h" |
| 43 | #include "ospfd/ospf_flood.h" |
| 44 | #include "ospfd/ospf_abr.h" |
| 45 | #include "ospfd/ospf_spf.h" |
| 46 | #include "ospfd/ospf_route.h" |
| 47 | #include "ospfd/ospf_zebra.h" |
| 48 | /*#include "ospfd/ospf_routemap.h" */ |
| 49 | #include "ospfd/ospf_vty.h" |
| 50 | #include "ospfd/ospf_dump.h" |
| 51 | |
| 52 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 53 | const static char *ospf_network_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 54 | { |
| 55 | "Null", |
| 56 | "POINTOPOINT", |
| 57 | "BROADCAST", |
| 58 | "NBMA", |
| 59 | "POINTOMULTIPOINT", |
| 60 | "VIRTUALLINK", |
| 61 | "LOOPBACK" |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | /* Utility functions. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 66 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 67 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | { |
| 69 | char *endptr = NULL; |
| 70 | unsigned long ret; |
| 71 | |
| 72 | /* match "A.B.C.D". */ |
| 73 | if (strchr (str, '.') != NULL) |
| 74 | { |
| 75 | ret = inet_aton (str, area_id); |
| 76 | if (!ret) |
| 77 | return -1; |
| 78 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; |
| 79 | } |
| 80 | /* match "<0-4294967295>". */ |
| 81 | else |
| 82 | { |
| 83 | ret = strtoul (str, &endptr, 10); |
| 84 | if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE)) |
| 85 | return -1; |
| 86 | |
| 87 | area_id->s_addr = htonl (ret); |
| 88 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 95 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 96 | str2distribute_source (const char *str, int *source) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 97 | { |
| 98 | /* Sanity check. */ |
| 99 | if (str == NULL) |
| 100 | return 0; |
| 101 | |
| 102 | if (strncmp (str, "k", 1) == 0) |
| 103 | *source = ZEBRA_ROUTE_KERNEL; |
| 104 | else if (strncmp (str, "c", 1) == 0) |
| 105 | *source = ZEBRA_ROUTE_CONNECT; |
| 106 | else if (strncmp (str, "s", 1) == 0) |
| 107 | *source = ZEBRA_ROUTE_STATIC; |
| 108 | else if (strncmp (str, "r", 1) == 0) |
| 109 | *source = ZEBRA_ROUTE_RIP; |
| 110 | else if (strncmp (str, "b", 1) == 0) |
| 111 | *source = ZEBRA_ROUTE_BGP; |
| 112 | else |
| 113 | return 0; |
| 114 | |
| 115 | return 1; |
| 116 | } |
| 117 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 118 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 119 | str2metric (const char *str, int *metric) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 120 | { |
| 121 | /* Sanity check. */ |
| 122 | if (str == NULL) |
| 123 | return 0; |
| 124 | |
| 125 | *metric = strtol (str, NULL, 10); |
| 126 | if (*metric < 0 && *metric > 16777214) |
| 127 | { |
| 128 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | return 1; |
| 133 | } |
| 134 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 135 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 136 | str2metric_type (const char *str, int *metric_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | { |
| 138 | /* Sanity check. */ |
| 139 | if (str == NULL) |
| 140 | return 0; |
| 141 | |
| 142 | if (strncmp (str, "1", 1) == 0) |
| 143 | *metric_type = EXTERNAL_METRIC_TYPE_1; |
| 144 | else if (strncmp (str, "2", 1) == 0) |
| 145 | *metric_type = EXTERNAL_METRIC_TYPE_2; |
| 146 | else |
| 147 | return 0; |
| 148 | |
| 149 | return 1; |
| 150 | } |
| 151 | |
| 152 | int |
| 153 | ospf_oi_count (struct interface *ifp) |
| 154 | { |
| 155 | struct route_node *rn; |
| 156 | int i = 0; |
| 157 | |
| 158 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 159 | if (rn->info) |
| 160 | i++; |
| 161 | |
| 162 | return i; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | DEFUN (router_ospf, |
| 167 | router_ospf_cmd, |
| 168 | "router ospf", |
| 169 | "Enable a routing process\n" |
| 170 | "Start OSPF configuration\n") |
| 171 | { |
| 172 | vty->node = OSPF_NODE; |
| 173 | vty->index = ospf_get (); |
| 174 | |
| 175 | return CMD_SUCCESS; |
| 176 | } |
| 177 | |
| 178 | DEFUN (no_router_ospf, |
| 179 | no_router_ospf_cmd, |
| 180 | "no router ospf", |
| 181 | NO_STR |
| 182 | "Enable a routing process\n" |
| 183 | "Start OSPF configuration\n") |
| 184 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 185 | struct ospf *ospf; |
| 186 | |
| 187 | ospf = ospf_lookup (); |
| 188 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 190 | vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 191 | return CMD_WARNING; |
| 192 | } |
| 193 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 194 | ospf_finish (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | |
| 196 | return CMD_SUCCESS; |
| 197 | } |
| 198 | |
| 199 | DEFUN (ospf_router_id, |
| 200 | ospf_router_id_cmd, |
| 201 | "ospf router-id A.B.C.D", |
| 202 | "OSPF specific commands\n" |
| 203 | "router-id for the OSPF process\n" |
| 204 | "OSPF router-id in IP address format\n") |
| 205 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 206 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | struct in_addr router_id; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 208 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 209 | |
| 210 | ret = inet_aton (argv[0], &router_id); |
| 211 | if (!ret) |
| 212 | { |
| 213 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); |
| 214 | return CMD_WARNING; |
| 215 | } |
| 216 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 217 | ospf->router_id_static = router_id; |
paul | b29800a | 2005-11-20 14:50:45 +0000 | [diff] [blame] | 218 | |
| 219 | ospf_router_id_update (ospf); |
| 220 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | return CMD_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 225 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 226 | "router-id A.B.C.D", |
| 227 | "router-id for the OSPF process\n" |
| 228 | "OSPF router-id in IP address format\n") |
| 229 | |
| 230 | DEFUN (no_ospf_router_id, |
| 231 | no_ospf_router_id_cmd, |
| 232 | "no ospf router-id", |
| 233 | NO_STR |
| 234 | "OSPF specific commands\n" |
| 235 | "router-id for the OSPF process\n") |
| 236 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 237 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 239 | ospf->router_id_static.s_addr = 0; |
| 240 | |
| 241 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 242 | |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
| 246 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 247 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | "no router-id", |
| 249 | NO_STR |
| 250 | "router-id for the OSPF process\n") |
| 251 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 252 | DEFUN (ospf_passive_interface, |
| 253 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 254 | "passive-interface IFNAME A.B.C.D", |
| 255 | "Suppress routing updates on an interface\n" |
| 256 | "Interface's name\n") |
| 257 | { |
| 258 | struct interface *ifp; |
| 259 | struct in_addr addr; |
| 260 | int ret; |
| 261 | struct ospf_if_params *params; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 262 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 263 | |
| 264 | ifp = if_lookup_by_name (argv[0]); |
| 265 | |
| 266 | if (ifp == NULL) |
| 267 | { |
| 268 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 269 | return CMD_WARNING; |
| 270 | } |
| 271 | |
| 272 | params = IF_DEF_PARAMS (ifp); |
| 273 | |
| 274 | if (argc == 2) |
| 275 | { |
| 276 | ret = inet_aton(argv[1], &addr); |
| 277 | if (!ret) |
| 278 | { |
| 279 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 280 | VTY_NEWLINE); |
| 281 | return CMD_WARNING; |
| 282 | } |
| 283 | |
| 284 | params = ospf_get_if_params (ifp, addr); |
| 285 | ospf_if_update_params (ifp, addr); |
| 286 | } |
| 287 | |
| 288 | SET_IF_PARAM (params, passive_interface); |
| 289 | params->passive_interface = OSPF_IF_PASSIVE; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 290 | |
| 291 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 292 | * interfaces for which the passive property changed. It is too much |
| 293 | * work to determine this set, so we do this for every interface. |
| 294 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 295 | * record of joined groups to avoid systems calls if the desired |
| 296 | * memberships match the current memership. |
| 297 | */ |
| 298 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 299 | { |
| 300 | struct ospf_interface *oi = rn->info; |
| 301 | |
| 302 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
| 303 | ospf_if_set_multicast(oi); |
| 304 | } |
| 305 | /* |
| 306 | * XXX It is not clear what state transitions the interface needs to |
| 307 | * undergo when going from active to passive. Fixing this will |
| 308 | * require precise identification of interfaces having such a |
| 309 | * transition. |
| 310 | */ |
| 311 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 312 | return CMD_SUCCESS; |
| 313 | } |
| 314 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 315 | ALIAS (ospf_passive_interface, |
| 316 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 317 | "passive-interface IFNAME", |
| 318 | "Suppress routing updates on an interface\n" |
| 319 | "Interface's name\n") |
| 320 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 321 | DEFUN (no_ospf_passive_interface, |
| 322 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 323 | "no passive-interface IFNAME A.B.C.D", |
| 324 | NO_STR |
| 325 | "Allow routing updates on an interface\n" |
| 326 | "Interface's name\n") |
| 327 | { |
| 328 | struct interface *ifp; |
| 329 | struct in_addr addr; |
| 330 | struct ospf_if_params *params; |
| 331 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 332 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 333 | |
| 334 | ifp = if_lookup_by_name (argv[0]); |
| 335 | |
| 336 | if (ifp == NULL) |
| 337 | { |
| 338 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 339 | return CMD_WARNING; |
| 340 | } |
| 341 | |
| 342 | params = IF_DEF_PARAMS (ifp); |
| 343 | |
| 344 | if (argc == 2) |
| 345 | { |
| 346 | ret = inet_aton(argv[1], &addr); |
| 347 | if (!ret) |
| 348 | { |
| 349 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 350 | VTY_NEWLINE); |
| 351 | return CMD_WARNING; |
| 352 | } |
| 353 | |
| 354 | params = ospf_lookup_if_params (ifp, addr); |
| 355 | if (params == NULL) |
| 356 | return CMD_SUCCESS; |
| 357 | } |
| 358 | |
| 359 | UNSET_IF_PARAM (params, passive_interface); |
| 360 | params->passive_interface = OSPF_IF_ACTIVE; |
| 361 | |
| 362 | if (params != IF_DEF_PARAMS (ifp)) |
| 363 | { |
| 364 | ospf_free_if_params (ifp, addr); |
| 365 | ospf_if_update_params (ifp, addr); |
| 366 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 367 | |
| 368 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 369 | * interfaces for which the passive property changed. It is too much |
| 370 | * work to determine this set, so we do this for every interface. |
| 371 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 372 | * record of joined groups to avoid systems calls if the desired |
| 373 | * memberships match the current memership. |
| 374 | */ |
| 375 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 376 | { |
| 377 | struct ospf_interface *oi = rn->info; |
| 378 | |
| 379 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 380 | ospf_if_set_multicast(oi); |
| 381 | } |
| 382 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 383 | return CMD_SUCCESS; |
| 384 | } |
| 385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 386 | ALIAS (no_ospf_passive_interface, |
| 387 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 388 | "no passive-interface IFNAME", |
| 389 | NO_STR |
| 390 | "Allow routing updates on an interface\n" |
| 391 | "Interface's name\n") |
| 392 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 393 | DEFUN (ospf_network_area, |
| 394 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 395 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 396 | "Enable routing on an IP network\n" |
| 397 | "OSPF network prefix\n" |
| 398 | "Set the OSPF area ID\n" |
| 399 | "OSPF area ID in IP address format\n" |
| 400 | "OSPF area ID as a decimal value\n") |
| 401 | { |
| 402 | struct ospf *ospf= vty->index; |
| 403 | struct prefix_ipv4 p; |
| 404 | struct in_addr area_id; |
| 405 | int ret, format; |
| 406 | |
| 407 | /* Get network prefix and Area ID. */ |
| 408 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 409 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 410 | |
| 411 | ret = ospf_network_set (ospf, &p, area_id); |
| 412 | if (ret == 0) |
| 413 | { |
| 414 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 415 | return CMD_WARNING; |
| 416 | } |
| 417 | |
| 418 | return CMD_SUCCESS; |
| 419 | } |
| 420 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 421 | DEFUN (no_ospf_network_area, |
| 422 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 423 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 424 | NO_STR |
| 425 | "Enable routing on an IP network\n" |
| 426 | "OSPF network prefix\n" |
| 427 | "Set the OSPF area ID\n" |
| 428 | "OSPF area ID in IP address format\n" |
| 429 | "OSPF area ID as a decimal value\n") |
| 430 | { |
| 431 | struct ospf *ospf = (struct ospf *) vty->index; |
| 432 | struct prefix_ipv4 p; |
| 433 | struct in_addr area_id; |
| 434 | int ret, format; |
| 435 | |
| 436 | /* Get network prefix and Area ID. */ |
| 437 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 438 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 439 | |
| 440 | ret = ospf_network_unset (ospf, &p, area_id); |
| 441 | if (ret == 0) |
| 442 | { |
| 443 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 444 | VTY_NEWLINE); |
| 445 | return CMD_WARNING; |
| 446 | } |
| 447 | |
| 448 | return CMD_SUCCESS; |
| 449 | } |
| 450 | |
| 451 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 452 | DEFUN (ospf_area_range, |
| 453 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 454 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 455 | "OSPF area parameters\n" |
| 456 | "OSPF area ID in IP address format\n" |
| 457 | "OSPF area ID as a decimal value\n" |
| 458 | "Summarize routes matching address/mask (border routers only)\n" |
| 459 | "Area range prefix\n") |
| 460 | { |
| 461 | struct ospf *ospf = vty->index; |
| 462 | struct prefix_ipv4 p; |
| 463 | struct in_addr area_id; |
| 464 | int format; |
| 465 | u_int32_t cost; |
| 466 | |
| 467 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 468 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 469 | |
| 470 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 471 | if (argc > 2) |
| 472 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 473 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 474 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 475 | } |
| 476 | |
| 477 | return CMD_SUCCESS; |
| 478 | } |
| 479 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 480 | ALIAS (ospf_area_range, |
| 481 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 482 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 483 | "OSPF area parameters\n" |
| 484 | "OSPF area ID in IP address format\n" |
| 485 | "OSPF area ID as a decimal value\n" |
| 486 | "OSPF area range for route advertise (default)\n" |
| 487 | "Area range prefix\n" |
| 488 | "Advertise this range (default)\n") |
| 489 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 490 | ALIAS (ospf_area_range, |
| 491 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 492 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 493 | "OSPF area parameters\n" |
| 494 | "OSPF area ID in IP address format\n" |
| 495 | "OSPF area ID as a decimal value\n" |
| 496 | "Summarize routes matching address/mask (border routers only)\n" |
| 497 | "Area range prefix\n" |
| 498 | "User specified metric for this range\n" |
| 499 | "Advertised metric for this range\n") |
| 500 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 501 | ALIAS (ospf_area_range, |
| 502 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 503 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 504 | "OSPF area parameters\n" |
| 505 | "OSPF area ID in IP address format\n" |
| 506 | "OSPF area ID as a decimal value\n" |
| 507 | "Summarize routes matching address/mask (border routers only)\n" |
| 508 | "Area range prefix\n" |
| 509 | "Advertise this range (default)\n" |
| 510 | "User specified metric for this range\n" |
| 511 | "Advertised metric for this range\n") |
| 512 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 513 | DEFUN (ospf_area_range_not_advertise, |
| 514 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 515 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 516 | "OSPF area parameters\n" |
| 517 | "OSPF area ID in IP address format\n" |
| 518 | "OSPF area ID as a decimal value\n" |
| 519 | "Summarize routes matching address/mask (border routers only)\n" |
| 520 | "Area range prefix\n" |
| 521 | "DoNotAdvertise this range\n") |
| 522 | { |
| 523 | struct ospf *ospf = vty->index; |
| 524 | struct prefix_ipv4 p; |
| 525 | struct in_addr area_id; |
| 526 | int format; |
| 527 | |
| 528 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 529 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 530 | |
| 531 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 532 | |
| 533 | return CMD_SUCCESS; |
| 534 | } |
| 535 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 536 | DEFUN (no_ospf_area_range, |
| 537 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 539 | NO_STR |
| 540 | "OSPF area parameters\n" |
| 541 | "OSPF area ID in IP address format\n" |
| 542 | "OSPF area ID as a decimal value\n" |
| 543 | "Summarize routes matching address/mask (border routers only)\n" |
| 544 | "Area range prefix\n") |
| 545 | { |
| 546 | struct ospf *ospf = vty->index; |
| 547 | struct prefix_ipv4 p; |
| 548 | struct in_addr area_id; |
| 549 | int format; |
| 550 | |
| 551 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 552 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 553 | |
| 554 | ospf_area_range_unset (ospf, area_id, &p); |
| 555 | |
| 556 | return CMD_SUCCESS; |
| 557 | } |
| 558 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 559 | ALIAS (no_ospf_area_range, |
| 560 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 562 | NO_STR |
| 563 | "OSPF area parameters\n" |
| 564 | "OSPF area ID in IP address format\n" |
| 565 | "OSPF area ID as a decimal value\n" |
| 566 | "Summarize routes matching address/mask (border routers only)\n" |
| 567 | "Area range prefix\n" |
| 568 | "Advertise this range (default)\n" |
| 569 | "DoNotAdvertise this range\n") |
| 570 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 571 | ALIAS (no_ospf_area_range, |
| 572 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 573 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 574 | NO_STR |
| 575 | "OSPF area parameters\n" |
| 576 | "OSPF area ID in IP address format\n" |
| 577 | "OSPF area ID as a decimal value\n" |
| 578 | "Summarize routes matching address/mask (border routers only)\n" |
| 579 | "Area range prefix\n" |
| 580 | "User specified metric for this range\n" |
| 581 | "Advertised metric for this range\n") |
| 582 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 583 | ALIAS (no_ospf_area_range, |
| 584 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 585 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 586 | NO_STR |
| 587 | "OSPF area parameters\n" |
| 588 | "OSPF area ID in IP address format\n" |
| 589 | "OSPF area ID as a decimal value\n" |
| 590 | "Summarize routes matching address/mask (border routers only)\n" |
| 591 | "Area range prefix\n" |
| 592 | "Advertise this range (default)\n" |
| 593 | "User specified metric for this range\n" |
| 594 | "Advertised metric for this range\n") |
| 595 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 596 | DEFUN (ospf_area_range_substitute, |
| 597 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 598 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 599 | "OSPF area parameters\n" |
| 600 | "OSPF area ID in IP address format\n" |
| 601 | "OSPF area ID as a decimal value\n" |
| 602 | "Summarize routes matching address/mask (border routers only)\n" |
| 603 | "Area range prefix\n" |
| 604 | "Announce area range as another prefix\n" |
| 605 | "Network prefix to be announced instead of range\n") |
| 606 | { |
| 607 | struct ospf *ospf = vty->index; |
| 608 | struct prefix_ipv4 p, s; |
| 609 | struct in_addr area_id; |
| 610 | int format; |
| 611 | |
| 612 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 613 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 614 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 615 | |
| 616 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 617 | |
| 618 | return CMD_SUCCESS; |
| 619 | } |
| 620 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 621 | DEFUN (no_ospf_area_range_substitute, |
| 622 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 624 | NO_STR |
| 625 | "OSPF area parameters\n" |
| 626 | "OSPF area ID in IP address format\n" |
| 627 | "OSPF area ID as a decimal value\n" |
| 628 | "Summarize routes matching address/mask (border routers only)\n" |
| 629 | "Area range prefix\n" |
| 630 | "Announce area range as another prefix\n" |
| 631 | "Network prefix to be announced instead of range\n") |
| 632 | { |
| 633 | struct ospf *ospf = vty->index; |
| 634 | struct prefix_ipv4 p, s; |
| 635 | struct in_addr area_id; |
| 636 | int format; |
| 637 | |
| 638 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 639 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 640 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 641 | |
| 642 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 643 | |
| 644 | return CMD_SUCCESS; |
| 645 | } |
| 646 | |
| 647 | |
| 648 | /* Command Handler Logic in VLink stuff is delicate!! |
| 649 | |
| 650 | ALTER AT YOUR OWN RISK!!!! |
| 651 | |
| 652 | Various dummy values are used to represent 'NoChange' state for |
| 653 | VLink configuration NOT being changed by a VLink command, and |
| 654 | special syntax is used within the command strings so that the |
| 655 | typed in command verbs can be seen in the configuration command |
| 656 | bacckend handler. This is to drastically reduce the verbeage |
| 657 | required to coe up with a reasonably compatible Cisco VLink command |
| 658 | |
| 659 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 660 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 661 | */ |
| 662 | |
| 663 | |
| 664 | /* Configuration data for virtual links |
| 665 | */ |
| 666 | struct ospf_vl_config_data { |
| 667 | struct vty *vty; /* vty stuff */ |
| 668 | struct in_addr area_id; /* area ID from command line */ |
| 669 | int format; /* command line area ID format */ |
| 670 | struct in_addr vl_peer; /* command line vl_peer */ |
| 671 | int auth_type; /* Authehntication type, if given */ |
| 672 | char *auth_key; /* simple password if present */ |
| 673 | int crypto_key_id; /* Cryptographic key ID */ |
| 674 | char *md5_key; /* MD5 authentication key */ |
| 675 | int hello_interval; /* Obvious what these are... */ |
| 676 | int retransmit_interval; |
| 677 | int transmit_delay; |
| 678 | int dead_interval; |
| 679 | }; |
| 680 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 681 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 682 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 683 | struct vty *vty) |
| 684 | { |
| 685 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 686 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 687 | vl_config->vty = vty; |
| 688 | } |
| 689 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 690 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 691 | ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 692 | { |
| 693 | struct ospf_area *area; |
| 694 | struct ospf_vl_data *vl_data; |
| 695 | struct vty *vty; |
| 696 | struct in_addr area_id; |
| 697 | |
| 698 | vty = vl_config->vty; |
| 699 | area_id = vl_config->area_id; |
| 700 | |
| 701 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 702 | { |
| 703 | vty_out (vty, |
| 704 | "Configuring VLs over the backbone is not allowed%s", |
| 705 | VTY_NEWLINE); |
| 706 | return NULL; |
| 707 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 708 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | |
| 710 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 711 | { |
| 712 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 713 | vty_out (vty, "Area %s is %s%s", |
| 714 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 715 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 716 | VTY_NEWLINE); |
| 717 | else |
| 718 | vty_out (vty, "Area %ld is %s%s", |
| 719 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 720 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | VTY_NEWLINE); |
| 722 | return NULL; |
| 723 | } |
| 724 | |
| 725 | if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL) |
| 726 | { |
| 727 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 728 | if (vl_data->vl_oi == NULL) |
| 729 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 730 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 731 | ospf_vl_add (ospf, vl_data); |
| 732 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 733 | } |
| 734 | } |
| 735 | return vl_data; |
| 736 | } |
| 737 | |
| 738 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 739 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 740 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 741 | struct ospf_vl_config_data *vl_config) |
| 742 | { |
| 743 | struct crypt_key *ck; |
| 744 | struct vty *vty; |
| 745 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 746 | |
| 747 | vty = vl_config->vty; |
| 748 | |
| 749 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 750 | { |
| 751 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 752 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 753 | } |
| 754 | |
| 755 | if (vl_config->auth_key) |
| 756 | { |
| 757 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 758 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 759 | OSPF_AUTH_SIMPLE_SIZE); |
| 760 | } |
| 761 | else if (vl_config->md5_key) |
| 762 | { |
| 763 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 764 | != NULL) |
| 765 | { |
| 766 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 767 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 768 | return CMD_WARNING; |
| 769 | } |
| 770 | ck = ospf_crypt_key_new (); |
| 771 | ck->key_id = vl_config->crypto_key_id; |
| 772 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 773 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 774 | |
| 775 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 776 | } |
| 777 | else if (vl_config->crypto_key_id != 0) |
| 778 | { |
| 779 | /* Delete a key */ |
| 780 | |
| 781 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 782 | vl_config->crypto_key_id) == NULL) |
| 783 | { |
| 784 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 785 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 786 | return CMD_WARNING; |
| 787 | } |
| 788 | |
| 789 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 790 | |
| 791 | } |
| 792 | |
| 793 | return CMD_SUCCESS; |
| 794 | } |
| 795 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 796 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 797 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 798 | struct ospf_vl_config_data *vl_config) |
| 799 | { |
| 800 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 801 | /* Virtual Link data initialised to defaults, so only set |
| 802 | if a value given */ |
| 803 | if (vl_config->hello_interval) |
| 804 | { |
| 805 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 806 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 807 | } |
| 808 | |
| 809 | if (vl_config->dead_interval) |
| 810 | { |
| 811 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 812 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 813 | } |
| 814 | |
| 815 | if (vl_config->retransmit_interval) |
| 816 | { |
| 817 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 818 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 819 | } |
| 820 | |
| 821 | if (vl_config->transmit_delay) |
| 822 | { |
| 823 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 824 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 825 | } |
| 826 | |
| 827 | return CMD_SUCCESS; |
| 828 | } |
| 829 | |
| 830 | |
| 831 | |
| 832 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 833 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 834 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 835 | { |
| 836 | struct ospf_vl_data *vl_data; |
| 837 | int ret; |
| 838 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 839 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 840 | if (!vl_data) |
| 841 | return CMD_WARNING; |
| 842 | |
| 843 | /* Process this one first as it can have a fatal result, which can |
| 844 | only logically occur if the virtual link exists already |
| 845 | Thus a command error does not result in a change to the |
| 846 | running configuration such as unexpectedly altered timer |
| 847 | values etc.*/ |
| 848 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 849 | if (ret != CMD_SUCCESS) |
| 850 | return ret; |
| 851 | |
| 852 | /* Set any time based parameters, these area already range checked */ |
| 853 | |
| 854 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 855 | if (ret != CMD_SUCCESS) |
| 856 | return ret; |
| 857 | |
| 858 | return CMD_SUCCESS; |
| 859 | |
| 860 | } |
| 861 | |
| 862 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 863 | */ |
| 864 | #define VLINK_HELPSTR_IPADDR \ |
| 865 | "OSPF area parameters\n" \ |
| 866 | "OSPF area ID in IP address format\n" \ |
| 867 | "OSPF area ID as a decimal value\n" \ |
| 868 | "Configure a virtual link\n" \ |
| 869 | "Router ID of the remote ABR\n" |
| 870 | |
| 871 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 872 | "Enable authentication on this virtual link\n" \ |
| 873 | "dummy string \n" |
| 874 | |
| 875 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 876 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 877 | "Use null authentication\n" \ |
| 878 | "Use message-digest authentication\n" |
| 879 | |
| 880 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 881 | "Time between HELLO packets\n" \ |
| 882 | "Time between retransmitting lost link state advertisements\n" \ |
| 883 | "Link state transmit delay\n" \ |
| 884 | "Interval after which a neighbor is declared dead\n" |
| 885 | |
| 886 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 887 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 888 | "Seconds\n" |
| 889 | |
| 890 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 891 | "Authentication password (key)\n" \ |
| 892 | "The OSPF password (key)" |
| 893 | |
| 894 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 895 | "Message digest authentication password (key)\n" \ |
| 896 | "dummy string \n" \ |
| 897 | "Key ID\n" \ |
| 898 | "Use MD5 algorithm\n" \ |
| 899 | "The OSPF password (key)" |
| 900 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 901 | DEFUN (ospf_area_vlink, |
| 902 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 904 | VLINK_HELPSTR_IPADDR) |
| 905 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 906 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 907 | struct ospf_vl_config_data vl_config; |
| 908 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 909 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 910 | int i; |
| 911 | int ret; |
| 912 | |
| 913 | ospf_vl_config_data_init(&vl_config, vty); |
| 914 | |
| 915 | /* Read off first 2 parameters and check them */ |
| 916 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 917 | if (ret < 0) |
| 918 | { |
| 919 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 920 | return CMD_WARNING; |
| 921 | } |
| 922 | |
| 923 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 924 | if (! ret) |
| 925 | { |
| 926 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 927 | VTY_NEWLINE); |
| 928 | return CMD_WARNING; |
| 929 | } |
| 930 | |
| 931 | if (argc <=2) |
| 932 | { |
| 933 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 934 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 935 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | /* Deal with other parameters */ |
| 939 | for (i=2; i < argc; i++) |
| 940 | { |
| 941 | |
| 942 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 943 | |
| 944 | switch (argv[i][0]) |
| 945 | { |
| 946 | |
| 947 | case 'a': |
| 948 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 949 | { |
| 950 | /* authentication-key - this option can occur anywhere on |
| 951 | command line. At start of command line |
| 952 | must check for authentication option. */ |
| 953 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 954 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 955 | vl_config.auth_key = auth_key; |
| 956 | i++; |
| 957 | } |
| 958 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 959 | { |
| 960 | /* authentication - this option can only occur at start |
| 961 | of command line */ |
| 962 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 963 | if ((i+1) < argc) |
| 964 | { |
| 965 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 966 | { |
| 967 | /* "authentication null" */ |
| 968 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 969 | i++; |
| 970 | } |
| 971 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 972 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 973 | { |
| 974 | /* "authentication message-digest" */ |
| 975 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 976 | i++; |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | break; |
| 981 | |
| 982 | case 'm': |
| 983 | /* message-digest-key */ |
| 984 | i++; |
| 985 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 986 | if (vl_config.crypto_key_id < 0) |
| 987 | return CMD_WARNING; |
| 988 | i++; |
| 989 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 990 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 991 | vl_config.md5_key = md5_key; |
| 992 | break; |
| 993 | |
| 994 | case 'h': |
| 995 | /* Hello interval */ |
| 996 | i++; |
| 997 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 998 | if (vl_config.hello_interval < 0) |
| 999 | return CMD_WARNING; |
| 1000 | break; |
| 1001 | |
| 1002 | case 'r': |
| 1003 | /* Retransmit Interval */ |
| 1004 | i++; |
| 1005 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1006 | if (vl_config.retransmit_interval < 0) |
| 1007 | return CMD_WARNING; |
| 1008 | break; |
| 1009 | |
| 1010 | case 't': |
| 1011 | /* Transmit Delay */ |
| 1012 | i++; |
| 1013 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1014 | if (vl_config.transmit_delay < 0) |
| 1015 | return CMD_WARNING; |
| 1016 | break; |
| 1017 | |
| 1018 | case 'd': |
| 1019 | /* Dead Interval */ |
| 1020 | i++; |
| 1021 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1022 | if (vl_config.dead_interval < 0) |
| 1023 | return CMD_WARNING; |
| 1024 | break; |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | |
| 1029 | /* Action configuration */ |
| 1030 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1031 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1032 | |
| 1033 | } |
| 1034 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1035 | DEFUN (no_ospf_area_vlink, |
| 1036 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1037 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1038 | NO_STR |
| 1039 | VLINK_HELPSTR_IPADDR) |
| 1040 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1041 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1042 | struct ospf_area *area; |
| 1043 | struct ospf_vl_config_data vl_config; |
| 1044 | struct ospf_vl_data *vl_data = NULL; |
| 1045 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1046 | int i; |
| 1047 | int ret, format; |
| 1048 | |
| 1049 | ospf_vl_config_data_init(&vl_config, vty); |
| 1050 | |
| 1051 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1052 | if (ret < 0) |
| 1053 | { |
| 1054 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1055 | return CMD_WARNING; |
| 1056 | } |
| 1057 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1058 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1059 | if (!area) |
| 1060 | { |
| 1061 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1062 | return CMD_WARNING; |
| 1063 | } |
| 1064 | |
| 1065 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1066 | if (! ret) |
| 1067 | { |
| 1068 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1069 | VTY_NEWLINE); |
| 1070 | return CMD_WARNING; |
| 1071 | } |
| 1072 | |
| 1073 | if (argc <=2) |
| 1074 | { |
| 1075 | /* Basic VLink no command */ |
| 1076 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 1077 | if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1078 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1079 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1080 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1081 | |
| 1082 | return CMD_SUCCESS; |
| 1083 | } |
| 1084 | |
| 1085 | /* If we are down here, we are reseting parameters */ |
| 1086 | |
| 1087 | /* Deal with other parameters */ |
| 1088 | for (i=2; i < argc; i++) |
| 1089 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1090 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1091 | |
| 1092 | switch (argv[i][0]) |
| 1093 | { |
| 1094 | |
| 1095 | case 'a': |
| 1096 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1097 | { |
| 1098 | /* authentication-key - this option can occur anywhere on |
| 1099 | command line. At start of command line |
| 1100 | must check for authentication option. */ |
| 1101 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1102 | vl_config.auth_key = auth_key; |
| 1103 | } |
| 1104 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1105 | { |
| 1106 | /* authentication - this option can only occur at start |
| 1107 | of command line */ |
| 1108 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1109 | } |
| 1110 | break; |
| 1111 | |
| 1112 | case 'm': |
| 1113 | /* message-digest-key */ |
| 1114 | /* Delete one key */ |
| 1115 | i++; |
| 1116 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1117 | if (vl_config.crypto_key_id < 0) |
| 1118 | return CMD_WARNING; |
| 1119 | vl_config.md5_key = NULL; |
| 1120 | break; |
| 1121 | |
| 1122 | case 'h': |
| 1123 | /* Hello interval */ |
| 1124 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1125 | break; |
| 1126 | |
| 1127 | case 'r': |
| 1128 | /* Retransmit Interval */ |
| 1129 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1130 | break; |
| 1131 | |
| 1132 | case 't': |
| 1133 | /* Transmit Delay */ |
| 1134 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1135 | break; |
| 1136 | |
| 1137 | case 'd': |
| 1138 | /* Dead Interval */ |
| 1139 | i++; |
| 1140 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1141 | break; |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | |
| 1146 | /* Action configuration */ |
| 1147 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1148 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1149 | } |
| 1150 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1151 | ALIAS (ospf_area_vlink, |
| 1152 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1153 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1154 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1155 | VLINK_HELPSTR_IPADDR |
| 1156 | VLINK_HELPSTR_TIME_PARAM) |
| 1157 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1158 | ALIAS (no_ospf_area_vlink, |
| 1159 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1160 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1161 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1162 | NO_STR |
| 1163 | VLINK_HELPSTR_IPADDR |
| 1164 | VLINK_HELPSTR_TIME_PARAM) |
| 1165 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1166 | ALIAS (ospf_area_vlink, |
| 1167 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1168 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1169 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1170 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1171 | VLINK_HELPSTR_IPADDR |
| 1172 | VLINK_HELPSTR_TIME_PARAM |
| 1173 | VLINK_HELPSTR_TIME_PARAM) |
| 1174 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1175 | ALIAS (no_ospf_area_vlink, |
| 1176 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1177 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1178 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1179 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1180 | NO_STR |
| 1181 | VLINK_HELPSTR_IPADDR |
| 1182 | VLINK_HELPSTR_TIME_PARAM |
| 1183 | VLINK_HELPSTR_TIME_PARAM) |
| 1184 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1185 | ALIAS (ospf_area_vlink, |
| 1186 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1187 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1188 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1189 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1190 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1191 | VLINK_HELPSTR_IPADDR |
| 1192 | VLINK_HELPSTR_TIME_PARAM |
| 1193 | VLINK_HELPSTR_TIME_PARAM |
| 1194 | VLINK_HELPSTR_TIME_PARAM) |
| 1195 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1196 | ALIAS (no_ospf_area_vlink, |
| 1197 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1198 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1199 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1200 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1201 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1202 | NO_STR |
| 1203 | VLINK_HELPSTR_IPADDR |
| 1204 | VLINK_HELPSTR_TIME_PARAM |
| 1205 | VLINK_HELPSTR_TIME_PARAM |
| 1206 | VLINK_HELPSTR_TIME_PARAM) |
| 1207 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1208 | ALIAS (ospf_area_vlink, |
| 1209 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1210 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1211 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1212 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1213 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1214 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1215 | VLINK_HELPSTR_IPADDR |
| 1216 | VLINK_HELPSTR_TIME_PARAM |
| 1217 | VLINK_HELPSTR_TIME_PARAM |
| 1218 | VLINK_HELPSTR_TIME_PARAM |
| 1219 | VLINK_HELPSTR_TIME_PARAM) |
| 1220 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1221 | ALIAS (no_ospf_area_vlink, |
| 1222 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1223 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1224 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1225 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1226 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1227 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1228 | NO_STR |
| 1229 | VLINK_HELPSTR_IPADDR |
| 1230 | VLINK_HELPSTR_TIME_PARAM |
| 1231 | VLINK_HELPSTR_TIME_PARAM |
| 1232 | VLINK_HELPSTR_TIME_PARAM |
| 1233 | VLINK_HELPSTR_TIME_PARAM) |
| 1234 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1235 | ALIAS (ospf_area_vlink, |
| 1236 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1237 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1238 | "(authentication|) (message-digest|null)", |
| 1239 | VLINK_HELPSTR_IPADDR |
| 1240 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1241 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1242 | ALIAS (ospf_area_vlink, |
| 1243 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1244 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1245 | "(authentication|)", |
| 1246 | VLINK_HELPSTR_IPADDR |
| 1247 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1248 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1249 | ALIAS (no_ospf_area_vlink, |
| 1250 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1251 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1252 | "(authentication|)", |
| 1253 | NO_STR |
| 1254 | VLINK_HELPSTR_IPADDR |
| 1255 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1256 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1257 | ALIAS (ospf_area_vlink, |
| 1258 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1259 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1260 | "(message-digest-key|) <1-255> md5 KEY", |
| 1261 | VLINK_HELPSTR_IPADDR |
| 1262 | VLINK_HELPSTR_AUTH_MD5) |
| 1263 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1264 | ALIAS (no_ospf_area_vlink, |
| 1265 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1266 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1267 | "(message-digest-key|) <1-255>", |
| 1268 | NO_STR |
| 1269 | VLINK_HELPSTR_IPADDR |
| 1270 | VLINK_HELPSTR_AUTH_MD5) |
| 1271 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1272 | ALIAS (ospf_area_vlink, |
| 1273 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1274 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1275 | "(authentication-key|) AUTH_KEY", |
| 1276 | VLINK_HELPSTR_IPADDR |
| 1277 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1278 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1279 | ALIAS (no_ospf_area_vlink, |
| 1280 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1281 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1282 | "(authentication-key|)", |
| 1283 | NO_STR |
| 1284 | VLINK_HELPSTR_IPADDR |
| 1285 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1286 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1287 | ALIAS (ospf_area_vlink, |
| 1288 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1289 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1290 | "(authentication|) (message-digest|null) " |
| 1291 | "(authentication-key|) AUTH_KEY", |
| 1292 | VLINK_HELPSTR_IPADDR |
| 1293 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1294 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1295 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1296 | ALIAS (ospf_area_vlink, |
| 1297 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1298 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1299 | "(authentication|) " |
| 1300 | "(authentication-key|) AUTH_KEY", |
| 1301 | VLINK_HELPSTR_IPADDR |
| 1302 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1303 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1304 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1305 | ALIAS (no_ospf_area_vlink, |
| 1306 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1307 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1308 | "(authentication|) " |
| 1309 | "(authentication-key|)", |
| 1310 | NO_STR |
| 1311 | VLINK_HELPSTR_IPADDR |
| 1312 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1313 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1314 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1315 | ALIAS (ospf_area_vlink, |
| 1316 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1317 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1318 | "(authentication|) (message-digest|null) " |
| 1319 | "(message-digest-key|) <1-255> md5 KEY", |
| 1320 | VLINK_HELPSTR_IPADDR |
| 1321 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1322 | VLINK_HELPSTR_AUTH_MD5) |
| 1323 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1324 | ALIAS (ospf_area_vlink, |
| 1325 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1326 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1327 | "(authentication|) " |
| 1328 | "(message-digest-key|) <1-255> md5 KEY", |
| 1329 | VLINK_HELPSTR_IPADDR |
| 1330 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1331 | VLINK_HELPSTR_AUTH_MD5) |
| 1332 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1333 | ALIAS (no_ospf_area_vlink, |
| 1334 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1335 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1336 | "(authentication|) " |
| 1337 | "(message-digest-key|)", |
| 1338 | NO_STR |
| 1339 | VLINK_HELPSTR_IPADDR |
| 1340 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1341 | VLINK_HELPSTR_AUTH_MD5) |
| 1342 | |
| 1343 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1344 | DEFUN (ospf_area_shortcut, |
| 1345 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1346 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1347 | "OSPF area parameters\n" |
| 1348 | "OSPF area ID in IP address format\n" |
| 1349 | "OSPF area ID as a decimal value\n" |
| 1350 | "Configure the area's shortcutting mode\n" |
| 1351 | "Set default shortcutting behavior\n" |
| 1352 | "Enable shortcutting through the area\n" |
| 1353 | "Disable shortcutting through the area\n") |
| 1354 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1355 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1356 | struct ospf_area *area; |
| 1357 | struct in_addr area_id; |
| 1358 | int mode; |
| 1359 | int format; |
| 1360 | |
| 1361 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1362 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1363 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1364 | |
| 1365 | if (strncmp (argv[1], "de", 2) == 0) |
| 1366 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1367 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1368 | mode = OSPF_SHORTCUT_DISABLE; |
| 1369 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1370 | mode = OSPF_SHORTCUT_ENABLE; |
| 1371 | else |
| 1372 | return CMD_WARNING; |
| 1373 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1374 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1375 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1376 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1377 | vty_out (vty, "Shortcut area setting will take effect " |
| 1378 | "only when the router is configured as Shortcut ABR%s", |
| 1379 | VTY_NEWLINE); |
| 1380 | |
| 1381 | return CMD_SUCCESS; |
| 1382 | } |
| 1383 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1384 | DEFUN (no_ospf_area_shortcut, |
| 1385 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1386 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1387 | NO_STR |
| 1388 | "OSPF area parameters\n" |
| 1389 | "OSPF area ID in IP address format\n" |
| 1390 | "OSPF area ID as a decimal value\n" |
| 1391 | "Deconfigure the area's shortcutting mode\n" |
| 1392 | "Deconfigure enabled shortcutting through the area\n" |
| 1393 | "Deconfigure disabled shortcutting through the area\n") |
| 1394 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1395 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | struct ospf_area *area; |
| 1397 | struct in_addr area_id; |
| 1398 | int format; |
| 1399 | |
| 1400 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1401 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1402 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1403 | if (!area) |
| 1404 | return CMD_SUCCESS; |
| 1405 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1406 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1407 | |
| 1408 | return CMD_SUCCESS; |
| 1409 | } |
| 1410 | |
| 1411 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1412 | DEFUN (ospf_area_stub, |
| 1413 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1414 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1415 | "OSPF area parameters\n" |
| 1416 | "OSPF area ID in IP address format\n" |
| 1417 | "OSPF area ID as a decimal value\n" |
| 1418 | "Configure OSPF area as stub\n") |
| 1419 | { |
| 1420 | struct ospf *ospf = vty->index; |
| 1421 | struct in_addr area_id; |
| 1422 | int ret, format; |
| 1423 | |
| 1424 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1425 | |
| 1426 | ret = ospf_area_stub_set (ospf, area_id); |
| 1427 | if (ret == 0) |
| 1428 | { |
| 1429 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1430 | VTY_NEWLINE); |
| 1431 | return CMD_WARNING; |
| 1432 | } |
| 1433 | |
| 1434 | ospf_area_no_summary_unset (ospf, area_id); |
| 1435 | |
| 1436 | return CMD_SUCCESS; |
| 1437 | } |
| 1438 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1439 | DEFUN (ospf_area_stub_no_summary, |
| 1440 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1441 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1442 | "OSPF stub parameters\n" |
| 1443 | "OSPF area ID in IP address format\n" |
| 1444 | "OSPF area ID as a decimal value\n" |
| 1445 | "Configure OSPF area as stub\n" |
| 1446 | "Do not inject inter-area routes into stub\n") |
| 1447 | { |
| 1448 | struct ospf *ospf = vty->index; |
| 1449 | struct in_addr area_id; |
| 1450 | int ret, format; |
| 1451 | |
| 1452 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1453 | |
| 1454 | ret = ospf_area_stub_set (ospf, area_id); |
| 1455 | if (ret == 0) |
| 1456 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1457 | vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1458 | VTY_NEWLINE); |
| 1459 | return CMD_WARNING; |
| 1460 | } |
| 1461 | |
| 1462 | ospf_area_no_summary_set (ospf, area_id); |
| 1463 | |
| 1464 | return CMD_SUCCESS; |
| 1465 | } |
| 1466 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1467 | DEFUN (no_ospf_area_stub, |
| 1468 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1469 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1470 | NO_STR |
| 1471 | "OSPF area parameters\n" |
| 1472 | "OSPF area ID in IP address format\n" |
| 1473 | "OSPF area ID as a decimal value\n" |
| 1474 | "Configure OSPF area as stub\n") |
| 1475 | { |
| 1476 | struct ospf *ospf = vty->index; |
| 1477 | struct in_addr area_id; |
| 1478 | int format; |
| 1479 | |
| 1480 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1481 | |
| 1482 | ospf_area_stub_unset (ospf, area_id); |
| 1483 | ospf_area_no_summary_unset (ospf, area_id); |
| 1484 | |
| 1485 | return CMD_SUCCESS; |
| 1486 | } |
| 1487 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1488 | DEFUN (no_ospf_area_stub_no_summary, |
| 1489 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1490 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1491 | NO_STR |
| 1492 | "OSPF area parameters\n" |
| 1493 | "OSPF area ID in IP address format\n" |
| 1494 | "OSPF area ID as a decimal value\n" |
| 1495 | "Configure OSPF area as stub\n" |
| 1496 | "Do not inject inter-area routes into area\n") |
| 1497 | { |
| 1498 | struct ospf *ospf = vty->index; |
| 1499 | struct in_addr area_id; |
| 1500 | int format; |
| 1501 | |
| 1502 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1503 | ospf_area_no_summary_unset (ospf, area_id); |
| 1504 | |
| 1505 | return CMD_SUCCESS; |
| 1506 | } |
| 1507 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1508 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1509 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1510 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1511 | { |
| 1512 | struct ospf *ospf = vty->index; |
| 1513 | struct in_addr area_id; |
| 1514 | int ret, format; |
| 1515 | |
| 1516 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1517 | |
| 1518 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1519 | if (ret == 0) |
| 1520 | { |
| 1521 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1522 | VTY_NEWLINE); |
| 1523 | return CMD_WARNING; |
| 1524 | } |
| 1525 | |
| 1526 | if (argc > 1) |
| 1527 | { |
| 1528 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1529 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1530 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1531 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1532 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1533 | OSPF_NSSA_ROLE_NEVER); |
| 1534 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1535 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | OSPF_NSSA_ROLE_ALWAYS); |
| 1537 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1538 | else |
| 1539 | { |
| 1540 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1541 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1542 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1543 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1544 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1545 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1546 | else |
| 1547 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1548 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1549 | ospf_schedule_abr_task (ospf); |
| 1550 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1551 | return CMD_SUCCESS; |
| 1552 | } |
| 1553 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1554 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1555 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1556 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1557 | "OSPF area parameters\n" |
| 1558 | "OSPF area ID in IP address format\n" |
| 1559 | "OSPF area ID as a decimal value\n" |
| 1560 | "Configure OSPF area as nssa\n" |
| 1561 | "Configure NSSA-ABR for translate election (default)\n" |
| 1562 | "Configure NSSA-ABR to never translate\n" |
| 1563 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1564 | "Do not inject inter-area routes into nssa\n") |
| 1565 | { |
| 1566 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1567 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1568 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1569 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1570 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1571 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1572 | "OSPF area parameters\n" |
| 1573 | "OSPF area ID in IP address format\n" |
| 1574 | "OSPF area ID as a decimal value\n" |
| 1575 | "Configure OSPF area as nssa\n" |
| 1576 | "Configure NSSA-ABR for translate election (default)\n" |
| 1577 | "Configure NSSA-ABR to never translate\n" |
| 1578 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1579 | { |
| 1580 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1581 | } |
| 1582 | |
| 1583 | DEFUN (ospf_area_nssa, |
| 1584 | ospf_area_nssa_cmd, |
| 1585 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1586 | "OSPF area parameters\n" |
| 1587 | "OSPF area ID in IP address format\n" |
| 1588 | "OSPF area ID as a decimal value\n" |
| 1589 | "Configure OSPF area as nssa\n") |
| 1590 | { |
| 1591 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1592 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1593 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1594 | DEFUN (ospf_area_nssa_no_summary, |
| 1595 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1597 | "OSPF area parameters\n" |
| 1598 | "OSPF area ID in IP address format\n" |
| 1599 | "OSPF area ID as a decimal value\n" |
| 1600 | "Configure OSPF area as nssa\n" |
| 1601 | "Do not inject inter-area routes into nssa\n") |
| 1602 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1603 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1604 | } |
| 1605 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1606 | DEFUN (no_ospf_area_nssa, |
| 1607 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1608 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1609 | NO_STR |
| 1610 | "OSPF area parameters\n" |
| 1611 | "OSPF area ID in IP address format\n" |
| 1612 | "OSPF area ID as a decimal value\n" |
| 1613 | "Configure OSPF area as nssa\n") |
| 1614 | { |
| 1615 | struct ospf *ospf = vty->index; |
| 1616 | struct in_addr area_id; |
| 1617 | int format; |
| 1618 | |
| 1619 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1620 | |
| 1621 | ospf_area_nssa_unset (ospf, area_id); |
| 1622 | ospf_area_no_summary_unset (ospf, area_id); |
| 1623 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1624 | ospf_schedule_abr_task (ospf); |
| 1625 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1626 | return CMD_SUCCESS; |
| 1627 | } |
| 1628 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1629 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1630 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1631 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1632 | NO_STR |
| 1633 | "OSPF area parameters\n" |
| 1634 | "OSPF area ID in IP address format\n" |
| 1635 | "OSPF area ID as a decimal value\n" |
| 1636 | "Configure OSPF area as nssa\n" |
| 1637 | "Do not inject inter-area routes into nssa\n") |
| 1638 | { |
| 1639 | struct ospf *ospf = vty->index; |
| 1640 | struct in_addr area_id; |
| 1641 | int format; |
| 1642 | |
| 1643 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1644 | ospf_area_no_summary_unset (ospf, area_id); |
| 1645 | |
| 1646 | return CMD_SUCCESS; |
| 1647 | } |
| 1648 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1649 | DEFUN (ospf_area_default_cost, |
| 1650 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1651 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1652 | "OSPF area parameters\n" |
| 1653 | "OSPF area ID in IP address format\n" |
| 1654 | "OSPF area ID as a decimal value\n" |
| 1655 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1656 | "Stub's advertised default summary cost\n") |
| 1657 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1658 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1659 | struct ospf_area *area; |
| 1660 | struct in_addr area_id; |
| 1661 | u_int32_t cost; |
| 1662 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1663 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1664 | |
| 1665 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1666 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1667 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1668 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1669 | |
| 1670 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1671 | { |
| 1672 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1673 | return CMD_WARNING; |
| 1674 | } |
| 1675 | |
| 1676 | area->default_cost = cost; |
| 1677 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1678 | p.family = AF_INET; |
| 1679 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1680 | p.prefixlen = 0; |
| 1681 | if (IS_DEBUG_OSPF_EVENT) |
| 1682 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1683 | "announcing 0.0.0.0/0 to area %s", |
| 1684 | inet_ntoa (area->area_id)); |
| 1685 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1686 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1687 | return CMD_SUCCESS; |
| 1688 | } |
| 1689 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1690 | DEFUN (no_ospf_area_default_cost, |
| 1691 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1692 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1693 | NO_STR |
| 1694 | "OSPF area parameters\n" |
| 1695 | "OSPF area ID in IP address format\n" |
| 1696 | "OSPF area ID as a decimal value\n" |
| 1697 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1698 | "Stub's advertised default summary cost\n") |
| 1699 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1700 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1701 | struct ospf_area *area; |
| 1702 | struct in_addr area_id; |
| 1703 | u_int32_t cost; |
| 1704 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1705 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1706 | |
| 1707 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1708 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1709 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1710 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1711 | if (area == NULL) |
| 1712 | return CMD_SUCCESS; |
| 1713 | |
| 1714 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1715 | { |
| 1716 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1717 | return CMD_WARNING; |
| 1718 | } |
| 1719 | |
| 1720 | area->default_cost = 1; |
| 1721 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1722 | p.family = AF_INET; |
| 1723 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1724 | p.prefixlen = 0; |
| 1725 | if (IS_DEBUG_OSPF_EVENT) |
| 1726 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1727 | "announcing 0.0.0.0/0 to area %s", |
| 1728 | inet_ntoa (area->area_id)); |
| 1729 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1730 | |
| 1731 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1732 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1733 | |
| 1734 | return CMD_SUCCESS; |
| 1735 | } |
| 1736 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1737 | DEFUN (ospf_area_export_list, |
| 1738 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1739 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1740 | "OSPF area parameters\n" |
| 1741 | "OSPF area ID in IP address format\n" |
| 1742 | "OSPF area ID as a decimal value\n" |
| 1743 | "Set the filter for networks announced to other areas\n" |
| 1744 | "Name of the access-list\n") |
| 1745 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1746 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1747 | struct ospf_area *area; |
| 1748 | struct in_addr area_id; |
| 1749 | int format; |
| 1750 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1751 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1752 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1753 | area = ospf_area_get (ospf, area_id, format); |
| 1754 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1755 | |
| 1756 | return CMD_SUCCESS; |
| 1757 | } |
| 1758 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1759 | DEFUN (no_ospf_area_export_list, |
| 1760 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1761 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1762 | NO_STR |
| 1763 | "OSPF area parameters\n" |
| 1764 | "OSPF area ID in IP address format\n" |
| 1765 | "OSPF area ID as a decimal value\n" |
| 1766 | "Unset the filter for networks announced to other areas\n" |
| 1767 | "Name of the access-list\n") |
| 1768 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1769 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1770 | struct ospf_area *area; |
| 1771 | struct in_addr area_id; |
| 1772 | int format; |
| 1773 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1774 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1775 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1776 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1777 | if (area == NULL) |
| 1778 | return CMD_SUCCESS; |
| 1779 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1780 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1781 | |
| 1782 | return CMD_SUCCESS; |
| 1783 | } |
| 1784 | |
| 1785 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1786 | DEFUN (ospf_area_import_list, |
| 1787 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1788 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1789 | "OSPF area parameters\n" |
| 1790 | "OSPF area ID in IP address format\n" |
| 1791 | "OSPF area ID as a decimal value\n" |
| 1792 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1793 | "Name of the access-list\n") |
| 1794 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1795 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1796 | struct ospf_area *area; |
| 1797 | struct in_addr area_id; |
| 1798 | int format; |
| 1799 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1800 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1801 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1802 | area = ospf_area_get (ospf, area_id, format); |
| 1803 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1804 | |
| 1805 | return CMD_SUCCESS; |
| 1806 | } |
| 1807 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1808 | DEFUN (no_ospf_area_import_list, |
| 1809 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1810 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1811 | NO_STR |
| 1812 | "OSPF area parameters\n" |
| 1813 | "OSPF area ID in IP address format\n" |
| 1814 | "OSPF area ID as a decimal value\n" |
| 1815 | "Unset the filter for networks announced to other areas\n" |
| 1816 | "Name of the access-list\n") |
| 1817 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1818 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1819 | struct ospf_area *area; |
| 1820 | struct in_addr area_id; |
| 1821 | int format; |
| 1822 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1823 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1824 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1825 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1826 | if (area == NULL) |
| 1827 | return CMD_SUCCESS; |
| 1828 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1829 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1830 | |
| 1831 | return CMD_SUCCESS; |
| 1832 | } |
| 1833 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1834 | DEFUN (ospf_area_filter_list, |
| 1835 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1836 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1837 | "OSPF area parameters\n" |
| 1838 | "OSPF area ID in IP address format\n" |
| 1839 | "OSPF area ID as a decimal value\n" |
| 1840 | "Filter networks between OSPF areas\n" |
| 1841 | "Filter prefixes between OSPF areas\n" |
| 1842 | "Name of an IP prefix-list\n" |
| 1843 | "Filter networks sent to this area\n" |
| 1844 | "Filter networks sent from this area\n") |
| 1845 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1846 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1847 | struct ospf_area *area; |
| 1848 | struct in_addr area_id; |
| 1849 | struct prefix_list *plist; |
| 1850 | int format; |
| 1851 | |
| 1852 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1853 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1854 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1855 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1856 | if (strncmp (argv[2], "in", 2) == 0) |
| 1857 | { |
| 1858 | PREFIX_LIST_IN (area) = plist; |
| 1859 | if (PREFIX_NAME_IN (area)) |
| 1860 | free (PREFIX_NAME_IN (area)); |
| 1861 | |
| 1862 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1863 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1864 | } |
| 1865 | else |
| 1866 | { |
| 1867 | PREFIX_LIST_OUT (area) = plist; |
| 1868 | if (PREFIX_NAME_OUT (area)) |
| 1869 | free (PREFIX_NAME_OUT (area)); |
| 1870 | |
| 1871 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1872 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1873 | } |
| 1874 | |
| 1875 | return CMD_SUCCESS; |
| 1876 | } |
| 1877 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1878 | DEFUN (no_ospf_area_filter_list, |
| 1879 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1880 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1881 | NO_STR |
| 1882 | "OSPF area parameters\n" |
| 1883 | "OSPF area ID in IP address format\n" |
| 1884 | "OSPF area ID as a decimal value\n" |
| 1885 | "Filter networks between OSPF areas\n" |
| 1886 | "Filter prefixes between OSPF areas\n" |
| 1887 | "Name of an IP prefix-list\n" |
| 1888 | "Filter networks sent to this area\n" |
| 1889 | "Filter networks sent from this area\n") |
| 1890 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1891 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1892 | struct ospf_area *area; |
| 1893 | struct in_addr area_id; |
| 1894 | struct prefix_list *plist; |
| 1895 | int format; |
| 1896 | |
| 1897 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1898 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1899 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1900 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1901 | if (strncmp (argv[2], "in", 2) == 0) |
| 1902 | { |
| 1903 | if (PREFIX_NAME_IN (area)) |
| 1904 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1905 | return CMD_SUCCESS; |
| 1906 | |
| 1907 | PREFIX_LIST_IN (area) = NULL; |
| 1908 | if (PREFIX_NAME_IN (area)) |
| 1909 | free (PREFIX_NAME_IN (area)); |
| 1910 | |
| 1911 | PREFIX_NAME_IN (area) = NULL; |
| 1912 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1913 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1914 | } |
| 1915 | else |
| 1916 | { |
| 1917 | if (PREFIX_NAME_OUT (area)) |
| 1918 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1919 | return CMD_SUCCESS; |
| 1920 | |
| 1921 | PREFIX_LIST_OUT (area) = NULL; |
| 1922 | if (PREFIX_NAME_OUT (area)) |
| 1923 | free (PREFIX_NAME_OUT (area)); |
| 1924 | |
| 1925 | PREFIX_NAME_OUT (area) = NULL; |
| 1926 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1927 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1928 | } |
| 1929 | |
| 1930 | return CMD_SUCCESS; |
| 1931 | } |
| 1932 | |
| 1933 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1934 | DEFUN (ospf_area_authentication_message_digest, |
| 1935 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1936 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1937 | "OSPF area parameters\n" |
| 1938 | "Enable authentication\n" |
| 1939 | "Use message-digest authentication\n") |
| 1940 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1941 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1942 | struct ospf_area *area; |
| 1943 | struct in_addr area_id; |
| 1944 | int format; |
| 1945 | |
| 1946 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1947 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1948 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1949 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1950 | |
| 1951 | return CMD_SUCCESS; |
| 1952 | } |
| 1953 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1954 | DEFUN (ospf_area_authentication, |
| 1955 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1956 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1957 | "OSPF area parameters\n" |
| 1958 | "OSPF area ID in IP address format\n" |
| 1959 | "OSPF area ID as a decimal value\n" |
| 1960 | "Enable authentication\n") |
| 1961 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1962 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1963 | struct ospf_area *area; |
| 1964 | struct in_addr area_id; |
| 1965 | int format; |
| 1966 | |
| 1967 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1968 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1969 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1970 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1971 | |
| 1972 | return CMD_SUCCESS; |
| 1973 | } |
| 1974 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1975 | DEFUN (no_ospf_area_authentication, |
| 1976 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1977 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1978 | NO_STR |
| 1979 | "OSPF area parameters\n" |
| 1980 | "OSPF area ID in IP address format\n" |
| 1981 | "OSPF area ID as a decimal value\n" |
| 1982 | "Enable authentication\n") |
| 1983 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1984 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1985 | struct ospf_area *area; |
| 1986 | struct in_addr area_id; |
| 1987 | int format; |
| 1988 | |
| 1989 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1990 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1991 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1992 | if (area == NULL) |
| 1993 | return CMD_SUCCESS; |
| 1994 | |
| 1995 | area->auth_type = OSPF_AUTH_NULL; |
| 1996 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1997 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1998 | |
| 1999 | return CMD_SUCCESS; |
| 2000 | } |
| 2001 | |
| 2002 | |
| 2003 | DEFUN (ospf_abr_type, |
| 2004 | ospf_abr_type_cmd, |
| 2005 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 2006 | "OSPF specific commands\n" |
| 2007 | "Set OSPF ABR type\n" |
| 2008 | "Alternative ABR, cisco implementation\n" |
| 2009 | "Alternative ABR, IBM implementation\n" |
| 2010 | "Shortcut ABR\n" |
| 2011 | "Standard behavior (RFC2328)\n") |
| 2012 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2013 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2014 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2015 | |
| 2016 | if (strncmp (argv[0], "c", 1) == 0) |
| 2017 | abr_type = OSPF_ABR_CISCO; |
| 2018 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2019 | abr_type = OSPF_ABR_IBM; |
| 2020 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2021 | abr_type = OSPF_ABR_SHORTCUT; |
| 2022 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2023 | abr_type = OSPF_ABR_STAND; |
| 2024 | else |
| 2025 | return CMD_WARNING; |
| 2026 | |
| 2027 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2028 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2029 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2030 | ospf->abr_type = abr_type; |
| 2031 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | return CMD_SUCCESS; |
| 2035 | } |
| 2036 | |
| 2037 | DEFUN (no_ospf_abr_type, |
| 2038 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2039 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2040 | NO_STR |
| 2041 | "OSPF specific commands\n" |
| 2042 | "Set OSPF ABR type\n" |
| 2043 | "Alternative ABR, cisco implementation\n" |
| 2044 | "Alternative ABR, IBM implementation\n" |
| 2045 | "Shortcut ABR\n") |
| 2046 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2047 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2048 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2049 | |
| 2050 | if (strncmp (argv[0], "c", 1) == 0) |
| 2051 | abr_type = OSPF_ABR_CISCO; |
| 2052 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2053 | abr_type = OSPF_ABR_IBM; |
| 2054 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2055 | abr_type = OSPF_ABR_SHORTCUT; |
| 2056 | else |
| 2057 | return CMD_WARNING; |
| 2058 | |
| 2059 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2060 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2061 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2062 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2063 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2064 | } |
| 2065 | |
| 2066 | return CMD_SUCCESS; |
| 2067 | } |
| 2068 | |
| 2069 | DEFUN (ospf_compatible_rfc1583, |
| 2070 | ospf_compatible_rfc1583_cmd, |
| 2071 | "compatible rfc1583", |
| 2072 | "OSPF compatibility list\n" |
| 2073 | "compatible with RFC 1583\n") |
| 2074 | { |
| 2075 | struct ospf *ospf = vty->index; |
| 2076 | |
| 2077 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2078 | { |
| 2079 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2080 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2081 | } |
| 2082 | return CMD_SUCCESS; |
| 2083 | } |
| 2084 | |
| 2085 | DEFUN (no_ospf_compatible_rfc1583, |
| 2086 | no_ospf_compatible_rfc1583_cmd, |
| 2087 | "no compatible rfc1583", |
| 2088 | NO_STR |
| 2089 | "OSPF compatibility list\n" |
| 2090 | "compatible with RFC 1583\n") |
| 2091 | { |
| 2092 | struct ospf *ospf = vty->index; |
| 2093 | |
| 2094 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2095 | { |
| 2096 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2097 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2098 | } |
| 2099 | return CMD_SUCCESS; |
| 2100 | } |
| 2101 | |
| 2102 | ALIAS (ospf_compatible_rfc1583, |
| 2103 | ospf_rfc1583_flag_cmd, |
| 2104 | "ospf rfc1583compatibility", |
| 2105 | "OSPF specific commands\n" |
| 2106 | "Enable the RFC1583Compatibility flag\n") |
| 2107 | |
| 2108 | ALIAS (no_ospf_compatible_rfc1583, |
| 2109 | no_ospf_rfc1583_flag_cmd, |
| 2110 | "no ospf rfc1583compatibility", |
| 2111 | NO_STR |
| 2112 | "OSPF specific commands\n" |
| 2113 | "Disable the RFC1583Compatibility flag\n") |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2114 | |
| 2115 | static int |
| 2116 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2117 | unsigned int hold, |
| 2118 | unsigned int max) |
| 2119 | { |
| 2120 | struct ospf *ospf = vty->index; |
| 2121 | |
| 2122 | ospf->spf_delay = delay; |
| 2123 | ospf->spf_holdtime = hold; |
| 2124 | ospf->spf_max_holdtime = max; |
| 2125 | |
| 2126 | return CMD_SUCCESS; |
| 2127 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2129 | DEFUN (ospf_timers_throttle_spf, |
| 2130 | ospf_timers_throttle_spf_cmd, |
| 2131 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2132 | "Adjust routing timers\n" |
| 2133 | "Throttling adaptive timer\n" |
| 2134 | "OSPF SPF timers\n" |
| 2135 | "Delay (msec) from first change received till SPF calculation\n" |
| 2136 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2137 | "Maximum hold time (msec)\n") |
| 2138 | { |
| 2139 | unsigned int delay, hold, max; |
| 2140 | |
| 2141 | if (argc != 3) |
| 2142 | { |
| 2143 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2144 | return CMD_WARNING; |
| 2145 | } |
| 2146 | |
| 2147 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2148 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2149 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2150 | |
| 2151 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2152 | } |
| 2153 | |
| 2154 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2155 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2156 | "timers spf <0-4294967295> <0-4294967295>", |
| 2157 | "Adjust routing timers\n" |
| 2158 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2159 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2160 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2161 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2162 | unsigned int delay, hold; |
| 2163 | |
| 2164 | if (argc != 2) |
| 2165 | { |
| 2166 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2167 | return CMD_WARNING; |
| 2168 | } |
| 2169 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2170 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2171 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2172 | |
| 2173 | /* truncate down the second values if they're greater than 600000ms */ |
| 2174 | if (delay > (600000 / 1000)) |
| 2175 | delay = 600000; |
| 2176 | else if (delay == 0) |
| 2177 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2178 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2179 | if (hold > (600000 / 1000)) |
| 2180 | hold = 600000; |
| 2181 | |
| 2182 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2183 | } |
| 2184 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2185 | DEFUN (no_ospf_timers_throttle_spf, |
| 2186 | no_ospf_timers_throttle_spf_cmd, |
| 2187 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2188 | NO_STR |
| 2189 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2190 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2191 | "OSPF SPF timers\n") |
| 2192 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2193 | return ospf_timers_spf_set (vty, |
| 2194 | OSPF_SPF_DELAY_DEFAULT, |
| 2195 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2196 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2197 | } |
| 2198 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2199 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2200 | no_ospf_timers_spf_cmd, |
| 2201 | "no timers spf", |
| 2202 | NO_STR |
| 2203 | "Adjust routing timers\n" |
| 2204 | "OSPF SPF timers\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2205 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2206 | DEFUN (ospf_neighbor, |
| 2207 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2208 | "neighbor A.B.C.D", |
| 2209 | NEIGHBOR_STR |
| 2210 | "Neighbor IP address\n") |
| 2211 | { |
| 2212 | struct ospf *ospf = vty->index; |
| 2213 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2214 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2215 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2216 | |
| 2217 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2218 | |
| 2219 | if (argc > 1) |
| 2220 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2221 | |
| 2222 | if (argc > 2) |
| 2223 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2224 | |
| 2225 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2226 | if (argc > 1) |
| 2227 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2228 | if (argc > 2) |
| 2229 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2230 | |
| 2231 | return CMD_SUCCESS; |
| 2232 | } |
| 2233 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2234 | ALIAS (ospf_neighbor, |
| 2235 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2236 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2237 | NEIGHBOR_STR |
| 2238 | "Neighbor IP address\n" |
| 2239 | "Neighbor Priority\n" |
| 2240 | "Priority\n" |
| 2241 | "Dead Neighbor Polling interval\n" |
| 2242 | "Seconds\n") |
| 2243 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2244 | ALIAS (ospf_neighbor, |
| 2245 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | "neighbor A.B.C.D priority <0-255>", |
| 2247 | NEIGHBOR_STR |
| 2248 | "Neighbor IP address\n" |
| 2249 | "Neighbor Priority\n" |
| 2250 | "Seconds\n") |
| 2251 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2252 | DEFUN (ospf_neighbor_poll_interval, |
| 2253 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2255 | NEIGHBOR_STR |
| 2256 | "Neighbor IP address\n" |
| 2257 | "Dead Neighbor Polling interval\n" |
| 2258 | "Seconds\n") |
| 2259 | { |
| 2260 | struct ospf *ospf = vty->index; |
| 2261 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2262 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2263 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2264 | |
| 2265 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2266 | |
| 2267 | if (argc > 1) |
| 2268 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2269 | |
| 2270 | if (argc > 2) |
| 2271 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2272 | |
| 2273 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2274 | if (argc > 1) |
| 2275 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2276 | if (argc > 2) |
| 2277 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2278 | |
| 2279 | return CMD_SUCCESS; |
| 2280 | } |
| 2281 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2282 | ALIAS (ospf_neighbor_poll_interval, |
| 2283 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2285 | NEIGHBOR_STR |
| 2286 | "Neighbor address\n" |
| 2287 | "OSPF dead-router polling interval\n" |
| 2288 | "Seconds\n" |
| 2289 | "OSPF priority of non-broadcast neighbor\n" |
| 2290 | "Priority\n") |
| 2291 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2292 | DEFUN (no_ospf_neighbor, |
| 2293 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2294 | "no neighbor A.B.C.D", |
| 2295 | NO_STR |
| 2296 | NEIGHBOR_STR |
| 2297 | "Neighbor IP address\n") |
| 2298 | { |
| 2299 | struct ospf *ospf = vty->index; |
| 2300 | struct in_addr nbr_addr; |
| 2301 | int ret; |
| 2302 | |
| 2303 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2304 | |
| 2305 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2306 | |
| 2307 | return CMD_SUCCESS; |
| 2308 | } |
| 2309 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2310 | ALIAS (no_ospf_neighbor, |
| 2311 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2312 | "no neighbor A.B.C.D priority <0-255>", |
| 2313 | NO_STR |
| 2314 | NEIGHBOR_STR |
| 2315 | "Neighbor IP address\n" |
| 2316 | "Neighbor Priority\n" |
| 2317 | "Priority\n") |
| 2318 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2319 | ALIAS (no_ospf_neighbor, |
| 2320 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2321 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2322 | NO_STR |
| 2323 | NEIGHBOR_STR |
| 2324 | "Neighbor IP address\n" |
| 2325 | "Dead Neighbor Polling interval\n" |
| 2326 | "Seconds\n") |
| 2327 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2328 | ALIAS (no_ospf_neighbor, |
| 2329 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2330 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2331 | NO_STR |
| 2332 | NEIGHBOR_STR |
| 2333 | "Neighbor IP address\n" |
| 2334 | "Neighbor Priority\n" |
| 2335 | "Priority\n" |
| 2336 | "Dead Neighbor Polling interval\n" |
| 2337 | "Seconds\n") |
| 2338 | |
| 2339 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2340 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2341 | "refresh timer <10-1800>", |
| 2342 | "Adjust refresh parameters\n" |
| 2343 | "Set refresh timer\n" |
| 2344 | "Timer value in seconds\n") |
| 2345 | { |
| 2346 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2347 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | |
| 2349 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2350 | interval = (interval / 10) * 10; |
| 2351 | |
| 2352 | ospf_timers_refresh_set (ospf, interval); |
| 2353 | |
| 2354 | return CMD_SUCCESS; |
| 2355 | } |
| 2356 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2357 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2358 | "no refresh timer <10-1800>", |
| 2359 | "Adjust refresh parameters\n" |
| 2360 | "Unset refresh timer\n" |
| 2361 | "Timer value in seconds\n") |
| 2362 | { |
| 2363 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2364 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2365 | |
| 2366 | if (argc == 1) |
| 2367 | { |
| 2368 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2369 | |
| 2370 | if (ospf->lsa_refresh_interval != interval || |
| 2371 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2372 | return CMD_SUCCESS; |
| 2373 | } |
| 2374 | |
| 2375 | ospf_timers_refresh_unset (ospf); |
| 2376 | |
| 2377 | return CMD_SUCCESS; |
| 2378 | } |
| 2379 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2380 | ALIAS (no_ospf_refresh_timer, |
| 2381 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2382 | "no refresh timer", |
| 2383 | "Adjust refresh parameters\n" |
| 2384 | "Unset refresh timer\n") |
| 2385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2386 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2387 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2388 | "auto-cost reference-bandwidth <1-4294967>", |
| 2389 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2390 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2391 | "The reference bandwidth in terms of Mbits per second\n") |
| 2392 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2393 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2394 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2395 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2396 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | |
| 2398 | refbw = strtol (argv[0], NULL, 10); |
| 2399 | if (refbw < 1 || refbw > 4294967) |
| 2400 | { |
| 2401 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2402 | return CMD_WARNING; |
| 2403 | } |
| 2404 | |
| 2405 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2406 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | return CMD_SUCCESS; |
| 2408 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2409 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2410 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2411 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2412 | |
| 2413 | return CMD_SUCCESS; |
| 2414 | } |
| 2415 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2416 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2417 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2418 | "no auto-cost reference-bandwidth", |
| 2419 | NO_STR |
| 2420 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2421 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2422 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2423 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2424 | struct listnode *node, *nnode; |
| 2425 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2427 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2428 | return CMD_SUCCESS; |
| 2429 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2430 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2431 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2432 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2433 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2434 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2435 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2436 | |
| 2437 | return CMD_SUCCESS; |
| 2438 | } |
| 2439 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2440 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2441 | { |
| 2442 | "Unknown", |
| 2443 | "Standard (RFC2328)", |
| 2444 | "Alternative IBM", |
| 2445 | "Alternative Cisco", |
| 2446 | "Alternative Shortcut" |
| 2447 | }; |
| 2448 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2449 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2450 | { |
| 2451 | "Default", |
| 2452 | "Enabled", |
| 2453 | "Disabled" |
| 2454 | }; |
| 2455 | |
| 2456 | |
| 2457 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2458 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2459 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2460 | { |
| 2461 | /* Show Area ID. */ |
| 2462 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2463 | |
| 2464 | /* Show Area type/mode. */ |
| 2465 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2466 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2467 | else |
| 2468 | { |
| 2469 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2470 | vty_out (vty, " (Stub%s%s)", |
| 2471 | area->no_summary ? ", no summary" : "", |
| 2472 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2473 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2474 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2475 | vty_out (vty, " (NSSA%s%s)", |
| 2476 | area->no_summary ? ", no summary" : "", |
| 2477 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | |
| 2479 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2480 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2481 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2483 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2484 | } |
| 2485 | |
| 2486 | /* Show number of interfaces. */ |
| 2487 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2488 | "Active: %d%s", listcount (area->oiflist), |
| 2489 | area->act_ints, VTY_NEWLINE); |
| 2490 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2491 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2492 | { |
| 2493 | 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] | 2494 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2495 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2496 | VTY_NEWLINE); |
| 2497 | else if (area->NSSATranslatorState) |
| 2498 | { |
| 2499 | vty_out (vty, " We are an ABR and "); |
| 2500 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2501 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2502 | VTY_NEWLINE); |
| 2503 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2504 | vty_out (vty, "always an NSSA Translator. %s", |
| 2505 | VTY_NEWLINE); |
| 2506 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2507 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2508 | { |
| 2509 | vty_out (vty, " We are an ABR, but "); |
| 2510 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2511 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2512 | VTY_NEWLINE); |
| 2513 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2514 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2515 | VTY_NEWLINE); |
| 2516 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2517 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2518 | /* Stub-router state for this area */ |
| 2519 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2520 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2521 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2522 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2523 | VTY_NEWLINE); |
| 2524 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2525 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2526 | VTY_NEWLINE); |
| 2527 | if (area->t_stub_router) |
| 2528 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2529 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2530 | sizeof(timebuf)), VTY_NEWLINE); |
| 2531 | } |
| 2532 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2533 | /* Show number of fully adjacent neighbors. */ |
| 2534 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2535 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2536 | |
| 2537 | /* Show authentication type. */ |
| 2538 | vty_out (vty, " Area has "); |
| 2539 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2540 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2541 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2542 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2543 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2544 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2545 | |
| 2546 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2547 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2548 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2549 | |
| 2550 | /* Show SPF calculation times. */ |
| 2551 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2552 | area->spf_calculation, VTY_NEWLINE); |
| 2553 | |
| 2554 | /* Show number of LSA. */ |
| 2555 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2556 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2557 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2558 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2559 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2560 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2561 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2562 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2563 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2564 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2565 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2566 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2567 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2568 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2569 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2570 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2571 | #ifdef HAVE_OPAQUE_LSA |
| 2572 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2573 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2574 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2575 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2576 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2577 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2578 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2579 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2580 | } |
| 2581 | |
| 2582 | DEFUN (show_ip_ospf, |
| 2583 | show_ip_ospf_cmd, |
| 2584 | "show ip ospf", |
| 2585 | SHOW_STR |
| 2586 | IP_STR |
| 2587 | "OSPF information\n") |
| 2588 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2589 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2590 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2591 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2592 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2593 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2594 | |
| 2595 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2596 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2597 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2598 | { |
| 2599 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2600 | return CMD_SUCCESS; |
| 2601 | } |
| 2602 | |
| 2603 | /* Show Router ID. */ |
| 2604 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2605 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2606 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2607 | |
| 2608 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2609 | if (ospf->t_deferred_shutdown) |
| 2610 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2611 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2612 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2613 | /* Show capability. */ |
| 2614 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2615 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2616 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2617 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2618 | "enabled" : "disabled", VTY_NEWLINE); |
| 2619 | #ifdef HAVE_OPAQUE_LSA |
| 2620 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2621 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2622 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2623 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2624 | " (origination blocked)" : "", |
| 2625 | VTY_NEWLINE); |
| 2626 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2627 | |
| 2628 | /* Show stub-router configuration */ |
| 2629 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2630 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2631 | { |
| 2632 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2633 | VTY_NEWLINE); |
| 2634 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2635 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2636 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2637 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2638 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2639 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2640 | } |
| 2641 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2643 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2644 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2645 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2646 | " Hold time multiplier is currently %d%s", |
| 2647 | ospf->spf_delay, VTY_NEWLINE, |
| 2648 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2649 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2650 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2651 | vty_out (vty, " SPF algorithm "); |
| 2652 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2653 | { |
paul | c8c1521 | 2005-11-04 12:31:39 +0000 | [diff] [blame] | 2654 | result = tv_sub (recent_time, ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2655 | vty_out (vty, "last executed %s ago%s", |
| 2656 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2657 | VTY_NEWLINE); |
| 2658 | } |
| 2659 | else |
| 2660 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2661 | vty_out (vty, " SPF timer %s%s%s", |
| 2662 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2663 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2664 | VTY_NEWLINE); |
| 2665 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2666 | /* Show refresh parameters. */ |
| 2667 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2668 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2669 | |
| 2670 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2671 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2672 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2673 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2674 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2675 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2676 | vty_out (vty, " This router is an ASBR " |
| 2677 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2678 | |
| 2679 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2680 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2681 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2682 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2683 | #ifdef HAVE_OPAQUE_LSA |
| 2684 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2685 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2686 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2687 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2688 | /* Show number of areas attached. */ |
| 2689 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2690 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2691 | |
| 2692 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2693 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2694 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2695 | |
| 2696 | return CMD_SUCCESS; |
| 2697 | } |
| 2698 | |
| 2699 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2700 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2701 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2702 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2703 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2704 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2705 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2706 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2707 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2708 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2709 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2710 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2711 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2712 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2713 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2714 | |
| 2715 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2716 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2717 | { |
| 2718 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2719 | return; |
| 2720 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2721 | else if (!is_up) |
| 2722 | { |
| 2723 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2724 | VTY_NEWLINE); |
| 2725 | return; |
| 2726 | } |
| 2727 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2728 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2729 | { |
| 2730 | struct ospf_interface *oi = rn->info; |
| 2731 | |
| 2732 | if (oi == NULL) |
| 2733 | continue; |
| 2734 | |
| 2735 | /* Show OSPF interface information. */ |
| 2736 | vty_out (vty, " Internet Address %s/%d,", |
| 2737 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2738 | |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2739 | if (oi->connected->destination) |
| 2740 | vty_out (vty, " %s %s,", |
| 2741 | ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"), |
| 2742 | inet_ntoa (oi->connected->destination->u.prefix4)); |
| 2743 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2744 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2745 | VTY_NEWLINE); |
| 2746 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2747 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2748 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2749 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2750 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2751 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2752 | oi->output_cost, VTY_NEWLINE); |
| 2753 | |
| 2754 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2755 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2756 | PRIORITY (oi), VTY_NEWLINE); |
| 2757 | |
| 2758 | /* Show DR information. */ |
| 2759 | if (DR (oi).s_addr == 0) |
| 2760 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2761 | else |
| 2762 | { |
| 2763 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2764 | if (nbr == NULL) |
| 2765 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2766 | else |
| 2767 | { |
| 2768 | vty_out (vty, " Designated Router (ID) %s,", |
| 2769 | inet_ntoa (nbr->router_id)); |
| 2770 | vty_out (vty, " Interface Address %s%s", |
| 2771 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2772 | } |
| 2773 | } |
| 2774 | |
| 2775 | /* Show BDR information. */ |
| 2776 | if (BDR (oi).s_addr == 0) |
| 2777 | vty_out (vty, " No backup designated router on this network%s", |
| 2778 | VTY_NEWLINE); |
| 2779 | else |
| 2780 | { |
| 2781 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2782 | if (nbr == NULL) |
| 2783 | vty_out (vty, " No backup designated router on this network%s", |
| 2784 | VTY_NEWLINE); |
| 2785 | else |
| 2786 | { |
| 2787 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2788 | inet_ntoa (nbr->router_id)); |
| 2789 | vty_out (vty, " Interface Address %s%s", |
| 2790 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2791 | } |
| 2792 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2793 | |
| 2794 | vty_out (vty, " Multicast group memberships:"); |
| 2795 | if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS)) |
| 2796 | vty_out (vty, " OSPFAllRouters"); |
| 2797 | if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS)) |
| 2798 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2799 | if (!CHECK_FLAG(oi->multicast_memberships, |
| 2800 | MEMBER_ALLROUTERS|MEMBER_DROUTERS)) |
| 2801 | vty_out (vty, " <None>"); |
| 2802 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2803 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2804 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2805 | vty_out (vty, " Hello "); |
| 2806 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 2807 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 2808 | else |
| 2809 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 2810 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 2811 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2812 | OSPF_IF_PARAM (oi, v_wait), |
| 2813 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2814 | VTY_NEWLINE); |
| 2815 | |
| 2816 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2817 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2818 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2819 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2820 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2821 | VTY_NEWLINE); |
| 2822 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2823 | else /* OSPF_IF_PASSIVE is set */ |
| 2824 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2825 | |
| 2826 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2827 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2828 | VTY_NEWLINE); |
| 2829 | } |
| 2830 | } |
| 2831 | |
| 2832 | DEFUN (show_ip_ospf_interface, |
| 2833 | show_ip_ospf_interface_cmd, |
| 2834 | "show ip ospf interface [INTERFACE]", |
| 2835 | SHOW_STR |
| 2836 | IP_STR |
| 2837 | "OSPF information\n" |
| 2838 | "Interface information\n" |
| 2839 | "Interface name\n") |
| 2840 | { |
| 2841 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2842 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2843 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2844 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2845 | ospf = ospf_lookup (); |
| 2846 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2847 | /* Show All Interfaces. */ |
| 2848 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2849 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 2850 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2851 | /* Interface name is specified. */ |
| 2852 | else |
| 2853 | { |
| 2854 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2855 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2856 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2857 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2858 | } |
| 2859 | |
| 2860 | return CMD_SUCCESS; |
| 2861 | } |
| 2862 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2863 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2864 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 2865 | { |
| 2866 | vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
| 2867 | VTY_NEWLINE, |
| 2868 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 2869 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 2870 | VTY_NEWLINE); |
| 2871 | } |
| 2872 | |
| 2873 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2874 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2875 | { |
| 2876 | struct route_node *rn; |
| 2877 | struct ospf_neighbor *nbr; |
| 2878 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2879 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2880 | |
| 2881 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2882 | if ((nbr = rn->info)) |
| 2883 | /* Do not show myself. */ |
| 2884 | if (nbr != oi->nbr_self) |
| 2885 | /* Down state is not shown. */ |
| 2886 | if (nbr->state != NSM_Down) |
| 2887 | { |
| 2888 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2889 | |
| 2890 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2891 | vty_out (vty, "%-15s %3d %-15s ", |
| 2892 | "-", nbr->priority, |
| 2893 | msgbuf); |
| 2894 | else |
| 2895 | vty_out (vty, "%-15s %3d %-15s ", |
| 2896 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2897 | msgbuf); |
| 2898 | |
| 2899 | vty_out (vty, "%9s ", |
| 2900 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 2901 | sizeof(timebuf))); |
| 2902 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2903 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2904 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2905 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2906 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2907 | VTY_NEWLINE); |
| 2908 | } |
| 2909 | } |
| 2910 | |
| 2911 | DEFUN (show_ip_ospf_neighbor, |
| 2912 | show_ip_ospf_neighbor_cmd, |
| 2913 | "show ip ospf neighbor", |
| 2914 | SHOW_STR |
| 2915 | IP_STR |
| 2916 | "OSPF information\n" |
| 2917 | "Neighbor list\n") |
| 2918 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2919 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2920 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2921 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2922 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2923 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2924 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2925 | { |
| 2926 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2927 | return CMD_SUCCESS; |
| 2928 | } |
| 2929 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2930 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2931 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2932 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 2933 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2934 | |
| 2935 | return CMD_SUCCESS; |
| 2936 | } |
| 2937 | |
| 2938 | DEFUN (show_ip_ospf_neighbor_all, |
| 2939 | show_ip_ospf_neighbor_all_cmd, |
| 2940 | "show ip ospf neighbor all", |
| 2941 | SHOW_STR |
| 2942 | IP_STR |
| 2943 | "OSPF information\n" |
| 2944 | "Neighbor list\n" |
| 2945 | "include down status neighbor\n") |
| 2946 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2947 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2948 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2949 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2950 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2951 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2952 | { |
| 2953 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2954 | return CMD_SUCCESS; |
| 2955 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2956 | |
| 2957 | show_ip_ospf_neighbour_header (vty); |
| 2958 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2959 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2960 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2961 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2962 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2963 | |
| 2964 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2965 | |
| 2966 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2967 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2968 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2969 | if (nbr_nbma->nbr == NULL |
| 2970 | || nbr_nbma->nbr->state == NSM_Down) |
| 2971 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2972 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2973 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2974 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2975 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 2976 | 0, 0, 0, VTY_NEWLINE); |
| 2977 | } |
| 2978 | } |
| 2979 | } |
| 2980 | |
| 2981 | return CMD_SUCCESS; |
| 2982 | } |
| 2983 | |
| 2984 | DEFUN (show_ip_ospf_neighbor_int, |
| 2985 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2986 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2987 | SHOW_STR |
| 2988 | IP_STR |
| 2989 | "OSPF information\n" |
| 2990 | "Neighbor list\n" |
| 2991 | "Interface name\n") |
| 2992 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2993 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2994 | struct interface *ifp; |
| 2995 | struct route_node *rn; |
| 2996 | |
| 2997 | ifp = if_lookup_by_name (argv[0]); |
| 2998 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2999 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3000 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3001 | return CMD_WARNING; |
| 3002 | } |
| 3003 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3004 | ospf = ospf_lookup (); |
| 3005 | if (ospf == NULL) |
| 3006 | { |
| 3007 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3008 | return CMD_SUCCESS; |
| 3009 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3010 | |
| 3011 | show_ip_ospf_neighbour_header (vty); |
| 3012 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3013 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3014 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3015 | struct ospf_interface *oi = rn->info; |
| 3016 | |
| 3017 | if (oi == NULL) |
| 3018 | continue; |
| 3019 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3020 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3021 | } |
| 3022 | |
| 3023 | return CMD_SUCCESS; |
| 3024 | } |
| 3025 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3026 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3027 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3028 | struct ospf_nbr_nbma *nbr_nbma) |
| 3029 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3030 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3031 | |
| 3032 | /* Show neighbor ID. */ |
| 3033 | vty_out (vty, " Neighbor %s,", "-"); |
| 3034 | |
| 3035 | /* Show interface address. */ |
| 3036 | vty_out (vty, " interface address %s%s", |
| 3037 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3038 | /* Show Area ID. */ |
| 3039 | vty_out (vty, " In the area %s via interface %s%s", |
| 3040 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3041 | /* Show neighbor priority and state. */ |
| 3042 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3043 | nbr_nbma->priority, "Down"); |
| 3044 | /* Show state changes. */ |
| 3045 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3046 | |
| 3047 | /* Show PollInterval */ |
| 3048 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3049 | |
| 3050 | /* Show poll-interval timer. */ |
| 3051 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3052 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3053 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3054 | |
| 3055 | /* Show poll-interval timer thread. */ |
| 3056 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3057 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3058 | } |
| 3059 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3060 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3061 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3062 | struct ospf_neighbor *nbr) |
| 3063 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3064 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3065 | |
| 3066 | /* Show neighbor ID. */ |
| 3067 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3068 | vty_out (vty, " Neighbor %s,", "-"); |
| 3069 | else |
| 3070 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3071 | |
| 3072 | /* Show interface address. */ |
| 3073 | vty_out (vty, " interface address %s%s", |
| 3074 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3075 | /* Show Area ID. */ |
| 3076 | vty_out (vty, " In the area %s via interface %s%s", |
| 3077 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3078 | /* Show neighbor priority and state. */ |
| 3079 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3080 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3081 | /* Show state changes. */ |
| 3082 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 3083 | |
| 3084 | /* Show Designated Rotuer ID. */ |
| 3085 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3086 | /* Show Backup Designated Rotuer ID. */ |
| 3087 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3088 | /* Show options. */ |
| 3089 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3090 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3091 | /* Show Router Dead interval timer. */ |
| 3092 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3093 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3094 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3095 | /* Show Database Summary list. */ |
| 3096 | vty_out (vty, " Database Summary List %d%s", |
| 3097 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3098 | /* Show Link State Request list. */ |
| 3099 | vty_out (vty, " Link State Request List %ld%s", |
| 3100 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3101 | /* Show Link State Retransmission list. */ |
| 3102 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3103 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3104 | /* Show inactivity timer thread. */ |
| 3105 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3106 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3107 | /* Show Database Description retransmission thread. */ |
| 3108 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3109 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3110 | /* Show Link State Request Retransmission thread. */ |
| 3111 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3112 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3113 | /* Show Link State Update Retransmission thread. */ |
| 3114 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3115 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3116 | } |
| 3117 | |
| 3118 | DEFUN (show_ip_ospf_neighbor_id, |
| 3119 | show_ip_ospf_neighbor_id_cmd, |
| 3120 | "show ip ospf neighbor A.B.C.D", |
| 3121 | SHOW_STR |
| 3122 | IP_STR |
| 3123 | "OSPF information\n" |
| 3124 | "Neighbor list\n" |
| 3125 | "Neighbor ID\n") |
| 3126 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3127 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3128 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3129 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3130 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3131 | struct in_addr router_id; |
| 3132 | int ret; |
| 3133 | |
| 3134 | ret = inet_aton (argv[0], &router_id); |
| 3135 | if (!ret) |
| 3136 | { |
| 3137 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3138 | return CMD_WARNING; |
| 3139 | } |
| 3140 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3141 | ospf = ospf_lookup (); |
| 3142 | if (ospf == NULL) |
| 3143 | { |
| 3144 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3145 | return CMD_SUCCESS; |
| 3146 | } |
| 3147 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3148 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3149 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 3150 | { |
| 3151 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3152 | return CMD_SUCCESS; |
| 3153 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3154 | |
| 3155 | /* Nothing to show. */ |
| 3156 | return CMD_SUCCESS; |
| 3157 | } |
| 3158 | |
| 3159 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3160 | show_ip_ospf_neighbor_detail_cmd, |
| 3161 | "show ip ospf neighbor detail", |
| 3162 | SHOW_STR |
| 3163 | IP_STR |
| 3164 | "OSPF information\n" |
| 3165 | "Neighbor list\n" |
| 3166 | "detail of all neighbors\n") |
| 3167 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3168 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3169 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3170 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3171 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3172 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3173 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3174 | { |
| 3175 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3176 | return CMD_SUCCESS; |
| 3177 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3178 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3179 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3180 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3181 | struct route_node *rn; |
| 3182 | struct ospf_neighbor *nbr; |
| 3183 | |
| 3184 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3185 | if ((nbr = rn->info)) |
| 3186 | if (nbr != oi->nbr_self) |
| 3187 | if (nbr->state != NSM_Down) |
| 3188 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3189 | } |
| 3190 | |
| 3191 | return CMD_SUCCESS; |
| 3192 | } |
| 3193 | |
| 3194 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3195 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3196 | "show ip ospf neighbor detail all", |
| 3197 | SHOW_STR |
| 3198 | IP_STR |
| 3199 | "OSPF information\n" |
| 3200 | "Neighbor list\n" |
| 3201 | "detail of all neighbors\n" |
| 3202 | "include down status neighbor\n") |
| 3203 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3204 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3205 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3206 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3207 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3208 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3209 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3210 | { |
| 3211 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3212 | return CMD_SUCCESS; |
| 3213 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3214 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3215 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3216 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3217 | struct route_node *rn; |
| 3218 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3219 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3220 | |
| 3221 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3222 | if ((nbr = rn->info)) |
| 3223 | if (nbr != oi->nbr_self) |
| 3224 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3225 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3226 | |
| 3227 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3228 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3229 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3230 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3231 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3232 | if (nbr_nbma->nbr == NULL |
| 3233 | || nbr_nbma->nbr->state == NSM_Down) |
| 3234 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3235 | } |
| 3236 | } |
| 3237 | |
| 3238 | return CMD_SUCCESS; |
| 3239 | } |
| 3240 | |
| 3241 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3242 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3243 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3244 | SHOW_STR |
| 3245 | IP_STR |
| 3246 | "OSPF information\n" |
| 3247 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3248 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3249 | "detail of all neighbors") |
| 3250 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3251 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3252 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3253 | struct interface *ifp; |
| 3254 | struct route_node *rn, *nrn; |
| 3255 | struct ospf_neighbor *nbr; |
| 3256 | |
| 3257 | ifp = if_lookup_by_name (argv[0]); |
| 3258 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3259 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3260 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3261 | return CMD_WARNING; |
| 3262 | } |
| 3263 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3264 | ospf = ospf_lookup (); |
| 3265 | if (ospf == NULL) |
| 3266 | { |
| 3267 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3268 | return CMD_SUCCESS; |
| 3269 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3270 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3271 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3272 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3273 | if ((oi = rn->info)) |
| 3274 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3275 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3276 | if (nbr != oi->nbr_self) |
| 3277 | if (nbr->state != NSM_Down) |
| 3278 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3279 | |
| 3280 | return CMD_SUCCESS; |
| 3281 | } |
| 3282 | |
| 3283 | |
| 3284 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3285 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3286 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3287 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3288 | struct router_lsa *rl; |
| 3289 | struct summary_lsa *sl; |
| 3290 | struct as_external_lsa *asel; |
| 3291 | struct prefix_ipv4 p; |
| 3292 | |
| 3293 | if (lsa != NULL) |
| 3294 | /* If self option is set, check LSA self flag. */ |
| 3295 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3296 | { |
| 3297 | /* LSA common part show. */ |
| 3298 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3299 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3300 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3301 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3302 | /* LSA specific part show. */ |
| 3303 | switch (lsa->data->type) |
| 3304 | { |
| 3305 | case OSPF_ROUTER_LSA: |
| 3306 | rl = (struct router_lsa *) lsa->data; |
| 3307 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3308 | break; |
| 3309 | case OSPF_SUMMARY_LSA: |
| 3310 | sl = (struct summary_lsa *) lsa->data; |
| 3311 | |
| 3312 | p.family = AF_INET; |
| 3313 | p.prefix = sl->header.id; |
| 3314 | p.prefixlen = ip_masklen (sl->mask); |
| 3315 | apply_mask_ipv4 (&p); |
| 3316 | |
| 3317 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3318 | break; |
| 3319 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3320 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3321 | asel = (struct as_external_lsa *) lsa->data; |
| 3322 | |
| 3323 | p.family = AF_INET; |
| 3324 | p.prefix = asel->header.id; |
| 3325 | p.prefixlen = ip_masklen (asel->mask); |
| 3326 | apply_mask_ipv4 (&p); |
| 3327 | |
| 3328 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3329 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3330 | inet_ntoa (p.prefix), p.prefixlen, |
| 3331 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3332 | break; |
| 3333 | case OSPF_NETWORK_LSA: |
| 3334 | case OSPF_ASBR_SUMMARY_LSA: |
| 3335 | #ifdef HAVE_OPAQUE_LSA |
| 3336 | case OSPF_OPAQUE_LINK_LSA: |
| 3337 | case OSPF_OPAQUE_AREA_LSA: |
| 3338 | case OSPF_OPAQUE_AS_LSA: |
| 3339 | #endif /* HAVE_OPAQUE_LSA */ |
| 3340 | default: |
| 3341 | break; |
| 3342 | } |
| 3343 | vty_out (vty, VTY_NEWLINE); |
| 3344 | } |
| 3345 | |
| 3346 | return 0; |
| 3347 | } |
| 3348 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3349 | const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3350 | { |
| 3351 | "unknown", |
| 3352 | "Router Link States", |
| 3353 | "Net Link States", |
| 3354 | "Summary Link States", |
| 3355 | "ASBR-Summary Link States", |
| 3356 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3357 | "Group Membership LSA", |
| 3358 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3359 | #ifdef HAVE_OPAQUE_LSA |
| 3360 | "Type-8 LSA", |
| 3361 | "Link-Local Opaque-LSA", |
| 3362 | "Area-Local Opaque-LSA", |
| 3363 | "AS-external Opaque-LSA", |
| 3364 | #endif /* HAVE_OPAQUE_LSA */ |
| 3365 | }; |
| 3366 | |
| 3367 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3368 | "Link ID ADV Router Age Seq# CkSum" |
| 3369 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3370 | const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3371 | { |
| 3372 | "", |
| 3373 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3374 | "Link ID ADV Router Age Seq# CkSum", |
| 3375 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3376 | "Link ID ADV Router Age Seq# CkSum", |
| 3377 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3378 | " --- header for Group Member ----", |
| 3379 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3380 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3381 | " --- type-8 ---", |
| 3382 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3383 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3384 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3385 | #endif /* HAVE_OPAQUE_LSA */ |
| 3386 | }; |
| 3387 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3388 | const char *show_lsa_flags[] = |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3389 | { |
| 3390 | "Self-originated", |
| 3391 | "Checked", |
| 3392 | "Received", |
| 3393 | "Approved", |
| 3394 | "Discard", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3395 | "Translated", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3396 | }; |
| 3397 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3398 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3399 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3400 | { |
| 3401 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3402 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3403 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3404 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3405 | lsa->data->options, |
| 3406 | ospf_options_dump(lsa->data->options), |
| 3407 | VTY_NEWLINE); |
| 3408 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3409 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3410 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3411 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3412 | |
| 3413 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3414 | { |
| 3415 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3416 | |
| 3417 | if (rlsa->flags) |
| 3418 | vty_out (vty, " :%s%s%s%s", |
| 3419 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3420 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3421 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3422 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3423 | |
| 3424 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3425 | } |
| 3426 | vty_out (vty, " LS Type: %s%s", |
| 3427 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3428 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3429 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3430 | vty_out (vty, " Advertising Router: %s%s", |
| 3431 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3432 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3433 | VTY_NEWLINE); |
| 3434 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3435 | VTY_NEWLINE); |
| 3436 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3437 | } |
| 3438 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3439 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3440 | { |
| 3441 | "(null)", |
| 3442 | "another Router (point-to-point)", |
| 3443 | "a Transit Network", |
| 3444 | "Stub Network", |
| 3445 | "a Virtual Link", |
| 3446 | }; |
| 3447 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3448 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3449 | { |
| 3450 | "(null)", |
| 3451 | "Neighboring Router ID", |
| 3452 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3453 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3454 | "Neighboring Router ID", |
| 3455 | }; |
| 3456 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3457 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3458 | { |
| 3459 | "(null)", |
| 3460 | "Router Interface address", |
| 3461 | "Router Interface address", |
| 3462 | "Network Mask", |
| 3463 | "Router Interface address", |
| 3464 | }; |
| 3465 | |
| 3466 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3467 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3468 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3469 | struct router_lsa *rl) |
| 3470 | { |
| 3471 | int len, i, type; |
| 3472 | |
| 3473 | len = ntohs (rl->header.length) - 4; |
| 3474 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3475 | { |
| 3476 | type = rl->link[i].type; |
| 3477 | |
| 3478 | vty_out (vty, " Link connected to: %s%s", |
| 3479 | link_type_desc[type], VTY_NEWLINE); |
| 3480 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3481 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3482 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3483 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3484 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3485 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3486 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3487 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3488 | } |
| 3489 | } |
| 3490 | |
| 3491 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3492 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3493 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3494 | { |
| 3495 | if (lsa != NULL) |
| 3496 | { |
| 3497 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3498 | |
| 3499 | show_ip_ospf_database_header (vty, lsa); |
| 3500 | |
| 3501 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3502 | VTY_NEWLINE, VTY_NEWLINE); |
| 3503 | |
| 3504 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3505 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3506 | } |
| 3507 | |
| 3508 | return 0; |
| 3509 | } |
| 3510 | |
| 3511 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3512 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3513 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3514 | { |
| 3515 | int length, i; |
| 3516 | |
| 3517 | if (lsa != NULL) |
| 3518 | { |
| 3519 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3520 | |
| 3521 | show_ip_ospf_database_header (vty, lsa); |
| 3522 | |
| 3523 | vty_out (vty, " Network Mask: /%d%s", |
| 3524 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3525 | |
| 3526 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3527 | |
| 3528 | for (i = 0; length > 0; i++, length -= 4) |
| 3529 | vty_out (vty, " Attached Router: %s%s", |
| 3530 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3531 | |
| 3532 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3533 | } |
| 3534 | |
| 3535 | return 0; |
| 3536 | } |
| 3537 | |
| 3538 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3539 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3540 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3541 | { |
| 3542 | if (lsa != NULL) |
| 3543 | { |
| 3544 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3545 | |
| 3546 | show_ip_ospf_database_header (vty, lsa); |
| 3547 | |
| 3548 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3549 | VTY_NEWLINE); |
| 3550 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3551 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3552 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3553 | } |
| 3554 | |
| 3555 | return 0; |
| 3556 | } |
| 3557 | |
| 3558 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3559 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3560 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3561 | { |
| 3562 | if (lsa != NULL) |
| 3563 | { |
| 3564 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3565 | |
| 3566 | show_ip_ospf_database_header (vty, lsa); |
| 3567 | |
| 3568 | vty_out (vty, " Network Mask: /%d%s", |
| 3569 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3570 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3571 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3572 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3573 | } |
| 3574 | |
| 3575 | return 0; |
| 3576 | } |
| 3577 | |
| 3578 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3579 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3580 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3581 | { |
| 3582 | if (lsa != NULL) |
| 3583 | { |
| 3584 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3585 | |
| 3586 | show_ip_ospf_database_header (vty, lsa); |
| 3587 | |
| 3588 | vty_out (vty, " Network Mask: /%d%s", |
| 3589 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3590 | vty_out (vty, " Metric Type: %s%s", |
| 3591 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3592 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3593 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3594 | vty_out (vty, " Metric: %d%s", |
| 3595 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3596 | vty_out (vty, " Forward Address: %s%s", |
| 3597 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3598 | |
| 3599 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3600 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3601 | } |
| 3602 | |
| 3603 | return 0; |
| 3604 | } |
| 3605 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3606 | /* N.B. This function currently seems to be unused. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3607 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3608 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3609 | { |
| 3610 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3611 | |
| 3612 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3613 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3614 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3615 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3616 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3617 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3618 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3619 | zlog_debug( " TOS: 0%s", "\n"); |
| 3620 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3621 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3622 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3623 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3624 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3625 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3626 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3627 | |
| 3628 | return 0; |
| 3629 | } |
| 3630 | |
| 3631 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3632 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3633 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3634 | { |
| 3635 | if (lsa != NULL) |
| 3636 | { |
| 3637 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3638 | |
| 3639 | show_ip_ospf_database_header (vty, lsa); |
| 3640 | |
| 3641 | vty_out (vty, " Network Mask: /%d%s", |
| 3642 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3643 | vty_out (vty, " Metric Type: %s%s", |
| 3644 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3645 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3646 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3647 | vty_out (vty, " Metric: %d%s", |
| 3648 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3649 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3650 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3651 | |
| 3652 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3653 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3654 | } |
| 3655 | |
| 3656 | return 0; |
| 3657 | } |
| 3658 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3659 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3660 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3661 | { |
| 3662 | return 0; |
| 3663 | } |
| 3664 | |
| 3665 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3666 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3667 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3668 | { |
| 3669 | if (lsa != NULL) |
| 3670 | { |
| 3671 | show_ip_ospf_database_header (vty, lsa); |
| 3672 | show_opaque_info_detail (vty, lsa); |
| 3673 | |
| 3674 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3675 | } |
| 3676 | return 0; |
| 3677 | } |
| 3678 | #endif /* HAVE_OPAQUE_LSA */ |
| 3679 | |
| 3680 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3681 | { |
| 3682 | NULL, |
| 3683 | show_router_lsa_detail, |
| 3684 | show_network_lsa_detail, |
| 3685 | show_summary_lsa_detail, |
| 3686 | show_summary_asbr_lsa_detail, |
| 3687 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3688 | show_func_dummy, |
| 3689 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3690 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3691 | NULL, /* type-8 */ |
| 3692 | show_opaque_lsa_detail, |
| 3693 | show_opaque_lsa_detail, |
| 3694 | show_opaque_lsa_detail, |
| 3695 | #endif /* HAVE_OPAQUE_LSA */ |
| 3696 | }; |
| 3697 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3698 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3699 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3700 | struct in_addr *adv_router) |
| 3701 | { |
| 3702 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3703 | lp->family = 0; |
| 3704 | if (id == NULL) |
| 3705 | lp->prefixlen = 0; |
| 3706 | else if (adv_router == NULL) |
| 3707 | { |
| 3708 | lp->prefixlen = 32; |
| 3709 | lp->id = *id; |
| 3710 | } |
| 3711 | else |
| 3712 | { |
| 3713 | lp->prefixlen = 64; |
| 3714 | lp->id = *id; |
| 3715 | lp->adv_router = *adv_router; |
| 3716 | } |
| 3717 | } |
| 3718 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3719 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3720 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3721 | struct in_addr *id, struct in_addr *adv_router) |
| 3722 | { |
| 3723 | struct prefix_ls lp; |
| 3724 | struct route_node *rn, *start; |
| 3725 | struct ospf_lsa *lsa; |
| 3726 | |
| 3727 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3728 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3729 | if (start) |
| 3730 | { |
| 3731 | route_lock_node (start); |
| 3732 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3733 | if ((lsa = rn->info)) |
| 3734 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3735 | if (show_function[lsa->data->type] != NULL) |
| 3736 | show_function[lsa->data->type] (vty, lsa); |
| 3737 | } |
| 3738 | route_unlock_node (start); |
| 3739 | } |
| 3740 | } |
| 3741 | |
| 3742 | /* Show detail LSA information |
| 3743 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3744 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3745 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3746 | struct in_addr *id, struct in_addr *adv_router) |
| 3747 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3748 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3749 | struct ospf_area *area; |
| 3750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3751 | switch (type) |
| 3752 | { |
| 3753 | case OSPF_AS_EXTERNAL_LSA: |
| 3754 | #ifdef HAVE_OPAQUE_LSA |
| 3755 | case OSPF_OPAQUE_AS_LSA: |
| 3756 | #endif /* HAVE_OPAQUE_LSA */ |
| 3757 | vty_out (vty, " %s %s%s", |
| 3758 | show_database_desc[type], |
| 3759 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3760 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3761 | break; |
| 3762 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3763 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3764 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3765 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3766 | VTY_NEWLINE, show_database_desc[type], |
| 3767 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3768 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3769 | } |
| 3770 | break; |
| 3771 | } |
| 3772 | } |
| 3773 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3774 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3775 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3776 | struct in_addr *adv_router) |
| 3777 | { |
| 3778 | struct route_node *rn; |
| 3779 | struct ospf_lsa *lsa; |
| 3780 | |
| 3781 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3782 | if ((lsa = rn->info)) |
| 3783 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3784 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3785 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3786 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3787 | if (show_function[lsa->data->type] != NULL) |
| 3788 | show_function[lsa->data->type] (vty, lsa); |
| 3789 | } |
| 3790 | } |
| 3791 | |
| 3792 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3793 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3794 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3795 | struct in_addr *adv_router) |
| 3796 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3797 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3798 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3799 | |
| 3800 | switch (type) |
| 3801 | { |
| 3802 | case OSPF_AS_EXTERNAL_LSA: |
| 3803 | #ifdef HAVE_OPAQUE_LSA |
| 3804 | case OSPF_OPAQUE_AS_LSA: |
| 3805 | #endif /* HAVE_OPAQUE_LSA */ |
| 3806 | vty_out (vty, " %s %s%s", |
| 3807 | show_database_desc[type], |
| 3808 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3809 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3810 | adv_router); |
| 3811 | break; |
| 3812 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3813 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3814 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3815 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3816 | VTY_NEWLINE, show_database_desc[type], |
| 3817 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3818 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3819 | adv_router); |
| 3820 | } |
| 3821 | break; |
| 3822 | } |
| 3823 | } |
| 3824 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3825 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3826 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3827 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3828 | struct ospf_lsa *lsa; |
| 3829 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3830 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3831 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3832 | int type; |
| 3833 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3834 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3835 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3836 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3837 | { |
| 3838 | switch (type) |
| 3839 | { |
| 3840 | case OSPF_AS_EXTERNAL_LSA: |
| 3841 | #ifdef HAVE_OPAQUE_LSA |
| 3842 | case OSPF_OPAQUE_AS_LSA: |
| 3843 | #endif /* HAVE_OPAQUE_LSA */ |
| 3844 | continue; |
| 3845 | default: |
| 3846 | break; |
| 3847 | } |
| 3848 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3849 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3850 | { |
| 3851 | vty_out (vty, " %s (Area %s)%s%s", |
| 3852 | show_database_desc[type], |
| 3853 | ospf_area_desc_string (area), |
| 3854 | VTY_NEWLINE, VTY_NEWLINE); |
| 3855 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3856 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3857 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3858 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3859 | |
| 3860 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3861 | } |
| 3862 | } |
| 3863 | } |
| 3864 | |
| 3865 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3866 | { |
| 3867 | switch (type) |
| 3868 | { |
| 3869 | case OSPF_AS_EXTERNAL_LSA: |
| 3870 | #ifdef HAVE_OPAQUE_LSA |
| 3871 | case OSPF_OPAQUE_AS_LSA: |
| 3872 | #endif /* HAVE_OPAQUE_LSA */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame^] | 3873 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3874 | default: |
| 3875 | continue; |
| 3876 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3877 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3878 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3879 | { |
| 3880 | vty_out (vty, " %s%s%s", |
| 3881 | show_database_desc[type], |
| 3882 | VTY_NEWLINE, VTY_NEWLINE); |
| 3883 | vty_out (vty, "%s%s", show_database_header[type], |
| 3884 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3885 | |
| 3886 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3887 | show_lsa_summary (vty, lsa, self); |
| 3888 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3889 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3890 | } |
| 3891 | } |
| 3892 | |
| 3893 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3894 | } |
| 3895 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3896 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3897 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3898 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3899 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3900 | struct ospf_lsa *lsa; |
| 3901 | |
| 3902 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3903 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3904 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3905 | for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa)) |
| 3906 | { |
| 3907 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3908 | vty_out (vty, "Link State ID: %s%s", |
| 3909 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3910 | vty_out (vty, "Advertising Router: %s%s", |
| 3911 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3912 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3913 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3914 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3915 | } |
| 3916 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3917 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3918 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3919 | |
| 3920 | #ifdef HAVE_OPAQUE_LSA |
| 3921 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3922 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3923 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3924 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3925 | #else /* HAVE_OPAQUE_LSA */ |
| 3926 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3927 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3928 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3929 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3930 | #endif /* HAVE_OPAQUE_LSA */ |
| 3931 | |
| 3932 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3933 | "asbr-summary|external|network|router|summary" \ |
| 3934 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3935 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3936 | |
| 3937 | #define OSPF_LSA_TYPES_DESC \ |
| 3938 | "ASBR summary link states\n" \ |
| 3939 | "External link states\n" \ |
| 3940 | "Network link states\n" \ |
| 3941 | "Router link states\n" \ |
| 3942 | "Network summary link states\n" \ |
| 3943 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3944 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3945 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3946 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3947 | |
| 3948 | DEFUN (show_ip_ospf_database, |
| 3949 | show_ip_ospf_database_cmd, |
| 3950 | "show ip ospf database", |
| 3951 | SHOW_STR |
| 3952 | IP_STR |
| 3953 | "OSPF information\n" |
| 3954 | "Database summary\n") |
| 3955 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3956 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3957 | int type, ret; |
| 3958 | struct in_addr id, adv_router; |
| 3959 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3960 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3961 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3962 | return CMD_SUCCESS; |
| 3963 | |
| 3964 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3965 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3966 | |
| 3967 | /* Show all LSA. */ |
| 3968 | if (argc == 0) |
| 3969 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3970 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3971 | return CMD_SUCCESS; |
| 3972 | } |
| 3973 | |
| 3974 | /* Set database type to show. */ |
| 3975 | if (strncmp (argv[0], "r", 1) == 0) |
| 3976 | type = OSPF_ROUTER_LSA; |
| 3977 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3978 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3979 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3980 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3981 | else if (strncmp (argv[0], "su", 2) == 0) |
| 3982 | type = OSPF_SUMMARY_LSA; |
| 3983 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3984 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3985 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3986 | type = OSPF_AS_EXTERNAL_LSA; |
| 3987 | else if (strncmp (argv[0], "se", 2) == 0) |
| 3988 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3989 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3990 | return CMD_SUCCESS; |
| 3991 | } |
| 3992 | else if (strncmp (argv[0], "m", 1) == 0) |
| 3993 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3994 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3995 | return CMD_SUCCESS; |
| 3996 | } |
| 3997 | #ifdef HAVE_OPAQUE_LSA |
| 3998 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3999 | type = OSPF_OPAQUE_LINK_LSA; |
| 4000 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4001 | type = OSPF_OPAQUE_AREA_LSA; |
| 4002 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4003 | type = OSPF_OPAQUE_AS_LSA; |
| 4004 | #endif /* HAVE_OPAQUE_LSA */ |
| 4005 | else |
| 4006 | return CMD_WARNING; |
| 4007 | |
| 4008 | /* `show ip ospf database LSA'. */ |
| 4009 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4010 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4011 | else if (argc >= 2) |
| 4012 | { |
| 4013 | ret = inet_aton (argv[1], &id); |
| 4014 | if (!ret) |
| 4015 | return CMD_WARNING; |
| 4016 | |
| 4017 | /* `show ip ospf database LSA ID'. */ |
| 4018 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4019 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4020 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4021 | else if (argc == 3) |
| 4022 | { |
| 4023 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4024 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4025 | else |
| 4026 | { |
| 4027 | ret = inet_aton (argv[2], &adv_router); |
| 4028 | if (!ret) |
| 4029 | return CMD_WARNING; |
| 4030 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4031 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4032 | } |
| 4033 | } |
| 4034 | |
| 4035 | return CMD_SUCCESS; |
| 4036 | } |
| 4037 | |
| 4038 | ALIAS (show_ip_ospf_database, |
| 4039 | show_ip_ospf_database_type_cmd, |
| 4040 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4041 | SHOW_STR |
| 4042 | IP_STR |
| 4043 | "OSPF information\n" |
| 4044 | "Database summary\n" |
| 4045 | OSPF_LSA_TYPES_DESC |
| 4046 | "LSAs in MaxAge list\n" |
| 4047 | "Self-originated link states\n") |
| 4048 | |
| 4049 | ALIAS (show_ip_ospf_database, |
| 4050 | show_ip_ospf_database_type_id_cmd, |
| 4051 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4052 | SHOW_STR |
| 4053 | IP_STR |
| 4054 | "OSPF information\n" |
| 4055 | "Database summary\n" |
| 4056 | OSPF_LSA_TYPES_DESC |
| 4057 | "Link State ID (as an IP address)\n") |
| 4058 | |
| 4059 | ALIAS (show_ip_ospf_database, |
| 4060 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4061 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4062 | SHOW_STR |
| 4063 | IP_STR |
| 4064 | "OSPF information\n" |
| 4065 | "Database summary\n" |
| 4066 | OSPF_LSA_TYPES_DESC |
| 4067 | "Link State ID (as an IP address)\n" |
| 4068 | "Advertising Router link states\n" |
| 4069 | "Advertising Router (as an IP address)\n") |
| 4070 | |
| 4071 | ALIAS (show_ip_ospf_database, |
| 4072 | show_ip_ospf_database_type_id_self_cmd, |
| 4073 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4074 | SHOW_STR |
| 4075 | IP_STR |
| 4076 | "OSPF information\n" |
| 4077 | "Database summary\n" |
| 4078 | OSPF_LSA_TYPES_DESC |
| 4079 | "Link State ID (as an IP address)\n" |
| 4080 | "Self-originated link states\n" |
| 4081 | "\n") |
| 4082 | |
| 4083 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4084 | show_ip_ospf_database_type_adv_router_cmd, |
| 4085 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4086 | SHOW_STR |
| 4087 | IP_STR |
| 4088 | "OSPF information\n" |
| 4089 | "Database summary\n" |
| 4090 | OSPF_LSA_TYPES_DESC |
| 4091 | "Advertising Router link states\n" |
| 4092 | "Advertising Router (as an IP address)\n") |
| 4093 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4094 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4095 | int type, ret; |
| 4096 | struct in_addr adv_router; |
| 4097 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4098 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4099 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4100 | return CMD_SUCCESS; |
| 4101 | |
| 4102 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4103 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4104 | |
| 4105 | if (argc != 2) |
| 4106 | return CMD_WARNING; |
| 4107 | |
| 4108 | /* Set database type to show. */ |
| 4109 | if (strncmp (argv[0], "r", 1) == 0) |
| 4110 | type = OSPF_ROUTER_LSA; |
| 4111 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4112 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4113 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4114 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4115 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4116 | type = OSPF_SUMMARY_LSA; |
| 4117 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4118 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4119 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4120 | type = OSPF_AS_EXTERNAL_LSA; |
| 4121 | #ifdef HAVE_OPAQUE_LSA |
| 4122 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4123 | type = OSPF_OPAQUE_LINK_LSA; |
| 4124 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4125 | type = OSPF_OPAQUE_AREA_LSA; |
| 4126 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4127 | type = OSPF_OPAQUE_AS_LSA; |
| 4128 | #endif /* HAVE_OPAQUE_LSA */ |
| 4129 | else |
| 4130 | return CMD_WARNING; |
| 4131 | |
| 4132 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4133 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4134 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4135 | else |
| 4136 | { |
| 4137 | ret = inet_aton (argv[1], &adv_router); |
| 4138 | if (!ret) |
| 4139 | return CMD_WARNING; |
| 4140 | } |
| 4141 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4142 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4143 | |
| 4144 | return CMD_SUCCESS; |
| 4145 | } |
| 4146 | |
| 4147 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4148 | show_ip_ospf_database_type_self_cmd, |
| 4149 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4150 | SHOW_STR |
| 4151 | IP_STR |
| 4152 | "OSPF information\n" |
| 4153 | "Database summary\n" |
| 4154 | OSPF_LSA_TYPES_DESC |
| 4155 | "Self-originated link states\n") |
| 4156 | |
| 4157 | |
| 4158 | DEFUN (ip_ospf_authentication_args, |
| 4159 | ip_ospf_authentication_args_addr_cmd, |
| 4160 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4161 | "IP Information\n" |
| 4162 | "OSPF interface commands\n" |
| 4163 | "Enable authentication on this interface\n" |
| 4164 | "Use null authentication\n" |
| 4165 | "Use message-digest authentication\n" |
| 4166 | "Address of interface") |
| 4167 | { |
| 4168 | struct interface *ifp; |
| 4169 | struct in_addr addr; |
| 4170 | int ret; |
| 4171 | struct ospf_if_params *params; |
| 4172 | |
| 4173 | ifp = vty->index; |
| 4174 | params = IF_DEF_PARAMS (ifp); |
| 4175 | |
| 4176 | if (argc == 2) |
| 4177 | { |
| 4178 | ret = inet_aton(argv[1], &addr); |
| 4179 | if (!ret) |
| 4180 | { |
| 4181 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4182 | VTY_NEWLINE); |
| 4183 | return CMD_WARNING; |
| 4184 | } |
| 4185 | |
| 4186 | params = ospf_get_if_params (ifp, addr); |
| 4187 | ospf_if_update_params (ifp, addr); |
| 4188 | } |
| 4189 | |
| 4190 | /* Handle null authentication */ |
| 4191 | if ( argv[0][0] == 'n' ) |
| 4192 | { |
| 4193 | SET_IF_PARAM (params, auth_type); |
| 4194 | params->auth_type = OSPF_AUTH_NULL; |
| 4195 | return CMD_SUCCESS; |
| 4196 | } |
| 4197 | |
| 4198 | /* Handle message-digest authentication */ |
| 4199 | if ( argv[0][0] == 'm' ) |
| 4200 | { |
| 4201 | SET_IF_PARAM (params, auth_type); |
| 4202 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4203 | return CMD_SUCCESS; |
| 4204 | } |
| 4205 | |
| 4206 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4207 | return CMD_WARNING; |
| 4208 | } |
| 4209 | |
| 4210 | ALIAS (ip_ospf_authentication_args, |
| 4211 | ip_ospf_authentication_args_cmd, |
| 4212 | "ip ospf authentication (null|message-digest)", |
| 4213 | "IP Information\n" |
| 4214 | "OSPF interface commands\n" |
| 4215 | "Enable authentication on this interface\n" |
| 4216 | "Use null authentication\n" |
| 4217 | "Use message-digest authentication\n") |
| 4218 | |
| 4219 | DEFUN (ip_ospf_authentication, |
| 4220 | ip_ospf_authentication_addr_cmd, |
| 4221 | "ip ospf authentication A.B.C.D", |
| 4222 | "IP Information\n" |
| 4223 | "OSPF interface commands\n" |
| 4224 | "Enable authentication on this interface\n" |
| 4225 | "Address of interface") |
| 4226 | { |
| 4227 | struct interface *ifp; |
| 4228 | struct in_addr addr; |
| 4229 | int ret; |
| 4230 | struct ospf_if_params *params; |
| 4231 | |
| 4232 | ifp = vty->index; |
| 4233 | params = IF_DEF_PARAMS (ifp); |
| 4234 | |
| 4235 | if (argc == 1) |
| 4236 | { |
| 4237 | ret = inet_aton(argv[1], &addr); |
| 4238 | if (!ret) |
| 4239 | { |
| 4240 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4241 | VTY_NEWLINE); |
| 4242 | return CMD_WARNING; |
| 4243 | } |
| 4244 | |
| 4245 | params = ospf_get_if_params (ifp, addr); |
| 4246 | ospf_if_update_params (ifp, addr); |
| 4247 | } |
| 4248 | |
| 4249 | SET_IF_PARAM (params, auth_type); |
| 4250 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4251 | |
| 4252 | return CMD_SUCCESS; |
| 4253 | } |
| 4254 | |
| 4255 | ALIAS (ip_ospf_authentication, |
| 4256 | ip_ospf_authentication_cmd, |
| 4257 | "ip ospf authentication", |
| 4258 | "IP Information\n" |
| 4259 | "OSPF interface commands\n" |
| 4260 | "Enable authentication on this interface\n") |
| 4261 | |
| 4262 | DEFUN (no_ip_ospf_authentication, |
| 4263 | no_ip_ospf_authentication_addr_cmd, |
| 4264 | "no ip ospf authentication A.B.C.D", |
| 4265 | NO_STR |
| 4266 | "IP Information\n" |
| 4267 | "OSPF interface commands\n" |
| 4268 | "Enable authentication on this interface\n" |
| 4269 | "Address of interface") |
| 4270 | { |
| 4271 | struct interface *ifp; |
| 4272 | struct in_addr addr; |
| 4273 | int ret; |
| 4274 | struct ospf_if_params *params; |
| 4275 | |
| 4276 | ifp = vty->index; |
| 4277 | params = IF_DEF_PARAMS (ifp); |
| 4278 | |
| 4279 | if (argc == 1) |
| 4280 | { |
| 4281 | ret = inet_aton(argv[1], &addr); |
| 4282 | if (!ret) |
| 4283 | { |
| 4284 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4285 | VTY_NEWLINE); |
| 4286 | return CMD_WARNING; |
| 4287 | } |
| 4288 | |
| 4289 | params = ospf_lookup_if_params (ifp, addr); |
| 4290 | if (params == NULL) |
| 4291 | return CMD_SUCCESS; |
| 4292 | } |
| 4293 | |
| 4294 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4295 | UNSET_IF_PARAM (params, auth_type); |
| 4296 | |
| 4297 | if (params != IF_DEF_PARAMS (ifp)) |
| 4298 | { |
| 4299 | ospf_free_if_params (ifp, addr); |
| 4300 | ospf_if_update_params (ifp, addr); |
| 4301 | } |
| 4302 | |
| 4303 | return CMD_SUCCESS; |
| 4304 | } |
| 4305 | |
| 4306 | ALIAS (no_ip_ospf_authentication, |
| 4307 | no_ip_ospf_authentication_cmd, |
| 4308 | "no ip ospf authentication", |
| 4309 | NO_STR |
| 4310 | "IP Information\n" |
| 4311 | "OSPF interface commands\n" |
| 4312 | "Enable authentication on this interface\n") |
| 4313 | |
| 4314 | DEFUN (ip_ospf_authentication_key, |
| 4315 | ip_ospf_authentication_key_addr_cmd, |
| 4316 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4317 | "IP Information\n" |
| 4318 | "OSPF interface commands\n" |
| 4319 | "Authentication password (key)\n" |
| 4320 | "The OSPF password (key)\n" |
| 4321 | "Address of interface") |
| 4322 | { |
| 4323 | struct interface *ifp; |
| 4324 | struct in_addr addr; |
| 4325 | int ret; |
| 4326 | struct ospf_if_params *params; |
| 4327 | |
| 4328 | ifp = vty->index; |
| 4329 | params = IF_DEF_PARAMS (ifp); |
| 4330 | |
| 4331 | if (argc == 2) |
| 4332 | { |
| 4333 | ret = inet_aton(argv[1], &addr); |
| 4334 | if (!ret) |
| 4335 | { |
| 4336 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4337 | VTY_NEWLINE); |
| 4338 | return CMD_WARNING; |
| 4339 | } |
| 4340 | |
| 4341 | params = ospf_get_if_params (ifp, addr); |
| 4342 | ospf_if_update_params (ifp, addr); |
| 4343 | } |
| 4344 | |
| 4345 | |
| 4346 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4347 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4348 | SET_IF_PARAM (params, auth_simple); |
| 4349 | |
| 4350 | return CMD_SUCCESS; |
| 4351 | } |
| 4352 | |
| 4353 | ALIAS (ip_ospf_authentication_key, |
| 4354 | ip_ospf_authentication_key_cmd, |
| 4355 | "ip ospf authentication-key AUTH_KEY", |
| 4356 | "IP Information\n" |
| 4357 | "OSPF interface commands\n" |
| 4358 | "Authentication password (key)\n" |
| 4359 | "The OSPF password (key)") |
| 4360 | |
| 4361 | ALIAS (ip_ospf_authentication_key, |
| 4362 | ospf_authentication_key_cmd, |
| 4363 | "ospf authentication-key AUTH_KEY", |
| 4364 | "OSPF interface commands\n" |
| 4365 | "Authentication password (key)\n" |
| 4366 | "The OSPF password (key)") |
| 4367 | |
| 4368 | DEFUN (no_ip_ospf_authentication_key, |
| 4369 | no_ip_ospf_authentication_key_addr_cmd, |
| 4370 | "no ip ospf authentication-key A.B.C.D", |
| 4371 | NO_STR |
| 4372 | "IP Information\n" |
| 4373 | "OSPF interface commands\n" |
| 4374 | "Authentication password (key)\n" |
| 4375 | "Address of interface") |
| 4376 | { |
| 4377 | struct interface *ifp; |
| 4378 | struct in_addr addr; |
| 4379 | int ret; |
| 4380 | struct ospf_if_params *params; |
| 4381 | |
| 4382 | ifp = vty->index; |
| 4383 | params = IF_DEF_PARAMS (ifp); |
| 4384 | |
| 4385 | if (argc == 2) |
| 4386 | { |
| 4387 | ret = inet_aton(argv[1], &addr); |
| 4388 | if (!ret) |
| 4389 | { |
| 4390 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4391 | VTY_NEWLINE); |
| 4392 | return CMD_WARNING; |
| 4393 | } |
| 4394 | |
| 4395 | params = ospf_lookup_if_params (ifp, addr); |
| 4396 | if (params == NULL) |
| 4397 | return CMD_SUCCESS; |
| 4398 | } |
| 4399 | |
| 4400 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4401 | UNSET_IF_PARAM (params, auth_simple); |
| 4402 | |
| 4403 | if (params != IF_DEF_PARAMS (ifp)) |
| 4404 | { |
| 4405 | ospf_free_if_params (ifp, addr); |
| 4406 | ospf_if_update_params (ifp, addr); |
| 4407 | } |
| 4408 | |
| 4409 | return CMD_SUCCESS; |
| 4410 | } |
| 4411 | |
| 4412 | ALIAS (no_ip_ospf_authentication_key, |
| 4413 | no_ip_ospf_authentication_key_cmd, |
| 4414 | "no ip ospf authentication-key", |
| 4415 | NO_STR |
| 4416 | "IP Information\n" |
| 4417 | "OSPF interface commands\n" |
| 4418 | "Authentication password (key)\n") |
| 4419 | |
| 4420 | ALIAS (no_ip_ospf_authentication_key, |
| 4421 | no_ospf_authentication_key_cmd, |
| 4422 | "no ospf authentication-key", |
| 4423 | NO_STR |
| 4424 | "OSPF interface commands\n" |
| 4425 | "Authentication password (key)\n") |
| 4426 | |
| 4427 | DEFUN (ip_ospf_message_digest_key, |
| 4428 | ip_ospf_message_digest_key_addr_cmd, |
| 4429 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4430 | "IP Information\n" |
| 4431 | "OSPF interface commands\n" |
| 4432 | "Message digest authentication password (key)\n" |
| 4433 | "Key ID\n" |
| 4434 | "Use MD5 algorithm\n" |
| 4435 | "The OSPF password (key)" |
| 4436 | "Address of interface") |
| 4437 | { |
| 4438 | struct interface *ifp; |
| 4439 | struct crypt_key *ck; |
| 4440 | u_char key_id; |
| 4441 | struct in_addr addr; |
| 4442 | int ret; |
| 4443 | struct ospf_if_params *params; |
| 4444 | |
| 4445 | ifp = vty->index; |
| 4446 | params = IF_DEF_PARAMS (ifp); |
| 4447 | |
| 4448 | if (argc == 3) |
| 4449 | { |
| 4450 | ret = inet_aton(argv[2], &addr); |
| 4451 | if (!ret) |
| 4452 | { |
| 4453 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4454 | VTY_NEWLINE); |
| 4455 | return CMD_WARNING; |
| 4456 | } |
| 4457 | |
| 4458 | params = ospf_get_if_params (ifp, addr); |
| 4459 | ospf_if_update_params (ifp, addr); |
| 4460 | } |
| 4461 | |
| 4462 | key_id = strtol (argv[0], NULL, 10); |
| 4463 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4464 | { |
| 4465 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4466 | return CMD_WARNING; |
| 4467 | } |
| 4468 | |
| 4469 | ck = ospf_crypt_key_new (); |
| 4470 | ck->key_id = (u_char) key_id; |
| 4471 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4472 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4473 | |
| 4474 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4475 | SET_IF_PARAM (params, auth_crypt); |
| 4476 | |
| 4477 | return CMD_SUCCESS; |
| 4478 | } |
| 4479 | |
| 4480 | ALIAS (ip_ospf_message_digest_key, |
| 4481 | ip_ospf_message_digest_key_cmd, |
| 4482 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4483 | "IP Information\n" |
| 4484 | "OSPF interface commands\n" |
| 4485 | "Message digest authentication password (key)\n" |
| 4486 | "Key ID\n" |
| 4487 | "Use MD5 algorithm\n" |
| 4488 | "The OSPF password (key)") |
| 4489 | |
| 4490 | ALIAS (ip_ospf_message_digest_key, |
| 4491 | ospf_message_digest_key_cmd, |
| 4492 | "ospf message-digest-key <1-255> md5 KEY", |
| 4493 | "OSPF interface commands\n" |
| 4494 | "Message digest authentication password (key)\n" |
| 4495 | "Key ID\n" |
| 4496 | "Use MD5 algorithm\n" |
| 4497 | "The OSPF password (key)") |
| 4498 | |
| 4499 | DEFUN (no_ip_ospf_message_digest_key, |
| 4500 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4501 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4502 | NO_STR |
| 4503 | "IP Information\n" |
| 4504 | "OSPF interface commands\n" |
| 4505 | "Message digest authentication password (key)\n" |
| 4506 | "Key ID\n" |
| 4507 | "Address of interface") |
| 4508 | { |
| 4509 | struct interface *ifp; |
| 4510 | struct crypt_key *ck; |
| 4511 | int key_id; |
| 4512 | struct in_addr addr; |
| 4513 | int ret; |
| 4514 | struct ospf_if_params *params; |
| 4515 | |
| 4516 | ifp = vty->index; |
| 4517 | params = IF_DEF_PARAMS (ifp); |
| 4518 | |
| 4519 | if (argc == 2) |
| 4520 | { |
| 4521 | ret = inet_aton(argv[1], &addr); |
| 4522 | if (!ret) |
| 4523 | { |
| 4524 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4525 | VTY_NEWLINE); |
| 4526 | return CMD_WARNING; |
| 4527 | } |
| 4528 | |
| 4529 | params = ospf_lookup_if_params (ifp, addr); |
| 4530 | if (params == NULL) |
| 4531 | return CMD_SUCCESS; |
| 4532 | } |
| 4533 | |
| 4534 | key_id = strtol (argv[0], NULL, 10); |
| 4535 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4536 | if (ck == NULL) |
| 4537 | { |
| 4538 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4539 | return CMD_WARNING; |
| 4540 | } |
| 4541 | |
| 4542 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4543 | |
| 4544 | if (params != IF_DEF_PARAMS (ifp)) |
| 4545 | { |
| 4546 | ospf_free_if_params (ifp, addr); |
| 4547 | ospf_if_update_params (ifp, addr); |
| 4548 | } |
| 4549 | |
| 4550 | return CMD_SUCCESS; |
| 4551 | } |
| 4552 | |
| 4553 | ALIAS (no_ip_ospf_message_digest_key, |
| 4554 | no_ip_ospf_message_digest_key_cmd, |
| 4555 | "no ip ospf message-digest-key <1-255>", |
| 4556 | NO_STR |
| 4557 | "IP Information\n" |
| 4558 | "OSPF interface commands\n" |
| 4559 | "Message digest authentication password (key)\n" |
| 4560 | "Key ID\n") |
| 4561 | |
| 4562 | ALIAS (no_ip_ospf_message_digest_key, |
| 4563 | no_ospf_message_digest_key_cmd, |
| 4564 | "no ospf message-digest-key <1-255>", |
| 4565 | NO_STR |
| 4566 | "OSPF interface commands\n" |
| 4567 | "Message digest authentication password (key)\n" |
| 4568 | "Key ID\n") |
| 4569 | |
| 4570 | DEFUN (ip_ospf_cost, |
| 4571 | ip_ospf_cost_addr_cmd, |
| 4572 | "ip ospf cost <1-65535> A.B.C.D", |
| 4573 | "IP Information\n" |
| 4574 | "OSPF interface commands\n" |
| 4575 | "Interface cost\n" |
| 4576 | "Cost\n" |
| 4577 | "Address of interface") |
| 4578 | { |
| 4579 | struct interface *ifp = vty->index; |
| 4580 | u_int32_t cost; |
| 4581 | struct in_addr addr; |
| 4582 | int ret; |
| 4583 | struct ospf_if_params *params; |
| 4584 | |
| 4585 | params = IF_DEF_PARAMS (ifp); |
| 4586 | |
| 4587 | cost = strtol (argv[0], NULL, 10); |
| 4588 | |
| 4589 | /* cost range is <1-65535>. */ |
| 4590 | if (cost < 1 || cost > 65535) |
| 4591 | { |
| 4592 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4593 | return CMD_WARNING; |
| 4594 | } |
| 4595 | |
| 4596 | if (argc == 2) |
| 4597 | { |
| 4598 | ret = inet_aton(argv[1], &addr); |
| 4599 | if (!ret) |
| 4600 | { |
| 4601 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4602 | VTY_NEWLINE); |
| 4603 | return CMD_WARNING; |
| 4604 | } |
| 4605 | |
| 4606 | params = ospf_get_if_params (ifp, addr); |
| 4607 | ospf_if_update_params (ifp, addr); |
| 4608 | } |
| 4609 | |
| 4610 | SET_IF_PARAM (params, output_cost_cmd); |
| 4611 | params->output_cost_cmd = cost; |
| 4612 | |
| 4613 | ospf_if_recalculate_output_cost (ifp); |
| 4614 | |
| 4615 | return CMD_SUCCESS; |
| 4616 | } |
| 4617 | |
| 4618 | ALIAS (ip_ospf_cost, |
| 4619 | ip_ospf_cost_cmd, |
| 4620 | "ip ospf cost <1-65535>", |
| 4621 | "IP Information\n" |
| 4622 | "OSPF interface commands\n" |
| 4623 | "Interface cost\n" |
| 4624 | "Cost") |
| 4625 | |
| 4626 | ALIAS (ip_ospf_cost, |
| 4627 | ospf_cost_cmd, |
| 4628 | "ospf cost <1-65535>", |
| 4629 | "OSPF interface commands\n" |
| 4630 | "Interface cost\n" |
| 4631 | "Cost") |
| 4632 | |
| 4633 | DEFUN (no_ip_ospf_cost, |
| 4634 | no_ip_ospf_cost_addr_cmd, |
| 4635 | "no ip ospf cost A.B.C.D", |
| 4636 | NO_STR |
| 4637 | "IP Information\n" |
| 4638 | "OSPF interface commands\n" |
| 4639 | "Interface cost\n" |
| 4640 | "Address of interface") |
| 4641 | { |
| 4642 | struct interface *ifp = vty->index; |
| 4643 | struct in_addr addr; |
| 4644 | int ret; |
| 4645 | struct ospf_if_params *params; |
| 4646 | |
| 4647 | ifp = vty->index; |
| 4648 | params = IF_DEF_PARAMS (ifp); |
| 4649 | |
| 4650 | if (argc == 1) |
| 4651 | { |
| 4652 | ret = inet_aton(argv[0], &addr); |
| 4653 | if (!ret) |
| 4654 | { |
| 4655 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4656 | VTY_NEWLINE); |
| 4657 | return CMD_WARNING; |
| 4658 | } |
| 4659 | |
| 4660 | params = ospf_lookup_if_params (ifp, addr); |
| 4661 | if (params == NULL) |
| 4662 | return CMD_SUCCESS; |
| 4663 | } |
| 4664 | |
| 4665 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4666 | |
| 4667 | if (params != IF_DEF_PARAMS (ifp)) |
| 4668 | { |
| 4669 | ospf_free_if_params (ifp, addr); |
| 4670 | ospf_if_update_params (ifp, addr); |
| 4671 | } |
| 4672 | |
| 4673 | ospf_if_recalculate_output_cost (ifp); |
| 4674 | |
| 4675 | return CMD_SUCCESS; |
| 4676 | } |
| 4677 | |
| 4678 | ALIAS (no_ip_ospf_cost, |
| 4679 | no_ip_ospf_cost_cmd, |
| 4680 | "no ip ospf cost", |
| 4681 | NO_STR |
| 4682 | "IP Information\n" |
| 4683 | "OSPF interface commands\n" |
| 4684 | "Interface cost\n") |
| 4685 | |
| 4686 | ALIAS (no_ip_ospf_cost, |
| 4687 | no_ospf_cost_cmd, |
| 4688 | "no ospf cost", |
| 4689 | NO_STR |
| 4690 | "OSPF interface commands\n" |
| 4691 | "Interface cost\n") |
| 4692 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4693 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4694 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4695 | { |
| 4696 | struct route_node *rn; |
| 4697 | struct ospf_neighbor *nbr; |
| 4698 | |
| 4699 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4700 | if ((nbr = rn->info)) |
| 4701 | { |
| 4702 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4703 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4704 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4705 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4706 | } |
| 4707 | } |
| 4708 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4709 | static int |
| 4710 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 4711 | const char *nbr_str, |
| 4712 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4713 | { |
| 4714 | struct interface *ifp = vty->index; |
| 4715 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4716 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4717 | struct in_addr addr; |
| 4718 | int ret; |
| 4719 | struct ospf_if_params *params; |
| 4720 | struct ospf_interface *oi; |
| 4721 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4722 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4723 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4724 | ospf = ospf_lookup (); |
| 4725 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4726 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4727 | |
| 4728 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4729 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4730 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4731 | if (!ret) |
| 4732 | { |
| 4733 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4734 | VTY_NEWLINE); |
| 4735 | return CMD_WARNING; |
| 4736 | } |
| 4737 | |
| 4738 | params = ospf_get_if_params (ifp, addr); |
| 4739 | ospf_if_update_params (ifp, addr); |
| 4740 | } |
| 4741 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4742 | if (interval_str) |
| 4743 | { |
| 4744 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 4745 | 1, 65535); |
| 4746 | |
| 4747 | /* reset fast_hello too, just to be sure */ |
| 4748 | UNSET_IF_PARAM (params, fast_hello); |
| 4749 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4750 | } |
| 4751 | else if (fast_hello_str) |
| 4752 | { |
| 4753 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 4754 | 1, 10); |
| 4755 | /* 1s dead-interval with sub-second hellos desired */ |
| 4756 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 4757 | SET_IF_PARAM (params, fast_hello); |
| 4758 | params->fast_hello = hellomult; |
| 4759 | } |
| 4760 | else |
| 4761 | { |
| 4762 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 4763 | VTY_NEWLINE); |
| 4764 | return CMD_WARNING; |
| 4765 | } |
| 4766 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4767 | SET_IF_PARAM (params, v_wait); |
| 4768 | params->v_wait = seconds; |
| 4769 | |
| 4770 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4771 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4772 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4773 | if (ospf) |
| 4774 | { |
| 4775 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4776 | if (oi) |
| 4777 | ospf_nbr_timer_update (oi); |
| 4778 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4779 | } |
| 4780 | else |
| 4781 | { |
| 4782 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4783 | if ((oi = rn->info)) |
| 4784 | ospf_nbr_timer_update (oi); |
| 4785 | } |
| 4786 | |
| 4787 | return CMD_SUCCESS; |
| 4788 | } |
| 4789 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4790 | |
| 4791 | DEFUN (ip_ospf_dead_interval, |
| 4792 | ip_ospf_dead_interval_addr_cmd, |
| 4793 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4794 | "IP Information\n" |
| 4795 | "OSPF interface commands\n" |
| 4796 | "Interval after which a neighbor is declared dead\n" |
| 4797 | "Seconds\n" |
| 4798 | "Address of interface\n") |
| 4799 | { |
| 4800 | if (argc == 2) |
| 4801 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 4802 | else |
| 4803 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 4804 | } |
| 4805 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4806 | ALIAS (ip_ospf_dead_interval, |
| 4807 | ip_ospf_dead_interval_cmd, |
| 4808 | "ip ospf dead-interval <1-65535>", |
| 4809 | "IP Information\n" |
| 4810 | "OSPF interface commands\n" |
| 4811 | "Interval after which a neighbor is declared dead\n" |
| 4812 | "Seconds\n") |
| 4813 | |
| 4814 | ALIAS (ip_ospf_dead_interval, |
| 4815 | ospf_dead_interval_cmd, |
| 4816 | "ospf dead-interval <1-65535>", |
| 4817 | "OSPF interface commands\n" |
| 4818 | "Interval after which a neighbor is declared dead\n" |
| 4819 | "Seconds\n") |
| 4820 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4821 | DEFUN (ip_ospf_dead_interval_minimal, |
| 4822 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 4823 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 4824 | "IP Information\n" |
| 4825 | "OSPF interface commands\n" |
| 4826 | "Interval after which a neighbor is declared dead\n" |
| 4827 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4828 | "Hello multiplier factor\n" |
| 4829 | "Number of Hellos to send each second\n" |
| 4830 | "Address of interface\n") |
| 4831 | { |
| 4832 | if (argc == 2) |
| 4833 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 4834 | else |
| 4835 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 4836 | } |
| 4837 | |
| 4838 | ALIAS (ip_ospf_dead_interval_minimal, |
| 4839 | ip_ospf_dead_interval_minimal_cmd, |
| 4840 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 4841 | "IP Information\n" |
| 4842 | "OSPF interface commands\n" |
| 4843 | "Interval after which a neighbor is declared dead\n" |
| 4844 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4845 | "Hello multiplier factor\n" |
| 4846 | "Number of Hellos to send each second\n") |
| 4847 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4848 | DEFUN (no_ip_ospf_dead_interval, |
| 4849 | no_ip_ospf_dead_interval_addr_cmd, |
| 4850 | "no ip ospf dead-interval A.B.C.D", |
| 4851 | NO_STR |
| 4852 | "IP Information\n" |
| 4853 | "OSPF interface commands\n" |
| 4854 | "Interval after which a neighbor is declared dead\n" |
| 4855 | "Address of interface") |
| 4856 | { |
| 4857 | struct interface *ifp = vty->index; |
| 4858 | struct in_addr addr; |
| 4859 | int ret; |
| 4860 | struct ospf_if_params *params; |
| 4861 | struct ospf_interface *oi; |
| 4862 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4863 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4864 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4865 | ospf = ospf_lookup (); |
| 4866 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4867 | ifp = vty->index; |
| 4868 | params = IF_DEF_PARAMS (ifp); |
| 4869 | |
| 4870 | if (argc == 1) |
| 4871 | { |
| 4872 | ret = inet_aton(argv[0], &addr); |
| 4873 | if (!ret) |
| 4874 | { |
| 4875 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4876 | VTY_NEWLINE); |
| 4877 | return CMD_WARNING; |
| 4878 | } |
| 4879 | |
| 4880 | params = ospf_lookup_if_params (ifp, addr); |
| 4881 | if (params == NULL) |
| 4882 | return CMD_SUCCESS; |
| 4883 | } |
| 4884 | |
| 4885 | UNSET_IF_PARAM (params, v_wait); |
| 4886 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4887 | |
| 4888 | UNSET_IF_PARAM (params, fast_hello); |
| 4889 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4891 | if (params != IF_DEF_PARAMS (ifp)) |
| 4892 | { |
| 4893 | ospf_free_if_params (ifp, addr); |
| 4894 | ospf_if_update_params (ifp, addr); |
| 4895 | } |
| 4896 | |
| 4897 | /* Update timer values in neighbor structure. */ |
| 4898 | if (argc == 1) |
| 4899 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4900 | if (ospf) |
| 4901 | { |
| 4902 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4903 | if (oi) |
| 4904 | ospf_nbr_timer_update (oi); |
| 4905 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4906 | } |
| 4907 | else |
| 4908 | { |
| 4909 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4910 | if ((oi = rn->info)) |
| 4911 | ospf_nbr_timer_update (oi); |
| 4912 | } |
| 4913 | |
| 4914 | return CMD_SUCCESS; |
| 4915 | } |
| 4916 | |
| 4917 | ALIAS (no_ip_ospf_dead_interval, |
| 4918 | no_ip_ospf_dead_interval_cmd, |
| 4919 | "no ip ospf dead-interval", |
| 4920 | NO_STR |
| 4921 | "IP Information\n" |
| 4922 | "OSPF interface commands\n" |
| 4923 | "Interval after which a neighbor is declared dead\n") |
| 4924 | |
| 4925 | ALIAS (no_ip_ospf_dead_interval, |
| 4926 | no_ospf_dead_interval_cmd, |
| 4927 | "no ospf dead-interval", |
| 4928 | NO_STR |
| 4929 | "OSPF interface commands\n" |
| 4930 | "Interval after which a neighbor is declared dead\n") |
| 4931 | |
| 4932 | DEFUN (ip_ospf_hello_interval, |
| 4933 | ip_ospf_hello_interval_addr_cmd, |
| 4934 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4935 | "IP Information\n" |
| 4936 | "OSPF interface commands\n" |
| 4937 | "Time between HELLO packets\n" |
| 4938 | "Seconds\n" |
| 4939 | "Address of interface") |
| 4940 | { |
| 4941 | struct interface *ifp = vty->index; |
| 4942 | u_int32_t seconds; |
| 4943 | struct in_addr addr; |
| 4944 | int ret; |
| 4945 | struct ospf_if_params *params; |
| 4946 | |
| 4947 | params = IF_DEF_PARAMS (ifp); |
| 4948 | |
| 4949 | seconds = strtol (argv[0], NULL, 10); |
| 4950 | |
| 4951 | /* HelloInterval range is <1-65535>. */ |
| 4952 | if (seconds < 1 || seconds > 65535) |
| 4953 | { |
| 4954 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4955 | return CMD_WARNING; |
| 4956 | } |
| 4957 | |
| 4958 | if (argc == 2) |
| 4959 | { |
| 4960 | ret = inet_aton(argv[1], &addr); |
| 4961 | if (!ret) |
| 4962 | { |
| 4963 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4964 | VTY_NEWLINE); |
| 4965 | return CMD_WARNING; |
| 4966 | } |
| 4967 | |
| 4968 | params = ospf_get_if_params (ifp, addr); |
| 4969 | ospf_if_update_params (ifp, addr); |
| 4970 | } |
| 4971 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4972 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4973 | params->v_hello = seconds; |
| 4974 | |
| 4975 | return CMD_SUCCESS; |
| 4976 | } |
| 4977 | |
| 4978 | ALIAS (ip_ospf_hello_interval, |
| 4979 | ip_ospf_hello_interval_cmd, |
| 4980 | "ip ospf hello-interval <1-65535>", |
| 4981 | "IP Information\n" |
| 4982 | "OSPF interface commands\n" |
| 4983 | "Time between HELLO packets\n" |
| 4984 | "Seconds\n") |
| 4985 | |
| 4986 | ALIAS (ip_ospf_hello_interval, |
| 4987 | ospf_hello_interval_cmd, |
| 4988 | "ospf hello-interval <1-65535>", |
| 4989 | "OSPF interface commands\n" |
| 4990 | "Time between HELLO packets\n" |
| 4991 | "Seconds\n") |
| 4992 | |
| 4993 | DEFUN (no_ip_ospf_hello_interval, |
| 4994 | no_ip_ospf_hello_interval_addr_cmd, |
| 4995 | "no ip ospf hello-interval A.B.C.D", |
| 4996 | NO_STR |
| 4997 | "IP Information\n" |
| 4998 | "OSPF interface commands\n" |
| 4999 | "Time between HELLO packets\n" |
| 5000 | "Address of interface") |
| 5001 | { |
| 5002 | struct interface *ifp = vty->index; |
| 5003 | struct in_addr addr; |
| 5004 | int ret; |
| 5005 | struct ospf_if_params *params; |
| 5006 | |
| 5007 | ifp = vty->index; |
| 5008 | params = IF_DEF_PARAMS (ifp); |
| 5009 | |
| 5010 | if (argc == 1) |
| 5011 | { |
| 5012 | ret = inet_aton(argv[0], &addr); |
| 5013 | if (!ret) |
| 5014 | { |
| 5015 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5016 | VTY_NEWLINE); |
| 5017 | return CMD_WARNING; |
| 5018 | } |
| 5019 | |
| 5020 | params = ospf_lookup_if_params (ifp, addr); |
| 5021 | if (params == NULL) |
| 5022 | return CMD_SUCCESS; |
| 5023 | } |
| 5024 | |
| 5025 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5026 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5027 | |
| 5028 | if (params != IF_DEF_PARAMS (ifp)) |
| 5029 | { |
| 5030 | ospf_free_if_params (ifp, addr); |
| 5031 | ospf_if_update_params (ifp, addr); |
| 5032 | } |
| 5033 | |
| 5034 | return CMD_SUCCESS; |
| 5035 | } |
| 5036 | |
| 5037 | ALIAS (no_ip_ospf_hello_interval, |
| 5038 | no_ip_ospf_hello_interval_cmd, |
| 5039 | "no ip ospf hello-interval", |
| 5040 | NO_STR |
| 5041 | "IP Information\n" |
| 5042 | "OSPF interface commands\n" |
| 5043 | "Time between HELLO packets\n") |
| 5044 | |
| 5045 | ALIAS (no_ip_ospf_hello_interval, |
| 5046 | no_ospf_hello_interval_cmd, |
| 5047 | "no ospf hello-interval", |
| 5048 | NO_STR |
| 5049 | "OSPF interface commands\n" |
| 5050 | "Time between HELLO packets\n") |
| 5051 | |
| 5052 | DEFUN (ip_ospf_network, |
| 5053 | ip_ospf_network_cmd, |
| 5054 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5055 | "IP Information\n" |
| 5056 | "OSPF interface commands\n" |
| 5057 | "Network type\n" |
| 5058 | "Specify OSPF broadcast multi-access network\n" |
| 5059 | "Specify OSPF NBMA network\n" |
| 5060 | "Specify OSPF point-to-multipoint network\n" |
| 5061 | "Specify OSPF point-to-point network\n") |
| 5062 | { |
| 5063 | struct interface *ifp = vty->index; |
| 5064 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5065 | struct route_node *rn; |
| 5066 | |
| 5067 | if (strncmp (argv[0], "b", 1) == 0) |
| 5068 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5069 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5070 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5071 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5072 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5073 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5074 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5075 | |
| 5076 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5077 | return CMD_SUCCESS; |
| 5078 | |
| 5079 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5080 | |
| 5081 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5082 | { |
| 5083 | struct ospf_interface *oi = rn->info; |
| 5084 | |
| 5085 | if (!oi) |
| 5086 | continue; |
| 5087 | |
| 5088 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5089 | |
| 5090 | if (oi->state > ISM_Down) |
| 5091 | { |
| 5092 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5093 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5094 | } |
| 5095 | } |
| 5096 | |
| 5097 | return CMD_SUCCESS; |
| 5098 | } |
| 5099 | |
| 5100 | ALIAS (ip_ospf_network, |
| 5101 | ospf_network_cmd, |
| 5102 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5103 | "OSPF interface commands\n" |
| 5104 | "Network type\n" |
| 5105 | "Specify OSPF broadcast multi-access network\n" |
| 5106 | "Specify OSPF NBMA network\n" |
| 5107 | "Specify OSPF point-to-multipoint network\n" |
| 5108 | "Specify OSPF point-to-point network\n") |
| 5109 | |
| 5110 | DEFUN (no_ip_ospf_network, |
| 5111 | no_ip_ospf_network_cmd, |
| 5112 | "no ip ospf network", |
| 5113 | NO_STR |
| 5114 | "IP Information\n" |
| 5115 | "OSPF interface commands\n" |
| 5116 | "Network type\n") |
| 5117 | { |
| 5118 | struct interface *ifp = vty->index; |
| 5119 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5120 | struct route_node *rn; |
| 5121 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5122 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5123 | |
| 5124 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5125 | return CMD_SUCCESS; |
| 5126 | |
| 5127 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5128 | { |
| 5129 | struct ospf_interface *oi = rn->info; |
| 5130 | |
| 5131 | if (!oi) |
| 5132 | continue; |
| 5133 | |
| 5134 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5135 | |
| 5136 | if (oi->state > ISM_Down) |
| 5137 | { |
| 5138 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5139 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5140 | } |
| 5141 | } |
| 5142 | |
| 5143 | return CMD_SUCCESS; |
| 5144 | } |
| 5145 | |
| 5146 | ALIAS (no_ip_ospf_network, |
| 5147 | no_ospf_network_cmd, |
| 5148 | "no ospf network", |
| 5149 | NO_STR |
| 5150 | "OSPF interface commands\n" |
| 5151 | "Network type\n") |
| 5152 | |
| 5153 | DEFUN (ip_ospf_priority, |
| 5154 | ip_ospf_priority_addr_cmd, |
| 5155 | "ip ospf priority <0-255> A.B.C.D", |
| 5156 | "IP Information\n" |
| 5157 | "OSPF interface commands\n" |
| 5158 | "Router priority\n" |
| 5159 | "Priority\n" |
| 5160 | "Address of interface") |
| 5161 | { |
| 5162 | struct interface *ifp = vty->index; |
| 5163 | u_int32_t priority; |
| 5164 | struct route_node *rn; |
| 5165 | struct in_addr addr; |
| 5166 | int ret; |
| 5167 | struct ospf_if_params *params; |
| 5168 | |
| 5169 | params = IF_DEF_PARAMS (ifp); |
| 5170 | |
| 5171 | priority = strtol (argv[0], NULL, 10); |
| 5172 | |
| 5173 | /* Router Priority range is <0-255>. */ |
| 5174 | if (priority < 0 || priority > 255) |
| 5175 | { |
| 5176 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5177 | return CMD_WARNING; |
| 5178 | } |
| 5179 | |
| 5180 | if (argc == 2) |
| 5181 | { |
| 5182 | ret = inet_aton(argv[1], &addr); |
| 5183 | if (!ret) |
| 5184 | { |
| 5185 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5186 | VTY_NEWLINE); |
| 5187 | return CMD_WARNING; |
| 5188 | } |
| 5189 | |
| 5190 | params = ospf_get_if_params (ifp, addr); |
| 5191 | ospf_if_update_params (ifp, addr); |
| 5192 | } |
| 5193 | |
| 5194 | SET_IF_PARAM (params, priority); |
| 5195 | params->priority = priority; |
| 5196 | |
| 5197 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5198 | { |
| 5199 | struct ospf_interface *oi = rn->info; |
| 5200 | |
| 5201 | if (!oi) |
| 5202 | continue; |
| 5203 | |
| 5204 | |
| 5205 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5206 | { |
| 5207 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5208 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5209 | } |
| 5210 | } |
| 5211 | |
| 5212 | return CMD_SUCCESS; |
| 5213 | } |
| 5214 | |
| 5215 | ALIAS (ip_ospf_priority, |
| 5216 | ip_ospf_priority_cmd, |
| 5217 | "ip ospf priority <0-255>", |
| 5218 | "IP Information\n" |
| 5219 | "OSPF interface commands\n" |
| 5220 | "Router priority\n" |
| 5221 | "Priority\n") |
| 5222 | |
| 5223 | ALIAS (ip_ospf_priority, |
| 5224 | ospf_priority_cmd, |
| 5225 | "ospf priority <0-255>", |
| 5226 | "OSPF interface commands\n" |
| 5227 | "Router priority\n" |
| 5228 | "Priority\n") |
| 5229 | |
| 5230 | DEFUN (no_ip_ospf_priority, |
| 5231 | no_ip_ospf_priority_addr_cmd, |
| 5232 | "no ip ospf priority A.B.C.D", |
| 5233 | NO_STR |
| 5234 | "IP Information\n" |
| 5235 | "OSPF interface commands\n" |
| 5236 | "Router priority\n" |
| 5237 | "Address of interface") |
| 5238 | { |
| 5239 | struct interface *ifp = vty->index; |
| 5240 | struct route_node *rn; |
| 5241 | struct in_addr addr; |
| 5242 | int ret; |
| 5243 | struct ospf_if_params *params; |
| 5244 | |
| 5245 | ifp = vty->index; |
| 5246 | params = IF_DEF_PARAMS (ifp); |
| 5247 | |
| 5248 | if (argc == 1) |
| 5249 | { |
| 5250 | ret = inet_aton(argv[0], &addr); |
| 5251 | if (!ret) |
| 5252 | { |
| 5253 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5254 | VTY_NEWLINE); |
| 5255 | return CMD_WARNING; |
| 5256 | } |
| 5257 | |
| 5258 | params = ospf_lookup_if_params (ifp, addr); |
| 5259 | if (params == NULL) |
| 5260 | return CMD_SUCCESS; |
| 5261 | } |
| 5262 | |
| 5263 | UNSET_IF_PARAM (params, priority); |
| 5264 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5265 | |
| 5266 | if (params != IF_DEF_PARAMS (ifp)) |
| 5267 | { |
| 5268 | ospf_free_if_params (ifp, addr); |
| 5269 | ospf_if_update_params (ifp, addr); |
| 5270 | } |
| 5271 | |
| 5272 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5273 | { |
| 5274 | struct ospf_interface *oi = rn->info; |
| 5275 | |
| 5276 | if (!oi) |
| 5277 | continue; |
| 5278 | |
| 5279 | |
| 5280 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5281 | { |
| 5282 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5283 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5284 | } |
| 5285 | } |
| 5286 | |
| 5287 | return CMD_SUCCESS; |
| 5288 | } |
| 5289 | |
| 5290 | ALIAS (no_ip_ospf_priority, |
| 5291 | no_ip_ospf_priority_cmd, |
| 5292 | "no ip ospf priority", |
| 5293 | NO_STR |
| 5294 | "IP Information\n" |
| 5295 | "OSPF interface commands\n" |
| 5296 | "Router priority\n") |
| 5297 | |
| 5298 | ALIAS (no_ip_ospf_priority, |
| 5299 | no_ospf_priority_cmd, |
| 5300 | "no ospf priority", |
| 5301 | NO_STR |
| 5302 | "OSPF interface commands\n" |
| 5303 | "Router priority\n") |
| 5304 | |
| 5305 | DEFUN (ip_ospf_retransmit_interval, |
| 5306 | ip_ospf_retransmit_interval_addr_cmd, |
| 5307 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5308 | "IP Information\n" |
| 5309 | "OSPF interface commands\n" |
| 5310 | "Time between retransmitting lost link state advertisements\n" |
| 5311 | "Seconds\n" |
| 5312 | "Address of interface") |
| 5313 | { |
| 5314 | struct interface *ifp = vty->index; |
| 5315 | u_int32_t seconds; |
| 5316 | struct in_addr addr; |
| 5317 | int ret; |
| 5318 | struct ospf_if_params *params; |
| 5319 | |
| 5320 | params = IF_DEF_PARAMS (ifp); |
| 5321 | seconds = strtol (argv[0], NULL, 10); |
| 5322 | |
| 5323 | /* Retransmit Interval range is <3-65535>. */ |
| 5324 | if (seconds < 3 || seconds > 65535) |
| 5325 | { |
| 5326 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5327 | return CMD_WARNING; |
| 5328 | } |
| 5329 | |
| 5330 | |
| 5331 | if (argc == 2) |
| 5332 | { |
| 5333 | ret = inet_aton(argv[1], &addr); |
| 5334 | if (!ret) |
| 5335 | { |
| 5336 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5337 | VTY_NEWLINE); |
| 5338 | return CMD_WARNING; |
| 5339 | } |
| 5340 | |
| 5341 | params = ospf_get_if_params (ifp, addr); |
| 5342 | ospf_if_update_params (ifp, addr); |
| 5343 | } |
| 5344 | |
| 5345 | SET_IF_PARAM (params, retransmit_interval); |
| 5346 | params->retransmit_interval = seconds; |
| 5347 | |
| 5348 | return CMD_SUCCESS; |
| 5349 | } |
| 5350 | |
| 5351 | ALIAS (ip_ospf_retransmit_interval, |
| 5352 | ip_ospf_retransmit_interval_cmd, |
| 5353 | "ip ospf retransmit-interval <3-65535>", |
| 5354 | "IP Information\n" |
| 5355 | "OSPF interface commands\n" |
| 5356 | "Time between retransmitting lost link state advertisements\n" |
| 5357 | "Seconds\n") |
| 5358 | |
| 5359 | ALIAS (ip_ospf_retransmit_interval, |
| 5360 | ospf_retransmit_interval_cmd, |
| 5361 | "ospf retransmit-interval <3-65535>", |
| 5362 | "OSPF interface commands\n" |
| 5363 | "Time between retransmitting lost link state advertisements\n" |
| 5364 | "Seconds\n") |
| 5365 | |
| 5366 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5367 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5368 | "no ip ospf retransmit-interval A.B.C.D", |
| 5369 | NO_STR |
| 5370 | "IP Information\n" |
| 5371 | "OSPF interface commands\n" |
| 5372 | "Time between retransmitting lost link state advertisements\n" |
| 5373 | "Address of interface") |
| 5374 | { |
| 5375 | struct interface *ifp = vty->index; |
| 5376 | struct in_addr addr; |
| 5377 | int ret; |
| 5378 | struct ospf_if_params *params; |
| 5379 | |
| 5380 | ifp = vty->index; |
| 5381 | params = IF_DEF_PARAMS (ifp); |
| 5382 | |
| 5383 | if (argc == 1) |
| 5384 | { |
| 5385 | ret = inet_aton(argv[0], &addr); |
| 5386 | if (!ret) |
| 5387 | { |
| 5388 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5389 | VTY_NEWLINE); |
| 5390 | return CMD_WARNING; |
| 5391 | } |
| 5392 | |
| 5393 | params = ospf_lookup_if_params (ifp, addr); |
| 5394 | if (params == NULL) |
| 5395 | return CMD_SUCCESS; |
| 5396 | } |
| 5397 | |
| 5398 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5399 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5400 | |
| 5401 | if (params != IF_DEF_PARAMS (ifp)) |
| 5402 | { |
| 5403 | ospf_free_if_params (ifp, addr); |
| 5404 | ospf_if_update_params (ifp, addr); |
| 5405 | } |
| 5406 | |
| 5407 | return CMD_SUCCESS; |
| 5408 | } |
| 5409 | |
| 5410 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5411 | no_ip_ospf_retransmit_interval_cmd, |
| 5412 | "no ip ospf retransmit-interval", |
| 5413 | NO_STR |
| 5414 | "IP Information\n" |
| 5415 | "OSPF interface commands\n" |
| 5416 | "Time between retransmitting lost link state advertisements\n") |
| 5417 | |
| 5418 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5419 | no_ospf_retransmit_interval_cmd, |
| 5420 | "no ospf retransmit-interval", |
| 5421 | NO_STR |
| 5422 | "OSPF interface commands\n" |
| 5423 | "Time between retransmitting lost link state advertisements\n") |
| 5424 | |
| 5425 | DEFUN (ip_ospf_transmit_delay, |
| 5426 | ip_ospf_transmit_delay_addr_cmd, |
| 5427 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5428 | "IP Information\n" |
| 5429 | "OSPF interface commands\n" |
| 5430 | "Link state transmit delay\n" |
| 5431 | "Seconds\n" |
| 5432 | "Address of interface") |
| 5433 | { |
| 5434 | struct interface *ifp = vty->index; |
| 5435 | u_int32_t seconds; |
| 5436 | struct in_addr addr; |
| 5437 | int ret; |
| 5438 | struct ospf_if_params *params; |
| 5439 | |
| 5440 | params = IF_DEF_PARAMS (ifp); |
| 5441 | seconds = strtol (argv[0], NULL, 10); |
| 5442 | |
| 5443 | /* Transmit Delay range is <1-65535>. */ |
| 5444 | if (seconds < 1 || seconds > 65535) |
| 5445 | { |
| 5446 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5447 | return CMD_WARNING; |
| 5448 | } |
| 5449 | |
| 5450 | if (argc == 2) |
| 5451 | { |
| 5452 | ret = inet_aton(argv[1], &addr); |
| 5453 | if (!ret) |
| 5454 | { |
| 5455 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5456 | VTY_NEWLINE); |
| 5457 | return CMD_WARNING; |
| 5458 | } |
| 5459 | |
| 5460 | params = ospf_get_if_params (ifp, addr); |
| 5461 | ospf_if_update_params (ifp, addr); |
| 5462 | } |
| 5463 | |
| 5464 | SET_IF_PARAM (params, transmit_delay); |
| 5465 | params->transmit_delay = seconds; |
| 5466 | |
| 5467 | return CMD_SUCCESS; |
| 5468 | } |
| 5469 | |
| 5470 | ALIAS (ip_ospf_transmit_delay, |
| 5471 | ip_ospf_transmit_delay_cmd, |
| 5472 | "ip ospf transmit-delay <1-65535>", |
| 5473 | "IP Information\n" |
| 5474 | "OSPF interface commands\n" |
| 5475 | "Link state transmit delay\n" |
| 5476 | "Seconds\n") |
| 5477 | |
| 5478 | ALIAS (ip_ospf_transmit_delay, |
| 5479 | ospf_transmit_delay_cmd, |
| 5480 | "ospf transmit-delay <1-65535>", |
| 5481 | "OSPF interface commands\n" |
| 5482 | "Link state transmit delay\n" |
| 5483 | "Seconds\n") |
| 5484 | |
| 5485 | DEFUN (no_ip_ospf_transmit_delay, |
| 5486 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5487 | "no ip ospf transmit-delay A.B.C.D", |
| 5488 | NO_STR |
| 5489 | "IP Information\n" |
| 5490 | "OSPF interface commands\n" |
| 5491 | "Link state transmit delay\n" |
| 5492 | "Address of interface") |
| 5493 | { |
| 5494 | struct interface *ifp = vty->index; |
| 5495 | struct in_addr addr; |
| 5496 | int ret; |
| 5497 | struct ospf_if_params *params; |
| 5498 | |
| 5499 | ifp = vty->index; |
| 5500 | params = IF_DEF_PARAMS (ifp); |
| 5501 | |
| 5502 | if (argc == 1) |
| 5503 | { |
| 5504 | ret = inet_aton(argv[0], &addr); |
| 5505 | if (!ret) |
| 5506 | { |
| 5507 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5508 | VTY_NEWLINE); |
| 5509 | return CMD_WARNING; |
| 5510 | } |
| 5511 | |
| 5512 | params = ospf_lookup_if_params (ifp, addr); |
| 5513 | if (params == NULL) |
| 5514 | return CMD_SUCCESS; |
| 5515 | } |
| 5516 | |
| 5517 | UNSET_IF_PARAM (params, transmit_delay); |
| 5518 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5519 | |
| 5520 | if (params != IF_DEF_PARAMS (ifp)) |
| 5521 | { |
| 5522 | ospf_free_if_params (ifp, addr); |
| 5523 | ospf_if_update_params (ifp, addr); |
| 5524 | } |
| 5525 | |
| 5526 | return CMD_SUCCESS; |
| 5527 | } |
| 5528 | |
| 5529 | ALIAS (no_ip_ospf_transmit_delay, |
| 5530 | no_ip_ospf_transmit_delay_cmd, |
| 5531 | "no ip ospf transmit-delay", |
| 5532 | NO_STR |
| 5533 | "IP Information\n" |
| 5534 | "OSPF interface commands\n" |
| 5535 | "Link state transmit delay\n") |
| 5536 | |
| 5537 | ALIAS (no_ip_ospf_transmit_delay, |
| 5538 | no_ospf_transmit_delay_cmd, |
| 5539 | "no ospf transmit-delay", |
| 5540 | NO_STR |
| 5541 | "OSPF interface commands\n" |
| 5542 | "Link state transmit delay\n") |
| 5543 | |
| 5544 | |
| 5545 | DEFUN (ospf_redistribute_source_metric_type, |
| 5546 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5547 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5548 | "Redistribute information from another routing protocol\n" |
| 5549 | "Kernel routes\n" |
| 5550 | "Connected\n" |
| 5551 | "Static routes\n" |
| 5552 | "Routing Information Protocol (RIP)\n" |
| 5553 | "Border Gateway Protocol (BGP)\n" |
| 5554 | "Metric for redistributed routes\n" |
| 5555 | "OSPF default metric\n" |
| 5556 | "OSPF exterior metric type for redistributed routes\n" |
| 5557 | "Set OSPF External Type 1 metrics\n" |
| 5558 | "Set OSPF External Type 2 metrics\n" |
| 5559 | "Route map reference\n" |
| 5560 | "Pointer to route-map entries\n") |
| 5561 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5562 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5563 | int source; |
| 5564 | int type = -1; |
| 5565 | int metric = -1; |
| 5566 | |
| 5567 | /* Get distribute source. */ |
| 5568 | if (!str2distribute_source (argv[0], &source)) |
| 5569 | return CMD_WARNING; |
| 5570 | |
| 5571 | /* Get metric value. */ |
| 5572 | if (argc >= 2) |
| 5573 | if (!str2metric (argv[1], &metric)) |
| 5574 | return CMD_WARNING; |
| 5575 | |
| 5576 | /* Get metric type. */ |
| 5577 | if (argc >= 3) |
| 5578 | if (!str2metric_type (argv[2], &type)) |
| 5579 | return CMD_WARNING; |
| 5580 | |
| 5581 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5582 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5583 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5584 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5585 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5586 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5587 | } |
| 5588 | |
| 5589 | ALIAS (ospf_redistribute_source_metric_type, |
| 5590 | ospf_redistribute_source_metric_type_cmd, |
| 5591 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5592 | "Redistribute information from another routing protocol\n" |
| 5593 | "Kernel routes\n" |
| 5594 | "Connected\n" |
| 5595 | "Static routes\n" |
| 5596 | "Routing Information Protocol (RIP)\n" |
| 5597 | "Border Gateway Protocol (BGP)\n" |
| 5598 | "Metric for redistributed routes\n" |
| 5599 | "OSPF default metric\n" |
| 5600 | "OSPF exterior metric type for redistributed routes\n" |
| 5601 | "Set OSPF External Type 1 metrics\n" |
| 5602 | "Set OSPF External Type 2 metrics\n") |
| 5603 | |
| 5604 | ALIAS (ospf_redistribute_source_metric_type, |
| 5605 | ospf_redistribute_source_metric_cmd, |
| 5606 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5607 | "Redistribute information from another routing protocol\n" |
| 5608 | "Kernel routes\n" |
| 5609 | "Connected\n" |
| 5610 | "Static routes\n" |
| 5611 | "Routing Information Protocol (RIP)\n" |
| 5612 | "Border Gateway Protocol (BGP)\n" |
| 5613 | "Metric for redistributed routes\n" |
| 5614 | "OSPF default metric\n") |
| 5615 | |
| 5616 | DEFUN (ospf_redistribute_source_type_metric, |
| 5617 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5618 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5619 | "Redistribute information from another routing protocol\n" |
| 5620 | "Kernel routes\n" |
| 5621 | "Connected\n" |
| 5622 | "Static routes\n" |
| 5623 | "Routing Information Protocol (RIP)\n" |
| 5624 | "Border Gateway Protocol (BGP)\n" |
| 5625 | "OSPF exterior metric type for redistributed routes\n" |
| 5626 | "Set OSPF External Type 1 metrics\n" |
| 5627 | "Set OSPF External Type 2 metrics\n" |
| 5628 | "Metric for redistributed routes\n" |
| 5629 | "OSPF default metric\n" |
| 5630 | "Route map reference\n" |
| 5631 | "Pointer to route-map entries\n") |
| 5632 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5633 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5634 | int source; |
| 5635 | int type = -1; |
| 5636 | int metric = -1; |
| 5637 | |
| 5638 | /* Get distribute source. */ |
| 5639 | if (!str2distribute_source (argv[0], &source)) |
| 5640 | return CMD_WARNING; |
| 5641 | |
| 5642 | /* Get metric value. */ |
| 5643 | if (argc >= 2) |
| 5644 | if (!str2metric_type (argv[1], &type)) |
| 5645 | return CMD_WARNING; |
| 5646 | |
| 5647 | /* Get metric type. */ |
| 5648 | if (argc >= 3) |
| 5649 | if (!str2metric (argv[2], &metric)) |
| 5650 | return CMD_WARNING; |
| 5651 | |
| 5652 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5653 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5654 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5655 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5656 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5657 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5658 | } |
| 5659 | |
| 5660 | ALIAS (ospf_redistribute_source_type_metric, |
| 5661 | ospf_redistribute_source_type_metric_cmd, |
| 5662 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5663 | "Redistribute information from another routing protocol\n" |
| 5664 | "Kernel routes\n" |
| 5665 | "Connected\n" |
| 5666 | "Static routes\n" |
| 5667 | "Routing Information Protocol (RIP)\n" |
| 5668 | "Border Gateway Protocol (BGP)\n" |
| 5669 | "OSPF exterior metric type for redistributed routes\n" |
| 5670 | "Set OSPF External Type 1 metrics\n" |
| 5671 | "Set OSPF External Type 2 metrics\n" |
| 5672 | "Metric for redistributed routes\n" |
| 5673 | "OSPF default metric\n") |
| 5674 | |
| 5675 | ALIAS (ospf_redistribute_source_type_metric, |
| 5676 | ospf_redistribute_source_type_cmd, |
| 5677 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5678 | "Redistribute information from another routing protocol\n" |
| 5679 | "Kernel routes\n" |
| 5680 | "Connected\n" |
| 5681 | "Static routes\n" |
| 5682 | "Routing Information Protocol (RIP)\n" |
| 5683 | "Border Gateway Protocol (BGP)\n" |
| 5684 | "OSPF exterior metric type for redistributed routes\n" |
| 5685 | "Set OSPF External Type 1 metrics\n" |
| 5686 | "Set OSPF External Type 2 metrics\n") |
| 5687 | |
| 5688 | ALIAS (ospf_redistribute_source_type_metric, |
| 5689 | ospf_redistribute_source_cmd, |
| 5690 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5691 | "Redistribute information from another routing protocol\n" |
| 5692 | "Kernel routes\n" |
| 5693 | "Connected\n" |
| 5694 | "Static routes\n" |
| 5695 | "Routing Information Protocol (RIP)\n" |
| 5696 | "Border Gateway Protocol (BGP)\n") |
| 5697 | |
| 5698 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5699 | ospf_redistribute_source_metric_routemap_cmd, |
| 5700 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5701 | "Redistribute information from another routing protocol\n" |
| 5702 | "Kernel routes\n" |
| 5703 | "Connected\n" |
| 5704 | "Static routes\n" |
| 5705 | "Routing Information Protocol (RIP)\n" |
| 5706 | "Border Gateway Protocol (BGP)\n" |
| 5707 | "Metric for redistributed routes\n" |
| 5708 | "OSPF default metric\n" |
| 5709 | "Route map reference\n" |
| 5710 | "Pointer to route-map entries\n") |
| 5711 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5712 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5713 | int source; |
| 5714 | int metric = -1; |
| 5715 | |
| 5716 | /* Get distribute source. */ |
| 5717 | if (!str2distribute_source (argv[0], &source)) |
| 5718 | return CMD_WARNING; |
| 5719 | |
| 5720 | /* Get metric value. */ |
| 5721 | if (argc >= 2) |
| 5722 | if (!str2metric (argv[1], &metric)) |
| 5723 | return CMD_WARNING; |
| 5724 | |
| 5725 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5726 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5727 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5728 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5729 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5730 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5731 | } |
| 5732 | |
| 5733 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5734 | ospf_redistribute_source_type_routemap_cmd, |
| 5735 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5736 | "Redistribute information from another routing protocol\n" |
| 5737 | "Kernel routes\n" |
| 5738 | "Connected\n" |
| 5739 | "Static routes\n" |
| 5740 | "Routing Information Protocol (RIP)\n" |
| 5741 | "Border Gateway Protocol (BGP)\n" |
| 5742 | "OSPF exterior metric type for redistributed routes\n" |
| 5743 | "Set OSPF External Type 1 metrics\n" |
| 5744 | "Set OSPF External Type 2 metrics\n" |
| 5745 | "Route map reference\n" |
| 5746 | "Pointer to route-map entries\n") |
| 5747 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5748 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | int source; |
| 5750 | int type = -1; |
| 5751 | |
| 5752 | /* Get distribute source. */ |
| 5753 | if (!str2distribute_source (argv[0], &source)) |
| 5754 | return CMD_WARNING; |
| 5755 | |
| 5756 | /* Get metric value. */ |
| 5757 | if (argc >= 2) |
| 5758 | if (!str2metric_type (argv[1], &type)) |
| 5759 | return CMD_WARNING; |
| 5760 | |
| 5761 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5762 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5763 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5764 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5765 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5766 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5767 | } |
| 5768 | |
| 5769 | DEFUN (ospf_redistribute_source_routemap, |
| 5770 | ospf_redistribute_source_routemap_cmd, |
| 5771 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5772 | "Redistribute information from another routing protocol\n" |
| 5773 | "Kernel routes\n" |
| 5774 | "Connected\n" |
| 5775 | "Static routes\n" |
| 5776 | "Routing Information Protocol (RIP)\n" |
| 5777 | "Border Gateway Protocol (BGP)\n" |
| 5778 | "Route map reference\n" |
| 5779 | "Pointer to route-map entries\n") |
| 5780 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5781 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5782 | int source; |
| 5783 | |
| 5784 | /* Get distribute source. */ |
| 5785 | if (!str2distribute_source (argv[0], &source)) |
| 5786 | return CMD_WARNING; |
| 5787 | |
| 5788 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5789 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5790 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5791 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5792 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5793 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5794 | } |
| 5795 | |
| 5796 | DEFUN (no_ospf_redistribute_source, |
| 5797 | no_ospf_redistribute_source_cmd, |
| 5798 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5799 | NO_STR |
| 5800 | "Redistribute information from another routing protocol\n" |
| 5801 | "Kernel routes\n" |
| 5802 | "Connected\n" |
| 5803 | "Static routes\n" |
| 5804 | "Routing Information Protocol (RIP)\n" |
| 5805 | "Border Gateway Protocol (BGP)\n") |
| 5806 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5807 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | int source; |
| 5809 | |
| 5810 | if (!str2distribute_source (argv[0], &source)) |
| 5811 | return CMD_WARNING; |
| 5812 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5813 | ospf_routemap_unset (ospf, source); |
| 5814 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5815 | } |
| 5816 | |
| 5817 | DEFUN (ospf_distribute_list_out, |
| 5818 | ospf_distribute_list_out_cmd, |
| 5819 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5820 | "Filter networks in routing updates\n" |
| 5821 | "Access-list name\n" |
| 5822 | OUT_STR |
| 5823 | "Kernel routes\n" |
| 5824 | "Connected\n" |
| 5825 | "Static routes\n" |
| 5826 | "Routing Information Protocol (RIP)\n" |
| 5827 | "Border Gateway Protocol (BGP)\n") |
| 5828 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5829 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5830 | int source; |
| 5831 | |
| 5832 | /* Get distribute source. */ |
| 5833 | if (!str2distribute_source (argv[1], &source)) |
| 5834 | return CMD_WARNING; |
| 5835 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5836 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5837 | } |
| 5838 | |
| 5839 | DEFUN (no_ospf_distribute_list_out, |
| 5840 | no_ospf_distribute_list_out_cmd, |
| 5841 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5842 | NO_STR |
| 5843 | "Filter networks in routing updates\n" |
| 5844 | "Access-list name\n" |
| 5845 | OUT_STR |
| 5846 | "Kernel routes\n" |
| 5847 | "Connected\n" |
| 5848 | "Static routes\n" |
| 5849 | "Routing Information Protocol (RIP)\n" |
| 5850 | "Border Gateway Protocol (BGP)\n") |
| 5851 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5852 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5853 | int source; |
| 5854 | |
| 5855 | if (!str2distribute_source (argv[1], &source)) |
| 5856 | return CMD_WARNING; |
| 5857 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5858 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5859 | } |
| 5860 | |
| 5861 | /* Default information originate. */ |
| 5862 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5863 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5864 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5865 | "Control distribution of default information\n" |
| 5866 | "Distribute a default route\n" |
| 5867 | "OSPF default metric\n" |
| 5868 | "OSPF metric\n" |
| 5869 | "OSPF metric type for default routes\n" |
| 5870 | "Set OSPF External Type 1 metrics\n" |
| 5871 | "Set OSPF External Type 2 metrics\n" |
| 5872 | "Route map reference\n" |
| 5873 | "Pointer to route-map entries\n") |
| 5874 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5875 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5876 | int type = -1; |
| 5877 | int metric = -1; |
| 5878 | |
| 5879 | /* Get metric value. */ |
| 5880 | if (argc >= 1) |
| 5881 | if (!str2metric (argv[0], &metric)) |
| 5882 | return CMD_WARNING; |
| 5883 | |
| 5884 | /* Get metric type. */ |
| 5885 | if (argc >= 2) |
| 5886 | if (!str2metric_type (argv[1], &type)) |
| 5887 | return CMD_WARNING; |
| 5888 | |
| 5889 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5890 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5891 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5892 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5893 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5894 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5895 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5896 | } |
| 5897 | |
| 5898 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5899 | ospf_default_information_originate_metric_type_cmd, |
| 5900 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5901 | "Control distribution of default information\n" |
| 5902 | "Distribute a default route\n" |
| 5903 | "OSPF default metric\n" |
| 5904 | "OSPF metric\n" |
| 5905 | "OSPF metric type for default routes\n" |
| 5906 | "Set OSPF External Type 1 metrics\n" |
| 5907 | "Set OSPF External Type 2 metrics\n") |
| 5908 | |
| 5909 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5910 | ospf_default_information_originate_metric_cmd, |
| 5911 | "default-information originate metric <0-16777214>", |
| 5912 | "Control distribution of default information\n" |
| 5913 | "Distribute a default route\n" |
| 5914 | "OSPF default metric\n" |
| 5915 | "OSPF metric\n") |
| 5916 | |
| 5917 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5918 | ospf_default_information_originate_cmd, |
| 5919 | "default-information originate", |
| 5920 | "Control distribution of default information\n" |
| 5921 | "Distribute a default route\n") |
| 5922 | |
| 5923 | /* Default information originate. */ |
| 5924 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5925 | ospf_default_information_originate_metric_routemap_cmd, |
| 5926 | "default-information originate metric <0-16777214> route-map WORD", |
| 5927 | "Control distribution of default information\n" |
| 5928 | "Distribute a default route\n" |
| 5929 | "OSPF default metric\n" |
| 5930 | "OSPF metric\n" |
| 5931 | "Route map reference\n" |
| 5932 | "Pointer to route-map entries\n") |
| 5933 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5934 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5935 | int metric = -1; |
| 5936 | |
| 5937 | /* Get metric value. */ |
| 5938 | if (argc >= 1) |
| 5939 | if (!str2metric (argv[0], &metric)) |
| 5940 | return CMD_WARNING; |
| 5941 | |
| 5942 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5943 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5944 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5945 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5946 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5947 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5948 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5949 | } |
| 5950 | |
| 5951 | /* Default information originate. */ |
| 5952 | DEFUN (ospf_default_information_originate_routemap, |
| 5953 | ospf_default_information_originate_routemap_cmd, |
| 5954 | "default-information originate route-map WORD", |
| 5955 | "Control distribution of default information\n" |
| 5956 | "Distribute a default route\n" |
| 5957 | "Route map reference\n" |
| 5958 | "Pointer to route-map entries\n") |
| 5959 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5960 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5962 | if (argc == 1) |
| 5963 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5964 | else |
| 5965 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5966 | |
| 5967 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5968 | } |
| 5969 | |
| 5970 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 5971 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 5972 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5973 | "Control distribution of default information\n" |
| 5974 | "Distribute a default route\n" |
| 5975 | "OSPF metric type for default routes\n" |
| 5976 | "Set OSPF External Type 1 metrics\n" |
| 5977 | "Set OSPF External Type 2 metrics\n" |
| 5978 | "OSPF default metric\n" |
| 5979 | "OSPF metric\n" |
| 5980 | "Route map reference\n" |
| 5981 | "Pointer to route-map entries\n") |
| 5982 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5983 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5984 | int type = -1; |
| 5985 | int metric = -1; |
| 5986 | |
| 5987 | /* Get metric type. */ |
| 5988 | if (argc >= 1) |
| 5989 | if (!str2metric_type (argv[0], &type)) |
| 5990 | return CMD_WARNING; |
| 5991 | |
| 5992 | /* Get metric value. */ |
| 5993 | if (argc >= 2) |
| 5994 | if (!str2metric (argv[1], &metric)) |
| 5995 | return CMD_WARNING; |
| 5996 | |
| 5997 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5998 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6000 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6001 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6002 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6003 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6004 | } |
| 6005 | |
| 6006 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6007 | ospf_default_information_originate_type_metric_cmd, |
| 6008 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 6009 | "Control distribution of default information\n" |
| 6010 | "Distribute a default route\n" |
| 6011 | "OSPF metric type for default routes\n" |
| 6012 | "Set OSPF External Type 1 metrics\n" |
| 6013 | "Set OSPF External Type 2 metrics\n" |
| 6014 | "OSPF default metric\n" |
| 6015 | "OSPF metric\n") |
| 6016 | |
| 6017 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6018 | ospf_default_information_originate_type_cmd, |
| 6019 | "default-information originate metric-type (1|2)", |
| 6020 | "Control distribution of default information\n" |
| 6021 | "Distribute a default route\n" |
| 6022 | "OSPF metric type for default routes\n" |
| 6023 | "Set OSPF External Type 1 metrics\n" |
| 6024 | "Set OSPF External Type 2 metrics\n") |
| 6025 | |
| 6026 | DEFUN (ospf_default_information_originate_type_routemap, |
| 6027 | ospf_default_information_originate_type_routemap_cmd, |
| 6028 | "default-information originate metric-type (1|2) route-map WORD", |
| 6029 | "Control distribution of default information\n" |
| 6030 | "Distribute a default route\n" |
| 6031 | "OSPF metric type for default routes\n" |
| 6032 | "Set OSPF External Type 1 metrics\n" |
| 6033 | "Set OSPF External Type 2 metrics\n" |
| 6034 | "Route map reference\n" |
| 6035 | "Pointer to route-map entries\n") |
| 6036 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6037 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6038 | int type = -1; |
| 6039 | |
| 6040 | /* Get metric type. */ |
| 6041 | if (argc >= 1) |
| 6042 | if (!str2metric_type (argv[0], &type)) |
| 6043 | return CMD_WARNING; |
| 6044 | |
| 6045 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6046 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6047 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6048 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6049 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6050 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6051 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | } |
| 6053 | |
| 6054 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 6055 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 6056 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 6057 | "Control distribution of default information\n" |
| 6058 | "Distribute a default route\n" |
| 6059 | "Always advertise default route\n" |
| 6060 | "OSPF default metric\n" |
| 6061 | "OSPF metric\n" |
| 6062 | "OSPF metric type for default routes\n" |
| 6063 | "Set OSPF External Type 1 metrics\n" |
| 6064 | "Set OSPF External Type 2 metrics\n" |
| 6065 | "Route map reference\n" |
| 6066 | "Pointer to route-map entries\n") |
| 6067 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6068 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6069 | int type = -1; |
| 6070 | int metric = -1; |
| 6071 | |
| 6072 | /* Get metric value. */ |
| 6073 | if (argc >= 1) |
| 6074 | if (!str2metric (argv[0], &metric)) |
| 6075 | return CMD_WARNING; |
| 6076 | |
| 6077 | /* Get metric type. */ |
| 6078 | if (argc >= 2) |
| 6079 | if (!str2metric_type (argv[1], &type)) |
| 6080 | return CMD_WARNING; |
| 6081 | |
| 6082 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6083 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6084 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6085 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6086 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6087 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6088 | type, metric); |
| 6089 | } |
| 6090 | |
| 6091 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6092 | ospf_default_information_originate_always_metric_type_cmd, |
| 6093 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 6094 | "Control distribution of default information\n" |
| 6095 | "Distribute a default route\n" |
| 6096 | "Always advertise default route\n" |
| 6097 | "OSPF default metric\n" |
| 6098 | "OSPF metric\n" |
| 6099 | "OSPF metric type for default routes\n" |
| 6100 | "Set OSPF External Type 1 metrics\n" |
| 6101 | "Set OSPF External Type 2 metrics\n") |
| 6102 | |
| 6103 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6104 | ospf_default_information_originate_always_metric_cmd, |
| 6105 | "default-information originate always metric <0-16777214>", |
| 6106 | "Control distribution of default information\n" |
| 6107 | "Distribute a default route\n" |
| 6108 | "Always advertise default route\n" |
| 6109 | "OSPF default metric\n" |
| 6110 | "OSPF metric\n" |
| 6111 | "OSPF metric type for default routes\n") |
| 6112 | |
| 6113 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6114 | ospf_default_information_originate_always_cmd, |
| 6115 | "default-information originate always", |
| 6116 | "Control distribution of default information\n" |
| 6117 | "Distribute a default route\n" |
| 6118 | "Always advertise default route\n") |
| 6119 | |
| 6120 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 6121 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 6122 | "default-information originate always metric <0-16777214> route-map WORD", |
| 6123 | "Control distribution of default information\n" |
| 6124 | "Distribute a default route\n" |
| 6125 | "Always advertise default route\n" |
| 6126 | "OSPF default metric\n" |
| 6127 | "OSPF metric\n" |
| 6128 | "Route map reference\n" |
| 6129 | "Pointer to route-map entries\n") |
| 6130 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6131 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6132 | int metric = -1; |
| 6133 | |
| 6134 | /* Get metric value. */ |
| 6135 | if (argc >= 1) |
| 6136 | if (!str2metric (argv[0], &metric)) |
| 6137 | return CMD_WARNING; |
| 6138 | |
| 6139 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6140 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6141 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6142 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6143 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6144 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 6145 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6146 | } |
| 6147 | |
| 6148 | DEFUN (ospf_default_information_originate_always_routemap, |
| 6149 | ospf_default_information_originate_always_routemap_cmd, |
| 6150 | "default-information originate always route-map WORD", |
| 6151 | "Control distribution of default information\n" |
| 6152 | "Distribute a default route\n" |
| 6153 | "Always advertise default route\n" |
| 6154 | "Route map reference\n" |
| 6155 | "Pointer to route-map entries\n") |
| 6156 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6157 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6158 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6159 | if (argc == 1) |
| 6160 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 6161 | else |
| 6162 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6163 | |
| 6164 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6165 | } |
| 6166 | |
| 6167 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 6168 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 6169 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 6170 | "Control distribution of default information\n" |
| 6171 | "Distribute a default route\n" |
| 6172 | "Always advertise default route\n" |
| 6173 | "OSPF metric type for default routes\n" |
| 6174 | "Set OSPF External Type 1 metrics\n" |
| 6175 | "Set OSPF External Type 2 metrics\n" |
| 6176 | "OSPF default metric\n" |
| 6177 | "OSPF metric\n" |
| 6178 | "Route map reference\n" |
| 6179 | "Pointer to route-map entries\n") |
| 6180 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6181 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6182 | int type = -1; |
| 6183 | int metric = -1; |
| 6184 | |
| 6185 | /* Get metric type. */ |
| 6186 | if (argc >= 1) |
| 6187 | if (!str2metric_type (argv[0], &type)) |
| 6188 | return CMD_WARNING; |
| 6189 | |
| 6190 | /* Get metric value. */ |
| 6191 | if (argc >= 2) |
| 6192 | if (!str2metric (argv[1], &metric)) |
| 6193 | return CMD_WARNING; |
| 6194 | |
| 6195 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6196 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6197 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6198 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6199 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6200 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6201 | type, metric); |
| 6202 | } |
| 6203 | |
| 6204 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6205 | ospf_default_information_originate_always_type_metric_cmd, |
| 6206 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 6207 | "Control distribution of default information\n" |
| 6208 | "Distribute a default route\n" |
| 6209 | "Always advertise default route\n" |
| 6210 | "OSPF metric type for default routes\n" |
| 6211 | "Set OSPF External Type 1 metrics\n" |
| 6212 | "Set OSPF External Type 2 metrics\n" |
| 6213 | "OSPF default metric\n" |
| 6214 | "OSPF metric\n") |
| 6215 | |
| 6216 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6217 | ospf_default_information_originate_always_type_cmd, |
| 6218 | "default-information originate always metric-type (1|2)", |
| 6219 | "Control distribution of default information\n" |
| 6220 | "Distribute a default route\n" |
| 6221 | "Always advertise default route\n" |
| 6222 | "OSPF metric type for default routes\n" |
| 6223 | "Set OSPF External Type 1 metrics\n" |
| 6224 | "Set OSPF External Type 2 metrics\n") |
| 6225 | |
| 6226 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 6227 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6228 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6229 | "Control distribution of default information\n" |
| 6230 | "Distribute a default route\n" |
| 6231 | "Always advertise default route\n" |
| 6232 | "OSPF metric type for default routes\n" |
| 6233 | "Set OSPF External Type 1 metrics\n" |
| 6234 | "Set OSPF External Type 2 metrics\n" |
| 6235 | "Route map reference\n" |
| 6236 | "Pointer to route-map entries\n") |
| 6237 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6238 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6239 | int type = -1; |
| 6240 | |
| 6241 | /* Get metric type. */ |
| 6242 | if (argc >= 1) |
| 6243 | if (!str2metric_type (argv[0], &type)) |
| 6244 | return CMD_WARNING; |
| 6245 | |
| 6246 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6247 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6248 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6249 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6250 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6251 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6252 | type, -1); |
| 6253 | } |
| 6254 | |
| 6255 | DEFUN (no_ospf_default_information_originate, |
| 6256 | no_ospf_default_information_originate_cmd, |
| 6257 | "no default-information originate", |
| 6258 | NO_STR |
| 6259 | "Control distribution of default information\n" |
| 6260 | "Distribute a default route\n") |
| 6261 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6262 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6263 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6264 | |
| 6265 | p.family = AF_INET; |
| 6266 | p.prefix.s_addr = 0; |
| 6267 | p.prefixlen = 0; |
| 6268 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6269 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6270 | |
| 6271 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6272 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6273 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6274 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6275 | } |
| 6276 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6277 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6278 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6279 | } |
| 6280 | |
| 6281 | DEFUN (ospf_default_metric, |
| 6282 | ospf_default_metric_cmd, |
| 6283 | "default-metric <0-16777214>", |
| 6284 | "Set metric of redistributed routes\n" |
| 6285 | "Default metric\n") |
| 6286 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6287 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6288 | int metric = -1; |
| 6289 | |
| 6290 | if (!str2metric (argv[0], &metric)) |
| 6291 | return CMD_WARNING; |
| 6292 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6293 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6294 | |
| 6295 | return CMD_SUCCESS; |
| 6296 | } |
| 6297 | |
| 6298 | DEFUN (no_ospf_default_metric, |
| 6299 | no_ospf_default_metric_cmd, |
| 6300 | "no default-metric", |
| 6301 | NO_STR |
| 6302 | "Set metric of redistributed routes\n") |
| 6303 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6304 | struct ospf *ospf = vty->index; |
| 6305 | |
| 6306 | ospf->default_metric = -1; |
| 6307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6308 | return CMD_SUCCESS; |
| 6309 | } |
| 6310 | |
| 6311 | ALIAS (no_ospf_default_metric, |
| 6312 | no_ospf_default_metric_val_cmd, |
| 6313 | "no default-metric <0-16777214>", |
| 6314 | NO_STR |
| 6315 | "Set metric of redistributed routes\n" |
| 6316 | "Default metric\n") |
| 6317 | |
| 6318 | DEFUN (ospf_distance, |
| 6319 | ospf_distance_cmd, |
| 6320 | "distance <1-255>", |
| 6321 | "Define an administrative distance\n" |
| 6322 | "OSPF Administrative distance\n") |
| 6323 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6324 | struct ospf *ospf = vty->index; |
| 6325 | |
| 6326 | ospf->distance_all = atoi (argv[0]); |
| 6327 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6328 | return CMD_SUCCESS; |
| 6329 | } |
| 6330 | |
| 6331 | DEFUN (no_ospf_distance, |
| 6332 | no_ospf_distance_cmd, |
| 6333 | "no distance <1-255>", |
| 6334 | NO_STR |
| 6335 | "Define an administrative distance\n" |
| 6336 | "OSPF Administrative distance\n") |
| 6337 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6338 | struct ospf *ospf = vty->index; |
| 6339 | |
| 6340 | ospf->distance_all = 0; |
| 6341 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6342 | return CMD_SUCCESS; |
| 6343 | } |
| 6344 | |
| 6345 | DEFUN (no_ospf_distance_ospf, |
| 6346 | no_ospf_distance_ospf_cmd, |
| 6347 | "no distance ospf", |
| 6348 | NO_STR |
| 6349 | "Define an administrative distance\n" |
| 6350 | "OSPF Administrative distance\n" |
| 6351 | "OSPF Distance\n") |
| 6352 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6353 | struct ospf *ospf = vty->index; |
| 6354 | |
| 6355 | ospf->distance_intra = 0; |
| 6356 | ospf->distance_inter = 0; |
| 6357 | ospf->distance_external = 0; |
| 6358 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6359 | return CMD_SUCCESS; |
| 6360 | } |
| 6361 | |
| 6362 | DEFUN (ospf_distance_ospf_intra, |
| 6363 | ospf_distance_ospf_intra_cmd, |
| 6364 | "distance ospf intra-area <1-255>", |
| 6365 | "Define an administrative distance\n" |
| 6366 | "OSPF Administrative distance\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_intra = atoi (argv[0]); |
| 6373 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6374 | return CMD_SUCCESS; |
| 6375 | } |
| 6376 | |
| 6377 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6378 | ospf_distance_ospf_intra_inter_cmd, |
| 6379 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6380 | "Define an administrative distance\n" |
| 6381 | "OSPF Administrative distance\n" |
| 6382 | "Intra-area routes\n" |
| 6383 | "Distance for intra-area routes\n" |
| 6384 | "Inter-area routes\n" |
| 6385 | "Distance for inter-area routes\n") |
| 6386 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6387 | struct ospf *ospf = vty->index; |
| 6388 | |
| 6389 | ospf->distance_intra = atoi (argv[0]); |
| 6390 | ospf->distance_inter = atoi (argv[1]); |
| 6391 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6392 | return CMD_SUCCESS; |
| 6393 | } |
| 6394 | |
| 6395 | DEFUN (ospf_distance_ospf_intra_external, |
| 6396 | ospf_distance_ospf_intra_external_cmd, |
| 6397 | "distance ospf intra-area <1-255> external <1-255>", |
| 6398 | "Define an administrative distance\n" |
| 6399 | "OSPF Administrative distance\n" |
| 6400 | "Intra-area routes\n" |
| 6401 | "Distance for intra-area routes\n" |
| 6402 | "External routes\n" |
| 6403 | "Distance for external routes\n") |
| 6404 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6405 | struct ospf *ospf = vty->index; |
| 6406 | |
| 6407 | ospf->distance_intra = atoi (argv[0]); |
| 6408 | ospf->distance_external = atoi (argv[1]); |
| 6409 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6410 | return CMD_SUCCESS; |
| 6411 | } |
| 6412 | |
| 6413 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6414 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6415 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6416 | "Define an administrative distance\n" |
| 6417 | "OSPF Administrative distance\n" |
| 6418 | "Intra-area routes\n" |
| 6419 | "Distance for intra-area routes\n" |
| 6420 | "Inter-area routes\n" |
| 6421 | "Distance for inter-area routes\n" |
| 6422 | "External routes\n" |
| 6423 | "Distance for external routes\n") |
| 6424 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6425 | struct ospf *ospf = vty->index; |
| 6426 | |
| 6427 | ospf->distance_intra = atoi (argv[0]); |
| 6428 | ospf->distance_inter = atoi (argv[1]); |
| 6429 | ospf->distance_external = atoi (argv[2]); |
| 6430 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6431 | return CMD_SUCCESS; |
| 6432 | } |
| 6433 | |
| 6434 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6435 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6436 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6437 | "Define an administrative distance\n" |
| 6438 | "OSPF Administrative distance\n" |
| 6439 | "Intra-area routes\n" |
| 6440 | "Distance for intra-area routes\n" |
| 6441 | "External routes\n" |
| 6442 | "Distance for external routes\n" |
| 6443 | "Inter-area routes\n" |
| 6444 | "Distance for inter-area routes\n") |
| 6445 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6446 | struct ospf *ospf = vty->index; |
| 6447 | |
| 6448 | ospf->distance_intra = atoi (argv[0]); |
| 6449 | ospf->distance_external = atoi (argv[1]); |
| 6450 | ospf->distance_inter = atoi (argv[2]); |
| 6451 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6452 | return CMD_SUCCESS; |
| 6453 | } |
| 6454 | |
| 6455 | DEFUN (ospf_distance_ospf_inter, |
| 6456 | ospf_distance_ospf_inter_cmd, |
| 6457 | "distance ospf inter-area <1-255>", |
| 6458 | "Define an administrative distance\n" |
| 6459 | "OSPF Administrative distance\n" |
| 6460 | "Inter-area routes\n" |
| 6461 | "Distance for inter-area routes\n") |
| 6462 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6463 | struct ospf *ospf = vty->index; |
| 6464 | |
| 6465 | ospf->distance_inter = atoi (argv[0]); |
| 6466 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6467 | return CMD_SUCCESS; |
| 6468 | } |
| 6469 | |
| 6470 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6471 | ospf_distance_ospf_inter_intra_cmd, |
| 6472 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6473 | "Define an administrative distance\n" |
| 6474 | "OSPF Administrative distance\n" |
| 6475 | "Inter-area routes\n" |
| 6476 | "Distance for inter-area routes\n" |
| 6477 | "Intra-area routes\n" |
| 6478 | "Distance for intra-area routes\n") |
| 6479 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6480 | struct ospf *ospf = vty->index; |
| 6481 | |
| 6482 | ospf->distance_inter = atoi (argv[0]); |
| 6483 | ospf->distance_intra = atoi (argv[1]); |
| 6484 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6485 | return CMD_SUCCESS; |
| 6486 | } |
| 6487 | |
| 6488 | DEFUN (ospf_distance_ospf_inter_external, |
| 6489 | ospf_distance_ospf_inter_external_cmd, |
| 6490 | "distance ospf inter-area <1-255> external <1-255>", |
| 6491 | "Define an administrative distance\n" |
| 6492 | "OSPF Administrative distance\n" |
| 6493 | "Inter-area routes\n" |
| 6494 | "Distance for inter-area routes\n" |
| 6495 | "External routes\n" |
| 6496 | "Distance for external routes\n") |
| 6497 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6498 | struct ospf *ospf = vty->index; |
| 6499 | |
| 6500 | ospf->distance_inter = atoi (argv[0]); |
| 6501 | ospf->distance_external = atoi (argv[1]); |
| 6502 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6503 | return CMD_SUCCESS; |
| 6504 | } |
| 6505 | |
| 6506 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6507 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6508 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6509 | "Define an administrative distance\n" |
| 6510 | "OSPF Administrative distance\n" |
| 6511 | "Inter-area routes\n" |
| 6512 | "Distance for inter-area routes\n" |
| 6513 | "Intra-area routes\n" |
| 6514 | "Distance for intra-area routes\n" |
| 6515 | "External routes\n" |
| 6516 | "Distance for external routes\n") |
| 6517 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6518 | struct ospf *ospf = vty->index; |
| 6519 | |
| 6520 | ospf->distance_inter = atoi (argv[0]); |
| 6521 | ospf->distance_intra = atoi (argv[1]); |
| 6522 | ospf->distance_external = atoi (argv[2]); |
| 6523 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6524 | return CMD_SUCCESS; |
| 6525 | } |
| 6526 | |
| 6527 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6528 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6529 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6530 | "Define an administrative distance\n" |
| 6531 | "OSPF Administrative distance\n" |
| 6532 | "Inter-area routes\n" |
| 6533 | "Distance for inter-area routes\n" |
| 6534 | "External routes\n" |
| 6535 | "Distance for external routes\n" |
| 6536 | "Intra-area routes\n" |
| 6537 | "Distance for intra-area routes\n") |
| 6538 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6539 | struct ospf *ospf = vty->index; |
| 6540 | |
| 6541 | ospf->distance_inter = atoi (argv[0]); |
| 6542 | ospf->distance_external = atoi (argv[1]); |
| 6543 | ospf->distance_intra = atoi (argv[2]); |
| 6544 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6545 | return CMD_SUCCESS; |
| 6546 | } |
| 6547 | |
| 6548 | DEFUN (ospf_distance_ospf_external, |
| 6549 | ospf_distance_ospf_external_cmd, |
| 6550 | "distance ospf external <1-255>", |
| 6551 | "Define an administrative distance\n" |
| 6552 | "OSPF Administrative distance\n" |
| 6553 | "External routes\n" |
| 6554 | "Distance for external routes\n") |
| 6555 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6556 | struct ospf *ospf = vty->index; |
| 6557 | |
| 6558 | ospf->distance_external = atoi (argv[0]); |
| 6559 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6560 | return CMD_SUCCESS; |
| 6561 | } |
| 6562 | |
| 6563 | DEFUN (ospf_distance_ospf_external_intra, |
| 6564 | ospf_distance_ospf_external_intra_cmd, |
| 6565 | "distance ospf external <1-255> intra-area <1-255>", |
| 6566 | "Define an administrative distance\n" |
| 6567 | "OSPF Administrative distance\n" |
| 6568 | "External routes\n" |
| 6569 | "Distance for external routes\n" |
| 6570 | "Intra-area routes\n" |
| 6571 | "Distance for intra-area routes\n") |
| 6572 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6573 | struct ospf *ospf = vty->index; |
| 6574 | |
| 6575 | ospf->distance_external = atoi (argv[0]); |
| 6576 | ospf->distance_intra = atoi (argv[1]); |
| 6577 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6578 | return CMD_SUCCESS; |
| 6579 | } |
| 6580 | |
| 6581 | DEFUN (ospf_distance_ospf_external_inter, |
| 6582 | ospf_distance_ospf_external_inter_cmd, |
| 6583 | "distance ospf external <1-255> inter-area <1-255>", |
| 6584 | "Define an administrative distance\n" |
| 6585 | "OSPF Administrative distance\n" |
| 6586 | "External routes\n" |
| 6587 | "Distance for external routes\n" |
| 6588 | "Inter-area routes\n" |
| 6589 | "Distance for inter-area routes\n") |
| 6590 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6591 | struct ospf *ospf = vty->index; |
| 6592 | |
| 6593 | ospf->distance_external = atoi (argv[0]); |
| 6594 | ospf->distance_inter = atoi (argv[1]); |
| 6595 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6596 | return CMD_SUCCESS; |
| 6597 | } |
| 6598 | |
| 6599 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6600 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6601 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6602 | "Define an administrative distance\n" |
| 6603 | "OSPF Administrative distance\n" |
| 6604 | "External routes\n" |
| 6605 | "Distance for external routes\n" |
| 6606 | "Intra-area routes\n" |
| 6607 | "Distance for intra-area routes\n" |
| 6608 | "Inter-area routes\n" |
| 6609 | "Distance for inter-area routes\n") |
| 6610 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6611 | struct ospf *ospf = vty->index; |
| 6612 | |
| 6613 | ospf->distance_external = atoi (argv[0]); |
| 6614 | ospf->distance_intra = atoi (argv[1]); |
| 6615 | ospf->distance_inter = atoi (argv[2]); |
| 6616 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6617 | return CMD_SUCCESS; |
| 6618 | } |
| 6619 | |
| 6620 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6621 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6622 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6623 | "Define an administrative distance\n" |
| 6624 | "OSPF Administrative distance\n" |
| 6625 | "External routes\n" |
| 6626 | "Distance for external routes\n" |
| 6627 | "Inter-area routes\n" |
| 6628 | "Distance for inter-area routes\n" |
| 6629 | "Intra-area routes\n" |
| 6630 | "Distance for intra-area routes\n") |
| 6631 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6632 | struct ospf *ospf = vty->index; |
| 6633 | |
| 6634 | ospf->distance_external = atoi (argv[0]); |
| 6635 | ospf->distance_inter = atoi (argv[1]); |
| 6636 | ospf->distance_intra = atoi (argv[2]); |
| 6637 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6638 | return CMD_SUCCESS; |
| 6639 | } |
| 6640 | |
| 6641 | DEFUN (ospf_distance_source, |
| 6642 | ospf_distance_source_cmd, |
| 6643 | "distance <1-255> A.B.C.D/M", |
| 6644 | "Administrative distance\n" |
| 6645 | "Distance value\n" |
| 6646 | "IP source prefix\n") |
| 6647 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6648 | struct ospf *ospf = vty->index; |
| 6649 | |
| 6650 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6651 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6652 | return CMD_SUCCESS; |
| 6653 | } |
| 6654 | |
| 6655 | DEFUN (no_ospf_distance_source, |
| 6656 | no_ospf_distance_source_cmd, |
| 6657 | "no distance <1-255> A.B.C.D/M", |
| 6658 | NO_STR |
| 6659 | "Administrative distance\n" |
| 6660 | "Distance value\n" |
| 6661 | "IP source prefix\n") |
| 6662 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6663 | struct ospf *ospf = vty->index; |
| 6664 | |
| 6665 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6666 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6667 | return CMD_SUCCESS; |
| 6668 | } |
| 6669 | |
| 6670 | DEFUN (ospf_distance_source_access_list, |
| 6671 | ospf_distance_source_access_list_cmd, |
| 6672 | "distance <1-255> A.B.C.D/M WORD", |
| 6673 | "Administrative distance\n" |
| 6674 | "Distance value\n" |
| 6675 | "IP source prefix\n" |
| 6676 | "Access list name\n") |
| 6677 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6678 | struct ospf *ospf = vty->index; |
| 6679 | |
| 6680 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6681 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6682 | return CMD_SUCCESS; |
| 6683 | } |
| 6684 | |
| 6685 | DEFUN (no_ospf_distance_source_access_list, |
| 6686 | no_ospf_distance_source_access_list_cmd, |
| 6687 | "no distance <1-255> A.B.C.D/M WORD", |
| 6688 | NO_STR |
| 6689 | "Administrative distance\n" |
| 6690 | "Distance value\n" |
| 6691 | "IP source prefix\n" |
| 6692 | "Access list name\n") |
| 6693 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6694 | struct ospf *ospf = vty->index; |
| 6695 | |
| 6696 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6698 | return CMD_SUCCESS; |
| 6699 | } |
| 6700 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6701 | DEFUN (ip_ospf_mtu_ignore, |
| 6702 | ip_ospf_mtu_ignore_addr_cmd, |
| 6703 | "ip ospf mtu-ignore A.B.C.D", |
| 6704 | "IP Information\n" |
| 6705 | "OSPF interface commands\n" |
| 6706 | "Disable mtu mismatch detection\n" |
| 6707 | "Address of interface") |
| 6708 | { |
| 6709 | struct interface *ifp = vty->index; |
| 6710 | struct in_addr addr; |
| 6711 | int ret; |
| 6712 | |
| 6713 | struct ospf_if_params *params; |
| 6714 | params = IF_DEF_PARAMS (ifp); |
| 6715 | |
| 6716 | if (argc == 1) |
| 6717 | { |
| 6718 | ret = inet_aton(argv[0], &addr); |
| 6719 | if (!ret) |
| 6720 | { |
| 6721 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6722 | VTY_NEWLINE); |
| 6723 | return CMD_WARNING; |
| 6724 | } |
| 6725 | params = ospf_get_if_params (ifp, addr); |
| 6726 | ospf_if_update_params (ifp, addr); |
| 6727 | } |
| 6728 | params->mtu_ignore = 1; |
| 6729 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6730 | SET_IF_PARAM (params, mtu_ignore); |
| 6731 | else |
| 6732 | { |
| 6733 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6734 | if (params != IF_DEF_PARAMS (ifp)) |
| 6735 | { |
| 6736 | ospf_free_if_params (ifp, addr); |
| 6737 | ospf_if_update_params (ifp, addr); |
| 6738 | } |
| 6739 | } |
| 6740 | return CMD_SUCCESS; |
| 6741 | } |
| 6742 | |
| 6743 | ALIAS (ip_ospf_mtu_ignore, |
| 6744 | ip_ospf_mtu_ignore_cmd, |
| 6745 | "ip ospf mtu-ignore", |
| 6746 | "IP Information\n" |
| 6747 | "OSPF interface commands\n" |
| 6748 | "Disable mtu mismatch detection\n") |
| 6749 | |
| 6750 | |
| 6751 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6752 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6753 | "no ip ospf mtu-ignore A.B.C.D", |
| 6754 | "IP Information\n" |
| 6755 | "OSPF interface commands\n" |
| 6756 | "Disable mtu mismatch detection\n" |
| 6757 | "Address of interface") |
| 6758 | { |
| 6759 | struct interface *ifp = vty->index; |
| 6760 | struct in_addr addr; |
| 6761 | int ret; |
| 6762 | |
| 6763 | struct ospf_if_params *params; |
| 6764 | params = IF_DEF_PARAMS (ifp); |
| 6765 | |
| 6766 | if (argc == 1) |
| 6767 | { |
| 6768 | ret = inet_aton(argv[0], &addr); |
| 6769 | if (!ret) |
| 6770 | { |
| 6771 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6772 | VTY_NEWLINE); |
| 6773 | return CMD_WARNING; |
| 6774 | } |
| 6775 | params = ospf_get_if_params (ifp, addr); |
| 6776 | ospf_if_update_params (ifp, addr); |
| 6777 | } |
| 6778 | params->mtu_ignore = 0; |
| 6779 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6780 | SET_IF_PARAM (params, mtu_ignore); |
| 6781 | else |
| 6782 | { |
| 6783 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6784 | if (params != IF_DEF_PARAMS (ifp)) |
| 6785 | { |
| 6786 | ospf_free_if_params (ifp, addr); |
| 6787 | ospf_if_update_params (ifp, addr); |
| 6788 | } |
| 6789 | } |
| 6790 | return CMD_SUCCESS; |
| 6791 | } |
| 6792 | |
| 6793 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6794 | no_ip_ospf_mtu_ignore_cmd, |
| 6795 | "no ip ospf mtu-ignore", |
| 6796 | "IP Information\n" |
| 6797 | "OSPF interface commands\n" |
| 6798 | "Disable mtu mismatch detection\n") |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6799 | |
| 6800 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6801 | ospf_max_metric_router_lsa_admin_cmd, |
| 6802 | "max-metric router-lsa administrative", |
| 6803 | "OSPF maximum / infinite-distance metric\n" |
| 6804 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6805 | "Administratively applied, for an indefinite period\n") |
| 6806 | { |
| 6807 | struct listnode *ln; |
| 6808 | struct ospf_area *area; |
| 6809 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6810 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6811 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6812 | { |
| 6813 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6814 | |
| 6815 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 6816 | ospf_router_lsa_timer_add (area); |
| 6817 | } |
| 6818 | return CMD_SUCCESS; |
| 6819 | } |
| 6820 | |
| 6821 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6822 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6823 | "no max-metric router-lsa administrative", |
| 6824 | NO_STR |
| 6825 | "OSPF maximum / infinite-distance metric\n" |
| 6826 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6827 | "Administratively applied, for an indefinite period\n") |
| 6828 | { |
| 6829 | struct listnode *ln; |
| 6830 | struct ospf_area *area; |
| 6831 | struct ospf *ospf = vty->index; |
| 6832 | |
| 6833 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6834 | { |
| 6835 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6836 | |
| 6837 | /* Don't trample on the start-up stub timer */ |
| 6838 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6839 | && !area->t_stub_router) |
| 6840 | { |
| 6841 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6842 | ospf_router_lsa_timer_add (area); |
| 6843 | } |
| 6844 | } |
| 6845 | return CMD_SUCCESS; |
| 6846 | } |
| 6847 | |
| 6848 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6849 | ospf_max_metric_router_lsa_startup_cmd, |
| 6850 | "max-metric router-lsa on-startup <5-86400>", |
| 6851 | "OSPF maximum / infinite-distance metric\n" |
| 6852 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6853 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6854 | "Time (seconds) to advertise self as stub-router\n") |
| 6855 | { |
| 6856 | unsigned int seconds; |
| 6857 | struct ospf *ospf = vty->index; |
| 6858 | |
| 6859 | if (argc != 1) |
| 6860 | { |
| 6861 | vty_out (vty, "%% Must supply stub-router period"); |
| 6862 | return CMD_WARNING; |
| 6863 | } |
| 6864 | |
| 6865 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6866 | |
| 6867 | ospf->stub_router_startup_time = seconds; |
| 6868 | |
| 6869 | return CMD_SUCCESS; |
| 6870 | } |
| 6871 | |
| 6872 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6873 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6874 | "no max-metric router-lsa on-startup", |
| 6875 | NO_STR |
| 6876 | "OSPF maximum / infinite-distance metric\n" |
| 6877 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6878 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6879 | { |
| 6880 | struct listnode *ln; |
| 6881 | struct ospf_area *area; |
| 6882 | struct ospf *ospf = vty->index; |
| 6883 | |
| 6884 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6885 | |
| 6886 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6887 | { |
| 6888 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 6889 | OSPF_TIMER_OFF (area->t_stub_router); |
| 6890 | |
| 6891 | /* Don't trample on admin stub routed */ |
| 6892 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6893 | { |
| 6894 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6895 | ospf_router_lsa_timer_add (area); |
| 6896 | } |
| 6897 | } |
| 6898 | return CMD_SUCCESS; |
| 6899 | } |
| 6900 | |
| 6901 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 6902 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 6903 | "max-metric router-lsa on-shutdown <5-86400>", |
| 6904 | "OSPF maximum / infinite-distance metric\n" |
| 6905 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6906 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 6907 | "Time (seconds) to wait till full shutdown\n") |
| 6908 | { |
| 6909 | unsigned int seconds; |
| 6910 | struct ospf *ospf = vty->index; |
| 6911 | |
| 6912 | if (argc != 1) |
| 6913 | { |
| 6914 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 6915 | return CMD_WARNING; |
| 6916 | } |
| 6917 | |
| 6918 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 6919 | |
| 6920 | ospf->stub_router_shutdown_time = seconds; |
| 6921 | |
| 6922 | return CMD_SUCCESS; |
| 6923 | } |
| 6924 | |
| 6925 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 6926 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 6927 | "no max-metric router-lsa on-shutdown", |
| 6928 | NO_STR |
| 6929 | "OSPF maximum / infinite-distance metric\n" |
| 6930 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6931 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 6932 | { |
| 6933 | struct ospf *ospf = vty->index; |
| 6934 | |
| 6935 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6936 | |
| 6937 | return CMD_SUCCESS; |
| 6938 | } |
| 6939 | |
| 6940 | static void |
| 6941 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 6942 | { |
| 6943 | struct listnode *ln; |
| 6944 | struct ospf_area *area; |
| 6945 | |
| 6946 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6947 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 6948 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 6949 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6950 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 6951 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 6952 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6953 | { |
| 6954 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6955 | { |
| 6956 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 6957 | VTY_NEWLINE); |
| 6958 | break; |
| 6959 | } |
| 6960 | } |
| 6961 | return; |
| 6962 | } |
| 6963 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6964 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6965 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6966 | { |
| 6967 | struct route_node *rn; |
| 6968 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6969 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6970 | struct ospf_path *path; |
| 6971 | |
| 6972 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6973 | VTY_NEWLINE); |
| 6974 | |
| 6975 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6976 | if ((or = rn->info) != NULL) |
| 6977 | { |
| 6978 | char buf1[19]; |
| 6979 | snprintf (buf1, 19, "%s/%d", |
| 6980 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6981 | |
| 6982 | switch (or->path_type) |
| 6983 | { |
| 6984 | case OSPF_PATH_INTER_AREA: |
| 6985 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6986 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6987 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6988 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6989 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6990 | break; |
| 6991 | case OSPF_PATH_INTRA_AREA: |
| 6992 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6993 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6994 | break; |
| 6995 | default: |
| 6996 | break; |
| 6997 | } |
| 6998 | |
| 6999 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7000 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7001 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7002 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7003 | { |
| 7004 | if (path->nexthop.s_addr == 0) |
| 7005 | vty_out (vty, "%24s directly attached to %s%s", |
| 7006 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7007 | else |
| 7008 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7009 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7010 | VTY_NEWLINE); |
| 7011 | } |
| 7012 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7013 | } |
| 7014 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7015 | } |
| 7016 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7017 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7018 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 7019 | { |
| 7020 | struct route_node *rn; |
| 7021 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7022 | struct listnode *pnode; |
| 7023 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7024 | struct ospf_path *path; |
| 7025 | |
| 7026 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 7027 | VTY_NEWLINE); |
| 7028 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 7029 | if (rn->info) |
| 7030 | { |
| 7031 | int flag = 0; |
| 7032 | |
| 7033 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 7034 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7035 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 7036 | { |
| 7037 | if (flag++) |
| 7038 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7039 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7040 | /* Show path. */ |
| 7041 | vty_out (vty, "%s [%d] area: %s", |
| 7042 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 7043 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 7044 | /* Show flags. */ |
| 7045 | vty_out (vty, "%s%s%s", |
| 7046 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 7047 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 7048 | VTY_NEWLINE); |
| 7049 | |
| 7050 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 7051 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7052 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
| 7053 | { |
| 7054 | if (path->nexthop.s_addr == 0) |
| 7055 | vty_out (vty, "%24s directly attached to %s%s", |
| 7056 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7057 | else |
| 7058 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7059 | inet_ntoa (path->nexthop), |
| 7060 | path->oi->ifp->name, VTY_NEWLINE); |
| 7061 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7062 | } |
| 7063 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7064 | } |
| 7065 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7066 | } |
| 7067 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7068 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7069 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 7070 | { |
| 7071 | struct route_node *rn; |
| 7072 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7073 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7074 | struct ospf_path *path; |
| 7075 | |
| 7076 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 7077 | VTY_NEWLINE); |
| 7078 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 7079 | if ((er = rn->info) != NULL) |
| 7080 | { |
| 7081 | char buf1[19]; |
| 7082 | snprintf (buf1, 19, "%s/%d", |
| 7083 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 7084 | |
| 7085 | switch (er->path_type) |
| 7086 | { |
| 7087 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 7088 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 7089 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 7090 | break; |
| 7091 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 7092 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 7093 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 7094 | break; |
| 7095 | } |
| 7096 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7097 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7098 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7099 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7100 | { |
| 7101 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7102 | vty_out (vty, "%24s directly attached to %s%s", |
| 7103 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7104 | else |
| 7105 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7106 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7107 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7108 | } |
| 7109 | } |
| 7110 | } |
| 7111 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7112 | } |
| 7113 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7114 | DEFUN (show_ip_ospf_border_routers, |
| 7115 | show_ip_ospf_border_routers_cmd, |
| 7116 | "show ip ospf border-routers", |
| 7117 | SHOW_STR |
| 7118 | IP_STR |
| 7119 | "show all the ABR's and ASBR's\n" |
| 7120 | "for this area\n") |
| 7121 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7122 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7123 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7124 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7125 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7126 | { |
| 7127 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 7128 | return CMD_SUCCESS; |
| 7129 | } |
| 7130 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7131 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7132 | { |
| 7133 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7134 | return CMD_SUCCESS; |
| 7135 | } |
| 7136 | |
| 7137 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7138 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7139 | |
| 7140 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7141 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7142 | |
| 7143 | return CMD_SUCCESS; |
| 7144 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7145 | |
| 7146 | DEFUN (show_ip_ospf_route, |
| 7147 | show_ip_ospf_route_cmd, |
| 7148 | "show ip ospf route", |
| 7149 | SHOW_STR |
| 7150 | IP_STR |
| 7151 | "OSPF information\n" |
| 7152 | "OSPF routing table\n") |
| 7153 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7154 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7155 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7156 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7157 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7158 | { |
| 7159 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 7160 | return CMD_SUCCESS; |
| 7161 | } |
| 7162 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7163 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7164 | { |
| 7165 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7166 | return CMD_SUCCESS; |
| 7167 | } |
| 7168 | |
| 7169 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7170 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7171 | |
| 7172 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7173 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7174 | |
| 7175 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7176 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7177 | |
| 7178 | return CMD_SUCCESS; |
| 7179 | } |
| 7180 | |
| 7181 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7182 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7183 | { |
| 7184 | "unknown", |
| 7185 | "standard", |
| 7186 | "ibm", |
| 7187 | "cisco", |
| 7188 | "shortcut" |
| 7189 | }; |
| 7190 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7191 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7192 | { |
| 7193 | "default", |
| 7194 | "enable", |
| 7195 | "disable" |
| 7196 | }; |
| 7197 | |
| 7198 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7199 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7200 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 7201 | { |
| 7202 | memset (buf, 0, length); |
| 7203 | |
| 7204 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 7205 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 7206 | else |
| 7207 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 7208 | } |
| 7209 | |
| 7210 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7211 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7212 | { |
| 7213 | "unknown", /* should never be used. */ |
| 7214 | "point-to-point", |
| 7215 | "broadcast", |
| 7216 | "non-broadcast", |
| 7217 | "point-to-multipoint", |
| 7218 | "virtual-link", /* should never be used. */ |
| 7219 | "loopback" |
| 7220 | }; |
| 7221 | |
| 7222 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7223 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7224 | config_write_interface (struct vty *vty) |
| 7225 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7226 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7227 | struct interface *ifp; |
| 7228 | struct crypt_key *ck; |
| 7229 | int write = 0; |
| 7230 | struct route_node *rn = NULL; |
| 7231 | struct ospf_if_params *params; |
| 7232 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7233 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7234 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7235 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 7236 | continue; |
| 7237 | |
| 7238 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 7239 | vty_out (vty, "interface %s%s", ifp->name, |
| 7240 | VTY_NEWLINE); |
| 7241 | if (ifp->desc) |
| 7242 | vty_out (vty, " description %s%s", ifp->desc, |
| 7243 | VTY_NEWLINE); |
| 7244 | |
| 7245 | write++; |
| 7246 | |
| 7247 | params = IF_DEF_PARAMS (ifp); |
| 7248 | |
| 7249 | do { |
| 7250 | /* Interface Network print. */ |
| 7251 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7252 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 7253 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 7254 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 7255 | { |
| 7256 | vty_out (vty, " ip ospf network %s", |
| 7257 | ospf_int_type_str[params->type]); |
| 7258 | if (params != IF_DEF_PARAMS (ifp)) |
| 7259 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7260 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7261 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7262 | } |
| 7263 | |
| 7264 | /* OSPF interface authentication print */ |
| 7265 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 7266 | params->auth_type != OSPF_AUTH_NOTSET) |
| 7267 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7268 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7269 | |
| 7270 | /* Translation tables are not that much help here due to syntax |
| 7271 | of the simple option */ |
| 7272 | switch (params->auth_type) |
| 7273 | { |
| 7274 | |
| 7275 | case OSPF_AUTH_NULL: |
| 7276 | auth_str = " null"; |
| 7277 | break; |
| 7278 | |
| 7279 | case OSPF_AUTH_SIMPLE: |
| 7280 | auth_str = ""; |
| 7281 | break; |
| 7282 | |
| 7283 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 7284 | auth_str = " message-digest"; |
| 7285 | break; |
| 7286 | |
| 7287 | default: |
| 7288 | auth_str = ""; |
| 7289 | break; |
| 7290 | } |
| 7291 | |
| 7292 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 7293 | if (params != IF_DEF_PARAMS (ifp)) |
| 7294 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7295 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7296 | } |
| 7297 | |
| 7298 | /* Simple Authentication Password print. */ |
| 7299 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 7300 | params->auth_simple[0] != '\0') |
| 7301 | { |
| 7302 | vty_out (vty, " ip ospf authentication-key %s", |
| 7303 | params->auth_simple); |
| 7304 | if (params != IF_DEF_PARAMS (ifp)) |
| 7305 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7306 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7307 | } |
| 7308 | |
| 7309 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7310 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7311 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7312 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 7313 | ck->key_id, ck->auth_key); |
| 7314 | if (params != IF_DEF_PARAMS (ifp)) |
| 7315 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7316 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7317 | } |
| 7318 | |
| 7319 | /* Interface Output Cost print. */ |
| 7320 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 7321 | { |
| 7322 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 7323 | if (params != IF_DEF_PARAMS (ifp)) |
| 7324 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7325 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7326 | } |
| 7327 | |
| 7328 | /* Hello Interval print. */ |
| 7329 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 7330 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 7331 | { |
| 7332 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 7333 | if (params != IF_DEF_PARAMS (ifp)) |
| 7334 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7335 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7336 | } |
| 7337 | |
| 7338 | |
| 7339 | /* Router Dead Interval print. */ |
| 7340 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 7341 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 7342 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7343 | vty_out (vty, " ip ospf dead-interval "); |
| 7344 | |
| 7345 | /* fast hello ? */ |
| 7346 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 7347 | vty_out (vty, "minimal hello-multiplier %d", |
| 7348 | params->fast_hello); |
| 7349 | else |
| 7350 | vty_out (vty, "%u", params->v_wait); |
| 7351 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7352 | if (params != IF_DEF_PARAMS (ifp)) |
| 7353 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7354 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7355 | } |
| 7356 | |
| 7357 | /* Router Priority print. */ |
| 7358 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 7359 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 7360 | { |
| 7361 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 7362 | if (params != IF_DEF_PARAMS (ifp)) |
| 7363 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7364 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7365 | } |
| 7366 | |
| 7367 | /* Retransmit Interval print. */ |
| 7368 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 7369 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 7370 | { |
| 7371 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 7372 | params->retransmit_interval); |
| 7373 | if (params != IF_DEF_PARAMS (ifp)) |
| 7374 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7375 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7376 | } |
| 7377 | |
| 7378 | /* Transmit Delay print. */ |
| 7379 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 7380 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7381 | { |
| 7382 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 7383 | if (params != IF_DEF_PARAMS (ifp)) |
| 7384 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7385 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7386 | } |
| 7387 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7388 | /* MTU ignore print. */ |
| 7389 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 7390 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 7391 | { |
| 7392 | if (params->mtu_ignore == 0) |
| 7393 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 7394 | else |
| 7395 | vty_out (vty, " ip ospf mtu-ignore"); |
| 7396 | if (params != IF_DEF_PARAMS (ifp)) |
| 7397 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7398 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7399 | } |
| 7400 | |
| 7401 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7402 | while (1) |
| 7403 | { |
| 7404 | if (rn == NULL) |
| 7405 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 7406 | else |
| 7407 | rn = route_next (rn); |
| 7408 | |
| 7409 | if (rn == NULL) |
| 7410 | break; |
| 7411 | params = rn->info; |
| 7412 | if (params != NULL) |
| 7413 | break; |
| 7414 | } |
| 7415 | } while (rn); |
| 7416 | |
| 7417 | #ifdef HAVE_OPAQUE_LSA |
| 7418 | ospf_opaque_config_write_if (vty, ifp); |
| 7419 | #endif /* HAVE_OPAQUE_LSA */ |
| 7420 | } |
| 7421 | |
| 7422 | return write; |
| 7423 | } |
| 7424 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7425 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7426 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7427 | { |
| 7428 | struct route_node *rn; |
| 7429 | u_char buf[INET_ADDRSTRLEN]; |
| 7430 | |
| 7431 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7432 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7433 | if (rn->info) |
| 7434 | { |
| 7435 | struct ospf_network *n = rn->info; |
| 7436 | |
| 7437 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7438 | |
| 7439 | /* Create Area ID string by specified Area ID format. */ |
| 7440 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7441 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7442 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7443 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7444 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7445 | |
| 7446 | /* Network print. */ |
| 7447 | vty_out (vty, " network %s/%d area %s%s", |
| 7448 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7449 | buf, VTY_NEWLINE); |
| 7450 | } |
| 7451 | |
| 7452 | return 0; |
| 7453 | } |
| 7454 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7455 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7456 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7457 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7458 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7459 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7460 | u_char buf[INET_ADDRSTRLEN]; |
| 7461 | |
| 7462 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7463 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7464 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7465 | struct route_node *rn1; |
| 7466 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7467 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7468 | |
| 7469 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7470 | { |
| 7471 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7472 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7473 | else |
| 7474 | vty_out (vty, " area %s authentication message-digest%s", |
| 7475 | buf, VTY_NEWLINE); |
| 7476 | } |
| 7477 | |
| 7478 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7479 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7480 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7481 | VTY_NEWLINE); |
| 7482 | |
| 7483 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7484 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7485 | ) |
| 7486 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7487 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7488 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7489 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7490 | { |
| 7491 | vty_out (vty, " area %s nssa", buf); |
| 7492 | switch (area->NSSATranslatorRole) |
| 7493 | { |
| 7494 | case OSPF_NSSA_ROLE_NEVER: |
| 7495 | vty_out (vty, " translate-never"); |
| 7496 | break; |
| 7497 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7498 | vty_out (vty, " translate-always"); |
| 7499 | break; |
| 7500 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7501 | default: |
| 7502 | vty_out (vty, " translate-candidate"); |
| 7503 | } |
| 7504 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7505 | |
| 7506 | if (area->no_summary) |
| 7507 | vty_out (vty, " no-summary"); |
| 7508 | |
| 7509 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7510 | |
| 7511 | if (area->default_cost != 1) |
| 7512 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7513 | area->default_cost, VTY_NEWLINE); |
| 7514 | } |
| 7515 | |
| 7516 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7517 | if (rn1->info) |
| 7518 | { |
| 7519 | struct ospf_area_range *range = rn1->info; |
| 7520 | |
| 7521 | vty_out (vty, " area %s range %s/%d", buf, |
| 7522 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7523 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7524 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7525 | vty_out (vty, " cost %d", range->cost_config); |
| 7526 | |
| 7527 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7528 | vty_out (vty, " not-advertise"); |
| 7529 | |
| 7530 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7531 | vty_out (vty, " substitute %s/%d", |
| 7532 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7533 | |
| 7534 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7535 | } |
| 7536 | |
| 7537 | if (EXPORT_NAME (area)) |
| 7538 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7539 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7540 | |
| 7541 | if (IMPORT_NAME (area)) |
| 7542 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7543 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7544 | |
| 7545 | if (PREFIX_NAME_IN (area)) |
| 7546 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7547 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7548 | |
| 7549 | if (PREFIX_NAME_OUT (area)) |
| 7550 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7551 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7552 | } |
| 7553 | |
| 7554 | return 0; |
| 7555 | } |
| 7556 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7557 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7558 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7559 | { |
| 7560 | struct ospf_nbr_nbma *nbr_nbma; |
| 7561 | struct route_node *rn; |
| 7562 | |
| 7563 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7564 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7565 | if ((nbr_nbma = rn->info)) |
| 7566 | { |
| 7567 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7568 | |
| 7569 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7570 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7571 | |
| 7572 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7573 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7574 | |
| 7575 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7576 | } |
| 7577 | |
| 7578 | return 0; |
| 7579 | } |
| 7580 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7581 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7582 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7583 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7584 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7585 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7586 | u_char buf[INET_ADDRSTRLEN]; |
| 7587 | |
| 7588 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7589 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7590 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7591 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7592 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7593 | struct ospf_interface *oi; |
| 7594 | |
| 7595 | if (vl_data != NULL) |
| 7596 | { |
| 7597 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7598 | |
| 7599 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7600 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7601 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7602 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7603 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7604 | oi = vl_data->vl_oi; |
| 7605 | |
| 7606 | /* timers */ |
| 7607 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7608 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7609 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7610 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7611 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7612 | buf, |
| 7613 | inet_ntoa (vl_data->vl_peer), |
| 7614 | OSPF_IF_PARAM (oi, v_hello), |
| 7615 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7616 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7617 | OSPF_IF_PARAM (oi, v_wait), |
| 7618 | VTY_NEWLINE); |
| 7619 | else |
| 7620 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7621 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7622 | /* Auth key */ |
| 7623 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7624 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7625 | buf, |
| 7626 | inet_ntoa (vl_data->vl_peer), |
| 7627 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7628 | VTY_NEWLINE); |
| 7629 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7630 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7631 | n2, ck)) |
| 7632 | vty_out (vty, " area %s virtual-link %s" |
| 7633 | " message-digest-key %d md5 %s%s", |
| 7634 | buf, |
| 7635 | inet_ntoa (vl_data->vl_peer), |
| 7636 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7637 | |
| 7638 | } |
| 7639 | } |
| 7640 | |
| 7641 | return 0; |
| 7642 | } |
| 7643 | |
| 7644 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7645 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7646 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7647 | { |
| 7648 | int type; |
| 7649 | |
| 7650 | /* redistribute print. */ |
| 7651 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7652 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7653 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7654 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7655 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7656 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7657 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7658 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7659 | vty_out (vty, " metric-type 1"); |
| 7660 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7661 | if (ROUTEMAP_NAME (ospf, type)) |
| 7662 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7663 | |
| 7664 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7665 | } |
| 7666 | |
| 7667 | return 0; |
| 7668 | } |
| 7669 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7670 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7671 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7672 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7673 | if (ospf->default_metric != -1) |
| 7674 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7675 | VTY_NEWLINE); |
| 7676 | return 0; |
| 7677 | } |
| 7678 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7679 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7680 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7681 | { |
| 7682 | int type; |
| 7683 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7684 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7685 | { |
| 7686 | /* distribute-list print. */ |
| 7687 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7688 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7689 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7690 | ospf->dlist[type].name, |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7691 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7692 | |
| 7693 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7694 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7695 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7696 | vty_out (vty, " default-information originate"); |
| 7697 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7698 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7699 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7700 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7701 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7702 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7703 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7704 | vty_out (vty, " metric-type 1"); |
| 7705 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7706 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7707 | vty_out (vty, " route-map %s", |
| 7708 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7709 | |
| 7710 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7711 | } |
| 7712 | |
| 7713 | } |
| 7714 | |
| 7715 | return 0; |
| 7716 | } |
| 7717 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7718 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7719 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7720 | { |
| 7721 | struct route_node *rn; |
| 7722 | struct ospf_distance *odistance; |
| 7723 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7724 | if (ospf->distance_all) |
| 7725 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7726 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7727 | if (ospf->distance_intra |
| 7728 | || ospf->distance_inter |
| 7729 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7730 | { |
| 7731 | vty_out (vty, " distance ospf"); |
| 7732 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7733 | if (ospf->distance_intra) |
| 7734 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7735 | if (ospf->distance_inter) |
| 7736 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7737 | if (ospf->distance_external) |
| 7738 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7739 | |
| 7740 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7741 | } |
| 7742 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7743 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7744 | if ((odistance = rn->info) != NULL) |
| 7745 | { |
| 7746 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7747 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7748 | odistance->access_list ? odistance->access_list : "", |
| 7749 | VTY_NEWLINE); |
| 7750 | } |
| 7751 | return 0; |
| 7752 | } |
| 7753 | |
| 7754 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7755 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7756 | ospf_config_write (struct vty *vty) |
| 7757 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7758 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7759 | struct interface *ifp; |
| 7760 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7761 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7762 | int write = 0; |
| 7763 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7764 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7765 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7766 | { |
| 7767 | /* `router ospf' print. */ |
| 7768 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7769 | |
| 7770 | write++; |
| 7771 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7772 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7773 | return write; |
| 7774 | |
| 7775 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7776 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7777 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7778 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7779 | |
| 7780 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7781 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7782 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7783 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7784 | |
| 7785 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7786 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7787 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7788 | |
| 7789 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7790 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7791 | { |
| 7792 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7793 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7794 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7795 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7796 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7797 | |
| 7798 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7799 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7800 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7801 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7802 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7803 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7804 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7805 | |
| 7806 | /* Max-metric router-lsa print */ |
| 7807 | config_write_stub_router (vty, ospf); |
| 7808 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7809 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7810 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7811 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7812 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7813 | |
| 7814 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7815 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7816 | |
| 7817 | /* passive-interface print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7818 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 7819 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7820 | vty_out (vty, " passive-interface %s%s", |
| 7821 | ifp->name, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7822 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7823 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 7824 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7825 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
| 7826 | vty_out (vty, " passive-interface %s %s%s", |
| 7827 | oi->ifp->name, |
| 7828 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7829 | |
| 7830 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7831 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7832 | |
| 7833 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7834 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7835 | |
| 7836 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7837 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7838 | |
| 7839 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7840 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7841 | |
| 7842 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7843 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7844 | |
| 7845 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7846 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7847 | |
| 7848 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7849 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7850 | |
| 7851 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7852 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7853 | #endif /* HAVE_OPAQUE_LSA */ |
| 7854 | } |
| 7855 | |
| 7856 | return write; |
| 7857 | } |
| 7858 | |
| 7859 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7860 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7861 | { |
| 7862 | /* "show ip ospf" commands. */ |
| 7863 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7864 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7865 | |
| 7866 | /* "show ip ospf database" commands. */ |
| 7867 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7868 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7869 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7870 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7871 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7872 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7873 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7874 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7875 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7876 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7877 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7878 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7879 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7880 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7881 | |
| 7882 | /* "show ip ospf interface" commands. */ |
| 7883 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7884 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7885 | |
| 7886 | /* "show ip ospf neighbor" commands. */ |
| 7887 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7888 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7889 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7890 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7891 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7892 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7893 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7894 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7895 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7896 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7897 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7898 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7899 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7900 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7901 | |
| 7902 | /* "show ip ospf route" commands. */ |
| 7903 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7904 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7905 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7906 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7907 | } |
| 7908 | |
| 7909 | |
| 7910 | /* ospfd's interface node. */ |
| 7911 | struct cmd_node interface_node = |
| 7912 | { |
| 7913 | INTERFACE_NODE, |
| 7914 | "%s(config-if)# ", |
| 7915 | 1 |
| 7916 | }; |
| 7917 | |
| 7918 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7919 | static void |
| 7920 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7921 | { |
| 7922 | /* Install interface node. */ |
| 7923 | install_node (&interface_node, config_write_interface); |
| 7924 | |
| 7925 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7926 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7927 | install_default (INTERFACE_NODE); |
| 7928 | |
| 7929 | /* "description" commands. */ |
| 7930 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7931 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7932 | |
| 7933 | /* "ip ospf authentication" commands. */ |
| 7934 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7935 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7936 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7937 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7938 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7939 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7940 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7941 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7942 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7943 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7944 | |
| 7945 | /* "ip ospf message-digest-key" commands. */ |
| 7946 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7947 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7948 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7949 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7950 | |
| 7951 | /* "ip ospf cost" commands. */ |
| 7952 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7953 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7954 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7955 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7956 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7957 | /* "ip ospf mtu-ignore" commands. */ |
| 7958 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7959 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7960 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7961 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7962 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7963 | /* "ip ospf dead-interval" commands. */ |
| 7964 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7965 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7966 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 7967 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7968 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7969 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7970 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7971 | /* "ip ospf hello-interval" commands. */ |
| 7972 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7973 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7974 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7975 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7976 | |
| 7977 | /* "ip ospf network" commands. */ |
| 7978 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7979 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7980 | |
| 7981 | /* "ip ospf priority" commands. */ |
| 7982 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7983 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7984 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7985 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7986 | |
| 7987 | /* "ip ospf retransmit-interval" commands. */ |
| 7988 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7989 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7990 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7991 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7992 | |
| 7993 | /* "ip ospf transmit-delay" commands. */ |
| 7994 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7995 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7996 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7997 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7998 | |
| 7999 | /* These commands are compatibitliy for previous version. */ |
| 8000 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 8001 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 8002 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 8003 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 8004 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 8005 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 8006 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 8007 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 8008 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 8009 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 8010 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 8011 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 8012 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 8013 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 8014 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 8015 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 8016 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 8017 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 8018 | } |
| 8019 | |
| 8020 | /* Zebra node structure. */ |
| 8021 | struct cmd_node zebra_node = |
| 8022 | { |
| 8023 | ZEBRA_NODE, |
| 8024 | "%s(config-router)#", |
| 8025 | }; |
| 8026 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8027 | static void |
| 8028 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8029 | { |
| 8030 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 8031 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 8032 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 8033 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 8034 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 8035 | install_element (OSPF_NODE, |
| 8036 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 8037 | install_element (OSPF_NODE, |
| 8038 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 8039 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 8040 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 8041 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 8042 | |
| 8043 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 8044 | |
| 8045 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 8046 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 8047 | |
| 8048 | install_element (OSPF_NODE, |
| 8049 | &ospf_default_information_originate_metric_type_cmd); |
| 8050 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 8051 | install_element (OSPF_NODE, |
| 8052 | &ospf_default_information_originate_type_metric_cmd); |
| 8053 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 8054 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 8055 | install_element (OSPF_NODE, |
| 8056 | &ospf_default_information_originate_always_metric_type_cmd); |
| 8057 | install_element (OSPF_NODE, |
| 8058 | &ospf_default_information_originate_always_metric_cmd); |
| 8059 | install_element (OSPF_NODE, |
| 8060 | &ospf_default_information_originate_always_cmd); |
| 8061 | install_element (OSPF_NODE, |
| 8062 | &ospf_default_information_originate_always_type_metric_cmd); |
| 8063 | install_element (OSPF_NODE, |
| 8064 | &ospf_default_information_originate_always_type_cmd); |
| 8065 | |
| 8066 | install_element (OSPF_NODE, |
| 8067 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 8068 | install_element (OSPF_NODE, |
| 8069 | &ospf_default_information_originate_metric_routemap_cmd); |
| 8070 | install_element (OSPF_NODE, |
| 8071 | &ospf_default_information_originate_routemap_cmd); |
| 8072 | install_element (OSPF_NODE, |
| 8073 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 8074 | install_element (OSPF_NODE, |
| 8075 | &ospf_default_information_originate_type_routemap_cmd); |
| 8076 | install_element (OSPF_NODE, |
| 8077 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 8078 | install_element (OSPF_NODE, |
| 8079 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 8080 | install_element (OSPF_NODE, |
| 8081 | &ospf_default_information_originate_always_routemap_cmd); |
| 8082 | install_element (OSPF_NODE, |
| 8083 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 8084 | install_element (OSPF_NODE, |
| 8085 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 8086 | |
| 8087 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 8088 | |
| 8089 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 8090 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 8091 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 8092 | |
| 8093 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 8094 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 8095 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 8096 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 8097 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 8098 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 8099 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 8100 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 8101 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 8102 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 8103 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 8104 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 8105 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 8106 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 8107 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 8108 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 8109 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 8110 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 8111 | #if 0 |
| 8112 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 8113 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 8114 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 8115 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 8116 | #endif /* 0 */ |
| 8117 | } |
| 8118 | |
| 8119 | struct cmd_node ospf_node = |
| 8120 | { |
| 8121 | OSPF_NODE, |
| 8122 | "%s(config-router)# ", |
| 8123 | 1 |
| 8124 | }; |
| 8125 | |
| 8126 | |
| 8127 | /* Install OSPF related vty commands. */ |
| 8128 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8129 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8130 | { |
| 8131 | /* Install ospf top node. */ |
| 8132 | install_node (&ospf_node, ospf_config_write); |
| 8133 | |
| 8134 | /* "router ospf" commands. */ |
| 8135 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 8136 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 8137 | |
| 8138 | install_default (OSPF_NODE); |
| 8139 | |
| 8140 | /* "ospf router-id" commands. */ |
| 8141 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 8142 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8143 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 8144 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8145 | |
| 8146 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8147 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 8148 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 8149 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 8150 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8151 | |
| 8152 | /* "ospf abr-type" commands. */ |
| 8153 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 8154 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 8155 | |
| 8156 | /* "ospf rfc1583-compatible" commands. */ |
| 8157 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 8158 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 8159 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 8160 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 8161 | |
| 8162 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8163 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 8164 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8165 | |
| 8166 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8167 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 8168 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 8169 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8170 | |
| 8171 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8172 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 8173 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 8174 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 8175 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 8176 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 8177 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 8178 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 8179 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 8180 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 8181 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 8182 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8183 | |
| 8184 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8185 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 8186 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8187 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8188 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 8189 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8190 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8191 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 8192 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8193 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8194 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 8195 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8196 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8197 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 8198 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8199 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8200 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 8201 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 8202 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8203 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8204 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 8205 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8206 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8207 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 8208 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8209 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8210 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 8211 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 8212 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8213 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8214 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 8215 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 8216 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8217 | |
| 8218 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8219 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 8220 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 8221 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 8222 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8223 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8224 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8225 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 8226 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 8227 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 8228 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 8229 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 8230 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8231 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8232 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 8233 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8234 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8235 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 8236 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8237 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8238 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 8239 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8240 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8241 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 8242 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8243 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8244 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 8245 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8246 | |
| 8247 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8248 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 8249 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 8250 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 8251 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 8252 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8253 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8254 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 8255 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 8256 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8257 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8258 | /* max-metric commands */ |
| 8259 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 8260 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 8261 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 8262 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 8263 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 8264 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 8265 | |
| 8266 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8267 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 8268 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8269 | |
| 8270 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8271 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 8272 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 8273 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 8274 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 8275 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 8276 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 8277 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 8278 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8279 | |
| 8280 | /* Init interface related vty commands. */ |
| 8281 | ospf_vty_if_init (); |
| 8282 | |
| 8283 | /* Init zebra related vty commands. */ |
| 8284 | ospf_vty_zebra_init (); |
| 8285 | } |