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 | |
Andrew J. Schorr | 6e72cb6 | 2006-06-18 00:45:48 +0000 | [diff] [blame] | 264 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 265 | |
| 266 | params = IF_DEF_PARAMS (ifp); |
| 267 | |
| 268 | if (argc == 2) |
| 269 | { |
| 270 | ret = inet_aton(argv[1], &addr); |
| 271 | if (!ret) |
| 272 | { |
| 273 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 274 | VTY_NEWLINE); |
| 275 | return CMD_WARNING; |
| 276 | } |
| 277 | |
| 278 | params = ospf_get_if_params (ifp, addr); |
| 279 | ospf_if_update_params (ifp, addr); |
| 280 | } |
| 281 | |
| 282 | SET_IF_PARAM (params, passive_interface); |
| 283 | params->passive_interface = OSPF_IF_PASSIVE; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 284 | |
| 285 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 286 | * interfaces for which the passive property changed. It is too much |
| 287 | * work to determine this set, so we do this for every interface. |
| 288 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 289 | * record of joined groups to avoid systems calls if the desired |
| 290 | * memberships match the current memership. |
| 291 | */ |
| 292 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 293 | { |
| 294 | struct ospf_interface *oi = rn->info; |
| 295 | |
| 296 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
| 297 | ospf_if_set_multicast(oi); |
| 298 | } |
| 299 | /* |
| 300 | * XXX It is not clear what state transitions the interface needs to |
| 301 | * undergo when going from active to passive. Fixing this will |
| 302 | * require precise identification of interfaces having such a |
| 303 | * transition. |
| 304 | */ |
| 305 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 306 | return CMD_SUCCESS; |
| 307 | } |
| 308 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 309 | ALIAS (ospf_passive_interface, |
| 310 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | "passive-interface IFNAME", |
| 312 | "Suppress routing updates on an interface\n" |
| 313 | "Interface's name\n") |
| 314 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 315 | DEFUN (no_ospf_passive_interface, |
| 316 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 317 | "no passive-interface IFNAME A.B.C.D", |
| 318 | NO_STR |
| 319 | "Allow routing updates on an interface\n" |
| 320 | "Interface's name\n") |
| 321 | { |
| 322 | struct interface *ifp; |
| 323 | struct in_addr addr; |
| 324 | struct ospf_if_params *params; |
| 325 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 326 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 327 | |
Andrew J. Schorr | 6e72cb6 | 2006-06-18 00:45:48 +0000 | [diff] [blame] | 328 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 329 | |
| 330 | params = IF_DEF_PARAMS (ifp); |
| 331 | |
| 332 | if (argc == 2) |
| 333 | { |
| 334 | ret = inet_aton(argv[1], &addr); |
| 335 | if (!ret) |
| 336 | { |
| 337 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 338 | VTY_NEWLINE); |
| 339 | return CMD_WARNING; |
| 340 | } |
| 341 | |
| 342 | params = ospf_lookup_if_params (ifp, addr); |
| 343 | if (params == NULL) |
| 344 | return CMD_SUCCESS; |
| 345 | } |
| 346 | |
| 347 | UNSET_IF_PARAM (params, passive_interface); |
| 348 | params->passive_interface = OSPF_IF_ACTIVE; |
| 349 | |
| 350 | if (params != IF_DEF_PARAMS (ifp)) |
| 351 | { |
| 352 | ospf_free_if_params (ifp, addr); |
| 353 | ospf_if_update_params (ifp, addr); |
| 354 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 355 | |
| 356 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 357 | * interfaces for which the passive property changed. It is too much |
| 358 | * work to determine this set, so we do this for every interface. |
| 359 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 360 | * record of joined groups to avoid systems calls if the desired |
| 361 | * memberships match the current memership. |
| 362 | */ |
| 363 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 364 | { |
| 365 | struct ospf_interface *oi = rn->info; |
| 366 | |
| 367 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 368 | ospf_if_set_multicast(oi); |
| 369 | } |
| 370 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 371 | return CMD_SUCCESS; |
| 372 | } |
| 373 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 374 | ALIAS (no_ospf_passive_interface, |
| 375 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 376 | "no passive-interface IFNAME", |
| 377 | NO_STR |
| 378 | "Allow routing updates on an interface\n" |
| 379 | "Interface's name\n") |
| 380 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 381 | DEFUN (ospf_network_area, |
| 382 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 383 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 384 | "Enable routing on an IP network\n" |
| 385 | "OSPF network prefix\n" |
| 386 | "Set the OSPF area ID\n" |
| 387 | "OSPF area ID in IP address format\n" |
| 388 | "OSPF area ID as a decimal value\n") |
| 389 | { |
| 390 | struct ospf *ospf= vty->index; |
| 391 | struct prefix_ipv4 p; |
| 392 | struct in_addr area_id; |
| 393 | int ret, format; |
| 394 | |
| 395 | /* Get network prefix and Area ID. */ |
| 396 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 397 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 398 | |
| 399 | ret = ospf_network_set (ospf, &p, area_id); |
| 400 | if (ret == 0) |
| 401 | { |
| 402 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 403 | return CMD_WARNING; |
| 404 | } |
| 405 | |
| 406 | return CMD_SUCCESS; |
| 407 | } |
| 408 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 409 | DEFUN (no_ospf_network_area, |
| 410 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 411 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 412 | NO_STR |
| 413 | "Enable routing on an IP network\n" |
| 414 | "OSPF network prefix\n" |
| 415 | "Set the OSPF area ID\n" |
| 416 | "OSPF area ID in IP address format\n" |
| 417 | "OSPF area ID as a decimal value\n") |
| 418 | { |
| 419 | struct ospf *ospf = (struct ospf *) vty->index; |
| 420 | struct prefix_ipv4 p; |
| 421 | struct in_addr area_id; |
| 422 | int ret, format; |
| 423 | |
| 424 | /* Get network prefix and Area ID. */ |
| 425 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 426 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 427 | |
| 428 | ret = ospf_network_unset (ospf, &p, area_id); |
| 429 | if (ret == 0) |
| 430 | { |
| 431 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 432 | VTY_NEWLINE); |
| 433 | return CMD_WARNING; |
| 434 | } |
| 435 | |
| 436 | return CMD_SUCCESS; |
| 437 | } |
| 438 | |
| 439 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 440 | DEFUN (ospf_area_range, |
| 441 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 442 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 443 | "OSPF area parameters\n" |
| 444 | "OSPF area ID in IP address format\n" |
| 445 | "OSPF area ID as a decimal value\n" |
| 446 | "Summarize routes matching address/mask (border routers only)\n" |
| 447 | "Area range prefix\n") |
| 448 | { |
| 449 | struct ospf *ospf = vty->index; |
| 450 | struct prefix_ipv4 p; |
| 451 | struct in_addr area_id; |
| 452 | int format; |
| 453 | u_int32_t cost; |
| 454 | |
| 455 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 456 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 457 | |
| 458 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 459 | if (argc > 2) |
| 460 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 461 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 462 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 463 | } |
| 464 | |
| 465 | return CMD_SUCCESS; |
| 466 | } |
| 467 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 468 | ALIAS (ospf_area_range, |
| 469 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 470 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 471 | "OSPF area parameters\n" |
| 472 | "OSPF area ID in IP address format\n" |
| 473 | "OSPF area ID as a decimal value\n" |
| 474 | "OSPF area range for route advertise (default)\n" |
| 475 | "Area range prefix\n" |
| 476 | "Advertise this range (default)\n") |
| 477 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 478 | ALIAS (ospf_area_range, |
| 479 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 480 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 481 | "OSPF area parameters\n" |
| 482 | "OSPF area ID in IP address format\n" |
| 483 | "OSPF area ID as a decimal value\n" |
| 484 | "Summarize routes matching address/mask (border routers only)\n" |
| 485 | "Area range prefix\n" |
| 486 | "User specified metric for this range\n" |
| 487 | "Advertised metric for this range\n") |
| 488 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 489 | ALIAS (ospf_area_range, |
| 490 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 491 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 492 | "OSPF area parameters\n" |
| 493 | "OSPF area ID in IP address format\n" |
| 494 | "OSPF area ID as a decimal value\n" |
| 495 | "Summarize routes matching address/mask (border routers only)\n" |
| 496 | "Area range prefix\n" |
| 497 | "Advertise this range (default)\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 | DEFUN (ospf_area_range_not_advertise, |
| 502 | ospf_area_range_not_advertise_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 not-advertise", |
| 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 | "DoNotAdvertise this range\n") |
| 510 | { |
| 511 | struct ospf *ospf = vty->index; |
| 512 | struct prefix_ipv4 p; |
| 513 | struct in_addr area_id; |
| 514 | int format; |
| 515 | |
| 516 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 517 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 518 | |
| 519 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 520 | |
| 521 | return CMD_SUCCESS; |
| 522 | } |
| 523 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 524 | DEFUN (no_ospf_area_range, |
| 525 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 526 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 527 | NO_STR |
| 528 | "OSPF area parameters\n" |
| 529 | "OSPF area ID in IP address format\n" |
| 530 | "OSPF area ID as a decimal value\n" |
| 531 | "Summarize routes matching address/mask (border routers only)\n" |
| 532 | "Area range prefix\n") |
| 533 | { |
| 534 | struct ospf *ospf = vty->index; |
| 535 | struct prefix_ipv4 p; |
| 536 | struct in_addr area_id; |
| 537 | int format; |
| 538 | |
| 539 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 540 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 541 | |
| 542 | ospf_area_range_unset (ospf, area_id, &p); |
| 543 | |
| 544 | return CMD_SUCCESS; |
| 545 | } |
| 546 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 547 | ALIAS (no_ospf_area_range, |
| 548 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 549 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 550 | NO_STR |
| 551 | "OSPF area parameters\n" |
| 552 | "OSPF area ID in IP address format\n" |
| 553 | "OSPF area ID as a decimal value\n" |
| 554 | "Summarize routes matching address/mask (border routers only)\n" |
| 555 | "Area range prefix\n" |
| 556 | "Advertise this range (default)\n" |
| 557 | "DoNotAdvertise this range\n") |
| 558 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 559 | ALIAS (no_ospf_area_range, |
| 560 | no_ospf_area_range_cost_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 cost <0-16777215>", |
| 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 | "User specified metric for this range\n" |
| 569 | "Advertised metric for 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_advertise_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 advertise 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 | "Advertise this range (default)\n" |
| 581 | "User specified metric for this range\n" |
| 582 | "Advertised metric for this range\n") |
| 583 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 584 | DEFUN (ospf_area_range_substitute, |
| 585 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 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 | "Announce area range as another prefix\n" |
| 593 | "Network prefix to be announced instead of range\n") |
| 594 | { |
| 595 | struct ospf *ospf = vty->index; |
| 596 | struct prefix_ipv4 p, s; |
| 597 | struct in_addr area_id; |
| 598 | int format; |
| 599 | |
| 600 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 601 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 602 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 603 | |
| 604 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 605 | |
| 606 | return CMD_SUCCESS; |
| 607 | } |
| 608 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 609 | DEFUN (no_ospf_area_range_substitute, |
| 610 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 611 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 612 | NO_STR |
| 613 | "OSPF area parameters\n" |
| 614 | "OSPF area ID in IP address format\n" |
| 615 | "OSPF area ID as a decimal value\n" |
| 616 | "Summarize routes matching address/mask (border routers only)\n" |
| 617 | "Area range prefix\n" |
| 618 | "Announce area range as another prefix\n" |
| 619 | "Network prefix to be announced instead of range\n") |
| 620 | { |
| 621 | struct ospf *ospf = vty->index; |
| 622 | struct prefix_ipv4 p, s; |
| 623 | struct in_addr area_id; |
| 624 | int format; |
| 625 | |
| 626 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 627 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 628 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 629 | |
| 630 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 631 | |
| 632 | return CMD_SUCCESS; |
| 633 | } |
| 634 | |
| 635 | |
| 636 | /* Command Handler Logic in VLink stuff is delicate!! |
| 637 | |
| 638 | ALTER AT YOUR OWN RISK!!!! |
| 639 | |
| 640 | Various dummy values are used to represent 'NoChange' state for |
| 641 | VLink configuration NOT being changed by a VLink command, and |
| 642 | special syntax is used within the command strings so that the |
| 643 | typed in command verbs can be seen in the configuration command |
| 644 | bacckend handler. This is to drastically reduce the verbeage |
| 645 | required to coe up with a reasonably compatible Cisco VLink command |
| 646 | |
| 647 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 648 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 649 | */ |
| 650 | |
| 651 | |
| 652 | /* Configuration data for virtual links |
| 653 | */ |
| 654 | struct ospf_vl_config_data { |
| 655 | struct vty *vty; /* vty stuff */ |
| 656 | struct in_addr area_id; /* area ID from command line */ |
| 657 | int format; /* command line area ID format */ |
| 658 | struct in_addr vl_peer; /* command line vl_peer */ |
| 659 | int auth_type; /* Authehntication type, if given */ |
| 660 | char *auth_key; /* simple password if present */ |
| 661 | int crypto_key_id; /* Cryptographic key ID */ |
| 662 | char *md5_key; /* MD5 authentication key */ |
| 663 | int hello_interval; /* Obvious what these are... */ |
| 664 | int retransmit_interval; |
| 665 | int transmit_delay; |
| 666 | int dead_interval; |
| 667 | }; |
| 668 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 669 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 670 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 671 | struct vty *vty) |
| 672 | { |
| 673 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 674 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 675 | vl_config->vty = vty; |
| 676 | } |
| 677 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 678 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 679 | 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] | 680 | { |
| 681 | struct ospf_area *area; |
| 682 | struct ospf_vl_data *vl_data; |
| 683 | struct vty *vty; |
| 684 | struct in_addr area_id; |
| 685 | |
| 686 | vty = vl_config->vty; |
| 687 | area_id = vl_config->area_id; |
| 688 | |
| 689 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 690 | { |
| 691 | vty_out (vty, |
| 692 | "Configuring VLs over the backbone is not allowed%s", |
| 693 | VTY_NEWLINE); |
| 694 | return NULL; |
| 695 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 696 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 697 | |
| 698 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 699 | { |
| 700 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 701 | vty_out (vty, "Area %s is %s%s", |
| 702 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 703 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 704 | VTY_NEWLINE); |
| 705 | else |
| 706 | vty_out (vty, "Area %ld is %s%s", |
| 707 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 708 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 709 | VTY_NEWLINE); |
| 710 | return NULL; |
| 711 | } |
| 712 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 713 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 714 | { |
| 715 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 716 | if (vl_data->vl_oi == NULL) |
| 717 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 718 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 719 | ospf_vl_add (ospf, vl_data); |
| 720 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | } |
| 722 | } |
| 723 | return vl_data; |
| 724 | } |
| 725 | |
| 726 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 727 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 728 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 729 | struct ospf_vl_config_data *vl_config) |
| 730 | { |
| 731 | struct crypt_key *ck; |
| 732 | struct vty *vty; |
| 733 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 734 | |
| 735 | vty = vl_config->vty; |
| 736 | |
| 737 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 738 | { |
| 739 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 740 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 741 | } |
| 742 | |
| 743 | if (vl_config->auth_key) |
| 744 | { |
| 745 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 746 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 747 | OSPF_AUTH_SIMPLE_SIZE); |
| 748 | } |
| 749 | else if (vl_config->md5_key) |
| 750 | { |
| 751 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 752 | != NULL) |
| 753 | { |
| 754 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 755 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 756 | return CMD_WARNING; |
| 757 | } |
| 758 | ck = ospf_crypt_key_new (); |
| 759 | ck->key_id = vl_config->crypto_key_id; |
| 760 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 761 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 762 | |
| 763 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 764 | } |
| 765 | else if (vl_config->crypto_key_id != 0) |
| 766 | { |
| 767 | /* Delete a key */ |
| 768 | |
| 769 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 770 | vl_config->crypto_key_id) == NULL) |
| 771 | { |
| 772 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 773 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 774 | return CMD_WARNING; |
| 775 | } |
| 776 | |
| 777 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 778 | |
| 779 | } |
| 780 | |
| 781 | return CMD_SUCCESS; |
| 782 | } |
| 783 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 784 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 785 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 786 | struct ospf_vl_config_data *vl_config) |
| 787 | { |
| 788 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 789 | /* Virtual Link data initialised to defaults, so only set |
| 790 | if a value given */ |
| 791 | if (vl_config->hello_interval) |
| 792 | { |
| 793 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 794 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 795 | } |
| 796 | |
| 797 | if (vl_config->dead_interval) |
| 798 | { |
| 799 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 800 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 801 | } |
| 802 | |
| 803 | if (vl_config->retransmit_interval) |
| 804 | { |
| 805 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 806 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 807 | } |
| 808 | |
| 809 | if (vl_config->transmit_delay) |
| 810 | { |
| 811 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 812 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 813 | } |
| 814 | |
| 815 | return CMD_SUCCESS; |
| 816 | } |
| 817 | |
| 818 | |
| 819 | |
| 820 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 821 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 822 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 823 | { |
| 824 | struct ospf_vl_data *vl_data; |
| 825 | int ret; |
| 826 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 827 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | if (!vl_data) |
| 829 | return CMD_WARNING; |
| 830 | |
| 831 | /* Process this one first as it can have a fatal result, which can |
| 832 | only logically occur if the virtual link exists already |
| 833 | Thus a command error does not result in a change to the |
| 834 | running configuration such as unexpectedly altered timer |
| 835 | values etc.*/ |
| 836 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 837 | if (ret != CMD_SUCCESS) |
| 838 | return ret; |
| 839 | |
| 840 | /* Set any time based parameters, these area already range checked */ |
| 841 | |
| 842 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 843 | if (ret != CMD_SUCCESS) |
| 844 | return ret; |
| 845 | |
| 846 | return CMD_SUCCESS; |
| 847 | |
| 848 | } |
| 849 | |
| 850 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 851 | */ |
| 852 | #define VLINK_HELPSTR_IPADDR \ |
| 853 | "OSPF area parameters\n" \ |
| 854 | "OSPF area ID in IP address format\n" \ |
| 855 | "OSPF area ID as a decimal value\n" \ |
| 856 | "Configure a virtual link\n" \ |
| 857 | "Router ID of the remote ABR\n" |
| 858 | |
| 859 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 860 | "Enable authentication on this virtual link\n" \ |
| 861 | "dummy string \n" |
| 862 | |
| 863 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 864 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 865 | "Use null authentication\n" \ |
| 866 | "Use message-digest authentication\n" |
| 867 | |
| 868 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 869 | "Time between HELLO packets\n" \ |
| 870 | "Time between retransmitting lost link state advertisements\n" \ |
| 871 | "Link state transmit delay\n" \ |
| 872 | "Interval after which a neighbor is declared dead\n" |
| 873 | |
| 874 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 875 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 876 | "Seconds\n" |
| 877 | |
| 878 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 879 | "Authentication password (key)\n" \ |
| 880 | "The OSPF password (key)" |
| 881 | |
| 882 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 883 | "Message digest authentication password (key)\n" \ |
| 884 | "dummy string \n" \ |
| 885 | "Key ID\n" \ |
| 886 | "Use MD5 algorithm\n" \ |
| 887 | "The OSPF password (key)" |
| 888 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 889 | DEFUN (ospf_area_vlink, |
| 890 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 891 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 892 | VLINK_HELPSTR_IPADDR) |
| 893 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 894 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 895 | struct ospf_vl_config_data vl_config; |
| 896 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 897 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 898 | int i; |
| 899 | int ret; |
| 900 | |
| 901 | ospf_vl_config_data_init(&vl_config, vty); |
| 902 | |
| 903 | /* Read off first 2 parameters and check them */ |
| 904 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 905 | if (ret < 0) |
| 906 | { |
| 907 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 908 | return CMD_WARNING; |
| 909 | } |
| 910 | |
| 911 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 912 | if (! ret) |
| 913 | { |
| 914 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 915 | VTY_NEWLINE); |
| 916 | return CMD_WARNING; |
| 917 | } |
| 918 | |
| 919 | if (argc <=2) |
| 920 | { |
| 921 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 922 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 923 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | /* Deal with other parameters */ |
| 927 | for (i=2; i < argc; i++) |
| 928 | { |
| 929 | |
| 930 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 931 | |
| 932 | switch (argv[i][0]) |
| 933 | { |
| 934 | |
| 935 | case 'a': |
| 936 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 937 | { |
| 938 | /* authentication-key - this option can occur anywhere on |
| 939 | command line. At start of command line |
| 940 | must check for authentication option. */ |
| 941 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 942 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 943 | vl_config.auth_key = auth_key; |
| 944 | i++; |
| 945 | } |
| 946 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 947 | { |
| 948 | /* authentication - this option can only occur at start |
| 949 | of command line */ |
| 950 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 951 | if ((i+1) < argc) |
| 952 | { |
| 953 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 954 | { |
| 955 | /* "authentication null" */ |
| 956 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 957 | i++; |
| 958 | } |
| 959 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 960 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 961 | { |
| 962 | /* "authentication message-digest" */ |
| 963 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 964 | i++; |
| 965 | } |
| 966 | } |
| 967 | } |
| 968 | break; |
| 969 | |
| 970 | case 'm': |
| 971 | /* message-digest-key */ |
| 972 | i++; |
| 973 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 974 | if (vl_config.crypto_key_id < 0) |
| 975 | return CMD_WARNING; |
| 976 | i++; |
| 977 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 978 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 979 | vl_config.md5_key = md5_key; |
| 980 | break; |
| 981 | |
| 982 | case 'h': |
| 983 | /* Hello interval */ |
| 984 | i++; |
| 985 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 986 | if (vl_config.hello_interval < 0) |
| 987 | return CMD_WARNING; |
| 988 | break; |
| 989 | |
| 990 | case 'r': |
| 991 | /* Retransmit Interval */ |
| 992 | i++; |
| 993 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 994 | if (vl_config.retransmit_interval < 0) |
| 995 | return CMD_WARNING; |
| 996 | break; |
| 997 | |
| 998 | case 't': |
| 999 | /* Transmit Delay */ |
| 1000 | i++; |
| 1001 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1002 | if (vl_config.transmit_delay < 0) |
| 1003 | return CMD_WARNING; |
| 1004 | break; |
| 1005 | |
| 1006 | case 'd': |
| 1007 | /* Dead Interval */ |
| 1008 | i++; |
| 1009 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1010 | if (vl_config.dead_interval < 0) |
| 1011 | return CMD_WARNING; |
| 1012 | break; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | /* Action configuration */ |
| 1018 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1019 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1020 | |
| 1021 | } |
| 1022 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1023 | DEFUN (no_ospf_area_vlink, |
| 1024 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1025 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1026 | NO_STR |
| 1027 | VLINK_HELPSTR_IPADDR) |
| 1028 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1029 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1030 | struct ospf_area *area; |
| 1031 | struct ospf_vl_config_data vl_config; |
| 1032 | struct ospf_vl_data *vl_data = NULL; |
| 1033 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1034 | int i; |
| 1035 | int ret, format; |
| 1036 | |
| 1037 | ospf_vl_config_data_init(&vl_config, vty); |
| 1038 | |
| 1039 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1040 | if (ret < 0) |
| 1041 | { |
| 1042 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1043 | return CMD_WARNING; |
| 1044 | } |
| 1045 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1046 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1047 | if (!area) |
| 1048 | { |
| 1049 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1050 | return CMD_WARNING; |
| 1051 | } |
| 1052 | |
| 1053 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1054 | if (! ret) |
| 1055 | { |
| 1056 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1057 | VTY_NEWLINE); |
| 1058 | return CMD_WARNING; |
| 1059 | } |
| 1060 | |
| 1061 | if (argc <=2) |
| 1062 | { |
| 1063 | /* Basic VLink no command */ |
| 1064 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 1065 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1066 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1067 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1068 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1069 | |
| 1070 | return CMD_SUCCESS; |
| 1071 | } |
| 1072 | |
| 1073 | /* If we are down here, we are reseting parameters */ |
| 1074 | |
| 1075 | /* Deal with other parameters */ |
| 1076 | for (i=2; i < argc; i++) |
| 1077 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1078 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1079 | |
| 1080 | switch (argv[i][0]) |
| 1081 | { |
| 1082 | |
| 1083 | case 'a': |
| 1084 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1085 | { |
| 1086 | /* authentication-key - this option can occur anywhere on |
| 1087 | command line. At start of command line |
| 1088 | must check for authentication option. */ |
| 1089 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1090 | vl_config.auth_key = auth_key; |
| 1091 | } |
| 1092 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1093 | { |
| 1094 | /* authentication - this option can only occur at start |
| 1095 | of command line */ |
| 1096 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1097 | } |
| 1098 | break; |
| 1099 | |
| 1100 | case 'm': |
| 1101 | /* message-digest-key */ |
| 1102 | /* Delete one key */ |
| 1103 | i++; |
| 1104 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1105 | if (vl_config.crypto_key_id < 0) |
| 1106 | return CMD_WARNING; |
| 1107 | vl_config.md5_key = NULL; |
| 1108 | break; |
| 1109 | |
| 1110 | case 'h': |
| 1111 | /* Hello interval */ |
| 1112 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1113 | break; |
| 1114 | |
| 1115 | case 'r': |
| 1116 | /* Retransmit Interval */ |
| 1117 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1118 | break; |
| 1119 | |
| 1120 | case 't': |
| 1121 | /* Transmit Delay */ |
| 1122 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1123 | break; |
| 1124 | |
| 1125 | case 'd': |
| 1126 | /* Dead Interval */ |
| 1127 | i++; |
| 1128 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1129 | break; |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | |
| 1134 | /* Action configuration */ |
| 1135 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1136 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1139 | ALIAS (ospf_area_vlink, |
| 1140 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1141 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1142 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1143 | VLINK_HELPSTR_IPADDR |
| 1144 | VLINK_HELPSTR_TIME_PARAM) |
| 1145 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1146 | ALIAS (no_ospf_area_vlink, |
| 1147 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1148 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1149 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1150 | NO_STR |
| 1151 | VLINK_HELPSTR_IPADDR |
| 1152 | VLINK_HELPSTR_TIME_PARAM) |
| 1153 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1154 | ALIAS (ospf_area_vlink, |
| 1155 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1156 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1157 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1158 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1159 | VLINK_HELPSTR_IPADDR |
| 1160 | VLINK_HELPSTR_TIME_PARAM |
| 1161 | VLINK_HELPSTR_TIME_PARAM) |
| 1162 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1163 | ALIAS (no_ospf_area_vlink, |
| 1164 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1165 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1166 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1167 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1168 | NO_STR |
| 1169 | VLINK_HELPSTR_IPADDR |
| 1170 | VLINK_HELPSTR_TIME_PARAM |
| 1171 | VLINK_HELPSTR_TIME_PARAM) |
| 1172 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1173 | ALIAS (ospf_area_vlink, |
| 1174 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1175 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1176 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1177 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1178 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1179 | VLINK_HELPSTR_IPADDR |
| 1180 | VLINK_HELPSTR_TIME_PARAM |
| 1181 | VLINK_HELPSTR_TIME_PARAM |
| 1182 | VLINK_HELPSTR_TIME_PARAM) |
| 1183 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1184 | ALIAS (no_ospf_area_vlink, |
| 1185 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1186 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1187 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1188 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1189 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1190 | NO_STR |
| 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 (ospf_area_vlink, |
| 1197 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1198 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1199 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1200 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1201 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1202 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1203 | VLINK_HELPSTR_IPADDR |
| 1204 | VLINK_HELPSTR_TIME_PARAM |
| 1205 | VLINK_HELPSTR_TIME_PARAM |
| 1206 | VLINK_HELPSTR_TIME_PARAM |
| 1207 | VLINK_HELPSTR_TIME_PARAM) |
| 1208 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1209 | ALIAS (no_ospf_area_vlink, |
| 1210 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1211 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1212 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1213 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1214 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1215 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1216 | NO_STR |
| 1217 | VLINK_HELPSTR_IPADDR |
| 1218 | VLINK_HELPSTR_TIME_PARAM |
| 1219 | VLINK_HELPSTR_TIME_PARAM |
| 1220 | VLINK_HELPSTR_TIME_PARAM |
| 1221 | VLINK_HELPSTR_TIME_PARAM) |
| 1222 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1223 | ALIAS (ospf_area_vlink, |
| 1224 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1225 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1226 | "(authentication|) (message-digest|null)", |
| 1227 | VLINK_HELPSTR_IPADDR |
| 1228 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1229 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1230 | ALIAS (ospf_area_vlink, |
| 1231 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1232 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1233 | "(authentication|)", |
| 1234 | VLINK_HELPSTR_IPADDR |
| 1235 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1236 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1237 | ALIAS (no_ospf_area_vlink, |
| 1238 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1239 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1240 | "(authentication|)", |
| 1241 | NO_STR |
| 1242 | VLINK_HELPSTR_IPADDR |
| 1243 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1244 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1245 | ALIAS (ospf_area_vlink, |
| 1246 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1248 | "(message-digest-key|) <1-255> md5 KEY", |
| 1249 | VLINK_HELPSTR_IPADDR |
| 1250 | VLINK_HELPSTR_AUTH_MD5) |
| 1251 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1252 | ALIAS (no_ospf_area_vlink, |
| 1253 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1254 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1255 | "(message-digest-key|) <1-255>", |
| 1256 | NO_STR |
| 1257 | VLINK_HELPSTR_IPADDR |
| 1258 | VLINK_HELPSTR_AUTH_MD5) |
| 1259 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1260 | ALIAS (ospf_area_vlink, |
| 1261 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1262 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1263 | "(authentication-key|) AUTH_KEY", |
| 1264 | VLINK_HELPSTR_IPADDR |
| 1265 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1266 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1267 | ALIAS (no_ospf_area_vlink, |
| 1268 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1269 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1270 | "(authentication-key|)", |
| 1271 | NO_STR |
| 1272 | VLINK_HELPSTR_IPADDR |
| 1273 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1274 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1275 | ALIAS (ospf_area_vlink, |
| 1276 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1277 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1278 | "(authentication|) (message-digest|null) " |
| 1279 | "(authentication-key|) AUTH_KEY", |
| 1280 | VLINK_HELPSTR_IPADDR |
| 1281 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1282 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1283 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1284 | ALIAS (ospf_area_vlink, |
| 1285 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1286 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1287 | "(authentication|) " |
| 1288 | "(authentication-key|) AUTH_KEY", |
| 1289 | VLINK_HELPSTR_IPADDR |
| 1290 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1291 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1292 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1293 | ALIAS (no_ospf_area_vlink, |
| 1294 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1295 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1296 | "(authentication|) " |
| 1297 | "(authentication-key|)", |
| 1298 | NO_STR |
| 1299 | VLINK_HELPSTR_IPADDR |
| 1300 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1301 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1302 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1303 | ALIAS (ospf_area_vlink, |
| 1304 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1305 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1306 | "(authentication|) (message-digest|null) " |
| 1307 | "(message-digest-key|) <1-255> md5 KEY", |
| 1308 | VLINK_HELPSTR_IPADDR |
| 1309 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1310 | VLINK_HELPSTR_AUTH_MD5) |
| 1311 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1312 | ALIAS (ospf_area_vlink, |
| 1313 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1314 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1315 | "(authentication|) " |
| 1316 | "(message-digest-key|) <1-255> md5 KEY", |
| 1317 | VLINK_HELPSTR_IPADDR |
| 1318 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1319 | VLINK_HELPSTR_AUTH_MD5) |
| 1320 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1321 | ALIAS (no_ospf_area_vlink, |
| 1322 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1323 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1324 | "(authentication|) " |
| 1325 | "(message-digest-key|)", |
| 1326 | NO_STR |
| 1327 | VLINK_HELPSTR_IPADDR |
| 1328 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1329 | VLINK_HELPSTR_AUTH_MD5) |
| 1330 | |
| 1331 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1332 | DEFUN (ospf_area_shortcut, |
| 1333 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1334 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1335 | "OSPF area parameters\n" |
| 1336 | "OSPF area ID in IP address format\n" |
| 1337 | "OSPF area ID as a decimal value\n" |
| 1338 | "Configure the area's shortcutting mode\n" |
| 1339 | "Set default shortcutting behavior\n" |
| 1340 | "Enable shortcutting through the area\n" |
| 1341 | "Disable shortcutting through the area\n") |
| 1342 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1343 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | struct ospf_area *area; |
| 1345 | struct in_addr area_id; |
| 1346 | int mode; |
| 1347 | int format; |
| 1348 | |
| 1349 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1350 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1351 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1352 | |
| 1353 | if (strncmp (argv[1], "de", 2) == 0) |
| 1354 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1355 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1356 | mode = OSPF_SHORTCUT_DISABLE; |
| 1357 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1358 | mode = OSPF_SHORTCUT_ENABLE; |
| 1359 | else |
| 1360 | return CMD_WARNING; |
| 1361 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1362 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1363 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1364 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1365 | vty_out (vty, "Shortcut area setting will take effect " |
| 1366 | "only when the router is configured as Shortcut ABR%s", |
| 1367 | VTY_NEWLINE); |
| 1368 | |
| 1369 | return CMD_SUCCESS; |
| 1370 | } |
| 1371 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1372 | DEFUN (no_ospf_area_shortcut, |
| 1373 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1374 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1375 | NO_STR |
| 1376 | "OSPF area parameters\n" |
| 1377 | "OSPF area ID in IP address format\n" |
| 1378 | "OSPF area ID as a decimal value\n" |
| 1379 | "Deconfigure the area's shortcutting mode\n" |
| 1380 | "Deconfigure enabled shortcutting through the area\n" |
| 1381 | "Deconfigure disabled shortcutting through the area\n") |
| 1382 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1383 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1384 | struct ospf_area *area; |
| 1385 | struct in_addr area_id; |
| 1386 | int format; |
| 1387 | |
| 1388 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1389 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1390 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1391 | if (!area) |
| 1392 | return CMD_SUCCESS; |
| 1393 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1394 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1395 | |
| 1396 | return CMD_SUCCESS; |
| 1397 | } |
| 1398 | |
| 1399 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1400 | DEFUN (ospf_area_stub, |
| 1401 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1402 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1403 | "OSPF area parameters\n" |
| 1404 | "OSPF area ID in IP address format\n" |
| 1405 | "OSPF area ID as a decimal value\n" |
| 1406 | "Configure OSPF area as stub\n") |
| 1407 | { |
| 1408 | struct ospf *ospf = vty->index; |
| 1409 | struct in_addr area_id; |
| 1410 | int ret, format; |
| 1411 | |
| 1412 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1413 | |
| 1414 | ret = ospf_area_stub_set (ospf, area_id); |
| 1415 | if (ret == 0) |
| 1416 | { |
| 1417 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1418 | VTY_NEWLINE); |
| 1419 | return CMD_WARNING; |
| 1420 | } |
| 1421 | |
| 1422 | ospf_area_no_summary_unset (ospf, area_id); |
| 1423 | |
| 1424 | return CMD_SUCCESS; |
| 1425 | } |
| 1426 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1427 | DEFUN (ospf_area_stub_no_summary, |
| 1428 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1429 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1430 | "OSPF stub parameters\n" |
| 1431 | "OSPF area ID in IP address format\n" |
| 1432 | "OSPF area ID as a decimal value\n" |
| 1433 | "Configure OSPF area as stub\n" |
| 1434 | "Do not inject inter-area routes into stub\n") |
| 1435 | { |
| 1436 | struct ospf *ospf = vty->index; |
| 1437 | struct in_addr area_id; |
| 1438 | int ret, format; |
| 1439 | |
| 1440 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1441 | |
| 1442 | ret = ospf_area_stub_set (ospf, area_id); |
| 1443 | if (ret == 0) |
| 1444 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1445 | 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] | 1446 | VTY_NEWLINE); |
| 1447 | return CMD_WARNING; |
| 1448 | } |
| 1449 | |
| 1450 | ospf_area_no_summary_set (ospf, area_id); |
| 1451 | |
| 1452 | return CMD_SUCCESS; |
| 1453 | } |
| 1454 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1455 | DEFUN (no_ospf_area_stub, |
| 1456 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1457 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1458 | NO_STR |
| 1459 | "OSPF area parameters\n" |
| 1460 | "OSPF area ID in IP address format\n" |
| 1461 | "OSPF area ID as a decimal value\n" |
| 1462 | "Configure OSPF area as stub\n") |
| 1463 | { |
| 1464 | struct ospf *ospf = vty->index; |
| 1465 | struct in_addr area_id; |
| 1466 | int format; |
| 1467 | |
| 1468 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1469 | |
| 1470 | ospf_area_stub_unset (ospf, area_id); |
| 1471 | ospf_area_no_summary_unset (ospf, area_id); |
| 1472 | |
| 1473 | return CMD_SUCCESS; |
| 1474 | } |
| 1475 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1476 | DEFUN (no_ospf_area_stub_no_summary, |
| 1477 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1478 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1479 | NO_STR |
| 1480 | "OSPF area parameters\n" |
| 1481 | "OSPF area ID in IP address format\n" |
| 1482 | "OSPF area ID as a decimal value\n" |
| 1483 | "Configure OSPF area as stub\n" |
| 1484 | "Do not inject inter-area routes into area\n") |
| 1485 | { |
| 1486 | struct ospf *ospf = vty->index; |
| 1487 | struct in_addr area_id; |
| 1488 | int format; |
| 1489 | |
| 1490 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1491 | ospf_area_no_summary_unset (ospf, area_id); |
| 1492 | |
| 1493 | return CMD_SUCCESS; |
| 1494 | } |
| 1495 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1496 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1497 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1498 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1499 | { |
| 1500 | struct ospf *ospf = vty->index; |
| 1501 | struct in_addr area_id; |
| 1502 | int ret, format; |
| 1503 | |
| 1504 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1505 | |
| 1506 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1507 | if (ret == 0) |
| 1508 | { |
| 1509 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1510 | VTY_NEWLINE); |
| 1511 | return CMD_WARNING; |
| 1512 | } |
| 1513 | |
| 1514 | if (argc > 1) |
| 1515 | { |
| 1516 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1517 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1518 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1519 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1520 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1521 | OSPF_NSSA_ROLE_NEVER); |
| 1522 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1523 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1524 | OSPF_NSSA_ROLE_ALWAYS); |
| 1525 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1526 | else |
| 1527 | { |
| 1528 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1529 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1530 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1531 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1532 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1533 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1534 | else |
| 1535 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1537 | ospf_schedule_abr_task (ospf); |
| 1538 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1539 | return CMD_SUCCESS; |
| 1540 | } |
| 1541 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1542 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1543 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1544 | "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] | 1545 | "OSPF area parameters\n" |
| 1546 | "OSPF area ID in IP address format\n" |
| 1547 | "OSPF area ID as a decimal value\n" |
| 1548 | "Configure OSPF area as nssa\n" |
| 1549 | "Configure NSSA-ABR for translate election (default)\n" |
| 1550 | "Configure NSSA-ABR to never translate\n" |
| 1551 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1552 | "Do not inject inter-area routes into nssa\n") |
| 1553 | { |
| 1554 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1555 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1556 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1557 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1558 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1559 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1560 | "OSPF area parameters\n" |
| 1561 | "OSPF area ID in IP address format\n" |
| 1562 | "OSPF area ID as a decimal value\n" |
| 1563 | "Configure OSPF area as nssa\n" |
| 1564 | "Configure NSSA-ABR for translate election (default)\n" |
| 1565 | "Configure NSSA-ABR to never translate\n" |
| 1566 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1567 | { |
| 1568 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1569 | } |
| 1570 | |
| 1571 | DEFUN (ospf_area_nssa, |
| 1572 | ospf_area_nssa_cmd, |
| 1573 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1574 | "OSPF area parameters\n" |
| 1575 | "OSPF area ID in IP address format\n" |
| 1576 | "OSPF area ID as a decimal value\n" |
| 1577 | "Configure OSPF area as nssa\n") |
| 1578 | { |
| 1579 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1580 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1581 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1582 | DEFUN (ospf_area_nssa_no_summary, |
| 1583 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1584 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1585 | "OSPF area parameters\n" |
| 1586 | "OSPF area ID in IP address format\n" |
| 1587 | "OSPF area ID as a decimal value\n" |
| 1588 | "Configure OSPF area as nssa\n" |
| 1589 | "Do not inject inter-area routes into nssa\n") |
| 1590 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1591 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1592 | } |
| 1593 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1594 | DEFUN (no_ospf_area_nssa, |
| 1595 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1597 | NO_STR |
| 1598 | "OSPF area parameters\n" |
| 1599 | "OSPF area ID in IP address format\n" |
| 1600 | "OSPF area ID as a decimal value\n" |
| 1601 | "Configure OSPF area as nssa\n") |
| 1602 | { |
| 1603 | struct ospf *ospf = vty->index; |
| 1604 | struct in_addr area_id; |
| 1605 | int format; |
| 1606 | |
| 1607 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1608 | |
| 1609 | ospf_area_nssa_unset (ospf, area_id); |
| 1610 | ospf_area_no_summary_unset (ospf, area_id); |
| 1611 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1612 | ospf_schedule_abr_task (ospf); |
| 1613 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1614 | return CMD_SUCCESS; |
| 1615 | } |
| 1616 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1617 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1618 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1619 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1620 | NO_STR |
| 1621 | "OSPF area parameters\n" |
| 1622 | "OSPF area ID in IP address format\n" |
| 1623 | "OSPF area ID as a decimal value\n" |
| 1624 | "Configure OSPF area as nssa\n" |
| 1625 | "Do not inject inter-area routes into nssa\n") |
| 1626 | { |
| 1627 | struct ospf *ospf = vty->index; |
| 1628 | struct in_addr area_id; |
| 1629 | int format; |
| 1630 | |
| 1631 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1632 | ospf_area_no_summary_unset (ospf, area_id); |
| 1633 | |
| 1634 | return CMD_SUCCESS; |
| 1635 | } |
| 1636 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1637 | DEFUN (ospf_area_default_cost, |
| 1638 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1639 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1640 | "OSPF area parameters\n" |
| 1641 | "OSPF area ID in IP address format\n" |
| 1642 | "OSPF area ID as a decimal value\n" |
| 1643 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1644 | "Stub's advertised default summary cost\n") |
| 1645 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1646 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1647 | struct ospf_area *area; |
| 1648 | struct in_addr area_id; |
| 1649 | u_int32_t cost; |
| 1650 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1651 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1652 | |
| 1653 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1654 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1655 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1656 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1657 | |
| 1658 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1659 | { |
| 1660 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1661 | return CMD_WARNING; |
| 1662 | } |
| 1663 | |
| 1664 | area->default_cost = cost; |
| 1665 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1666 | p.family = AF_INET; |
| 1667 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1668 | p.prefixlen = 0; |
| 1669 | if (IS_DEBUG_OSPF_EVENT) |
| 1670 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1671 | "announcing 0.0.0.0/0 to area %s", |
| 1672 | inet_ntoa (area->area_id)); |
| 1673 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1674 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1675 | return CMD_SUCCESS; |
| 1676 | } |
| 1677 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1678 | DEFUN (no_ospf_area_default_cost, |
| 1679 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1680 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1681 | NO_STR |
| 1682 | "OSPF area parameters\n" |
| 1683 | "OSPF area ID in IP address format\n" |
| 1684 | "OSPF area ID as a decimal value\n" |
| 1685 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1686 | "Stub's advertised default summary cost\n") |
| 1687 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1688 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1689 | struct ospf_area *area; |
| 1690 | struct in_addr area_id; |
| 1691 | u_int32_t cost; |
| 1692 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1693 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1694 | |
| 1695 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1696 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1697 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1698 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1699 | if (area == NULL) |
| 1700 | return CMD_SUCCESS; |
| 1701 | |
| 1702 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1703 | { |
| 1704 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1705 | return CMD_WARNING; |
| 1706 | } |
| 1707 | |
| 1708 | area->default_cost = 1; |
| 1709 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1710 | p.family = AF_INET; |
| 1711 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1712 | p.prefixlen = 0; |
| 1713 | if (IS_DEBUG_OSPF_EVENT) |
| 1714 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1715 | "announcing 0.0.0.0/0 to area %s", |
| 1716 | inet_ntoa (area->area_id)); |
| 1717 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1718 | |
| 1719 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1720 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1721 | |
| 1722 | return CMD_SUCCESS; |
| 1723 | } |
| 1724 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1725 | DEFUN (ospf_area_export_list, |
| 1726 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1727 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1728 | "OSPF area parameters\n" |
| 1729 | "OSPF area ID in IP address format\n" |
| 1730 | "OSPF area ID as a decimal value\n" |
| 1731 | "Set the filter for networks announced to other areas\n" |
| 1732 | "Name of the access-list\n") |
| 1733 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1734 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1735 | struct ospf_area *area; |
| 1736 | struct in_addr area_id; |
| 1737 | int format; |
| 1738 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1739 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1740 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1741 | area = ospf_area_get (ospf, area_id, format); |
| 1742 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1743 | |
| 1744 | return CMD_SUCCESS; |
| 1745 | } |
| 1746 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1747 | DEFUN (no_ospf_area_export_list, |
| 1748 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1749 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1750 | NO_STR |
| 1751 | "OSPF area parameters\n" |
| 1752 | "OSPF area ID in IP address format\n" |
| 1753 | "OSPF area ID as a decimal value\n" |
| 1754 | "Unset the filter for networks announced to other areas\n" |
| 1755 | "Name of the access-list\n") |
| 1756 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1757 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1758 | struct ospf_area *area; |
| 1759 | struct in_addr area_id; |
| 1760 | int format; |
| 1761 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1762 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1763 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1764 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1765 | if (area == NULL) |
| 1766 | return CMD_SUCCESS; |
| 1767 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1768 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1769 | |
| 1770 | return CMD_SUCCESS; |
| 1771 | } |
| 1772 | |
| 1773 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1774 | DEFUN (ospf_area_import_list, |
| 1775 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1776 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1777 | "OSPF area parameters\n" |
| 1778 | "OSPF area ID in IP address format\n" |
| 1779 | "OSPF area ID as a decimal value\n" |
| 1780 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1781 | "Name of the access-list\n") |
| 1782 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1783 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | struct ospf_area *area; |
| 1785 | struct in_addr area_id; |
| 1786 | int format; |
| 1787 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1788 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1789 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1790 | area = ospf_area_get (ospf, area_id, format); |
| 1791 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | |
| 1793 | return CMD_SUCCESS; |
| 1794 | } |
| 1795 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1796 | DEFUN (no_ospf_area_import_list, |
| 1797 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1798 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1799 | NO_STR |
| 1800 | "OSPF area parameters\n" |
| 1801 | "OSPF area ID in IP address format\n" |
| 1802 | "OSPF area ID as a decimal value\n" |
| 1803 | "Unset the filter for networks announced to other areas\n" |
| 1804 | "Name of the access-list\n") |
| 1805 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1806 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1807 | struct ospf_area *area; |
| 1808 | struct in_addr area_id; |
| 1809 | int format; |
| 1810 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1811 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1812 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1813 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1814 | if (area == NULL) |
| 1815 | return CMD_SUCCESS; |
| 1816 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1817 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | |
| 1819 | return CMD_SUCCESS; |
| 1820 | } |
| 1821 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1822 | DEFUN (ospf_area_filter_list, |
| 1823 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1824 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1825 | "OSPF area parameters\n" |
| 1826 | "OSPF area ID in IP address format\n" |
| 1827 | "OSPF area ID as a decimal value\n" |
| 1828 | "Filter networks between OSPF areas\n" |
| 1829 | "Filter prefixes between OSPF areas\n" |
| 1830 | "Name of an IP prefix-list\n" |
| 1831 | "Filter networks sent to this area\n" |
| 1832 | "Filter networks sent from this area\n") |
| 1833 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1834 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1835 | struct ospf_area *area; |
| 1836 | struct in_addr area_id; |
| 1837 | struct prefix_list *plist; |
| 1838 | int format; |
| 1839 | |
| 1840 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1841 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1842 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1844 | if (strncmp (argv[2], "in", 2) == 0) |
| 1845 | { |
| 1846 | PREFIX_LIST_IN (area) = plist; |
| 1847 | if (PREFIX_NAME_IN (area)) |
| 1848 | free (PREFIX_NAME_IN (area)); |
| 1849 | |
| 1850 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1851 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1852 | } |
| 1853 | else |
| 1854 | { |
| 1855 | PREFIX_LIST_OUT (area) = plist; |
| 1856 | if (PREFIX_NAME_OUT (area)) |
| 1857 | free (PREFIX_NAME_OUT (area)); |
| 1858 | |
| 1859 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1860 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1861 | } |
| 1862 | |
| 1863 | return CMD_SUCCESS; |
| 1864 | } |
| 1865 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1866 | DEFUN (no_ospf_area_filter_list, |
| 1867 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1868 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1869 | NO_STR |
| 1870 | "OSPF area parameters\n" |
| 1871 | "OSPF area ID in IP address format\n" |
| 1872 | "OSPF area ID as a decimal value\n" |
| 1873 | "Filter networks between OSPF areas\n" |
| 1874 | "Filter prefixes between OSPF areas\n" |
| 1875 | "Name of an IP prefix-list\n" |
| 1876 | "Filter networks sent to this area\n" |
| 1877 | "Filter networks sent from this area\n") |
| 1878 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1879 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1880 | struct ospf_area *area; |
| 1881 | struct in_addr area_id; |
| 1882 | struct prefix_list *plist; |
| 1883 | int format; |
| 1884 | |
| 1885 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1886 | |
Paul Jakma | 1a8ec2b | 2006-05-11 13:34:08 +0000 | [diff] [blame] | 1887 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
| 1888 | return CMD_SUCCESS; |
| 1889 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1890 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1891 | if (strncmp (argv[2], "in", 2) == 0) |
| 1892 | { |
| 1893 | if (PREFIX_NAME_IN (area)) |
| 1894 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1895 | return CMD_SUCCESS; |
| 1896 | |
| 1897 | PREFIX_LIST_IN (area) = NULL; |
| 1898 | if (PREFIX_NAME_IN (area)) |
| 1899 | free (PREFIX_NAME_IN (area)); |
| 1900 | |
| 1901 | PREFIX_NAME_IN (area) = NULL; |
| 1902 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1903 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1904 | } |
| 1905 | else |
| 1906 | { |
| 1907 | if (PREFIX_NAME_OUT (area)) |
| 1908 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1909 | return CMD_SUCCESS; |
| 1910 | |
| 1911 | PREFIX_LIST_OUT (area) = NULL; |
| 1912 | if (PREFIX_NAME_OUT (area)) |
| 1913 | free (PREFIX_NAME_OUT (area)); |
| 1914 | |
| 1915 | PREFIX_NAME_OUT (area) = NULL; |
| 1916 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1917 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1918 | } |
| 1919 | |
| 1920 | return CMD_SUCCESS; |
| 1921 | } |
| 1922 | |
| 1923 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1924 | DEFUN (ospf_area_authentication_message_digest, |
| 1925 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1926 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1927 | "OSPF area parameters\n" |
| 1928 | "Enable authentication\n" |
| 1929 | "Use message-digest authentication\n") |
| 1930 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1931 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1932 | struct ospf_area *area; |
| 1933 | struct in_addr area_id; |
| 1934 | int format; |
| 1935 | |
| 1936 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1937 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1938 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1939 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1940 | |
| 1941 | return CMD_SUCCESS; |
| 1942 | } |
| 1943 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1944 | DEFUN (ospf_area_authentication, |
| 1945 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1946 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1947 | "OSPF area parameters\n" |
| 1948 | "OSPF area ID in IP address format\n" |
| 1949 | "OSPF area ID as a decimal value\n" |
| 1950 | "Enable authentication\n") |
| 1951 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1952 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1953 | struct ospf_area *area; |
| 1954 | struct in_addr area_id; |
| 1955 | int format; |
| 1956 | |
| 1957 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1958 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1959 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1960 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1961 | |
| 1962 | return CMD_SUCCESS; |
| 1963 | } |
| 1964 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1965 | DEFUN (no_ospf_area_authentication, |
| 1966 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1967 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1968 | NO_STR |
| 1969 | "OSPF area parameters\n" |
| 1970 | "OSPF area ID in IP address format\n" |
| 1971 | "OSPF area ID as a decimal value\n" |
| 1972 | "Enable authentication\n") |
| 1973 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1974 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1975 | struct ospf_area *area; |
| 1976 | struct in_addr area_id; |
| 1977 | int format; |
| 1978 | |
| 1979 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1980 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1981 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1982 | if (area == NULL) |
| 1983 | return CMD_SUCCESS; |
| 1984 | |
| 1985 | area->auth_type = OSPF_AUTH_NULL; |
| 1986 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1987 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1988 | |
| 1989 | return CMD_SUCCESS; |
| 1990 | } |
| 1991 | |
| 1992 | |
| 1993 | DEFUN (ospf_abr_type, |
| 1994 | ospf_abr_type_cmd, |
| 1995 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 1996 | "OSPF specific commands\n" |
| 1997 | "Set OSPF ABR type\n" |
| 1998 | "Alternative ABR, cisco implementation\n" |
| 1999 | "Alternative ABR, IBM implementation\n" |
| 2000 | "Shortcut ABR\n" |
| 2001 | "Standard behavior (RFC2328)\n") |
| 2002 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2003 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2004 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2005 | |
| 2006 | if (strncmp (argv[0], "c", 1) == 0) |
| 2007 | abr_type = OSPF_ABR_CISCO; |
| 2008 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2009 | abr_type = OSPF_ABR_IBM; |
| 2010 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2011 | abr_type = OSPF_ABR_SHORTCUT; |
| 2012 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2013 | abr_type = OSPF_ABR_STAND; |
| 2014 | else |
| 2015 | return CMD_WARNING; |
| 2016 | |
| 2017 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2018 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2019 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2020 | ospf->abr_type = abr_type; |
| 2021 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | return CMD_SUCCESS; |
| 2025 | } |
| 2026 | |
| 2027 | DEFUN (no_ospf_abr_type, |
| 2028 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2029 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2030 | NO_STR |
| 2031 | "OSPF specific commands\n" |
| 2032 | "Set OSPF ABR type\n" |
| 2033 | "Alternative ABR, cisco implementation\n" |
| 2034 | "Alternative ABR, IBM implementation\n" |
| 2035 | "Shortcut ABR\n") |
| 2036 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2037 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2038 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2039 | |
| 2040 | if (strncmp (argv[0], "c", 1) == 0) |
| 2041 | abr_type = OSPF_ABR_CISCO; |
| 2042 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2043 | abr_type = OSPF_ABR_IBM; |
| 2044 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2045 | abr_type = OSPF_ABR_SHORTCUT; |
| 2046 | else |
| 2047 | return CMD_WARNING; |
| 2048 | |
| 2049 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2050 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2051 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2052 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2053 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2054 | } |
| 2055 | |
| 2056 | return CMD_SUCCESS; |
| 2057 | } |
| 2058 | |
| 2059 | DEFUN (ospf_compatible_rfc1583, |
| 2060 | ospf_compatible_rfc1583_cmd, |
| 2061 | "compatible rfc1583", |
| 2062 | "OSPF compatibility list\n" |
| 2063 | "compatible with RFC 1583\n") |
| 2064 | { |
| 2065 | struct ospf *ospf = vty->index; |
| 2066 | |
| 2067 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2068 | { |
| 2069 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2070 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2071 | } |
| 2072 | return CMD_SUCCESS; |
| 2073 | } |
| 2074 | |
| 2075 | DEFUN (no_ospf_compatible_rfc1583, |
| 2076 | no_ospf_compatible_rfc1583_cmd, |
| 2077 | "no compatible rfc1583", |
| 2078 | NO_STR |
| 2079 | "OSPF compatibility list\n" |
| 2080 | "compatible with RFC 1583\n") |
| 2081 | { |
| 2082 | struct ospf *ospf = vty->index; |
| 2083 | |
| 2084 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2085 | { |
| 2086 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2087 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2088 | } |
| 2089 | return CMD_SUCCESS; |
| 2090 | } |
| 2091 | |
| 2092 | ALIAS (ospf_compatible_rfc1583, |
| 2093 | ospf_rfc1583_flag_cmd, |
| 2094 | "ospf rfc1583compatibility", |
| 2095 | "OSPF specific commands\n" |
| 2096 | "Enable the RFC1583Compatibility flag\n") |
| 2097 | |
| 2098 | ALIAS (no_ospf_compatible_rfc1583, |
| 2099 | no_ospf_rfc1583_flag_cmd, |
| 2100 | "no ospf rfc1583compatibility", |
| 2101 | NO_STR |
| 2102 | "OSPF specific commands\n" |
| 2103 | "Disable the RFC1583Compatibility flag\n") |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2104 | |
| 2105 | static int |
| 2106 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2107 | unsigned int hold, |
| 2108 | unsigned int max) |
| 2109 | { |
| 2110 | struct ospf *ospf = vty->index; |
| 2111 | |
| 2112 | ospf->spf_delay = delay; |
| 2113 | ospf->spf_holdtime = hold; |
| 2114 | ospf->spf_max_holdtime = max; |
| 2115 | |
| 2116 | return CMD_SUCCESS; |
| 2117 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2119 | DEFUN (ospf_timers_throttle_spf, |
| 2120 | ospf_timers_throttle_spf_cmd, |
| 2121 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2122 | "Adjust routing timers\n" |
| 2123 | "Throttling adaptive timer\n" |
| 2124 | "OSPF SPF timers\n" |
| 2125 | "Delay (msec) from first change received till SPF calculation\n" |
| 2126 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2127 | "Maximum hold time (msec)\n") |
| 2128 | { |
| 2129 | unsigned int delay, hold, max; |
| 2130 | |
| 2131 | if (argc != 3) |
| 2132 | { |
| 2133 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2134 | return CMD_WARNING; |
| 2135 | } |
| 2136 | |
| 2137 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2138 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2139 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2140 | |
| 2141 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2142 | } |
| 2143 | |
| 2144 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2145 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2146 | "timers spf <0-4294967295> <0-4294967295>", |
| 2147 | "Adjust routing timers\n" |
| 2148 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2149 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2150 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2151 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2152 | unsigned int delay, hold; |
| 2153 | |
| 2154 | if (argc != 2) |
| 2155 | { |
| 2156 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2157 | return CMD_WARNING; |
| 2158 | } |
| 2159 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2160 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2161 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2162 | |
| 2163 | /* truncate down the second values if they're greater than 600000ms */ |
| 2164 | if (delay > (600000 / 1000)) |
| 2165 | delay = 600000; |
| 2166 | else if (delay == 0) |
| 2167 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2168 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2169 | if (hold > (600000 / 1000)) |
| 2170 | hold = 600000; |
| 2171 | |
| 2172 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2173 | } |
| 2174 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2175 | DEFUN (no_ospf_timers_throttle_spf, |
| 2176 | no_ospf_timers_throttle_spf_cmd, |
| 2177 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2178 | NO_STR |
| 2179 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2180 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2181 | "OSPF SPF timers\n") |
| 2182 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2183 | return ospf_timers_spf_set (vty, |
| 2184 | OSPF_SPF_DELAY_DEFAULT, |
| 2185 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2186 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2187 | } |
| 2188 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2189 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2190 | no_ospf_timers_spf_cmd, |
| 2191 | "no timers spf", |
| 2192 | NO_STR |
| 2193 | "Adjust routing timers\n" |
| 2194 | "OSPF SPF timers\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2196 | DEFUN (ospf_neighbor, |
| 2197 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2198 | "neighbor A.B.C.D", |
| 2199 | NEIGHBOR_STR |
| 2200 | "Neighbor IP address\n") |
| 2201 | { |
| 2202 | struct ospf *ospf = vty->index; |
| 2203 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2204 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2205 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2206 | |
| 2207 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2208 | |
| 2209 | if (argc > 1) |
| 2210 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2211 | |
| 2212 | if (argc > 2) |
| 2213 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2214 | |
| 2215 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2216 | if (argc > 1) |
| 2217 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2218 | if (argc > 2) |
| 2219 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2220 | |
| 2221 | return CMD_SUCCESS; |
| 2222 | } |
| 2223 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2224 | ALIAS (ospf_neighbor, |
| 2225 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2226 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2227 | NEIGHBOR_STR |
| 2228 | "Neighbor IP address\n" |
| 2229 | "Neighbor Priority\n" |
| 2230 | "Priority\n" |
| 2231 | "Dead Neighbor Polling interval\n" |
| 2232 | "Seconds\n") |
| 2233 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2234 | ALIAS (ospf_neighbor, |
| 2235 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2236 | "neighbor A.B.C.D priority <0-255>", |
| 2237 | NEIGHBOR_STR |
| 2238 | "Neighbor IP address\n" |
| 2239 | "Neighbor Priority\n" |
| 2240 | "Seconds\n") |
| 2241 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2242 | DEFUN (ospf_neighbor_poll_interval, |
| 2243 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2244 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2245 | NEIGHBOR_STR |
| 2246 | "Neighbor IP address\n" |
| 2247 | "Dead Neighbor Polling interval\n" |
| 2248 | "Seconds\n") |
| 2249 | { |
| 2250 | struct ospf *ospf = vty->index; |
| 2251 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2252 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2253 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | |
| 2255 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2256 | |
| 2257 | if (argc > 1) |
| 2258 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2259 | |
| 2260 | if (argc > 2) |
| 2261 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2262 | |
| 2263 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2264 | if (argc > 1) |
| 2265 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2266 | if (argc > 2) |
| 2267 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2268 | |
| 2269 | return CMD_SUCCESS; |
| 2270 | } |
| 2271 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2272 | ALIAS (ospf_neighbor_poll_interval, |
| 2273 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2274 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2275 | NEIGHBOR_STR |
| 2276 | "Neighbor address\n" |
| 2277 | "OSPF dead-router polling interval\n" |
| 2278 | "Seconds\n" |
| 2279 | "OSPF priority of non-broadcast neighbor\n" |
| 2280 | "Priority\n") |
| 2281 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2282 | DEFUN (no_ospf_neighbor, |
| 2283 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | "no neighbor A.B.C.D", |
| 2285 | NO_STR |
| 2286 | NEIGHBOR_STR |
| 2287 | "Neighbor IP address\n") |
| 2288 | { |
| 2289 | struct ospf *ospf = vty->index; |
| 2290 | struct in_addr nbr_addr; |
| 2291 | int ret; |
| 2292 | |
| 2293 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2294 | |
| 2295 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2296 | |
| 2297 | return CMD_SUCCESS; |
| 2298 | } |
| 2299 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2300 | ALIAS (no_ospf_neighbor, |
| 2301 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2302 | "no neighbor A.B.C.D priority <0-255>", |
| 2303 | NO_STR |
| 2304 | NEIGHBOR_STR |
| 2305 | "Neighbor IP address\n" |
| 2306 | "Neighbor Priority\n" |
| 2307 | "Priority\n") |
| 2308 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2309 | ALIAS (no_ospf_neighbor, |
| 2310 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2312 | NO_STR |
| 2313 | NEIGHBOR_STR |
| 2314 | "Neighbor IP address\n" |
| 2315 | "Dead Neighbor Polling interval\n" |
| 2316 | "Seconds\n") |
| 2317 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2318 | ALIAS (no_ospf_neighbor, |
| 2319 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2321 | NO_STR |
| 2322 | NEIGHBOR_STR |
| 2323 | "Neighbor IP address\n" |
| 2324 | "Neighbor Priority\n" |
| 2325 | "Priority\n" |
| 2326 | "Dead Neighbor Polling interval\n" |
| 2327 | "Seconds\n") |
| 2328 | |
| 2329 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2330 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | "refresh timer <10-1800>", |
| 2332 | "Adjust refresh parameters\n" |
| 2333 | "Set refresh timer\n" |
| 2334 | "Timer value in seconds\n") |
| 2335 | { |
| 2336 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2337 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2338 | |
| 2339 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2340 | interval = (interval / 10) * 10; |
| 2341 | |
| 2342 | ospf_timers_refresh_set (ospf, interval); |
| 2343 | |
| 2344 | return CMD_SUCCESS; |
| 2345 | } |
| 2346 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2347 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2348 | "no refresh timer <10-1800>", |
| 2349 | "Adjust refresh parameters\n" |
| 2350 | "Unset refresh timer\n" |
| 2351 | "Timer value in seconds\n") |
| 2352 | { |
| 2353 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2354 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2355 | |
| 2356 | if (argc == 1) |
| 2357 | { |
| 2358 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2359 | |
| 2360 | if (ospf->lsa_refresh_interval != interval || |
| 2361 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2362 | return CMD_SUCCESS; |
| 2363 | } |
| 2364 | |
| 2365 | ospf_timers_refresh_unset (ospf); |
| 2366 | |
| 2367 | return CMD_SUCCESS; |
| 2368 | } |
| 2369 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2370 | ALIAS (no_ospf_refresh_timer, |
| 2371 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2372 | "no refresh timer", |
| 2373 | "Adjust refresh parameters\n" |
| 2374 | "Unset refresh timer\n") |
| 2375 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2376 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2377 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2378 | "auto-cost reference-bandwidth <1-4294967>", |
| 2379 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2380 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2381 | "The reference bandwidth in terms of Mbits per second\n") |
| 2382 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2383 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2384 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2385 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2386 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2387 | |
| 2388 | refbw = strtol (argv[0], NULL, 10); |
| 2389 | if (refbw < 1 || refbw > 4294967) |
| 2390 | { |
| 2391 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2392 | return CMD_WARNING; |
| 2393 | } |
| 2394 | |
| 2395 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2396 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2397 | return CMD_SUCCESS; |
| 2398 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2399 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2400 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2401 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | |
| 2403 | return CMD_SUCCESS; |
| 2404 | } |
| 2405 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2406 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2407 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | "no auto-cost reference-bandwidth", |
| 2409 | NO_STR |
| 2410 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2411 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2412 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2413 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2414 | struct listnode *node, *nnode; |
| 2415 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2416 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2417 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2418 | return CMD_SUCCESS; |
| 2419 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2420 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2421 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2422 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2423 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2424 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2425 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | |
| 2427 | return CMD_SUCCESS; |
| 2428 | } |
| 2429 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2430 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2431 | { |
| 2432 | "Unknown", |
| 2433 | "Standard (RFC2328)", |
| 2434 | "Alternative IBM", |
| 2435 | "Alternative Cisco", |
| 2436 | "Alternative Shortcut" |
| 2437 | }; |
| 2438 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2439 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2440 | { |
| 2441 | "Default", |
| 2442 | "Enabled", |
| 2443 | "Disabled" |
| 2444 | }; |
| 2445 | |
| 2446 | |
| 2447 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2448 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2449 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2450 | { |
| 2451 | /* Show Area ID. */ |
| 2452 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2453 | |
| 2454 | /* Show Area type/mode. */ |
| 2455 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2456 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2457 | else |
| 2458 | { |
| 2459 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2460 | vty_out (vty, " (Stub%s%s)", |
| 2461 | area->no_summary ? ", no summary" : "", |
| 2462 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2463 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2464 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2465 | vty_out (vty, " (NSSA%s%s)", |
| 2466 | area->no_summary ? ", no summary" : "", |
| 2467 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2468 | |
| 2469 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2470 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2471 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2472 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2473 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2474 | } |
| 2475 | |
| 2476 | /* Show number of interfaces. */ |
| 2477 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2478 | "Active: %d%s", listcount (area->oiflist), |
| 2479 | area->act_ints, VTY_NEWLINE); |
| 2480 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2481 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2482 | { |
| 2483 | 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] | 2484 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2485 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2486 | VTY_NEWLINE); |
| 2487 | else if (area->NSSATranslatorState) |
| 2488 | { |
| 2489 | vty_out (vty, " We are an ABR and "); |
| 2490 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2491 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2492 | VTY_NEWLINE); |
| 2493 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2494 | vty_out (vty, "always an NSSA Translator. %s", |
| 2495 | VTY_NEWLINE); |
| 2496 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2497 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2498 | { |
| 2499 | vty_out (vty, " We are an ABR, but "); |
| 2500 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2501 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2502 | VTY_NEWLINE); |
| 2503 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2504 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2505 | VTY_NEWLINE); |
| 2506 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2507 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2508 | /* Stub-router state for this area */ |
| 2509 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2510 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2511 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2512 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2513 | VTY_NEWLINE); |
| 2514 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2515 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2516 | VTY_NEWLINE); |
| 2517 | if (area->t_stub_router) |
| 2518 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2519 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2520 | sizeof(timebuf)), VTY_NEWLINE); |
| 2521 | } |
| 2522 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2523 | /* Show number of fully adjacent neighbors. */ |
| 2524 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2525 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | |
| 2527 | /* Show authentication type. */ |
| 2528 | vty_out (vty, " Area has "); |
| 2529 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2530 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2531 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2532 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2533 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2534 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2535 | |
| 2536 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2537 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2538 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2539 | |
| 2540 | /* Show SPF calculation times. */ |
| 2541 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2542 | area->spf_calculation, VTY_NEWLINE); |
| 2543 | |
| 2544 | /* Show number of LSA. */ |
| 2545 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2546 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2547 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2548 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2549 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2550 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2551 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2552 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2553 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2554 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2555 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2556 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2557 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2558 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2559 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2560 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2561 | #ifdef HAVE_OPAQUE_LSA |
| 2562 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2563 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2564 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2565 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2566 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2567 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2568 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2569 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2570 | } |
| 2571 | |
| 2572 | DEFUN (show_ip_ospf, |
| 2573 | show_ip_ospf_cmd, |
| 2574 | "show ip ospf", |
| 2575 | SHOW_STR |
| 2576 | IP_STR |
| 2577 | "OSPF information\n") |
| 2578 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2579 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2580 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2581 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2582 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2583 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2584 | |
| 2585 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2586 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2587 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2588 | { |
| 2589 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2590 | return CMD_SUCCESS; |
| 2591 | } |
| 2592 | |
| 2593 | /* Show Router ID. */ |
| 2594 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2595 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2596 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2597 | |
| 2598 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2599 | if (ospf->t_deferred_shutdown) |
| 2600 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2601 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2602 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2603 | /* Show capability. */ |
| 2604 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2605 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2606 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2607 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2608 | "enabled" : "disabled", VTY_NEWLINE); |
| 2609 | #ifdef HAVE_OPAQUE_LSA |
| 2610 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2611 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2612 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2613 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2614 | " (origination blocked)" : "", |
| 2615 | VTY_NEWLINE); |
| 2616 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2617 | |
| 2618 | /* Show stub-router configuration */ |
| 2619 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2620 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2621 | { |
| 2622 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2623 | VTY_NEWLINE); |
| 2624 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2625 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2626 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2627 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2628 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2629 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2630 | } |
| 2631 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2632 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2633 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2634 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2635 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2636 | " Hold time multiplier is currently %d%s", |
| 2637 | ospf->spf_delay, VTY_NEWLINE, |
| 2638 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2639 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2640 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2641 | vty_out (vty, " SPF algorithm "); |
| 2642 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2643 | { |
paul | c8c1521 | 2005-11-04 12:31:39 +0000 | [diff] [blame] | 2644 | result = tv_sub (recent_time, ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2645 | vty_out (vty, "last executed %s ago%s", |
| 2646 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2647 | VTY_NEWLINE); |
| 2648 | } |
| 2649 | else |
| 2650 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2651 | vty_out (vty, " SPF timer %s%s%s", |
| 2652 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2653 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2654 | VTY_NEWLINE); |
| 2655 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2656 | /* Show refresh parameters. */ |
| 2657 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2658 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2659 | |
| 2660 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2661 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2662 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2663 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2664 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2665 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2666 | vty_out (vty, " This router is an ASBR " |
| 2667 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2668 | |
| 2669 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2670 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2671 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2672 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2673 | #ifdef HAVE_OPAQUE_LSA |
| 2674 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2675 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2676 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2677 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2678 | /* Show number of areas attached. */ |
| 2679 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2680 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2681 | |
| 2682 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2683 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2684 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2685 | |
| 2686 | return CMD_SUCCESS; |
| 2687 | } |
| 2688 | |
| 2689 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2690 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2691 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2692 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2693 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2694 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2695 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2696 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2698 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2699 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2700 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2701 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2702 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2703 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2704 | |
| 2705 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2706 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2707 | { |
| 2708 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2709 | return; |
| 2710 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2711 | else if (!is_up) |
| 2712 | { |
| 2713 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2714 | VTY_NEWLINE); |
| 2715 | return; |
| 2716 | } |
| 2717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2718 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2719 | { |
| 2720 | struct ospf_interface *oi = rn->info; |
| 2721 | |
| 2722 | if (oi == NULL) |
| 2723 | continue; |
| 2724 | |
| 2725 | /* Show OSPF interface information. */ |
| 2726 | vty_out (vty, " Internet Address %s/%d,", |
| 2727 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2728 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2729 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2730 | { |
| 2731 | struct in_addr *dest; |
| 2732 | const char *dstr; |
| 2733 | |
| 2734 | if ((ifp->flags & IFF_POINTOPOINT) |
| 2735 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2736 | dstr = "Peer"; |
| 2737 | else |
| 2738 | dstr = "Broadcast"; |
| 2739 | |
| 2740 | /* For Vlinks, showing the peer address is probably more |
| 2741 | * informative than the local interface that is being used |
| 2742 | */ |
| 2743 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2744 | dest = &oi->vl_data->peer_addr; |
| 2745 | else |
| 2746 | dest = &oi->connected->destination->u.prefix4; |
| 2747 | |
| 2748 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); |
| 2749 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2751 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2752 | VTY_NEWLINE); |
| 2753 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2754 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2755 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2756 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2757 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2758 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2759 | oi->output_cost, VTY_NEWLINE); |
| 2760 | |
| 2761 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2762 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2763 | PRIORITY (oi), VTY_NEWLINE); |
| 2764 | |
| 2765 | /* Show DR information. */ |
| 2766 | if (DR (oi).s_addr == 0) |
| 2767 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2768 | else |
| 2769 | { |
| 2770 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2771 | if (nbr == NULL) |
| 2772 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2773 | else |
| 2774 | { |
| 2775 | vty_out (vty, " Designated Router (ID) %s,", |
| 2776 | inet_ntoa (nbr->router_id)); |
| 2777 | vty_out (vty, " Interface Address %s%s", |
| 2778 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2779 | } |
| 2780 | } |
| 2781 | |
| 2782 | /* Show BDR information. */ |
| 2783 | if (BDR (oi).s_addr == 0) |
| 2784 | vty_out (vty, " No backup designated router on this network%s", |
| 2785 | VTY_NEWLINE); |
| 2786 | else |
| 2787 | { |
| 2788 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2789 | if (nbr == NULL) |
| 2790 | vty_out (vty, " No backup designated router on this network%s", |
| 2791 | VTY_NEWLINE); |
| 2792 | else |
| 2793 | { |
| 2794 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2795 | inet_ntoa (nbr->router_id)); |
| 2796 | vty_out (vty, " Interface Address %s%s", |
| 2797 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2798 | } |
| 2799 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2800 | |
| 2801 | vty_out (vty, " Multicast group memberships:"); |
Paul Jakma | 429ac78 | 2006-06-15 18:40:49 +0000 | [diff] [blame] | 2802 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
| 2803 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2804 | { |
| 2805 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) |
| 2806 | vty_out (vty, " OSPFAllRouters"); |
| 2807 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2808 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2809 | } |
| 2810 | else |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2811 | vty_out (vty, " <None>"); |
| 2812 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2813 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2814 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2815 | vty_out (vty, " Hello "); |
| 2816 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 2817 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 2818 | else |
| 2819 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 2820 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 2821 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2822 | OSPF_IF_PARAM (oi, v_wait), |
| 2823 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2824 | VTY_NEWLINE); |
| 2825 | |
| 2826 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2827 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2828 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2829 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2830 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2831 | VTY_NEWLINE); |
| 2832 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2833 | else /* OSPF_IF_PASSIVE is set */ |
| 2834 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2835 | |
| 2836 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2837 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2838 | VTY_NEWLINE); |
| 2839 | } |
| 2840 | } |
| 2841 | |
| 2842 | DEFUN (show_ip_ospf_interface, |
| 2843 | show_ip_ospf_interface_cmd, |
| 2844 | "show ip ospf interface [INTERFACE]", |
| 2845 | SHOW_STR |
| 2846 | IP_STR |
| 2847 | "OSPF information\n" |
| 2848 | "Interface information\n" |
| 2849 | "Interface name\n") |
| 2850 | { |
| 2851 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2852 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2853 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2854 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2855 | ospf = ospf_lookup (); |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 2856 | if (ospf == NULL) |
| 2857 | { |
| 2858 | vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2859 | return CMD_SUCCESS; |
| 2860 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2861 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2862 | /* Show All Interfaces. */ |
| 2863 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2864 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 2865 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2866 | /* Interface name is specified. */ |
| 2867 | else |
| 2868 | { |
| 2869 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2870 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2871 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2872 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2873 | } |
| 2874 | |
| 2875 | return CMD_SUCCESS; |
| 2876 | } |
| 2877 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2878 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2879 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 2880 | { |
| 2881 | vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
| 2882 | VTY_NEWLINE, |
| 2883 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 2884 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 2885 | VTY_NEWLINE); |
| 2886 | } |
| 2887 | |
| 2888 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2889 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2890 | { |
| 2891 | struct route_node *rn; |
| 2892 | struct ospf_neighbor *nbr; |
| 2893 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2894 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2895 | |
| 2896 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2897 | if ((nbr = rn->info)) |
| 2898 | /* Do not show myself. */ |
| 2899 | if (nbr != oi->nbr_self) |
| 2900 | /* Down state is not shown. */ |
| 2901 | if (nbr->state != NSM_Down) |
| 2902 | { |
| 2903 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2904 | |
| 2905 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2906 | vty_out (vty, "%-15s %3d %-15s ", |
| 2907 | "-", nbr->priority, |
| 2908 | msgbuf); |
| 2909 | else |
| 2910 | vty_out (vty, "%-15s %3d %-15s ", |
| 2911 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2912 | msgbuf); |
| 2913 | |
| 2914 | vty_out (vty, "%9s ", |
| 2915 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 2916 | sizeof(timebuf))); |
| 2917 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2918 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2919 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2920 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2921 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2922 | VTY_NEWLINE); |
| 2923 | } |
| 2924 | } |
| 2925 | |
| 2926 | DEFUN (show_ip_ospf_neighbor, |
| 2927 | show_ip_ospf_neighbor_cmd, |
| 2928 | "show ip ospf neighbor", |
| 2929 | SHOW_STR |
| 2930 | IP_STR |
| 2931 | "OSPF information\n" |
| 2932 | "Neighbor list\n") |
| 2933 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2934 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2935 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2936 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2937 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2938 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2939 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2940 | { |
| 2941 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2942 | return CMD_SUCCESS; |
| 2943 | } |
| 2944 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2945 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2946 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2947 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 2948 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2949 | |
| 2950 | return CMD_SUCCESS; |
| 2951 | } |
| 2952 | |
| 2953 | DEFUN (show_ip_ospf_neighbor_all, |
| 2954 | show_ip_ospf_neighbor_all_cmd, |
| 2955 | "show ip ospf neighbor all", |
| 2956 | SHOW_STR |
| 2957 | IP_STR |
| 2958 | "OSPF information\n" |
| 2959 | "Neighbor list\n" |
| 2960 | "include down status neighbor\n") |
| 2961 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2962 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2963 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2964 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2965 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2966 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2967 | { |
| 2968 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2969 | return CMD_SUCCESS; |
| 2970 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2971 | |
| 2972 | show_ip_ospf_neighbour_header (vty); |
| 2973 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2974 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2975 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2976 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2977 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2978 | |
| 2979 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2980 | |
| 2981 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2982 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2983 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2984 | if (nbr_nbma->nbr == NULL |
| 2985 | || nbr_nbma->nbr->state == NSM_Down) |
| 2986 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2987 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2988 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2989 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2990 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 2991 | 0, 0, 0, VTY_NEWLINE); |
| 2992 | } |
| 2993 | } |
| 2994 | } |
| 2995 | |
| 2996 | return CMD_SUCCESS; |
| 2997 | } |
| 2998 | |
| 2999 | DEFUN (show_ip_ospf_neighbor_int, |
| 3000 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3001 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3002 | SHOW_STR |
| 3003 | IP_STR |
| 3004 | "OSPF information\n" |
| 3005 | "Neighbor list\n" |
| 3006 | "Interface name\n") |
| 3007 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3008 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3009 | struct interface *ifp; |
| 3010 | struct route_node *rn; |
| 3011 | |
| 3012 | ifp = if_lookup_by_name (argv[0]); |
| 3013 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3014 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3015 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3016 | return CMD_WARNING; |
| 3017 | } |
| 3018 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3019 | ospf = ospf_lookup (); |
| 3020 | if (ospf == NULL) |
| 3021 | { |
| 3022 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3023 | return CMD_SUCCESS; |
| 3024 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3025 | |
| 3026 | show_ip_ospf_neighbour_header (vty); |
| 3027 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3028 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3029 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3030 | struct ospf_interface *oi = rn->info; |
| 3031 | |
| 3032 | if (oi == NULL) |
| 3033 | continue; |
| 3034 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3035 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3036 | } |
| 3037 | |
| 3038 | return CMD_SUCCESS; |
| 3039 | } |
| 3040 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3041 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3042 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3043 | struct ospf_nbr_nbma *nbr_nbma) |
| 3044 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3045 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3046 | |
| 3047 | /* Show neighbor ID. */ |
| 3048 | vty_out (vty, " Neighbor %s,", "-"); |
| 3049 | |
| 3050 | /* Show interface address. */ |
| 3051 | vty_out (vty, " interface address %s%s", |
| 3052 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3053 | /* Show Area ID. */ |
| 3054 | vty_out (vty, " In the area %s via interface %s%s", |
| 3055 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3056 | /* Show neighbor priority and state. */ |
| 3057 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3058 | nbr_nbma->priority, "Down"); |
| 3059 | /* Show state changes. */ |
| 3060 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3061 | |
| 3062 | /* Show PollInterval */ |
| 3063 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3064 | |
| 3065 | /* Show poll-interval timer. */ |
| 3066 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3067 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3068 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3069 | |
| 3070 | /* Show poll-interval timer thread. */ |
| 3071 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3072 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3073 | } |
| 3074 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3075 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3076 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3077 | struct ospf_neighbor *nbr) |
| 3078 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3079 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3080 | |
| 3081 | /* Show neighbor ID. */ |
| 3082 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3083 | vty_out (vty, " Neighbor %s,", "-"); |
| 3084 | else |
| 3085 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3086 | |
| 3087 | /* Show interface address. */ |
| 3088 | vty_out (vty, " interface address %s%s", |
| 3089 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3090 | /* Show Area ID. */ |
| 3091 | vty_out (vty, " In the area %s via interface %s%s", |
| 3092 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3093 | /* Show neighbor priority and state. */ |
| 3094 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3095 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3096 | /* Show state changes. */ |
| 3097 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 3098 | |
| 3099 | /* Show Designated Rotuer ID. */ |
| 3100 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3101 | /* Show Backup Designated Rotuer ID. */ |
| 3102 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3103 | /* Show options. */ |
| 3104 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3105 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3106 | /* Show Router Dead interval timer. */ |
| 3107 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3108 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3109 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3110 | /* Show Database Summary list. */ |
| 3111 | vty_out (vty, " Database Summary List %d%s", |
| 3112 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3113 | /* Show Link State Request list. */ |
| 3114 | vty_out (vty, " Link State Request List %ld%s", |
| 3115 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3116 | /* Show Link State Retransmission list. */ |
| 3117 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3118 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3119 | /* Show inactivity timer thread. */ |
| 3120 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3121 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3122 | /* Show Database Description retransmission thread. */ |
| 3123 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3124 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3125 | /* Show Link State Request Retransmission thread. */ |
| 3126 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3127 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3128 | /* Show Link State Update Retransmission thread. */ |
| 3129 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3130 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3131 | } |
| 3132 | |
| 3133 | DEFUN (show_ip_ospf_neighbor_id, |
| 3134 | show_ip_ospf_neighbor_id_cmd, |
| 3135 | "show ip ospf neighbor A.B.C.D", |
| 3136 | SHOW_STR |
| 3137 | IP_STR |
| 3138 | "OSPF information\n" |
| 3139 | "Neighbor list\n" |
| 3140 | "Neighbor ID\n") |
| 3141 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3142 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3143 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3144 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3145 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3146 | struct in_addr router_id; |
| 3147 | int ret; |
| 3148 | |
| 3149 | ret = inet_aton (argv[0], &router_id); |
| 3150 | if (!ret) |
| 3151 | { |
| 3152 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3153 | return CMD_WARNING; |
| 3154 | } |
| 3155 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3156 | ospf = ospf_lookup (); |
| 3157 | if (ospf == NULL) |
| 3158 | { |
| 3159 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3160 | return CMD_SUCCESS; |
| 3161 | } |
| 3162 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3163 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3164 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 3165 | { |
| 3166 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3167 | return CMD_SUCCESS; |
| 3168 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3169 | |
| 3170 | /* Nothing to show. */ |
| 3171 | return CMD_SUCCESS; |
| 3172 | } |
| 3173 | |
| 3174 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3175 | show_ip_ospf_neighbor_detail_cmd, |
| 3176 | "show ip ospf neighbor detail", |
| 3177 | SHOW_STR |
| 3178 | IP_STR |
| 3179 | "OSPF information\n" |
| 3180 | "Neighbor list\n" |
| 3181 | "detail of all neighbors\n") |
| 3182 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3183 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3184 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3185 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3186 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3187 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3188 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3189 | { |
| 3190 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3191 | return CMD_SUCCESS; |
| 3192 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3193 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3194 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3195 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3196 | struct route_node *rn; |
| 3197 | struct ospf_neighbor *nbr; |
| 3198 | |
| 3199 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3200 | if ((nbr = rn->info)) |
| 3201 | if (nbr != oi->nbr_self) |
| 3202 | if (nbr->state != NSM_Down) |
| 3203 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3204 | } |
| 3205 | |
| 3206 | return CMD_SUCCESS; |
| 3207 | } |
| 3208 | |
| 3209 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3210 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3211 | "show ip ospf neighbor detail all", |
| 3212 | SHOW_STR |
| 3213 | IP_STR |
| 3214 | "OSPF information\n" |
| 3215 | "Neighbor list\n" |
| 3216 | "detail of all neighbors\n" |
| 3217 | "include down status neighbor\n") |
| 3218 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3219 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3220 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3221 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3222 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3223 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3224 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3225 | { |
| 3226 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3227 | return CMD_SUCCESS; |
| 3228 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3229 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3230 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3231 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3232 | struct route_node *rn; |
| 3233 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3234 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3235 | |
| 3236 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3237 | if ((nbr = rn->info)) |
| 3238 | if (nbr != oi->nbr_self) |
| 3239 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3240 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3241 | |
| 3242 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3243 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3244 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3245 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3246 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3247 | if (nbr_nbma->nbr == NULL |
| 3248 | || nbr_nbma->nbr->state == NSM_Down) |
| 3249 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3250 | } |
| 3251 | } |
| 3252 | |
| 3253 | return CMD_SUCCESS; |
| 3254 | } |
| 3255 | |
| 3256 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3257 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3258 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3259 | SHOW_STR |
| 3260 | IP_STR |
| 3261 | "OSPF information\n" |
| 3262 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3263 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3264 | "detail of all neighbors") |
| 3265 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3266 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3267 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3268 | struct interface *ifp; |
| 3269 | struct route_node *rn, *nrn; |
| 3270 | struct ospf_neighbor *nbr; |
| 3271 | |
| 3272 | ifp = if_lookup_by_name (argv[0]); |
| 3273 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3274 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3275 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3276 | return CMD_WARNING; |
| 3277 | } |
| 3278 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3279 | ospf = ospf_lookup (); |
| 3280 | if (ospf == NULL) |
| 3281 | { |
| 3282 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3283 | return CMD_SUCCESS; |
| 3284 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3285 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3286 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3287 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3288 | if ((oi = rn->info)) |
| 3289 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3290 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3291 | if (nbr != oi->nbr_self) |
| 3292 | if (nbr->state != NSM_Down) |
| 3293 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3294 | |
| 3295 | return CMD_SUCCESS; |
| 3296 | } |
| 3297 | |
| 3298 | |
| 3299 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3300 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3301 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3302 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3303 | struct router_lsa *rl; |
| 3304 | struct summary_lsa *sl; |
| 3305 | struct as_external_lsa *asel; |
| 3306 | struct prefix_ipv4 p; |
| 3307 | |
| 3308 | if (lsa != NULL) |
| 3309 | /* If self option is set, check LSA self flag. */ |
| 3310 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3311 | { |
| 3312 | /* LSA common part show. */ |
| 3313 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3314 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3315 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3316 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3317 | /* LSA specific part show. */ |
| 3318 | switch (lsa->data->type) |
| 3319 | { |
| 3320 | case OSPF_ROUTER_LSA: |
| 3321 | rl = (struct router_lsa *) lsa->data; |
| 3322 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3323 | break; |
| 3324 | case OSPF_SUMMARY_LSA: |
| 3325 | sl = (struct summary_lsa *) lsa->data; |
| 3326 | |
| 3327 | p.family = AF_INET; |
| 3328 | p.prefix = sl->header.id; |
| 3329 | p.prefixlen = ip_masklen (sl->mask); |
| 3330 | apply_mask_ipv4 (&p); |
| 3331 | |
| 3332 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3333 | break; |
| 3334 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3335 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3336 | asel = (struct as_external_lsa *) lsa->data; |
| 3337 | |
| 3338 | p.family = AF_INET; |
| 3339 | p.prefix = asel->header.id; |
| 3340 | p.prefixlen = ip_masklen (asel->mask); |
| 3341 | apply_mask_ipv4 (&p); |
| 3342 | |
| 3343 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3344 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3345 | inet_ntoa (p.prefix), p.prefixlen, |
| 3346 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3347 | break; |
| 3348 | case OSPF_NETWORK_LSA: |
| 3349 | case OSPF_ASBR_SUMMARY_LSA: |
| 3350 | #ifdef HAVE_OPAQUE_LSA |
| 3351 | case OSPF_OPAQUE_LINK_LSA: |
| 3352 | case OSPF_OPAQUE_AREA_LSA: |
| 3353 | case OSPF_OPAQUE_AS_LSA: |
| 3354 | #endif /* HAVE_OPAQUE_LSA */ |
| 3355 | default: |
| 3356 | break; |
| 3357 | } |
| 3358 | vty_out (vty, VTY_NEWLINE); |
| 3359 | } |
| 3360 | |
| 3361 | return 0; |
| 3362 | } |
| 3363 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3364 | const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3365 | { |
| 3366 | "unknown", |
| 3367 | "Router Link States", |
| 3368 | "Net Link States", |
| 3369 | "Summary Link States", |
| 3370 | "ASBR-Summary Link States", |
| 3371 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3372 | "Group Membership LSA", |
| 3373 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3374 | #ifdef HAVE_OPAQUE_LSA |
| 3375 | "Type-8 LSA", |
| 3376 | "Link-Local Opaque-LSA", |
| 3377 | "Area-Local Opaque-LSA", |
| 3378 | "AS-external Opaque-LSA", |
| 3379 | #endif /* HAVE_OPAQUE_LSA */ |
| 3380 | }; |
| 3381 | |
| 3382 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3383 | "Link ID ADV Router Age Seq# CkSum" |
| 3384 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3385 | const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3386 | { |
| 3387 | "", |
| 3388 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3389 | "Link ID ADV Router Age Seq# CkSum", |
| 3390 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3391 | "Link ID ADV Router Age Seq# CkSum", |
| 3392 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3393 | " --- header for Group Member ----", |
| 3394 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3395 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3396 | " --- type-8 ---", |
| 3397 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3398 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3399 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3400 | #endif /* HAVE_OPAQUE_LSA */ |
| 3401 | }; |
| 3402 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3403 | const char *show_lsa_flags[] = |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3404 | { |
| 3405 | "Self-originated", |
| 3406 | "Checked", |
| 3407 | "Received", |
| 3408 | "Approved", |
| 3409 | "Discard", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3410 | "Translated", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3411 | }; |
| 3412 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3413 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3414 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3415 | { |
| 3416 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3418 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3419 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3420 | lsa->data->options, |
| 3421 | ospf_options_dump(lsa->data->options), |
| 3422 | VTY_NEWLINE); |
| 3423 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3424 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3425 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3426 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3427 | |
| 3428 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3429 | { |
| 3430 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3431 | |
| 3432 | if (rlsa->flags) |
| 3433 | vty_out (vty, " :%s%s%s%s", |
| 3434 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3435 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3436 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3437 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3438 | |
| 3439 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3440 | } |
| 3441 | vty_out (vty, " LS Type: %s%s", |
| 3442 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3443 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3444 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3445 | vty_out (vty, " Advertising Router: %s%s", |
| 3446 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3447 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3448 | VTY_NEWLINE); |
| 3449 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3450 | VTY_NEWLINE); |
| 3451 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3452 | } |
| 3453 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3454 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3455 | { |
| 3456 | "(null)", |
| 3457 | "another Router (point-to-point)", |
| 3458 | "a Transit Network", |
| 3459 | "Stub Network", |
| 3460 | "a Virtual Link", |
| 3461 | }; |
| 3462 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3463 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3464 | { |
| 3465 | "(null)", |
| 3466 | "Neighboring Router ID", |
| 3467 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3468 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3469 | "Neighboring Router ID", |
| 3470 | }; |
| 3471 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3472 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3473 | { |
| 3474 | "(null)", |
| 3475 | "Router Interface address", |
| 3476 | "Router Interface address", |
| 3477 | "Network Mask", |
| 3478 | "Router Interface address", |
| 3479 | }; |
| 3480 | |
| 3481 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3482 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3483 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3484 | struct router_lsa *rl) |
| 3485 | { |
| 3486 | int len, i, type; |
| 3487 | |
| 3488 | len = ntohs (rl->header.length) - 4; |
| 3489 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3490 | { |
| 3491 | type = rl->link[i].type; |
| 3492 | |
| 3493 | vty_out (vty, " Link connected to: %s%s", |
| 3494 | link_type_desc[type], VTY_NEWLINE); |
| 3495 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3496 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3497 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3498 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3499 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3500 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3501 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3502 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3507 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3508 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3509 | { |
| 3510 | if (lsa != NULL) |
| 3511 | { |
| 3512 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3513 | |
| 3514 | show_ip_ospf_database_header (vty, lsa); |
| 3515 | |
| 3516 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3517 | VTY_NEWLINE, VTY_NEWLINE); |
| 3518 | |
| 3519 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3520 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3521 | } |
| 3522 | |
| 3523 | return 0; |
| 3524 | } |
| 3525 | |
| 3526 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3527 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3528 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3529 | { |
| 3530 | int length, i; |
| 3531 | |
| 3532 | if (lsa != NULL) |
| 3533 | { |
| 3534 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3535 | |
| 3536 | show_ip_ospf_database_header (vty, lsa); |
| 3537 | |
| 3538 | vty_out (vty, " Network Mask: /%d%s", |
| 3539 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3540 | |
| 3541 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3542 | |
| 3543 | for (i = 0; length > 0; i++, length -= 4) |
| 3544 | vty_out (vty, " Attached Router: %s%s", |
| 3545 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3546 | |
| 3547 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3548 | } |
| 3549 | |
| 3550 | return 0; |
| 3551 | } |
| 3552 | |
| 3553 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3554 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3555 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3556 | { |
| 3557 | if (lsa != NULL) |
| 3558 | { |
| 3559 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3560 | |
| 3561 | show_ip_ospf_database_header (vty, lsa); |
| 3562 | |
| 3563 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3564 | VTY_NEWLINE); |
| 3565 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3566 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3567 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3568 | } |
| 3569 | |
| 3570 | return 0; |
| 3571 | } |
| 3572 | |
| 3573 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3574 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3575 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3576 | { |
| 3577 | if (lsa != NULL) |
| 3578 | { |
| 3579 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3580 | |
| 3581 | show_ip_ospf_database_header (vty, lsa); |
| 3582 | |
| 3583 | vty_out (vty, " Network Mask: /%d%s", |
| 3584 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3585 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3586 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3587 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3588 | } |
| 3589 | |
| 3590 | return 0; |
| 3591 | } |
| 3592 | |
| 3593 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3594 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3595 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3596 | { |
| 3597 | if (lsa != NULL) |
| 3598 | { |
| 3599 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3600 | |
| 3601 | show_ip_ospf_database_header (vty, lsa); |
| 3602 | |
| 3603 | vty_out (vty, " Network Mask: /%d%s", |
| 3604 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3605 | vty_out (vty, " Metric Type: %s%s", |
| 3606 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3607 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3608 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3609 | vty_out (vty, " Metric: %d%s", |
| 3610 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3611 | vty_out (vty, " Forward Address: %s%s", |
| 3612 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3613 | |
| 3614 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3615 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3616 | } |
| 3617 | |
| 3618 | return 0; |
| 3619 | } |
| 3620 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3621 | /* N.B. This function currently seems to be unused. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3622 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3623 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3624 | { |
| 3625 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3626 | |
| 3627 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3628 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3629 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3630 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3631 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3632 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3633 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3634 | zlog_debug( " TOS: 0%s", "\n"); |
| 3635 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3636 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3637 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3638 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3639 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3640 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3641 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3642 | |
| 3643 | return 0; |
| 3644 | } |
| 3645 | |
| 3646 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3647 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3649 | { |
| 3650 | if (lsa != NULL) |
| 3651 | { |
| 3652 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3653 | |
| 3654 | show_ip_ospf_database_header (vty, lsa); |
| 3655 | |
| 3656 | vty_out (vty, " Network Mask: /%d%s", |
| 3657 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3658 | vty_out (vty, " Metric Type: %s%s", |
| 3659 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3660 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3661 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3662 | vty_out (vty, " Metric: %d%s", |
| 3663 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3664 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3665 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3666 | |
| 3667 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3668 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3669 | } |
| 3670 | |
| 3671 | return 0; |
| 3672 | } |
| 3673 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3674 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3675 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3676 | { |
| 3677 | return 0; |
| 3678 | } |
| 3679 | |
| 3680 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3681 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3682 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3683 | { |
| 3684 | if (lsa != NULL) |
| 3685 | { |
| 3686 | show_ip_ospf_database_header (vty, lsa); |
| 3687 | show_opaque_info_detail (vty, lsa); |
| 3688 | |
| 3689 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3690 | } |
| 3691 | return 0; |
| 3692 | } |
| 3693 | #endif /* HAVE_OPAQUE_LSA */ |
| 3694 | |
| 3695 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3696 | { |
| 3697 | NULL, |
| 3698 | show_router_lsa_detail, |
| 3699 | show_network_lsa_detail, |
| 3700 | show_summary_lsa_detail, |
| 3701 | show_summary_asbr_lsa_detail, |
| 3702 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3703 | show_func_dummy, |
| 3704 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3705 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3706 | NULL, /* type-8 */ |
| 3707 | show_opaque_lsa_detail, |
| 3708 | show_opaque_lsa_detail, |
| 3709 | show_opaque_lsa_detail, |
| 3710 | #endif /* HAVE_OPAQUE_LSA */ |
| 3711 | }; |
| 3712 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3713 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3714 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3715 | struct in_addr *adv_router) |
| 3716 | { |
| 3717 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3718 | lp->family = 0; |
| 3719 | if (id == NULL) |
| 3720 | lp->prefixlen = 0; |
| 3721 | else if (adv_router == NULL) |
| 3722 | { |
| 3723 | lp->prefixlen = 32; |
| 3724 | lp->id = *id; |
| 3725 | } |
| 3726 | else |
| 3727 | { |
| 3728 | lp->prefixlen = 64; |
| 3729 | lp->id = *id; |
| 3730 | lp->adv_router = *adv_router; |
| 3731 | } |
| 3732 | } |
| 3733 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3734 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3735 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3736 | struct in_addr *id, struct in_addr *adv_router) |
| 3737 | { |
| 3738 | struct prefix_ls lp; |
| 3739 | struct route_node *rn, *start; |
| 3740 | struct ospf_lsa *lsa; |
| 3741 | |
| 3742 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3743 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3744 | if (start) |
| 3745 | { |
| 3746 | route_lock_node (start); |
| 3747 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3748 | if ((lsa = rn->info)) |
| 3749 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3750 | if (show_function[lsa->data->type] != NULL) |
| 3751 | show_function[lsa->data->type] (vty, lsa); |
| 3752 | } |
| 3753 | route_unlock_node (start); |
| 3754 | } |
| 3755 | } |
| 3756 | |
| 3757 | /* Show detail LSA information |
| 3758 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3759 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3760 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3761 | struct in_addr *id, struct in_addr *adv_router) |
| 3762 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3763 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3764 | struct ospf_area *area; |
| 3765 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3766 | switch (type) |
| 3767 | { |
| 3768 | case OSPF_AS_EXTERNAL_LSA: |
| 3769 | #ifdef HAVE_OPAQUE_LSA |
| 3770 | case OSPF_OPAQUE_AS_LSA: |
| 3771 | #endif /* HAVE_OPAQUE_LSA */ |
| 3772 | vty_out (vty, " %s %s%s", |
| 3773 | show_database_desc[type], |
| 3774 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3775 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3776 | break; |
| 3777 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3778 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3779 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3780 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3781 | VTY_NEWLINE, show_database_desc[type], |
| 3782 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3783 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3784 | } |
| 3785 | break; |
| 3786 | } |
| 3787 | } |
| 3788 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3789 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3790 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3791 | struct in_addr *adv_router) |
| 3792 | { |
| 3793 | struct route_node *rn; |
| 3794 | struct ospf_lsa *lsa; |
| 3795 | |
| 3796 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3797 | if ((lsa = rn->info)) |
| 3798 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3799 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3800 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3801 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3802 | if (show_function[lsa->data->type] != NULL) |
| 3803 | show_function[lsa->data->type] (vty, lsa); |
| 3804 | } |
| 3805 | } |
| 3806 | |
| 3807 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3808 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3809 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3810 | struct in_addr *adv_router) |
| 3811 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3812 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3813 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3814 | |
| 3815 | switch (type) |
| 3816 | { |
| 3817 | case OSPF_AS_EXTERNAL_LSA: |
| 3818 | #ifdef HAVE_OPAQUE_LSA |
| 3819 | case OSPF_OPAQUE_AS_LSA: |
| 3820 | #endif /* HAVE_OPAQUE_LSA */ |
| 3821 | vty_out (vty, " %s %s%s", |
| 3822 | show_database_desc[type], |
| 3823 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3824 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3825 | adv_router); |
| 3826 | break; |
| 3827 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3828 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3829 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3830 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3831 | VTY_NEWLINE, show_database_desc[type], |
| 3832 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3833 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3834 | adv_router); |
| 3835 | } |
| 3836 | break; |
| 3837 | } |
| 3838 | } |
| 3839 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3840 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3841 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3842 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3843 | struct ospf_lsa *lsa; |
| 3844 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3845 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3846 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3847 | int type; |
| 3848 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3849 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3850 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3851 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3852 | { |
| 3853 | switch (type) |
| 3854 | { |
| 3855 | case OSPF_AS_EXTERNAL_LSA: |
| 3856 | #ifdef HAVE_OPAQUE_LSA |
| 3857 | case OSPF_OPAQUE_AS_LSA: |
| 3858 | #endif /* HAVE_OPAQUE_LSA */ |
| 3859 | continue; |
| 3860 | default: |
| 3861 | break; |
| 3862 | } |
| 3863 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3864 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3865 | { |
| 3866 | vty_out (vty, " %s (Area %s)%s%s", |
| 3867 | show_database_desc[type], |
| 3868 | ospf_area_desc_string (area), |
| 3869 | VTY_NEWLINE, VTY_NEWLINE); |
| 3870 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3871 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3872 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3873 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3874 | |
| 3875 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3876 | } |
| 3877 | } |
| 3878 | } |
| 3879 | |
| 3880 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3881 | { |
| 3882 | switch (type) |
| 3883 | { |
| 3884 | case OSPF_AS_EXTERNAL_LSA: |
| 3885 | #ifdef HAVE_OPAQUE_LSA |
| 3886 | case OSPF_OPAQUE_AS_LSA: |
| 3887 | #endif /* HAVE_OPAQUE_LSA */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 3888 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3889 | default: |
| 3890 | continue; |
| 3891 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3892 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3893 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3894 | { |
| 3895 | vty_out (vty, " %s%s%s", |
| 3896 | show_database_desc[type], |
| 3897 | VTY_NEWLINE, VTY_NEWLINE); |
| 3898 | vty_out (vty, "%s%s", show_database_header[type], |
| 3899 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3900 | |
| 3901 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3902 | show_lsa_summary (vty, lsa, self); |
| 3903 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3904 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3905 | } |
| 3906 | } |
| 3907 | |
| 3908 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3909 | } |
| 3910 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3911 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3912 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3913 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3914 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3915 | struct ospf_lsa *lsa; |
| 3916 | |
| 3917 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3918 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3919 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3920 | for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa)) |
| 3921 | { |
| 3922 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3923 | vty_out (vty, "Link State ID: %s%s", |
| 3924 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3925 | vty_out (vty, "Advertising Router: %s%s", |
| 3926 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3927 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3928 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3929 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3930 | } |
| 3931 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3932 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3933 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3934 | |
| 3935 | #ifdef HAVE_OPAQUE_LSA |
| 3936 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3937 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3938 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3939 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3940 | #else /* HAVE_OPAQUE_LSA */ |
| 3941 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3942 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3943 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3944 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3945 | #endif /* HAVE_OPAQUE_LSA */ |
| 3946 | |
| 3947 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3948 | "asbr-summary|external|network|router|summary" \ |
| 3949 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3950 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3951 | |
| 3952 | #define OSPF_LSA_TYPES_DESC \ |
| 3953 | "ASBR summary link states\n" \ |
| 3954 | "External link states\n" \ |
| 3955 | "Network link states\n" \ |
| 3956 | "Router link states\n" \ |
| 3957 | "Network summary link states\n" \ |
| 3958 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3959 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3960 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3961 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3962 | |
| 3963 | DEFUN (show_ip_ospf_database, |
| 3964 | show_ip_ospf_database_cmd, |
| 3965 | "show ip ospf database", |
| 3966 | SHOW_STR |
| 3967 | IP_STR |
| 3968 | "OSPF information\n" |
| 3969 | "Database summary\n") |
| 3970 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3971 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3972 | int type, ret; |
| 3973 | struct in_addr id, adv_router; |
| 3974 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3975 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3976 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 3977 | { |
| 3978 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3979 | return CMD_SUCCESS; |
| 3980 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3981 | |
| 3982 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3983 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3984 | |
| 3985 | /* Show all LSA. */ |
| 3986 | if (argc == 0) |
| 3987 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3988 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3989 | return CMD_SUCCESS; |
| 3990 | } |
| 3991 | |
| 3992 | /* Set database type to show. */ |
| 3993 | if (strncmp (argv[0], "r", 1) == 0) |
| 3994 | type = OSPF_ROUTER_LSA; |
| 3995 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3996 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3997 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3998 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3999 | else if (strncmp (argv[0], "su", 2) == 0) |
| 4000 | type = OSPF_SUMMARY_LSA; |
| 4001 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4002 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4003 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4004 | type = OSPF_AS_EXTERNAL_LSA; |
| 4005 | else if (strncmp (argv[0], "se", 2) == 0) |
| 4006 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4007 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4008 | return CMD_SUCCESS; |
| 4009 | } |
| 4010 | else if (strncmp (argv[0], "m", 1) == 0) |
| 4011 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4012 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4013 | return CMD_SUCCESS; |
| 4014 | } |
| 4015 | #ifdef HAVE_OPAQUE_LSA |
| 4016 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4017 | type = OSPF_OPAQUE_LINK_LSA; |
| 4018 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4019 | type = OSPF_OPAQUE_AREA_LSA; |
| 4020 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4021 | type = OSPF_OPAQUE_AS_LSA; |
| 4022 | #endif /* HAVE_OPAQUE_LSA */ |
| 4023 | else |
| 4024 | return CMD_WARNING; |
| 4025 | |
| 4026 | /* `show ip ospf database LSA'. */ |
| 4027 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4028 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4029 | else if (argc >= 2) |
| 4030 | { |
| 4031 | ret = inet_aton (argv[1], &id); |
| 4032 | if (!ret) |
| 4033 | return CMD_WARNING; |
| 4034 | |
| 4035 | /* `show ip ospf database LSA ID'. */ |
| 4036 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4037 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4038 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4039 | else if (argc == 3) |
| 4040 | { |
| 4041 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4042 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4043 | else |
| 4044 | { |
| 4045 | ret = inet_aton (argv[2], &adv_router); |
| 4046 | if (!ret) |
| 4047 | return CMD_WARNING; |
| 4048 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4049 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4050 | } |
| 4051 | } |
| 4052 | |
| 4053 | return CMD_SUCCESS; |
| 4054 | } |
| 4055 | |
| 4056 | ALIAS (show_ip_ospf_database, |
| 4057 | show_ip_ospf_database_type_cmd, |
| 4058 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4059 | SHOW_STR |
| 4060 | IP_STR |
| 4061 | "OSPF information\n" |
| 4062 | "Database summary\n" |
| 4063 | OSPF_LSA_TYPES_DESC |
| 4064 | "LSAs in MaxAge list\n" |
| 4065 | "Self-originated link states\n") |
| 4066 | |
| 4067 | ALIAS (show_ip_ospf_database, |
| 4068 | show_ip_ospf_database_type_id_cmd, |
| 4069 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4070 | SHOW_STR |
| 4071 | IP_STR |
| 4072 | "OSPF information\n" |
| 4073 | "Database summary\n" |
| 4074 | OSPF_LSA_TYPES_DESC |
| 4075 | "Link State ID (as an IP address)\n") |
| 4076 | |
| 4077 | ALIAS (show_ip_ospf_database, |
| 4078 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4079 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4080 | SHOW_STR |
| 4081 | IP_STR |
| 4082 | "OSPF information\n" |
| 4083 | "Database summary\n" |
| 4084 | OSPF_LSA_TYPES_DESC |
| 4085 | "Link State ID (as an IP address)\n" |
| 4086 | "Advertising Router link states\n" |
| 4087 | "Advertising Router (as an IP address)\n") |
| 4088 | |
| 4089 | ALIAS (show_ip_ospf_database, |
| 4090 | show_ip_ospf_database_type_id_self_cmd, |
| 4091 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4092 | SHOW_STR |
| 4093 | IP_STR |
| 4094 | "OSPF information\n" |
| 4095 | "Database summary\n" |
| 4096 | OSPF_LSA_TYPES_DESC |
| 4097 | "Link State ID (as an IP address)\n" |
| 4098 | "Self-originated link states\n" |
| 4099 | "\n") |
| 4100 | |
| 4101 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4102 | show_ip_ospf_database_type_adv_router_cmd, |
| 4103 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4104 | SHOW_STR |
| 4105 | IP_STR |
| 4106 | "OSPF information\n" |
| 4107 | "Database summary\n" |
| 4108 | OSPF_LSA_TYPES_DESC |
| 4109 | "Advertising Router link states\n" |
| 4110 | "Advertising Router (as an IP address)\n") |
| 4111 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4112 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4113 | int type, ret; |
| 4114 | struct in_addr adv_router; |
| 4115 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4116 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4117 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4118 | { |
| 4119 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4120 | return CMD_SUCCESS; |
| 4121 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4122 | |
| 4123 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4124 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4125 | |
| 4126 | if (argc != 2) |
| 4127 | return CMD_WARNING; |
| 4128 | |
| 4129 | /* Set database type to show. */ |
| 4130 | if (strncmp (argv[0], "r", 1) == 0) |
| 4131 | type = OSPF_ROUTER_LSA; |
| 4132 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4133 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4134 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4135 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4136 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4137 | type = OSPF_SUMMARY_LSA; |
| 4138 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4139 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4140 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4141 | type = OSPF_AS_EXTERNAL_LSA; |
| 4142 | #ifdef HAVE_OPAQUE_LSA |
| 4143 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4144 | type = OSPF_OPAQUE_LINK_LSA; |
| 4145 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4146 | type = OSPF_OPAQUE_AREA_LSA; |
| 4147 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4148 | type = OSPF_OPAQUE_AS_LSA; |
| 4149 | #endif /* HAVE_OPAQUE_LSA */ |
| 4150 | else |
| 4151 | return CMD_WARNING; |
| 4152 | |
| 4153 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4154 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4155 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4156 | else |
| 4157 | { |
| 4158 | ret = inet_aton (argv[1], &adv_router); |
| 4159 | if (!ret) |
| 4160 | return CMD_WARNING; |
| 4161 | } |
| 4162 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4163 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4164 | |
| 4165 | return CMD_SUCCESS; |
| 4166 | } |
| 4167 | |
| 4168 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4169 | show_ip_ospf_database_type_self_cmd, |
| 4170 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4171 | SHOW_STR |
| 4172 | IP_STR |
| 4173 | "OSPF information\n" |
| 4174 | "Database summary\n" |
| 4175 | OSPF_LSA_TYPES_DESC |
| 4176 | "Self-originated link states\n") |
| 4177 | |
| 4178 | |
| 4179 | DEFUN (ip_ospf_authentication_args, |
| 4180 | ip_ospf_authentication_args_addr_cmd, |
| 4181 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4182 | "IP Information\n" |
| 4183 | "OSPF interface commands\n" |
| 4184 | "Enable authentication on this interface\n" |
| 4185 | "Use null authentication\n" |
| 4186 | "Use message-digest authentication\n" |
| 4187 | "Address of interface") |
| 4188 | { |
| 4189 | struct interface *ifp; |
| 4190 | struct in_addr addr; |
| 4191 | int ret; |
| 4192 | struct ospf_if_params *params; |
| 4193 | |
| 4194 | ifp = vty->index; |
| 4195 | params = IF_DEF_PARAMS (ifp); |
| 4196 | |
| 4197 | if (argc == 2) |
| 4198 | { |
| 4199 | ret = inet_aton(argv[1], &addr); |
| 4200 | if (!ret) |
| 4201 | { |
| 4202 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4203 | VTY_NEWLINE); |
| 4204 | return CMD_WARNING; |
| 4205 | } |
| 4206 | |
| 4207 | params = ospf_get_if_params (ifp, addr); |
| 4208 | ospf_if_update_params (ifp, addr); |
| 4209 | } |
| 4210 | |
| 4211 | /* Handle null authentication */ |
| 4212 | if ( argv[0][0] == 'n' ) |
| 4213 | { |
| 4214 | SET_IF_PARAM (params, auth_type); |
| 4215 | params->auth_type = OSPF_AUTH_NULL; |
| 4216 | return CMD_SUCCESS; |
| 4217 | } |
| 4218 | |
| 4219 | /* Handle message-digest authentication */ |
| 4220 | if ( argv[0][0] == 'm' ) |
| 4221 | { |
| 4222 | SET_IF_PARAM (params, auth_type); |
| 4223 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4224 | return CMD_SUCCESS; |
| 4225 | } |
| 4226 | |
| 4227 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4228 | return CMD_WARNING; |
| 4229 | } |
| 4230 | |
| 4231 | ALIAS (ip_ospf_authentication_args, |
| 4232 | ip_ospf_authentication_args_cmd, |
| 4233 | "ip ospf authentication (null|message-digest)", |
| 4234 | "IP Information\n" |
| 4235 | "OSPF interface commands\n" |
| 4236 | "Enable authentication on this interface\n" |
| 4237 | "Use null authentication\n" |
| 4238 | "Use message-digest authentication\n") |
| 4239 | |
| 4240 | DEFUN (ip_ospf_authentication, |
| 4241 | ip_ospf_authentication_addr_cmd, |
| 4242 | "ip ospf authentication A.B.C.D", |
| 4243 | "IP Information\n" |
| 4244 | "OSPF interface commands\n" |
| 4245 | "Enable authentication on this interface\n" |
| 4246 | "Address of interface") |
| 4247 | { |
| 4248 | struct interface *ifp; |
| 4249 | struct in_addr addr; |
| 4250 | int ret; |
| 4251 | struct ospf_if_params *params; |
| 4252 | |
| 4253 | ifp = vty->index; |
| 4254 | params = IF_DEF_PARAMS (ifp); |
| 4255 | |
| 4256 | if (argc == 1) |
| 4257 | { |
| 4258 | ret = inet_aton(argv[1], &addr); |
| 4259 | if (!ret) |
| 4260 | { |
| 4261 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4262 | VTY_NEWLINE); |
| 4263 | return CMD_WARNING; |
| 4264 | } |
| 4265 | |
| 4266 | params = ospf_get_if_params (ifp, addr); |
| 4267 | ospf_if_update_params (ifp, addr); |
| 4268 | } |
| 4269 | |
| 4270 | SET_IF_PARAM (params, auth_type); |
| 4271 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4272 | |
| 4273 | return CMD_SUCCESS; |
| 4274 | } |
| 4275 | |
| 4276 | ALIAS (ip_ospf_authentication, |
| 4277 | ip_ospf_authentication_cmd, |
| 4278 | "ip ospf authentication", |
| 4279 | "IP Information\n" |
| 4280 | "OSPF interface commands\n" |
| 4281 | "Enable authentication on this interface\n") |
| 4282 | |
| 4283 | DEFUN (no_ip_ospf_authentication, |
| 4284 | no_ip_ospf_authentication_addr_cmd, |
| 4285 | "no ip ospf authentication A.B.C.D", |
| 4286 | NO_STR |
| 4287 | "IP Information\n" |
| 4288 | "OSPF interface commands\n" |
| 4289 | "Enable authentication on this interface\n" |
| 4290 | "Address of interface") |
| 4291 | { |
| 4292 | struct interface *ifp; |
| 4293 | struct in_addr addr; |
| 4294 | int ret; |
| 4295 | struct ospf_if_params *params; |
| 4296 | |
| 4297 | ifp = vty->index; |
| 4298 | params = IF_DEF_PARAMS (ifp); |
| 4299 | |
| 4300 | if (argc == 1) |
| 4301 | { |
| 4302 | ret = inet_aton(argv[1], &addr); |
| 4303 | if (!ret) |
| 4304 | { |
| 4305 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4306 | VTY_NEWLINE); |
| 4307 | return CMD_WARNING; |
| 4308 | } |
| 4309 | |
| 4310 | params = ospf_lookup_if_params (ifp, addr); |
| 4311 | if (params == NULL) |
| 4312 | return CMD_SUCCESS; |
| 4313 | } |
| 4314 | |
| 4315 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4316 | UNSET_IF_PARAM (params, auth_type); |
| 4317 | |
| 4318 | if (params != IF_DEF_PARAMS (ifp)) |
| 4319 | { |
| 4320 | ospf_free_if_params (ifp, addr); |
| 4321 | ospf_if_update_params (ifp, addr); |
| 4322 | } |
| 4323 | |
| 4324 | return CMD_SUCCESS; |
| 4325 | } |
| 4326 | |
| 4327 | ALIAS (no_ip_ospf_authentication, |
| 4328 | no_ip_ospf_authentication_cmd, |
| 4329 | "no ip ospf authentication", |
| 4330 | NO_STR |
| 4331 | "IP Information\n" |
| 4332 | "OSPF interface commands\n" |
| 4333 | "Enable authentication on this interface\n") |
| 4334 | |
| 4335 | DEFUN (ip_ospf_authentication_key, |
| 4336 | ip_ospf_authentication_key_addr_cmd, |
| 4337 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4338 | "IP Information\n" |
| 4339 | "OSPF interface commands\n" |
| 4340 | "Authentication password (key)\n" |
| 4341 | "The OSPF password (key)\n" |
| 4342 | "Address of interface") |
| 4343 | { |
| 4344 | struct interface *ifp; |
| 4345 | struct in_addr addr; |
| 4346 | int ret; |
| 4347 | struct ospf_if_params *params; |
| 4348 | |
| 4349 | ifp = vty->index; |
| 4350 | params = IF_DEF_PARAMS (ifp); |
| 4351 | |
| 4352 | if (argc == 2) |
| 4353 | { |
| 4354 | ret = inet_aton(argv[1], &addr); |
| 4355 | if (!ret) |
| 4356 | { |
| 4357 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4358 | VTY_NEWLINE); |
| 4359 | return CMD_WARNING; |
| 4360 | } |
| 4361 | |
| 4362 | params = ospf_get_if_params (ifp, addr); |
| 4363 | ospf_if_update_params (ifp, addr); |
| 4364 | } |
| 4365 | |
| 4366 | |
| 4367 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4368 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4369 | SET_IF_PARAM (params, auth_simple); |
| 4370 | |
| 4371 | return CMD_SUCCESS; |
| 4372 | } |
| 4373 | |
| 4374 | ALIAS (ip_ospf_authentication_key, |
| 4375 | ip_ospf_authentication_key_cmd, |
| 4376 | "ip ospf authentication-key AUTH_KEY", |
| 4377 | "IP Information\n" |
| 4378 | "OSPF interface commands\n" |
| 4379 | "Authentication password (key)\n" |
| 4380 | "The OSPF password (key)") |
| 4381 | |
| 4382 | ALIAS (ip_ospf_authentication_key, |
| 4383 | ospf_authentication_key_cmd, |
| 4384 | "ospf authentication-key AUTH_KEY", |
| 4385 | "OSPF interface commands\n" |
| 4386 | "Authentication password (key)\n" |
| 4387 | "The OSPF password (key)") |
| 4388 | |
| 4389 | DEFUN (no_ip_ospf_authentication_key, |
| 4390 | no_ip_ospf_authentication_key_addr_cmd, |
| 4391 | "no ip ospf authentication-key A.B.C.D", |
| 4392 | NO_STR |
| 4393 | "IP Information\n" |
| 4394 | "OSPF interface commands\n" |
| 4395 | "Authentication password (key)\n" |
| 4396 | "Address of interface") |
| 4397 | { |
| 4398 | struct interface *ifp; |
| 4399 | struct in_addr addr; |
| 4400 | int ret; |
| 4401 | struct ospf_if_params *params; |
| 4402 | |
| 4403 | ifp = vty->index; |
| 4404 | params = IF_DEF_PARAMS (ifp); |
| 4405 | |
| 4406 | if (argc == 2) |
| 4407 | { |
| 4408 | ret = inet_aton(argv[1], &addr); |
| 4409 | if (!ret) |
| 4410 | { |
| 4411 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4412 | VTY_NEWLINE); |
| 4413 | return CMD_WARNING; |
| 4414 | } |
| 4415 | |
| 4416 | params = ospf_lookup_if_params (ifp, addr); |
| 4417 | if (params == NULL) |
| 4418 | return CMD_SUCCESS; |
| 4419 | } |
| 4420 | |
| 4421 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4422 | UNSET_IF_PARAM (params, auth_simple); |
| 4423 | |
| 4424 | if (params != IF_DEF_PARAMS (ifp)) |
| 4425 | { |
| 4426 | ospf_free_if_params (ifp, addr); |
| 4427 | ospf_if_update_params (ifp, addr); |
| 4428 | } |
| 4429 | |
| 4430 | return CMD_SUCCESS; |
| 4431 | } |
| 4432 | |
| 4433 | ALIAS (no_ip_ospf_authentication_key, |
| 4434 | no_ip_ospf_authentication_key_cmd, |
| 4435 | "no ip ospf authentication-key", |
| 4436 | NO_STR |
| 4437 | "IP Information\n" |
| 4438 | "OSPF interface commands\n" |
| 4439 | "Authentication password (key)\n") |
| 4440 | |
| 4441 | ALIAS (no_ip_ospf_authentication_key, |
| 4442 | no_ospf_authentication_key_cmd, |
| 4443 | "no ospf authentication-key", |
| 4444 | NO_STR |
| 4445 | "OSPF interface commands\n" |
| 4446 | "Authentication password (key)\n") |
| 4447 | |
| 4448 | DEFUN (ip_ospf_message_digest_key, |
| 4449 | ip_ospf_message_digest_key_addr_cmd, |
| 4450 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4451 | "IP Information\n" |
| 4452 | "OSPF interface commands\n" |
| 4453 | "Message digest authentication password (key)\n" |
| 4454 | "Key ID\n" |
| 4455 | "Use MD5 algorithm\n" |
| 4456 | "The OSPF password (key)" |
| 4457 | "Address of interface") |
| 4458 | { |
| 4459 | struct interface *ifp; |
| 4460 | struct crypt_key *ck; |
| 4461 | u_char key_id; |
| 4462 | struct in_addr addr; |
| 4463 | int ret; |
| 4464 | struct ospf_if_params *params; |
| 4465 | |
| 4466 | ifp = vty->index; |
| 4467 | params = IF_DEF_PARAMS (ifp); |
| 4468 | |
| 4469 | if (argc == 3) |
| 4470 | { |
| 4471 | ret = inet_aton(argv[2], &addr); |
| 4472 | if (!ret) |
| 4473 | { |
| 4474 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4475 | VTY_NEWLINE); |
| 4476 | return CMD_WARNING; |
| 4477 | } |
| 4478 | |
| 4479 | params = ospf_get_if_params (ifp, addr); |
| 4480 | ospf_if_update_params (ifp, addr); |
| 4481 | } |
| 4482 | |
| 4483 | key_id = strtol (argv[0], NULL, 10); |
| 4484 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4485 | { |
| 4486 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4487 | return CMD_WARNING; |
| 4488 | } |
| 4489 | |
| 4490 | ck = ospf_crypt_key_new (); |
| 4491 | ck->key_id = (u_char) key_id; |
| 4492 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4493 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4494 | |
| 4495 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4496 | SET_IF_PARAM (params, auth_crypt); |
| 4497 | |
| 4498 | return CMD_SUCCESS; |
| 4499 | } |
| 4500 | |
| 4501 | ALIAS (ip_ospf_message_digest_key, |
| 4502 | ip_ospf_message_digest_key_cmd, |
| 4503 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4504 | "IP Information\n" |
| 4505 | "OSPF interface commands\n" |
| 4506 | "Message digest authentication password (key)\n" |
| 4507 | "Key ID\n" |
| 4508 | "Use MD5 algorithm\n" |
| 4509 | "The OSPF password (key)") |
| 4510 | |
| 4511 | ALIAS (ip_ospf_message_digest_key, |
| 4512 | ospf_message_digest_key_cmd, |
| 4513 | "ospf message-digest-key <1-255> md5 KEY", |
| 4514 | "OSPF interface commands\n" |
| 4515 | "Message digest authentication password (key)\n" |
| 4516 | "Key ID\n" |
| 4517 | "Use MD5 algorithm\n" |
| 4518 | "The OSPF password (key)") |
| 4519 | |
| 4520 | DEFUN (no_ip_ospf_message_digest_key, |
| 4521 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4522 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4523 | NO_STR |
| 4524 | "IP Information\n" |
| 4525 | "OSPF interface commands\n" |
| 4526 | "Message digest authentication password (key)\n" |
| 4527 | "Key ID\n" |
| 4528 | "Address of interface") |
| 4529 | { |
| 4530 | struct interface *ifp; |
| 4531 | struct crypt_key *ck; |
| 4532 | int key_id; |
| 4533 | struct in_addr addr; |
| 4534 | int ret; |
| 4535 | struct ospf_if_params *params; |
| 4536 | |
| 4537 | ifp = vty->index; |
| 4538 | params = IF_DEF_PARAMS (ifp); |
| 4539 | |
| 4540 | if (argc == 2) |
| 4541 | { |
| 4542 | ret = inet_aton(argv[1], &addr); |
| 4543 | if (!ret) |
| 4544 | { |
| 4545 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4546 | VTY_NEWLINE); |
| 4547 | return CMD_WARNING; |
| 4548 | } |
| 4549 | |
| 4550 | params = ospf_lookup_if_params (ifp, addr); |
| 4551 | if (params == NULL) |
| 4552 | return CMD_SUCCESS; |
| 4553 | } |
| 4554 | |
| 4555 | key_id = strtol (argv[0], NULL, 10); |
| 4556 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4557 | if (ck == NULL) |
| 4558 | { |
| 4559 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4560 | return CMD_WARNING; |
| 4561 | } |
| 4562 | |
| 4563 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4564 | |
| 4565 | if (params != IF_DEF_PARAMS (ifp)) |
| 4566 | { |
| 4567 | ospf_free_if_params (ifp, addr); |
| 4568 | ospf_if_update_params (ifp, addr); |
| 4569 | } |
| 4570 | |
| 4571 | return CMD_SUCCESS; |
| 4572 | } |
| 4573 | |
| 4574 | ALIAS (no_ip_ospf_message_digest_key, |
| 4575 | no_ip_ospf_message_digest_key_cmd, |
| 4576 | "no ip ospf message-digest-key <1-255>", |
| 4577 | NO_STR |
| 4578 | "IP Information\n" |
| 4579 | "OSPF interface commands\n" |
| 4580 | "Message digest authentication password (key)\n" |
| 4581 | "Key ID\n") |
| 4582 | |
| 4583 | ALIAS (no_ip_ospf_message_digest_key, |
| 4584 | no_ospf_message_digest_key_cmd, |
| 4585 | "no ospf message-digest-key <1-255>", |
| 4586 | NO_STR |
| 4587 | "OSPF interface commands\n" |
| 4588 | "Message digest authentication password (key)\n" |
| 4589 | "Key ID\n") |
| 4590 | |
| 4591 | DEFUN (ip_ospf_cost, |
| 4592 | ip_ospf_cost_addr_cmd, |
| 4593 | "ip ospf cost <1-65535> A.B.C.D", |
| 4594 | "IP Information\n" |
| 4595 | "OSPF interface commands\n" |
| 4596 | "Interface cost\n" |
| 4597 | "Cost\n" |
| 4598 | "Address of interface") |
| 4599 | { |
| 4600 | struct interface *ifp = vty->index; |
| 4601 | u_int32_t cost; |
| 4602 | struct in_addr addr; |
| 4603 | int ret; |
| 4604 | struct ospf_if_params *params; |
| 4605 | |
| 4606 | params = IF_DEF_PARAMS (ifp); |
| 4607 | |
| 4608 | cost = strtol (argv[0], NULL, 10); |
| 4609 | |
| 4610 | /* cost range is <1-65535>. */ |
| 4611 | if (cost < 1 || cost > 65535) |
| 4612 | { |
| 4613 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4614 | return CMD_WARNING; |
| 4615 | } |
| 4616 | |
| 4617 | if (argc == 2) |
| 4618 | { |
| 4619 | ret = inet_aton(argv[1], &addr); |
| 4620 | if (!ret) |
| 4621 | { |
| 4622 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4623 | VTY_NEWLINE); |
| 4624 | return CMD_WARNING; |
| 4625 | } |
| 4626 | |
| 4627 | params = ospf_get_if_params (ifp, addr); |
| 4628 | ospf_if_update_params (ifp, addr); |
| 4629 | } |
| 4630 | |
| 4631 | SET_IF_PARAM (params, output_cost_cmd); |
| 4632 | params->output_cost_cmd = cost; |
| 4633 | |
| 4634 | ospf_if_recalculate_output_cost (ifp); |
| 4635 | |
| 4636 | return CMD_SUCCESS; |
| 4637 | } |
| 4638 | |
| 4639 | ALIAS (ip_ospf_cost, |
| 4640 | ip_ospf_cost_cmd, |
| 4641 | "ip ospf cost <1-65535>", |
| 4642 | "IP Information\n" |
| 4643 | "OSPF interface commands\n" |
| 4644 | "Interface cost\n" |
| 4645 | "Cost") |
| 4646 | |
| 4647 | ALIAS (ip_ospf_cost, |
| 4648 | ospf_cost_cmd, |
| 4649 | "ospf cost <1-65535>", |
| 4650 | "OSPF interface commands\n" |
| 4651 | "Interface cost\n" |
| 4652 | "Cost") |
| 4653 | |
| 4654 | DEFUN (no_ip_ospf_cost, |
| 4655 | no_ip_ospf_cost_addr_cmd, |
| 4656 | "no ip ospf cost A.B.C.D", |
| 4657 | NO_STR |
| 4658 | "IP Information\n" |
| 4659 | "OSPF interface commands\n" |
| 4660 | "Interface cost\n" |
| 4661 | "Address of interface") |
| 4662 | { |
| 4663 | struct interface *ifp = vty->index; |
| 4664 | struct in_addr addr; |
| 4665 | int ret; |
| 4666 | struct ospf_if_params *params; |
| 4667 | |
| 4668 | ifp = vty->index; |
| 4669 | params = IF_DEF_PARAMS (ifp); |
| 4670 | |
| 4671 | if (argc == 1) |
| 4672 | { |
| 4673 | ret = inet_aton(argv[0], &addr); |
| 4674 | if (!ret) |
| 4675 | { |
| 4676 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4677 | VTY_NEWLINE); |
| 4678 | return CMD_WARNING; |
| 4679 | } |
| 4680 | |
| 4681 | params = ospf_lookup_if_params (ifp, addr); |
| 4682 | if (params == NULL) |
| 4683 | return CMD_SUCCESS; |
| 4684 | } |
| 4685 | |
| 4686 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4687 | |
| 4688 | if (params != IF_DEF_PARAMS (ifp)) |
| 4689 | { |
| 4690 | ospf_free_if_params (ifp, addr); |
| 4691 | ospf_if_update_params (ifp, addr); |
| 4692 | } |
| 4693 | |
| 4694 | ospf_if_recalculate_output_cost (ifp); |
| 4695 | |
| 4696 | return CMD_SUCCESS; |
| 4697 | } |
| 4698 | |
| 4699 | ALIAS (no_ip_ospf_cost, |
| 4700 | no_ip_ospf_cost_cmd, |
| 4701 | "no ip ospf cost", |
| 4702 | NO_STR |
| 4703 | "IP Information\n" |
| 4704 | "OSPF interface commands\n" |
| 4705 | "Interface cost\n") |
| 4706 | |
| 4707 | ALIAS (no_ip_ospf_cost, |
| 4708 | no_ospf_cost_cmd, |
| 4709 | "no ospf cost", |
| 4710 | NO_STR |
| 4711 | "OSPF interface commands\n" |
| 4712 | "Interface cost\n") |
| 4713 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4714 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4715 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4716 | { |
| 4717 | struct route_node *rn; |
| 4718 | struct ospf_neighbor *nbr; |
| 4719 | |
| 4720 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4721 | if ((nbr = rn->info)) |
| 4722 | { |
| 4723 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4724 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4725 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4726 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4727 | } |
| 4728 | } |
| 4729 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4730 | static int |
| 4731 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 4732 | const char *nbr_str, |
| 4733 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4734 | { |
| 4735 | struct interface *ifp = vty->index; |
| 4736 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4737 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4738 | struct in_addr addr; |
| 4739 | int ret; |
| 4740 | struct ospf_if_params *params; |
| 4741 | struct ospf_interface *oi; |
| 4742 | struct route_node *rn; |
| 4743 | |
| 4744 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4745 | |
| 4746 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4747 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4748 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4749 | if (!ret) |
| 4750 | { |
| 4751 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4752 | VTY_NEWLINE); |
| 4753 | return CMD_WARNING; |
| 4754 | } |
| 4755 | |
| 4756 | params = ospf_get_if_params (ifp, addr); |
| 4757 | ospf_if_update_params (ifp, addr); |
| 4758 | } |
| 4759 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4760 | if (interval_str) |
| 4761 | { |
| 4762 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 4763 | 1, 65535); |
| 4764 | |
| 4765 | /* reset fast_hello too, just to be sure */ |
| 4766 | UNSET_IF_PARAM (params, fast_hello); |
| 4767 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4768 | } |
| 4769 | else if (fast_hello_str) |
| 4770 | { |
| 4771 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 4772 | 1, 10); |
| 4773 | /* 1s dead-interval with sub-second hellos desired */ |
| 4774 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 4775 | SET_IF_PARAM (params, fast_hello); |
| 4776 | params->fast_hello = hellomult; |
| 4777 | } |
| 4778 | else |
| 4779 | { |
| 4780 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 4781 | VTY_NEWLINE); |
| 4782 | return CMD_WARNING; |
| 4783 | } |
| 4784 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4785 | SET_IF_PARAM (params, v_wait); |
| 4786 | params->v_wait = seconds; |
| 4787 | |
| 4788 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4789 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4790 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4791 | struct ospf *ospf; |
| 4792 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4793 | { |
| 4794 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4795 | if (oi) |
| 4796 | ospf_nbr_timer_update (oi); |
| 4797 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4798 | } |
| 4799 | else |
| 4800 | { |
| 4801 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4802 | if ((oi = rn->info)) |
| 4803 | ospf_nbr_timer_update (oi); |
| 4804 | } |
| 4805 | |
| 4806 | return CMD_SUCCESS; |
| 4807 | } |
| 4808 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4809 | |
| 4810 | DEFUN (ip_ospf_dead_interval, |
| 4811 | ip_ospf_dead_interval_addr_cmd, |
| 4812 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4813 | "IP Information\n" |
| 4814 | "OSPF interface commands\n" |
| 4815 | "Interval after which a neighbor is declared dead\n" |
| 4816 | "Seconds\n" |
| 4817 | "Address of interface\n") |
| 4818 | { |
| 4819 | if (argc == 2) |
| 4820 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 4821 | else |
| 4822 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 4823 | } |
| 4824 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4825 | ALIAS (ip_ospf_dead_interval, |
| 4826 | ip_ospf_dead_interval_cmd, |
| 4827 | "ip ospf dead-interval <1-65535>", |
| 4828 | "IP Information\n" |
| 4829 | "OSPF interface commands\n" |
| 4830 | "Interval after which a neighbor is declared dead\n" |
| 4831 | "Seconds\n") |
| 4832 | |
| 4833 | ALIAS (ip_ospf_dead_interval, |
| 4834 | ospf_dead_interval_cmd, |
| 4835 | "ospf dead-interval <1-65535>", |
| 4836 | "OSPF interface commands\n" |
| 4837 | "Interval after which a neighbor is declared dead\n" |
| 4838 | "Seconds\n") |
| 4839 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4840 | DEFUN (ip_ospf_dead_interval_minimal, |
| 4841 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 4842 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 4843 | "IP Information\n" |
| 4844 | "OSPF interface commands\n" |
| 4845 | "Interval after which a neighbor is declared dead\n" |
| 4846 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4847 | "Hello multiplier factor\n" |
| 4848 | "Number of Hellos to send each second\n" |
| 4849 | "Address of interface\n") |
| 4850 | { |
| 4851 | if (argc == 2) |
| 4852 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 4853 | else |
| 4854 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 4855 | } |
| 4856 | |
| 4857 | ALIAS (ip_ospf_dead_interval_minimal, |
| 4858 | ip_ospf_dead_interval_minimal_cmd, |
| 4859 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 4860 | "IP Information\n" |
| 4861 | "OSPF interface commands\n" |
| 4862 | "Interval after which a neighbor is declared dead\n" |
| 4863 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4864 | "Hello multiplier factor\n" |
| 4865 | "Number of Hellos to send each second\n") |
| 4866 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4867 | DEFUN (no_ip_ospf_dead_interval, |
| 4868 | no_ip_ospf_dead_interval_addr_cmd, |
| 4869 | "no ip ospf dead-interval A.B.C.D", |
| 4870 | NO_STR |
| 4871 | "IP Information\n" |
| 4872 | "OSPF interface commands\n" |
| 4873 | "Interval after which a neighbor is declared dead\n" |
| 4874 | "Address of interface") |
| 4875 | { |
| 4876 | struct interface *ifp = vty->index; |
| 4877 | struct in_addr addr; |
| 4878 | int ret; |
| 4879 | struct ospf_if_params *params; |
| 4880 | struct ospf_interface *oi; |
| 4881 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4882 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4883 | ifp = vty->index; |
| 4884 | params = IF_DEF_PARAMS (ifp); |
| 4885 | |
| 4886 | if (argc == 1) |
| 4887 | { |
| 4888 | ret = inet_aton(argv[0], &addr); |
| 4889 | if (!ret) |
| 4890 | { |
| 4891 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4892 | VTY_NEWLINE); |
| 4893 | return CMD_WARNING; |
| 4894 | } |
| 4895 | |
| 4896 | params = ospf_lookup_if_params (ifp, addr); |
| 4897 | if (params == NULL) |
| 4898 | return CMD_SUCCESS; |
| 4899 | } |
| 4900 | |
| 4901 | UNSET_IF_PARAM (params, v_wait); |
| 4902 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4903 | |
| 4904 | UNSET_IF_PARAM (params, fast_hello); |
| 4905 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4906 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4907 | if (params != IF_DEF_PARAMS (ifp)) |
| 4908 | { |
| 4909 | ospf_free_if_params (ifp, addr); |
| 4910 | ospf_if_update_params (ifp, addr); |
| 4911 | } |
| 4912 | |
| 4913 | /* Update timer values in neighbor structure. */ |
| 4914 | if (argc == 1) |
| 4915 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4916 | struct ospf *ospf; |
| 4917 | |
| 4918 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4919 | { |
| 4920 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4921 | if (oi) |
| 4922 | ospf_nbr_timer_update (oi); |
| 4923 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4924 | } |
| 4925 | else |
| 4926 | { |
| 4927 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4928 | if ((oi = rn->info)) |
| 4929 | ospf_nbr_timer_update (oi); |
| 4930 | } |
| 4931 | |
| 4932 | return CMD_SUCCESS; |
| 4933 | } |
| 4934 | |
| 4935 | ALIAS (no_ip_ospf_dead_interval, |
| 4936 | no_ip_ospf_dead_interval_cmd, |
| 4937 | "no ip ospf dead-interval", |
| 4938 | NO_STR |
| 4939 | "IP Information\n" |
| 4940 | "OSPF interface commands\n" |
| 4941 | "Interval after which a neighbor is declared dead\n") |
| 4942 | |
| 4943 | ALIAS (no_ip_ospf_dead_interval, |
| 4944 | no_ospf_dead_interval_cmd, |
| 4945 | "no ospf dead-interval", |
| 4946 | NO_STR |
| 4947 | "OSPF interface commands\n" |
| 4948 | "Interval after which a neighbor is declared dead\n") |
| 4949 | |
| 4950 | DEFUN (ip_ospf_hello_interval, |
| 4951 | ip_ospf_hello_interval_addr_cmd, |
| 4952 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4953 | "IP Information\n" |
| 4954 | "OSPF interface commands\n" |
| 4955 | "Time between HELLO packets\n" |
| 4956 | "Seconds\n" |
| 4957 | "Address of interface") |
| 4958 | { |
| 4959 | struct interface *ifp = vty->index; |
| 4960 | u_int32_t seconds; |
| 4961 | struct in_addr addr; |
| 4962 | int ret; |
| 4963 | struct ospf_if_params *params; |
| 4964 | |
| 4965 | params = IF_DEF_PARAMS (ifp); |
| 4966 | |
| 4967 | seconds = strtol (argv[0], NULL, 10); |
| 4968 | |
| 4969 | /* HelloInterval range is <1-65535>. */ |
| 4970 | if (seconds < 1 || seconds > 65535) |
| 4971 | { |
| 4972 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4973 | return CMD_WARNING; |
| 4974 | } |
| 4975 | |
| 4976 | if (argc == 2) |
| 4977 | { |
| 4978 | ret = inet_aton(argv[1], &addr); |
| 4979 | if (!ret) |
| 4980 | { |
| 4981 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4982 | VTY_NEWLINE); |
| 4983 | return CMD_WARNING; |
| 4984 | } |
| 4985 | |
| 4986 | params = ospf_get_if_params (ifp, addr); |
| 4987 | ospf_if_update_params (ifp, addr); |
| 4988 | } |
| 4989 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4990 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4991 | params->v_hello = seconds; |
| 4992 | |
| 4993 | return CMD_SUCCESS; |
| 4994 | } |
| 4995 | |
| 4996 | ALIAS (ip_ospf_hello_interval, |
| 4997 | ip_ospf_hello_interval_cmd, |
| 4998 | "ip ospf hello-interval <1-65535>", |
| 4999 | "IP Information\n" |
| 5000 | "OSPF interface commands\n" |
| 5001 | "Time between HELLO packets\n" |
| 5002 | "Seconds\n") |
| 5003 | |
| 5004 | ALIAS (ip_ospf_hello_interval, |
| 5005 | ospf_hello_interval_cmd, |
| 5006 | "ospf hello-interval <1-65535>", |
| 5007 | "OSPF interface commands\n" |
| 5008 | "Time between HELLO packets\n" |
| 5009 | "Seconds\n") |
| 5010 | |
| 5011 | DEFUN (no_ip_ospf_hello_interval, |
| 5012 | no_ip_ospf_hello_interval_addr_cmd, |
| 5013 | "no ip ospf hello-interval A.B.C.D", |
| 5014 | NO_STR |
| 5015 | "IP Information\n" |
| 5016 | "OSPF interface commands\n" |
| 5017 | "Time between HELLO packets\n" |
| 5018 | "Address of interface") |
| 5019 | { |
| 5020 | struct interface *ifp = vty->index; |
| 5021 | struct in_addr addr; |
| 5022 | int ret; |
| 5023 | struct ospf_if_params *params; |
| 5024 | |
| 5025 | ifp = vty->index; |
| 5026 | params = IF_DEF_PARAMS (ifp); |
| 5027 | |
| 5028 | if (argc == 1) |
| 5029 | { |
| 5030 | ret = inet_aton(argv[0], &addr); |
| 5031 | if (!ret) |
| 5032 | { |
| 5033 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5034 | VTY_NEWLINE); |
| 5035 | return CMD_WARNING; |
| 5036 | } |
| 5037 | |
| 5038 | params = ospf_lookup_if_params (ifp, addr); |
| 5039 | if (params == NULL) |
| 5040 | return CMD_SUCCESS; |
| 5041 | } |
| 5042 | |
| 5043 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5044 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5045 | |
| 5046 | if (params != IF_DEF_PARAMS (ifp)) |
| 5047 | { |
| 5048 | ospf_free_if_params (ifp, addr); |
| 5049 | ospf_if_update_params (ifp, addr); |
| 5050 | } |
| 5051 | |
| 5052 | return CMD_SUCCESS; |
| 5053 | } |
| 5054 | |
| 5055 | ALIAS (no_ip_ospf_hello_interval, |
| 5056 | no_ip_ospf_hello_interval_cmd, |
| 5057 | "no ip ospf hello-interval", |
| 5058 | NO_STR |
| 5059 | "IP Information\n" |
| 5060 | "OSPF interface commands\n" |
| 5061 | "Time between HELLO packets\n") |
| 5062 | |
| 5063 | ALIAS (no_ip_ospf_hello_interval, |
| 5064 | no_ospf_hello_interval_cmd, |
| 5065 | "no ospf hello-interval", |
| 5066 | NO_STR |
| 5067 | "OSPF interface commands\n" |
| 5068 | "Time between HELLO packets\n") |
| 5069 | |
| 5070 | DEFUN (ip_ospf_network, |
| 5071 | ip_ospf_network_cmd, |
| 5072 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5073 | "IP Information\n" |
| 5074 | "OSPF interface commands\n" |
| 5075 | "Network type\n" |
| 5076 | "Specify OSPF broadcast multi-access network\n" |
| 5077 | "Specify OSPF NBMA network\n" |
| 5078 | "Specify OSPF point-to-multipoint network\n" |
| 5079 | "Specify OSPF point-to-point network\n") |
| 5080 | { |
| 5081 | struct interface *ifp = vty->index; |
| 5082 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5083 | struct route_node *rn; |
| 5084 | |
| 5085 | if (strncmp (argv[0], "b", 1) == 0) |
| 5086 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5087 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5088 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5089 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5090 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5091 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5092 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5093 | |
| 5094 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5095 | return CMD_SUCCESS; |
| 5096 | |
| 5097 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5098 | |
| 5099 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5100 | { |
| 5101 | struct ospf_interface *oi = rn->info; |
| 5102 | |
| 5103 | if (!oi) |
| 5104 | continue; |
| 5105 | |
| 5106 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5107 | |
| 5108 | if (oi->state > ISM_Down) |
| 5109 | { |
| 5110 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5111 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5112 | } |
| 5113 | } |
| 5114 | |
| 5115 | return CMD_SUCCESS; |
| 5116 | } |
| 5117 | |
| 5118 | ALIAS (ip_ospf_network, |
| 5119 | ospf_network_cmd, |
| 5120 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5121 | "OSPF interface commands\n" |
| 5122 | "Network type\n" |
| 5123 | "Specify OSPF broadcast multi-access network\n" |
| 5124 | "Specify OSPF NBMA network\n" |
| 5125 | "Specify OSPF point-to-multipoint network\n" |
| 5126 | "Specify OSPF point-to-point network\n") |
| 5127 | |
| 5128 | DEFUN (no_ip_ospf_network, |
| 5129 | no_ip_ospf_network_cmd, |
| 5130 | "no ip ospf network", |
| 5131 | NO_STR |
| 5132 | "IP Information\n" |
| 5133 | "OSPF interface commands\n" |
| 5134 | "Network type\n") |
| 5135 | { |
| 5136 | struct interface *ifp = vty->index; |
| 5137 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5138 | struct route_node *rn; |
| 5139 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5140 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5141 | |
| 5142 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5143 | return CMD_SUCCESS; |
| 5144 | |
| 5145 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5146 | { |
| 5147 | struct ospf_interface *oi = rn->info; |
| 5148 | |
| 5149 | if (!oi) |
| 5150 | continue; |
| 5151 | |
| 5152 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5153 | |
| 5154 | if (oi->state > ISM_Down) |
| 5155 | { |
| 5156 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5157 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5158 | } |
| 5159 | } |
| 5160 | |
| 5161 | return CMD_SUCCESS; |
| 5162 | } |
| 5163 | |
| 5164 | ALIAS (no_ip_ospf_network, |
| 5165 | no_ospf_network_cmd, |
| 5166 | "no ospf network", |
| 5167 | NO_STR |
| 5168 | "OSPF interface commands\n" |
| 5169 | "Network type\n") |
| 5170 | |
| 5171 | DEFUN (ip_ospf_priority, |
| 5172 | ip_ospf_priority_addr_cmd, |
| 5173 | "ip ospf priority <0-255> A.B.C.D", |
| 5174 | "IP Information\n" |
| 5175 | "OSPF interface commands\n" |
| 5176 | "Router priority\n" |
| 5177 | "Priority\n" |
| 5178 | "Address of interface") |
| 5179 | { |
| 5180 | struct interface *ifp = vty->index; |
| 5181 | u_int32_t priority; |
| 5182 | struct route_node *rn; |
| 5183 | struct in_addr addr; |
| 5184 | int ret; |
| 5185 | struct ospf_if_params *params; |
| 5186 | |
| 5187 | params = IF_DEF_PARAMS (ifp); |
| 5188 | |
| 5189 | priority = strtol (argv[0], NULL, 10); |
| 5190 | |
| 5191 | /* Router Priority range is <0-255>. */ |
| 5192 | if (priority < 0 || priority > 255) |
| 5193 | { |
| 5194 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5195 | return CMD_WARNING; |
| 5196 | } |
| 5197 | |
| 5198 | if (argc == 2) |
| 5199 | { |
| 5200 | ret = inet_aton(argv[1], &addr); |
| 5201 | if (!ret) |
| 5202 | { |
| 5203 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5204 | VTY_NEWLINE); |
| 5205 | return CMD_WARNING; |
| 5206 | } |
| 5207 | |
| 5208 | params = ospf_get_if_params (ifp, addr); |
| 5209 | ospf_if_update_params (ifp, addr); |
| 5210 | } |
| 5211 | |
| 5212 | SET_IF_PARAM (params, priority); |
| 5213 | params->priority = priority; |
| 5214 | |
| 5215 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5216 | { |
| 5217 | struct ospf_interface *oi = rn->info; |
| 5218 | |
| 5219 | if (!oi) |
| 5220 | continue; |
| 5221 | |
| 5222 | |
| 5223 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5224 | { |
| 5225 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5226 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5227 | } |
| 5228 | } |
| 5229 | |
| 5230 | return CMD_SUCCESS; |
| 5231 | } |
| 5232 | |
| 5233 | ALIAS (ip_ospf_priority, |
| 5234 | ip_ospf_priority_cmd, |
| 5235 | "ip ospf priority <0-255>", |
| 5236 | "IP Information\n" |
| 5237 | "OSPF interface commands\n" |
| 5238 | "Router priority\n" |
| 5239 | "Priority\n") |
| 5240 | |
| 5241 | ALIAS (ip_ospf_priority, |
| 5242 | ospf_priority_cmd, |
| 5243 | "ospf priority <0-255>", |
| 5244 | "OSPF interface commands\n" |
| 5245 | "Router priority\n" |
| 5246 | "Priority\n") |
| 5247 | |
| 5248 | DEFUN (no_ip_ospf_priority, |
| 5249 | no_ip_ospf_priority_addr_cmd, |
| 5250 | "no ip ospf priority A.B.C.D", |
| 5251 | NO_STR |
| 5252 | "IP Information\n" |
| 5253 | "OSPF interface commands\n" |
| 5254 | "Router priority\n" |
| 5255 | "Address of interface") |
| 5256 | { |
| 5257 | struct interface *ifp = vty->index; |
| 5258 | struct route_node *rn; |
| 5259 | struct in_addr addr; |
| 5260 | int ret; |
| 5261 | struct ospf_if_params *params; |
| 5262 | |
| 5263 | ifp = vty->index; |
| 5264 | params = IF_DEF_PARAMS (ifp); |
| 5265 | |
| 5266 | if (argc == 1) |
| 5267 | { |
| 5268 | ret = inet_aton(argv[0], &addr); |
| 5269 | if (!ret) |
| 5270 | { |
| 5271 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5272 | VTY_NEWLINE); |
| 5273 | return CMD_WARNING; |
| 5274 | } |
| 5275 | |
| 5276 | params = ospf_lookup_if_params (ifp, addr); |
| 5277 | if (params == NULL) |
| 5278 | return CMD_SUCCESS; |
| 5279 | } |
| 5280 | |
| 5281 | UNSET_IF_PARAM (params, priority); |
| 5282 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5283 | |
| 5284 | if (params != IF_DEF_PARAMS (ifp)) |
| 5285 | { |
| 5286 | ospf_free_if_params (ifp, addr); |
| 5287 | ospf_if_update_params (ifp, addr); |
| 5288 | } |
| 5289 | |
| 5290 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5291 | { |
| 5292 | struct ospf_interface *oi = rn->info; |
| 5293 | |
| 5294 | if (!oi) |
| 5295 | continue; |
| 5296 | |
| 5297 | |
| 5298 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5299 | { |
| 5300 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5301 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5302 | } |
| 5303 | } |
| 5304 | |
| 5305 | return CMD_SUCCESS; |
| 5306 | } |
| 5307 | |
| 5308 | ALIAS (no_ip_ospf_priority, |
| 5309 | no_ip_ospf_priority_cmd, |
| 5310 | "no ip ospf priority", |
| 5311 | NO_STR |
| 5312 | "IP Information\n" |
| 5313 | "OSPF interface commands\n" |
| 5314 | "Router priority\n") |
| 5315 | |
| 5316 | ALIAS (no_ip_ospf_priority, |
| 5317 | no_ospf_priority_cmd, |
| 5318 | "no ospf priority", |
| 5319 | NO_STR |
| 5320 | "OSPF interface commands\n" |
| 5321 | "Router priority\n") |
| 5322 | |
| 5323 | DEFUN (ip_ospf_retransmit_interval, |
| 5324 | ip_ospf_retransmit_interval_addr_cmd, |
| 5325 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5326 | "IP Information\n" |
| 5327 | "OSPF interface commands\n" |
| 5328 | "Time between retransmitting lost link state advertisements\n" |
| 5329 | "Seconds\n" |
| 5330 | "Address of interface") |
| 5331 | { |
| 5332 | struct interface *ifp = vty->index; |
| 5333 | u_int32_t seconds; |
| 5334 | struct in_addr addr; |
| 5335 | int ret; |
| 5336 | struct ospf_if_params *params; |
| 5337 | |
| 5338 | params = IF_DEF_PARAMS (ifp); |
| 5339 | seconds = strtol (argv[0], NULL, 10); |
| 5340 | |
| 5341 | /* Retransmit Interval range is <3-65535>. */ |
| 5342 | if (seconds < 3 || seconds > 65535) |
| 5343 | { |
| 5344 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5345 | return CMD_WARNING; |
| 5346 | } |
| 5347 | |
| 5348 | |
| 5349 | if (argc == 2) |
| 5350 | { |
| 5351 | ret = inet_aton(argv[1], &addr); |
| 5352 | if (!ret) |
| 5353 | { |
| 5354 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5355 | VTY_NEWLINE); |
| 5356 | return CMD_WARNING; |
| 5357 | } |
| 5358 | |
| 5359 | params = ospf_get_if_params (ifp, addr); |
| 5360 | ospf_if_update_params (ifp, addr); |
| 5361 | } |
| 5362 | |
| 5363 | SET_IF_PARAM (params, retransmit_interval); |
| 5364 | params->retransmit_interval = seconds; |
| 5365 | |
| 5366 | return CMD_SUCCESS; |
| 5367 | } |
| 5368 | |
| 5369 | ALIAS (ip_ospf_retransmit_interval, |
| 5370 | ip_ospf_retransmit_interval_cmd, |
| 5371 | "ip ospf retransmit-interval <3-65535>", |
| 5372 | "IP Information\n" |
| 5373 | "OSPF interface commands\n" |
| 5374 | "Time between retransmitting lost link state advertisements\n" |
| 5375 | "Seconds\n") |
| 5376 | |
| 5377 | ALIAS (ip_ospf_retransmit_interval, |
| 5378 | ospf_retransmit_interval_cmd, |
| 5379 | "ospf retransmit-interval <3-65535>", |
| 5380 | "OSPF interface commands\n" |
| 5381 | "Time between retransmitting lost link state advertisements\n" |
| 5382 | "Seconds\n") |
| 5383 | |
| 5384 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5385 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5386 | "no ip ospf retransmit-interval A.B.C.D", |
| 5387 | NO_STR |
| 5388 | "IP Information\n" |
| 5389 | "OSPF interface commands\n" |
| 5390 | "Time between retransmitting lost link state advertisements\n" |
| 5391 | "Address of interface") |
| 5392 | { |
| 5393 | struct interface *ifp = vty->index; |
| 5394 | struct in_addr addr; |
| 5395 | int ret; |
| 5396 | struct ospf_if_params *params; |
| 5397 | |
| 5398 | ifp = vty->index; |
| 5399 | params = IF_DEF_PARAMS (ifp); |
| 5400 | |
| 5401 | if (argc == 1) |
| 5402 | { |
| 5403 | ret = inet_aton(argv[0], &addr); |
| 5404 | if (!ret) |
| 5405 | { |
| 5406 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5407 | VTY_NEWLINE); |
| 5408 | return CMD_WARNING; |
| 5409 | } |
| 5410 | |
| 5411 | params = ospf_lookup_if_params (ifp, addr); |
| 5412 | if (params == NULL) |
| 5413 | return CMD_SUCCESS; |
| 5414 | } |
| 5415 | |
| 5416 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5417 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5418 | |
| 5419 | if (params != IF_DEF_PARAMS (ifp)) |
| 5420 | { |
| 5421 | ospf_free_if_params (ifp, addr); |
| 5422 | ospf_if_update_params (ifp, addr); |
| 5423 | } |
| 5424 | |
| 5425 | return CMD_SUCCESS; |
| 5426 | } |
| 5427 | |
| 5428 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5429 | no_ip_ospf_retransmit_interval_cmd, |
| 5430 | "no ip ospf retransmit-interval", |
| 5431 | NO_STR |
| 5432 | "IP Information\n" |
| 5433 | "OSPF interface commands\n" |
| 5434 | "Time between retransmitting lost link state advertisements\n") |
| 5435 | |
| 5436 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5437 | no_ospf_retransmit_interval_cmd, |
| 5438 | "no ospf retransmit-interval", |
| 5439 | NO_STR |
| 5440 | "OSPF interface commands\n" |
| 5441 | "Time between retransmitting lost link state advertisements\n") |
| 5442 | |
| 5443 | DEFUN (ip_ospf_transmit_delay, |
| 5444 | ip_ospf_transmit_delay_addr_cmd, |
| 5445 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5446 | "IP Information\n" |
| 5447 | "OSPF interface commands\n" |
| 5448 | "Link state transmit delay\n" |
| 5449 | "Seconds\n" |
| 5450 | "Address of interface") |
| 5451 | { |
| 5452 | struct interface *ifp = vty->index; |
| 5453 | u_int32_t seconds; |
| 5454 | struct in_addr addr; |
| 5455 | int ret; |
| 5456 | struct ospf_if_params *params; |
| 5457 | |
| 5458 | params = IF_DEF_PARAMS (ifp); |
| 5459 | seconds = strtol (argv[0], NULL, 10); |
| 5460 | |
| 5461 | /* Transmit Delay range is <1-65535>. */ |
| 5462 | if (seconds < 1 || seconds > 65535) |
| 5463 | { |
| 5464 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5465 | return CMD_WARNING; |
| 5466 | } |
| 5467 | |
| 5468 | if (argc == 2) |
| 5469 | { |
| 5470 | ret = inet_aton(argv[1], &addr); |
| 5471 | if (!ret) |
| 5472 | { |
| 5473 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5474 | VTY_NEWLINE); |
| 5475 | return CMD_WARNING; |
| 5476 | } |
| 5477 | |
| 5478 | params = ospf_get_if_params (ifp, addr); |
| 5479 | ospf_if_update_params (ifp, addr); |
| 5480 | } |
| 5481 | |
| 5482 | SET_IF_PARAM (params, transmit_delay); |
| 5483 | params->transmit_delay = seconds; |
| 5484 | |
| 5485 | return CMD_SUCCESS; |
| 5486 | } |
| 5487 | |
| 5488 | ALIAS (ip_ospf_transmit_delay, |
| 5489 | ip_ospf_transmit_delay_cmd, |
| 5490 | "ip ospf transmit-delay <1-65535>", |
| 5491 | "IP Information\n" |
| 5492 | "OSPF interface commands\n" |
| 5493 | "Link state transmit delay\n" |
| 5494 | "Seconds\n") |
| 5495 | |
| 5496 | ALIAS (ip_ospf_transmit_delay, |
| 5497 | ospf_transmit_delay_cmd, |
| 5498 | "ospf transmit-delay <1-65535>", |
| 5499 | "OSPF interface commands\n" |
| 5500 | "Link state transmit delay\n" |
| 5501 | "Seconds\n") |
| 5502 | |
| 5503 | DEFUN (no_ip_ospf_transmit_delay, |
| 5504 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5505 | "no ip ospf transmit-delay A.B.C.D", |
| 5506 | NO_STR |
| 5507 | "IP Information\n" |
| 5508 | "OSPF interface commands\n" |
| 5509 | "Link state transmit delay\n" |
| 5510 | "Address of interface") |
| 5511 | { |
| 5512 | struct interface *ifp = vty->index; |
| 5513 | struct in_addr addr; |
| 5514 | int ret; |
| 5515 | struct ospf_if_params *params; |
| 5516 | |
| 5517 | ifp = vty->index; |
| 5518 | params = IF_DEF_PARAMS (ifp); |
| 5519 | |
| 5520 | if (argc == 1) |
| 5521 | { |
| 5522 | ret = inet_aton(argv[0], &addr); |
| 5523 | if (!ret) |
| 5524 | { |
| 5525 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5526 | VTY_NEWLINE); |
| 5527 | return CMD_WARNING; |
| 5528 | } |
| 5529 | |
| 5530 | params = ospf_lookup_if_params (ifp, addr); |
| 5531 | if (params == NULL) |
| 5532 | return CMD_SUCCESS; |
| 5533 | } |
| 5534 | |
| 5535 | UNSET_IF_PARAM (params, transmit_delay); |
| 5536 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5537 | |
| 5538 | if (params != IF_DEF_PARAMS (ifp)) |
| 5539 | { |
| 5540 | ospf_free_if_params (ifp, addr); |
| 5541 | ospf_if_update_params (ifp, addr); |
| 5542 | } |
| 5543 | |
| 5544 | return CMD_SUCCESS; |
| 5545 | } |
| 5546 | |
| 5547 | ALIAS (no_ip_ospf_transmit_delay, |
| 5548 | no_ip_ospf_transmit_delay_cmd, |
| 5549 | "no ip ospf transmit-delay", |
| 5550 | NO_STR |
| 5551 | "IP Information\n" |
| 5552 | "OSPF interface commands\n" |
| 5553 | "Link state transmit delay\n") |
| 5554 | |
| 5555 | ALIAS (no_ip_ospf_transmit_delay, |
| 5556 | no_ospf_transmit_delay_cmd, |
| 5557 | "no ospf transmit-delay", |
| 5558 | NO_STR |
| 5559 | "OSPF interface commands\n" |
| 5560 | "Link state transmit delay\n") |
| 5561 | |
| 5562 | |
| 5563 | DEFUN (ospf_redistribute_source_metric_type, |
| 5564 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5565 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5566 | "Redistribute information from another routing protocol\n" |
| 5567 | "Kernel routes\n" |
| 5568 | "Connected\n" |
| 5569 | "Static routes\n" |
| 5570 | "Routing Information Protocol (RIP)\n" |
| 5571 | "Border Gateway Protocol (BGP)\n" |
| 5572 | "Metric for redistributed routes\n" |
| 5573 | "OSPF default metric\n" |
| 5574 | "OSPF exterior metric type for redistributed routes\n" |
| 5575 | "Set OSPF External Type 1 metrics\n" |
| 5576 | "Set OSPF External Type 2 metrics\n" |
| 5577 | "Route map reference\n" |
| 5578 | "Pointer to route-map entries\n") |
| 5579 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5580 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5581 | int source; |
| 5582 | int type = -1; |
| 5583 | int metric = -1; |
| 5584 | |
| 5585 | /* Get distribute source. */ |
| 5586 | if (!str2distribute_source (argv[0], &source)) |
| 5587 | return CMD_WARNING; |
| 5588 | |
| 5589 | /* Get metric value. */ |
| 5590 | if (argc >= 2) |
| 5591 | if (!str2metric (argv[1], &metric)) |
| 5592 | return CMD_WARNING; |
| 5593 | |
| 5594 | /* Get metric type. */ |
| 5595 | if (argc >= 3) |
| 5596 | if (!str2metric_type (argv[2], &type)) |
| 5597 | return CMD_WARNING; |
| 5598 | |
| 5599 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5600 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5601 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5602 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5603 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5604 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5605 | } |
| 5606 | |
| 5607 | ALIAS (ospf_redistribute_source_metric_type, |
| 5608 | ospf_redistribute_source_metric_type_cmd, |
| 5609 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5610 | "Redistribute information from another routing protocol\n" |
| 5611 | "Kernel routes\n" |
| 5612 | "Connected\n" |
| 5613 | "Static routes\n" |
| 5614 | "Routing Information Protocol (RIP)\n" |
| 5615 | "Border Gateway Protocol (BGP)\n" |
| 5616 | "Metric for redistributed routes\n" |
| 5617 | "OSPF default metric\n" |
| 5618 | "OSPF exterior metric type for redistributed routes\n" |
| 5619 | "Set OSPF External Type 1 metrics\n" |
| 5620 | "Set OSPF External Type 2 metrics\n") |
| 5621 | |
| 5622 | ALIAS (ospf_redistribute_source_metric_type, |
| 5623 | ospf_redistribute_source_metric_cmd, |
| 5624 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5625 | "Redistribute information from another routing protocol\n" |
| 5626 | "Kernel routes\n" |
| 5627 | "Connected\n" |
| 5628 | "Static routes\n" |
| 5629 | "Routing Information Protocol (RIP)\n" |
| 5630 | "Border Gateway Protocol (BGP)\n" |
| 5631 | "Metric for redistributed routes\n" |
| 5632 | "OSPF default metric\n") |
| 5633 | |
| 5634 | DEFUN (ospf_redistribute_source_type_metric, |
| 5635 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5636 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5637 | "Redistribute information from another routing protocol\n" |
| 5638 | "Kernel routes\n" |
| 5639 | "Connected\n" |
| 5640 | "Static routes\n" |
| 5641 | "Routing Information Protocol (RIP)\n" |
| 5642 | "Border Gateway Protocol (BGP)\n" |
| 5643 | "OSPF exterior metric type for redistributed routes\n" |
| 5644 | "Set OSPF External Type 1 metrics\n" |
| 5645 | "Set OSPF External Type 2 metrics\n" |
| 5646 | "Metric for redistributed routes\n" |
| 5647 | "OSPF default metric\n" |
| 5648 | "Route map reference\n" |
| 5649 | "Pointer to route-map entries\n") |
| 5650 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5651 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5652 | int source; |
| 5653 | int type = -1; |
| 5654 | int metric = -1; |
| 5655 | |
| 5656 | /* Get distribute source. */ |
| 5657 | if (!str2distribute_source (argv[0], &source)) |
| 5658 | return CMD_WARNING; |
| 5659 | |
| 5660 | /* Get metric value. */ |
| 5661 | if (argc >= 2) |
| 5662 | if (!str2metric_type (argv[1], &type)) |
| 5663 | return CMD_WARNING; |
| 5664 | |
| 5665 | /* Get metric type. */ |
| 5666 | if (argc >= 3) |
| 5667 | if (!str2metric (argv[2], &metric)) |
| 5668 | return CMD_WARNING; |
| 5669 | |
| 5670 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5671 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5672 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5673 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5674 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5675 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5676 | } |
| 5677 | |
| 5678 | ALIAS (ospf_redistribute_source_type_metric, |
| 5679 | ospf_redistribute_source_type_metric_cmd, |
| 5680 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5681 | "Redistribute information from another routing protocol\n" |
| 5682 | "Kernel routes\n" |
| 5683 | "Connected\n" |
| 5684 | "Static routes\n" |
| 5685 | "Routing Information Protocol (RIP)\n" |
| 5686 | "Border Gateway Protocol (BGP)\n" |
| 5687 | "OSPF exterior metric type for redistributed routes\n" |
| 5688 | "Set OSPF External Type 1 metrics\n" |
| 5689 | "Set OSPF External Type 2 metrics\n" |
| 5690 | "Metric for redistributed routes\n" |
| 5691 | "OSPF default metric\n") |
| 5692 | |
| 5693 | ALIAS (ospf_redistribute_source_type_metric, |
| 5694 | ospf_redistribute_source_type_cmd, |
| 5695 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5696 | "Redistribute information from another routing protocol\n" |
| 5697 | "Kernel routes\n" |
| 5698 | "Connected\n" |
| 5699 | "Static routes\n" |
| 5700 | "Routing Information Protocol (RIP)\n" |
| 5701 | "Border Gateway Protocol (BGP)\n" |
| 5702 | "OSPF exterior metric type for redistributed routes\n" |
| 5703 | "Set OSPF External Type 1 metrics\n" |
| 5704 | "Set OSPF External Type 2 metrics\n") |
| 5705 | |
| 5706 | ALIAS (ospf_redistribute_source_type_metric, |
| 5707 | ospf_redistribute_source_cmd, |
| 5708 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5709 | "Redistribute information from another routing protocol\n" |
| 5710 | "Kernel routes\n" |
| 5711 | "Connected\n" |
| 5712 | "Static routes\n" |
| 5713 | "Routing Information Protocol (RIP)\n" |
| 5714 | "Border Gateway Protocol (BGP)\n") |
| 5715 | |
| 5716 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5717 | ospf_redistribute_source_metric_routemap_cmd, |
| 5718 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5719 | "Redistribute information from another routing protocol\n" |
| 5720 | "Kernel routes\n" |
| 5721 | "Connected\n" |
| 5722 | "Static routes\n" |
| 5723 | "Routing Information Protocol (RIP)\n" |
| 5724 | "Border Gateway Protocol (BGP)\n" |
| 5725 | "Metric for redistributed routes\n" |
| 5726 | "OSPF default metric\n" |
| 5727 | "Route map reference\n" |
| 5728 | "Pointer to route-map entries\n") |
| 5729 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5730 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5731 | int source; |
| 5732 | int metric = -1; |
| 5733 | |
| 5734 | /* Get distribute source. */ |
| 5735 | if (!str2distribute_source (argv[0], &source)) |
| 5736 | return CMD_WARNING; |
| 5737 | |
| 5738 | /* Get metric value. */ |
| 5739 | if (argc >= 2) |
| 5740 | if (!str2metric (argv[1], &metric)) |
| 5741 | return CMD_WARNING; |
| 5742 | |
| 5743 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5744 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5745 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5746 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5747 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5748 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5749 | } |
| 5750 | |
| 5751 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5752 | ospf_redistribute_source_type_routemap_cmd, |
| 5753 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5754 | "Redistribute information from another routing protocol\n" |
| 5755 | "Kernel routes\n" |
| 5756 | "Connected\n" |
| 5757 | "Static routes\n" |
| 5758 | "Routing Information Protocol (RIP)\n" |
| 5759 | "Border Gateway Protocol (BGP)\n" |
| 5760 | "OSPF exterior metric type for redistributed routes\n" |
| 5761 | "Set OSPF External Type 1 metrics\n" |
| 5762 | "Set OSPF External Type 2 metrics\n" |
| 5763 | "Route map reference\n" |
| 5764 | "Pointer to route-map entries\n") |
| 5765 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5766 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5767 | int source; |
| 5768 | int type = -1; |
| 5769 | |
| 5770 | /* Get distribute source. */ |
| 5771 | if (!str2distribute_source (argv[0], &source)) |
| 5772 | return CMD_WARNING; |
| 5773 | |
| 5774 | /* Get metric value. */ |
| 5775 | if (argc >= 2) |
| 5776 | if (!str2metric_type (argv[1], &type)) |
| 5777 | return CMD_WARNING; |
| 5778 | |
| 5779 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5780 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5781 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5782 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5783 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5784 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5785 | } |
| 5786 | |
| 5787 | DEFUN (ospf_redistribute_source_routemap, |
| 5788 | ospf_redistribute_source_routemap_cmd, |
| 5789 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5790 | "Redistribute information from another routing protocol\n" |
| 5791 | "Kernel routes\n" |
| 5792 | "Connected\n" |
| 5793 | "Static routes\n" |
| 5794 | "Routing Information Protocol (RIP)\n" |
| 5795 | "Border Gateway Protocol (BGP)\n" |
| 5796 | "Route map reference\n" |
| 5797 | "Pointer to route-map entries\n") |
| 5798 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5799 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5800 | int source; |
| 5801 | |
| 5802 | /* Get distribute source. */ |
| 5803 | if (!str2distribute_source (argv[0], &source)) |
| 5804 | return CMD_WARNING; |
| 5805 | |
| 5806 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5807 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5809 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5810 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5811 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5812 | } |
| 5813 | |
| 5814 | DEFUN (no_ospf_redistribute_source, |
| 5815 | no_ospf_redistribute_source_cmd, |
| 5816 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5817 | NO_STR |
| 5818 | "Redistribute information from another routing protocol\n" |
| 5819 | "Kernel routes\n" |
| 5820 | "Connected\n" |
| 5821 | "Static routes\n" |
| 5822 | "Routing Information Protocol (RIP)\n" |
| 5823 | "Border Gateway Protocol (BGP)\n") |
| 5824 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5825 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5826 | int source; |
| 5827 | |
| 5828 | if (!str2distribute_source (argv[0], &source)) |
| 5829 | return CMD_WARNING; |
| 5830 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5831 | ospf_routemap_unset (ospf, source); |
| 5832 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5833 | } |
| 5834 | |
| 5835 | DEFUN (ospf_distribute_list_out, |
| 5836 | ospf_distribute_list_out_cmd, |
| 5837 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5838 | "Filter networks in routing updates\n" |
| 5839 | "Access-list name\n" |
| 5840 | OUT_STR |
| 5841 | "Kernel routes\n" |
| 5842 | "Connected\n" |
| 5843 | "Static routes\n" |
| 5844 | "Routing Information Protocol (RIP)\n" |
| 5845 | "Border Gateway Protocol (BGP)\n") |
| 5846 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5847 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5848 | int source; |
| 5849 | |
| 5850 | /* Get distribute source. */ |
| 5851 | if (!str2distribute_source (argv[1], &source)) |
| 5852 | return CMD_WARNING; |
| 5853 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5854 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5855 | } |
| 5856 | |
| 5857 | DEFUN (no_ospf_distribute_list_out, |
| 5858 | no_ospf_distribute_list_out_cmd, |
| 5859 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5860 | NO_STR |
| 5861 | "Filter networks in routing updates\n" |
| 5862 | "Access-list name\n" |
| 5863 | OUT_STR |
| 5864 | "Kernel routes\n" |
| 5865 | "Connected\n" |
| 5866 | "Static routes\n" |
| 5867 | "Routing Information Protocol (RIP)\n" |
| 5868 | "Border Gateway Protocol (BGP)\n") |
| 5869 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5870 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5871 | int source; |
| 5872 | |
| 5873 | if (!str2distribute_source (argv[1], &source)) |
| 5874 | return CMD_WARNING; |
| 5875 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5876 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5877 | } |
| 5878 | |
| 5879 | /* Default information originate. */ |
| 5880 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5881 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5882 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5883 | "Control distribution of default information\n" |
| 5884 | "Distribute a default route\n" |
| 5885 | "OSPF default metric\n" |
| 5886 | "OSPF metric\n" |
| 5887 | "OSPF metric type for default routes\n" |
| 5888 | "Set OSPF External Type 1 metrics\n" |
| 5889 | "Set OSPF External Type 2 metrics\n" |
| 5890 | "Route map reference\n" |
| 5891 | "Pointer to route-map entries\n") |
| 5892 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5893 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5894 | int type = -1; |
| 5895 | int metric = -1; |
| 5896 | |
| 5897 | /* Get metric value. */ |
| 5898 | if (argc >= 1) |
| 5899 | if (!str2metric (argv[0], &metric)) |
| 5900 | return CMD_WARNING; |
| 5901 | |
| 5902 | /* Get metric type. */ |
| 5903 | if (argc >= 2) |
| 5904 | if (!str2metric_type (argv[1], &type)) |
| 5905 | return CMD_WARNING; |
| 5906 | |
| 5907 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5908 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5909 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5910 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5911 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5912 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5913 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5914 | } |
| 5915 | |
| 5916 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5917 | ospf_default_information_originate_metric_type_cmd, |
| 5918 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5919 | "Control distribution of default information\n" |
| 5920 | "Distribute a default route\n" |
| 5921 | "OSPF default metric\n" |
| 5922 | "OSPF metric\n" |
| 5923 | "OSPF metric type for default routes\n" |
| 5924 | "Set OSPF External Type 1 metrics\n" |
| 5925 | "Set OSPF External Type 2 metrics\n") |
| 5926 | |
| 5927 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5928 | ospf_default_information_originate_metric_cmd, |
| 5929 | "default-information originate metric <0-16777214>", |
| 5930 | "Control distribution of default information\n" |
| 5931 | "Distribute a default route\n" |
| 5932 | "OSPF default metric\n" |
| 5933 | "OSPF metric\n") |
| 5934 | |
| 5935 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5936 | ospf_default_information_originate_cmd, |
| 5937 | "default-information originate", |
| 5938 | "Control distribution of default information\n" |
| 5939 | "Distribute a default route\n") |
| 5940 | |
| 5941 | /* Default information originate. */ |
| 5942 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5943 | ospf_default_information_originate_metric_routemap_cmd, |
| 5944 | "default-information originate metric <0-16777214> route-map WORD", |
| 5945 | "Control distribution of default information\n" |
| 5946 | "Distribute a default route\n" |
| 5947 | "OSPF default metric\n" |
| 5948 | "OSPF metric\n" |
| 5949 | "Route map reference\n" |
| 5950 | "Pointer to route-map entries\n") |
| 5951 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5952 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5953 | int metric = -1; |
| 5954 | |
| 5955 | /* Get metric value. */ |
| 5956 | if (argc >= 1) |
| 5957 | if (!str2metric (argv[0], &metric)) |
| 5958 | return CMD_WARNING; |
| 5959 | |
| 5960 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5961 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5962 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5963 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5964 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5965 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5966 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5967 | } |
| 5968 | |
| 5969 | /* Default information originate. */ |
| 5970 | DEFUN (ospf_default_information_originate_routemap, |
| 5971 | ospf_default_information_originate_routemap_cmd, |
| 5972 | "default-information originate route-map WORD", |
| 5973 | "Control distribution of default information\n" |
| 5974 | "Distribute a default route\n" |
| 5975 | "Route map reference\n" |
| 5976 | "Pointer to route-map entries\n") |
| 5977 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5978 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5979 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5980 | if (argc == 1) |
| 5981 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5982 | else |
| 5983 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5984 | |
| 5985 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5986 | } |
| 5987 | |
| 5988 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 5989 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 5990 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5991 | "Control distribution of default information\n" |
| 5992 | "Distribute a default route\n" |
| 5993 | "OSPF metric type for default routes\n" |
| 5994 | "Set OSPF External Type 1 metrics\n" |
| 5995 | "Set OSPF External Type 2 metrics\n" |
| 5996 | "OSPF default metric\n" |
| 5997 | "OSPF metric\n" |
| 5998 | "Route map reference\n" |
| 5999 | "Pointer to route-map entries\n") |
| 6000 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6001 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6002 | int type = -1; |
| 6003 | int metric = -1; |
| 6004 | |
| 6005 | /* Get metric type. */ |
| 6006 | if (argc >= 1) |
| 6007 | if (!str2metric_type (argv[0], &type)) |
| 6008 | return CMD_WARNING; |
| 6009 | |
| 6010 | /* Get metric value. */ |
| 6011 | if (argc >= 2) |
| 6012 | if (!str2metric (argv[1], &metric)) |
| 6013 | return CMD_WARNING; |
| 6014 | |
| 6015 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6016 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6018 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6019 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6020 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6021 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6022 | } |
| 6023 | |
| 6024 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6025 | ospf_default_information_originate_type_metric_cmd, |
| 6026 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 6027 | "Control distribution of default information\n" |
| 6028 | "Distribute a default route\n" |
| 6029 | "OSPF metric type for default routes\n" |
| 6030 | "Set OSPF External Type 1 metrics\n" |
| 6031 | "Set OSPF External Type 2 metrics\n" |
| 6032 | "OSPF default metric\n" |
| 6033 | "OSPF metric\n") |
| 6034 | |
| 6035 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6036 | ospf_default_information_originate_type_cmd, |
| 6037 | "default-information originate metric-type (1|2)", |
| 6038 | "Control distribution of default information\n" |
| 6039 | "Distribute a default route\n" |
| 6040 | "OSPF metric type for default routes\n" |
| 6041 | "Set OSPF External Type 1 metrics\n" |
| 6042 | "Set OSPF External Type 2 metrics\n") |
| 6043 | |
| 6044 | DEFUN (ospf_default_information_originate_type_routemap, |
| 6045 | ospf_default_information_originate_type_routemap_cmd, |
| 6046 | "default-information originate metric-type (1|2) route-map WORD", |
| 6047 | "Control distribution of default information\n" |
| 6048 | "Distribute a default route\n" |
| 6049 | "OSPF metric type for default routes\n" |
| 6050 | "Set OSPF External Type 1 metrics\n" |
| 6051 | "Set OSPF External Type 2 metrics\n" |
| 6052 | "Route map reference\n" |
| 6053 | "Pointer to route-map entries\n") |
| 6054 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6055 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6056 | int type = -1; |
| 6057 | |
| 6058 | /* Get metric type. */ |
| 6059 | if (argc >= 1) |
| 6060 | if (!str2metric_type (argv[0], &type)) |
| 6061 | return CMD_WARNING; |
| 6062 | |
| 6063 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6064 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6065 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6066 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6068 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6069 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6070 | } |
| 6071 | |
| 6072 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 6073 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 6074 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 6075 | "Control distribution of default information\n" |
| 6076 | "Distribute a default route\n" |
| 6077 | "Always advertise default route\n" |
| 6078 | "OSPF default metric\n" |
| 6079 | "OSPF metric\n" |
| 6080 | "OSPF metric type for default routes\n" |
| 6081 | "Set OSPF External Type 1 metrics\n" |
| 6082 | "Set OSPF External Type 2 metrics\n" |
| 6083 | "Route map reference\n" |
| 6084 | "Pointer to route-map entries\n") |
| 6085 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6086 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6087 | int type = -1; |
| 6088 | int metric = -1; |
| 6089 | |
| 6090 | /* Get metric value. */ |
| 6091 | if (argc >= 1) |
| 6092 | if (!str2metric (argv[0], &metric)) |
| 6093 | return CMD_WARNING; |
| 6094 | |
| 6095 | /* Get metric type. */ |
| 6096 | if (argc >= 2) |
| 6097 | if (!str2metric_type (argv[1], &type)) |
| 6098 | return CMD_WARNING; |
| 6099 | |
| 6100 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6101 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6102 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6103 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6104 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6105 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6106 | type, metric); |
| 6107 | } |
| 6108 | |
| 6109 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6110 | ospf_default_information_originate_always_metric_type_cmd, |
| 6111 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 6112 | "Control distribution of default information\n" |
| 6113 | "Distribute a default route\n" |
| 6114 | "Always advertise default route\n" |
| 6115 | "OSPF default metric\n" |
| 6116 | "OSPF metric\n" |
| 6117 | "OSPF metric type for default routes\n" |
| 6118 | "Set OSPF External Type 1 metrics\n" |
| 6119 | "Set OSPF External Type 2 metrics\n") |
| 6120 | |
| 6121 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6122 | ospf_default_information_originate_always_metric_cmd, |
| 6123 | "default-information originate always metric <0-16777214>", |
| 6124 | "Control distribution of default information\n" |
| 6125 | "Distribute a default route\n" |
| 6126 | "Always advertise default route\n" |
| 6127 | "OSPF default metric\n" |
| 6128 | "OSPF metric\n" |
| 6129 | "OSPF metric type for default routes\n") |
| 6130 | |
| 6131 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6132 | ospf_default_information_originate_always_cmd, |
| 6133 | "default-information originate always", |
| 6134 | "Control distribution of default information\n" |
| 6135 | "Distribute a default route\n" |
| 6136 | "Always advertise default route\n") |
| 6137 | |
| 6138 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 6139 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 6140 | "default-information originate always metric <0-16777214> route-map WORD", |
| 6141 | "Control distribution of default information\n" |
| 6142 | "Distribute a default route\n" |
| 6143 | "Always advertise default route\n" |
| 6144 | "OSPF default metric\n" |
| 6145 | "OSPF metric\n" |
| 6146 | "Route map reference\n" |
| 6147 | "Pointer to route-map entries\n") |
| 6148 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6149 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6150 | int metric = -1; |
| 6151 | |
| 6152 | /* Get metric value. */ |
| 6153 | if (argc >= 1) |
| 6154 | if (!str2metric (argv[0], &metric)) |
| 6155 | return CMD_WARNING; |
| 6156 | |
| 6157 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6158 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6159 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6160 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6161 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6162 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 6163 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6164 | } |
| 6165 | |
| 6166 | DEFUN (ospf_default_information_originate_always_routemap, |
| 6167 | ospf_default_information_originate_always_routemap_cmd, |
| 6168 | "default-information originate always route-map WORD", |
| 6169 | "Control distribution of default information\n" |
| 6170 | "Distribute a default route\n" |
| 6171 | "Always advertise default route\n" |
| 6172 | "Route map reference\n" |
| 6173 | "Pointer to route-map entries\n") |
| 6174 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6175 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6176 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6177 | if (argc == 1) |
| 6178 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 6179 | else |
| 6180 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6181 | |
| 6182 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6183 | } |
| 6184 | |
| 6185 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 6186 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 6187 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 6188 | "Control distribution of default information\n" |
| 6189 | "Distribute a default route\n" |
| 6190 | "Always advertise default route\n" |
| 6191 | "OSPF metric type for default routes\n" |
| 6192 | "Set OSPF External Type 1 metrics\n" |
| 6193 | "Set OSPF External Type 2 metrics\n" |
| 6194 | "OSPF default metric\n" |
| 6195 | "OSPF metric\n" |
| 6196 | "Route map reference\n" |
| 6197 | "Pointer to route-map entries\n") |
| 6198 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6199 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6200 | int type = -1; |
| 6201 | int metric = -1; |
| 6202 | |
| 6203 | /* Get metric type. */ |
| 6204 | if (argc >= 1) |
| 6205 | if (!str2metric_type (argv[0], &type)) |
| 6206 | return CMD_WARNING; |
| 6207 | |
| 6208 | /* Get metric value. */ |
| 6209 | if (argc >= 2) |
| 6210 | if (!str2metric (argv[1], &metric)) |
| 6211 | return CMD_WARNING; |
| 6212 | |
| 6213 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6214 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6215 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6216 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6217 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6218 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6219 | type, metric); |
| 6220 | } |
| 6221 | |
| 6222 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6223 | ospf_default_information_originate_always_type_metric_cmd, |
| 6224 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 6225 | "Control distribution of default information\n" |
| 6226 | "Distribute a default route\n" |
| 6227 | "Always advertise default route\n" |
| 6228 | "OSPF metric type for default routes\n" |
| 6229 | "Set OSPF External Type 1 metrics\n" |
| 6230 | "Set OSPF External Type 2 metrics\n" |
| 6231 | "OSPF default metric\n" |
| 6232 | "OSPF metric\n") |
| 6233 | |
| 6234 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6235 | ospf_default_information_originate_always_type_cmd, |
| 6236 | "default-information originate always metric-type (1|2)", |
| 6237 | "Control distribution of default information\n" |
| 6238 | "Distribute a default route\n" |
| 6239 | "Always advertise default route\n" |
| 6240 | "OSPF metric type for default routes\n" |
| 6241 | "Set OSPF External Type 1 metrics\n" |
| 6242 | "Set OSPF External Type 2 metrics\n") |
| 6243 | |
| 6244 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 6245 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6246 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6247 | "Control distribution of default information\n" |
| 6248 | "Distribute a default route\n" |
| 6249 | "Always advertise default route\n" |
| 6250 | "OSPF metric type for default routes\n" |
| 6251 | "Set OSPF External Type 1 metrics\n" |
| 6252 | "Set OSPF External Type 2 metrics\n" |
| 6253 | "Route map reference\n" |
| 6254 | "Pointer to route-map entries\n") |
| 6255 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6256 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6257 | int type = -1; |
| 6258 | |
| 6259 | /* Get metric type. */ |
| 6260 | if (argc >= 1) |
| 6261 | if (!str2metric_type (argv[0], &type)) |
| 6262 | return CMD_WARNING; |
| 6263 | |
| 6264 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6265 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6266 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6267 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6268 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6269 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6270 | type, -1); |
| 6271 | } |
| 6272 | |
| 6273 | DEFUN (no_ospf_default_information_originate, |
| 6274 | no_ospf_default_information_originate_cmd, |
| 6275 | "no default-information originate", |
| 6276 | NO_STR |
| 6277 | "Control distribution of default information\n" |
| 6278 | "Distribute a default route\n") |
| 6279 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6280 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6281 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6282 | |
| 6283 | p.family = AF_INET; |
| 6284 | p.prefix.s_addr = 0; |
| 6285 | p.prefixlen = 0; |
| 6286 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6287 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6288 | |
| 6289 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6290 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6291 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6292 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6293 | } |
| 6294 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6295 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6296 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6297 | } |
| 6298 | |
| 6299 | DEFUN (ospf_default_metric, |
| 6300 | ospf_default_metric_cmd, |
| 6301 | "default-metric <0-16777214>", |
| 6302 | "Set metric of redistributed routes\n" |
| 6303 | "Default metric\n") |
| 6304 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6305 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6306 | int metric = -1; |
| 6307 | |
| 6308 | if (!str2metric (argv[0], &metric)) |
| 6309 | return CMD_WARNING; |
| 6310 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6311 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6312 | |
| 6313 | return CMD_SUCCESS; |
| 6314 | } |
| 6315 | |
| 6316 | DEFUN (no_ospf_default_metric, |
| 6317 | no_ospf_default_metric_cmd, |
| 6318 | "no default-metric", |
| 6319 | NO_STR |
| 6320 | "Set metric of redistributed routes\n") |
| 6321 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6322 | struct ospf *ospf = vty->index; |
| 6323 | |
| 6324 | ospf->default_metric = -1; |
| 6325 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6326 | return CMD_SUCCESS; |
| 6327 | } |
| 6328 | |
| 6329 | ALIAS (no_ospf_default_metric, |
| 6330 | no_ospf_default_metric_val_cmd, |
| 6331 | "no default-metric <0-16777214>", |
| 6332 | NO_STR |
| 6333 | "Set metric of redistributed routes\n" |
| 6334 | "Default metric\n") |
| 6335 | |
| 6336 | DEFUN (ospf_distance, |
| 6337 | ospf_distance_cmd, |
| 6338 | "distance <1-255>", |
| 6339 | "Define an administrative distance\n" |
| 6340 | "OSPF Administrative distance\n") |
| 6341 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6342 | struct ospf *ospf = vty->index; |
| 6343 | |
| 6344 | ospf->distance_all = atoi (argv[0]); |
| 6345 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6346 | return CMD_SUCCESS; |
| 6347 | } |
| 6348 | |
| 6349 | DEFUN (no_ospf_distance, |
| 6350 | no_ospf_distance_cmd, |
| 6351 | "no distance <1-255>", |
| 6352 | NO_STR |
| 6353 | "Define an administrative distance\n" |
| 6354 | "OSPF Administrative distance\n") |
| 6355 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6356 | struct ospf *ospf = vty->index; |
| 6357 | |
| 6358 | ospf->distance_all = 0; |
| 6359 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6360 | return CMD_SUCCESS; |
| 6361 | } |
| 6362 | |
| 6363 | DEFUN (no_ospf_distance_ospf, |
| 6364 | no_ospf_distance_ospf_cmd, |
| 6365 | "no distance ospf", |
| 6366 | NO_STR |
| 6367 | "Define an administrative distance\n" |
| 6368 | "OSPF Administrative distance\n" |
| 6369 | "OSPF Distance\n") |
| 6370 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6371 | struct ospf *ospf = vty->index; |
| 6372 | |
| 6373 | ospf->distance_intra = 0; |
| 6374 | ospf->distance_inter = 0; |
| 6375 | ospf->distance_external = 0; |
| 6376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6377 | return CMD_SUCCESS; |
| 6378 | } |
| 6379 | |
| 6380 | DEFUN (ospf_distance_ospf_intra, |
| 6381 | ospf_distance_ospf_intra_cmd, |
| 6382 | "distance ospf intra-area <1-255>", |
| 6383 | "Define an administrative distance\n" |
| 6384 | "OSPF Administrative distance\n" |
| 6385 | "Intra-area routes\n" |
| 6386 | "Distance for intra-area routes\n") |
| 6387 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6388 | struct ospf *ospf = vty->index; |
| 6389 | |
| 6390 | ospf->distance_intra = atoi (argv[0]); |
| 6391 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6392 | return CMD_SUCCESS; |
| 6393 | } |
| 6394 | |
| 6395 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6396 | ospf_distance_ospf_intra_inter_cmd, |
| 6397 | "distance ospf intra-area <1-255> inter-area <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 | "Inter-area routes\n" |
| 6403 | "Distance for inter-area 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_inter = 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_external, |
| 6414 | ospf_distance_ospf_intra_external_cmd, |
| 6415 | "distance ospf intra-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 | "External routes\n" |
| 6421 | "Distance for external routes\n") |
| 6422 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6423 | struct ospf *ospf = vty->index; |
| 6424 | |
| 6425 | ospf->distance_intra = atoi (argv[0]); |
| 6426 | ospf->distance_external = atoi (argv[1]); |
| 6427 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6428 | return CMD_SUCCESS; |
| 6429 | } |
| 6430 | |
| 6431 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6432 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6433 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6434 | "Define an administrative distance\n" |
| 6435 | "OSPF Administrative distance\n" |
| 6436 | "Intra-area routes\n" |
| 6437 | "Distance for intra-area routes\n" |
| 6438 | "Inter-area routes\n" |
| 6439 | "Distance for inter-area routes\n" |
| 6440 | "External routes\n" |
| 6441 | "Distance for external routes\n") |
| 6442 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6443 | struct ospf *ospf = vty->index; |
| 6444 | |
| 6445 | ospf->distance_intra = atoi (argv[0]); |
| 6446 | ospf->distance_inter = atoi (argv[1]); |
| 6447 | ospf->distance_external = atoi (argv[2]); |
| 6448 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6449 | return CMD_SUCCESS; |
| 6450 | } |
| 6451 | |
| 6452 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6453 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6454 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6455 | "Define an administrative distance\n" |
| 6456 | "OSPF Administrative distance\n" |
| 6457 | "Intra-area routes\n" |
| 6458 | "Distance for intra-area routes\n" |
| 6459 | "External routes\n" |
| 6460 | "Distance for external routes\n" |
| 6461 | "Inter-area routes\n" |
| 6462 | "Distance for inter-area routes\n") |
| 6463 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6464 | struct ospf *ospf = vty->index; |
| 6465 | |
| 6466 | ospf->distance_intra = atoi (argv[0]); |
| 6467 | ospf->distance_external = atoi (argv[1]); |
| 6468 | ospf->distance_inter = atoi (argv[2]); |
| 6469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6470 | return CMD_SUCCESS; |
| 6471 | } |
| 6472 | |
| 6473 | DEFUN (ospf_distance_ospf_inter, |
| 6474 | ospf_distance_ospf_inter_cmd, |
| 6475 | "distance ospf inter-area <1-255>", |
| 6476 | "Define an administrative distance\n" |
| 6477 | "OSPF Administrative distance\n" |
| 6478 | "Inter-area routes\n" |
| 6479 | "Distance for inter-area routes\n") |
| 6480 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6481 | struct ospf *ospf = vty->index; |
| 6482 | |
| 6483 | ospf->distance_inter = atoi (argv[0]); |
| 6484 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6485 | return CMD_SUCCESS; |
| 6486 | } |
| 6487 | |
| 6488 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6489 | ospf_distance_ospf_inter_intra_cmd, |
| 6490 | "distance ospf inter-area <1-255> intra-area <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 | "Intra-area routes\n" |
| 6496 | "Distance for intra-area 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_intra = 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_external, |
| 6507 | ospf_distance_ospf_inter_external_cmd, |
| 6508 | "distance ospf inter-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 | "External routes\n" |
| 6514 | "Distance for external routes\n") |
| 6515 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6516 | struct ospf *ospf = vty->index; |
| 6517 | |
| 6518 | ospf->distance_inter = atoi (argv[0]); |
| 6519 | ospf->distance_external = atoi (argv[1]); |
| 6520 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6521 | return CMD_SUCCESS; |
| 6522 | } |
| 6523 | |
| 6524 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6525 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6526 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6527 | "Define an administrative distance\n" |
| 6528 | "OSPF Administrative distance\n" |
| 6529 | "Inter-area routes\n" |
| 6530 | "Distance for inter-area routes\n" |
| 6531 | "Intra-area routes\n" |
| 6532 | "Distance for intra-area routes\n" |
| 6533 | "External routes\n" |
| 6534 | "Distance for external routes\n") |
| 6535 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6536 | struct ospf *ospf = vty->index; |
| 6537 | |
| 6538 | ospf->distance_inter = atoi (argv[0]); |
| 6539 | ospf->distance_intra = atoi (argv[1]); |
| 6540 | ospf->distance_external = atoi (argv[2]); |
| 6541 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6542 | return CMD_SUCCESS; |
| 6543 | } |
| 6544 | |
| 6545 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6546 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6547 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6548 | "Define an administrative distance\n" |
| 6549 | "OSPF Administrative distance\n" |
| 6550 | "Inter-area routes\n" |
| 6551 | "Distance for inter-area routes\n" |
| 6552 | "External routes\n" |
| 6553 | "Distance for external routes\n" |
| 6554 | "Intra-area routes\n" |
| 6555 | "Distance for intra-area routes\n") |
| 6556 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6557 | struct ospf *ospf = vty->index; |
| 6558 | |
| 6559 | ospf->distance_inter = atoi (argv[0]); |
| 6560 | ospf->distance_external = atoi (argv[1]); |
| 6561 | ospf->distance_intra = atoi (argv[2]); |
| 6562 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6563 | return CMD_SUCCESS; |
| 6564 | } |
| 6565 | |
| 6566 | DEFUN (ospf_distance_ospf_external, |
| 6567 | ospf_distance_ospf_external_cmd, |
| 6568 | "distance ospf external <1-255>", |
| 6569 | "Define an administrative distance\n" |
| 6570 | "OSPF Administrative distance\n" |
| 6571 | "External routes\n" |
| 6572 | "Distance for external routes\n") |
| 6573 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6574 | struct ospf *ospf = vty->index; |
| 6575 | |
| 6576 | ospf->distance_external = atoi (argv[0]); |
| 6577 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6578 | return CMD_SUCCESS; |
| 6579 | } |
| 6580 | |
| 6581 | DEFUN (ospf_distance_ospf_external_intra, |
| 6582 | ospf_distance_ospf_external_intra_cmd, |
| 6583 | "distance ospf external <1-255> intra-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 | "Intra-area routes\n" |
| 6589 | "Distance for intra-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_intra = 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_inter, |
| 6600 | ospf_distance_ospf_external_inter_cmd, |
| 6601 | "distance ospf external <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 | "Inter-area routes\n" |
| 6607 | "Distance for inter-area routes\n") |
| 6608 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6609 | struct ospf *ospf = vty->index; |
| 6610 | |
| 6611 | ospf->distance_external = atoi (argv[0]); |
| 6612 | ospf->distance_inter = atoi (argv[1]); |
| 6613 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6614 | return CMD_SUCCESS; |
| 6615 | } |
| 6616 | |
| 6617 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6618 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6619 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6620 | "Define an administrative distance\n" |
| 6621 | "OSPF Administrative distance\n" |
| 6622 | "External routes\n" |
| 6623 | "Distance for external routes\n" |
| 6624 | "Intra-area routes\n" |
| 6625 | "Distance for intra-area routes\n" |
| 6626 | "Inter-area routes\n" |
| 6627 | "Distance for inter-area routes\n") |
| 6628 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6629 | struct ospf *ospf = vty->index; |
| 6630 | |
| 6631 | ospf->distance_external = atoi (argv[0]); |
| 6632 | ospf->distance_intra = atoi (argv[1]); |
| 6633 | ospf->distance_inter = atoi (argv[2]); |
| 6634 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6635 | return CMD_SUCCESS; |
| 6636 | } |
| 6637 | |
| 6638 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6639 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6640 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6641 | "Define an administrative distance\n" |
| 6642 | "OSPF Administrative distance\n" |
| 6643 | "External routes\n" |
| 6644 | "Distance for external routes\n" |
| 6645 | "Inter-area routes\n" |
| 6646 | "Distance for inter-area routes\n" |
| 6647 | "Intra-area routes\n" |
| 6648 | "Distance for intra-area routes\n") |
| 6649 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6650 | struct ospf *ospf = vty->index; |
| 6651 | |
| 6652 | ospf->distance_external = atoi (argv[0]); |
| 6653 | ospf->distance_inter = atoi (argv[1]); |
| 6654 | ospf->distance_intra = atoi (argv[2]); |
| 6655 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6656 | return CMD_SUCCESS; |
| 6657 | } |
| 6658 | |
| 6659 | DEFUN (ospf_distance_source, |
| 6660 | ospf_distance_source_cmd, |
| 6661 | "distance <1-255> A.B.C.D/M", |
| 6662 | "Administrative distance\n" |
| 6663 | "Distance value\n" |
| 6664 | "IP source prefix\n") |
| 6665 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6666 | struct ospf *ospf = vty->index; |
| 6667 | |
| 6668 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6669 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6670 | return CMD_SUCCESS; |
| 6671 | } |
| 6672 | |
| 6673 | DEFUN (no_ospf_distance_source, |
| 6674 | no_ospf_distance_source_cmd, |
| 6675 | "no distance <1-255> A.B.C.D/M", |
| 6676 | NO_STR |
| 6677 | "Administrative distance\n" |
| 6678 | "Distance value\n" |
| 6679 | "IP source prefix\n") |
| 6680 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6681 | struct ospf *ospf = vty->index; |
| 6682 | |
| 6683 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6684 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6685 | return CMD_SUCCESS; |
| 6686 | } |
| 6687 | |
| 6688 | DEFUN (ospf_distance_source_access_list, |
| 6689 | ospf_distance_source_access_list_cmd, |
| 6690 | "distance <1-255> A.B.C.D/M WORD", |
| 6691 | "Administrative distance\n" |
| 6692 | "Distance value\n" |
| 6693 | "IP source prefix\n" |
| 6694 | "Access list name\n") |
| 6695 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6696 | struct ospf *ospf = vty->index; |
| 6697 | |
| 6698 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6699 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6700 | return CMD_SUCCESS; |
| 6701 | } |
| 6702 | |
| 6703 | DEFUN (no_ospf_distance_source_access_list, |
| 6704 | no_ospf_distance_source_access_list_cmd, |
| 6705 | "no distance <1-255> A.B.C.D/M WORD", |
| 6706 | NO_STR |
| 6707 | "Administrative distance\n" |
| 6708 | "Distance value\n" |
| 6709 | "IP source prefix\n" |
| 6710 | "Access list name\n") |
| 6711 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6712 | struct ospf *ospf = vty->index; |
| 6713 | |
| 6714 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6715 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6716 | return CMD_SUCCESS; |
| 6717 | } |
| 6718 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6719 | DEFUN (ip_ospf_mtu_ignore, |
| 6720 | ip_ospf_mtu_ignore_addr_cmd, |
| 6721 | "ip ospf mtu-ignore A.B.C.D", |
| 6722 | "IP Information\n" |
| 6723 | "OSPF interface commands\n" |
| 6724 | "Disable mtu mismatch detection\n" |
| 6725 | "Address of interface") |
| 6726 | { |
| 6727 | struct interface *ifp = vty->index; |
| 6728 | struct in_addr addr; |
| 6729 | int ret; |
| 6730 | |
| 6731 | struct ospf_if_params *params; |
| 6732 | params = IF_DEF_PARAMS (ifp); |
| 6733 | |
| 6734 | if (argc == 1) |
| 6735 | { |
| 6736 | ret = inet_aton(argv[0], &addr); |
| 6737 | if (!ret) |
| 6738 | { |
| 6739 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6740 | VTY_NEWLINE); |
| 6741 | return CMD_WARNING; |
| 6742 | } |
| 6743 | params = ospf_get_if_params (ifp, addr); |
| 6744 | ospf_if_update_params (ifp, addr); |
| 6745 | } |
| 6746 | params->mtu_ignore = 1; |
| 6747 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6748 | SET_IF_PARAM (params, mtu_ignore); |
| 6749 | else |
| 6750 | { |
| 6751 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6752 | if (params != IF_DEF_PARAMS (ifp)) |
| 6753 | { |
| 6754 | ospf_free_if_params (ifp, addr); |
| 6755 | ospf_if_update_params (ifp, addr); |
| 6756 | } |
| 6757 | } |
| 6758 | return CMD_SUCCESS; |
| 6759 | } |
| 6760 | |
| 6761 | ALIAS (ip_ospf_mtu_ignore, |
| 6762 | ip_ospf_mtu_ignore_cmd, |
| 6763 | "ip ospf mtu-ignore", |
| 6764 | "IP Information\n" |
| 6765 | "OSPF interface commands\n" |
| 6766 | "Disable mtu mismatch detection\n") |
| 6767 | |
| 6768 | |
| 6769 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6770 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6771 | "no ip ospf mtu-ignore A.B.C.D", |
| 6772 | "IP Information\n" |
| 6773 | "OSPF interface commands\n" |
| 6774 | "Disable mtu mismatch detection\n" |
| 6775 | "Address of interface") |
| 6776 | { |
| 6777 | struct interface *ifp = vty->index; |
| 6778 | struct in_addr addr; |
| 6779 | int ret; |
| 6780 | |
| 6781 | struct ospf_if_params *params; |
| 6782 | params = IF_DEF_PARAMS (ifp); |
| 6783 | |
| 6784 | if (argc == 1) |
| 6785 | { |
| 6786 | ret = inet_aton(argv[0], &addr); |
| 6787 | if (!ret) |
| 6788 | { |
| 6789 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6790 | VTY_NEWLINE); |
| 6791 | return CMD_WARNING; |
| 6792 | } |
| 6793 | params = ospf_get_if_params (ifp, addr); |
| 6794 | ospf_if_update_params (ifp, addr); |
| 6795 | } |
| 6796 | params->mtu_ignore = 0; |
| 6797 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6798 | SET_IF_PARAM (params, mtu_ignore); |
| 6799 | else |
| 6800 | { |
| 6801 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6802 | if (params != IF_DEF_PARAMS (ifp)) |
| 6803 | { |
| 6804 | ospf_free_if_params (ifp, addr); |
| 6805 | ospf_if_update_params (ifp, addr); |
| 6806 | } |
| 6807 | } |
| 6808 | return CMD_SUCCESS; |
| 6809 | } |
| 6810 | |
| 6811 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6812 | no_ip_ospf_mtu_ignore_cmd, |
| 6813 | "no ip ospf mtu-ignore", |
| 6814 | "IP Information\n" |
| 6815 | "OSPF interface commands\n" |
| 6816 | "Disable mtu mismatch detection\n") |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6817 | |
| 6818 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6819 | ospf_max_metric_router_lsa_admin_cmd, |
| 6820 | "max-metric router-lsa administrative", |
| 6821 | "OSPF maximum / infinite-distance metric\n" |
| 6822 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6823 | "Administratively applied, for an indefinite period\n") |
| 6824 | { |
| 6825 | struct listnode *ln; |
| 6826 | struct ospf_area *area; |
| 6827 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6828 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6829 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6830 | { |
| 6831 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6832 | |
| 6833 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 6834 | ospf_router_lsa_timer_add (area); |
| 6835 | } |
| 6836 | return CMD_SUCCESS; |
| 6837 | } |
| 6838 | |
| 6839 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6840 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6841 | "no max-metric router-lsa administrative", |
| 6842 | NO_STR |
| 6843 | "OSPF maximum / infinite-distance metric\n" |
| 6844 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6845 | "Administratively applied, for an indefinite period\n") |
| 6846 | { |
| 6847 | struct listnode *ln; |
| 6848 | struct ospf_area *area; |
| 6849 | struct ospf *ospf = vty->index; |
| 6850 | |
| 6851 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6852 | { |
| 6853 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6854 | |
| 6855 | /* Don't trample on the start-up stub timer */ |
| 6856 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6857 | && !area->t_stub_router) |
| 6858 | { |
| 6859 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6860 | ospf_router_lsa_timer_add (area); |
| 6861 | } |
| 6862 | } |
| 6863 | return CMD_SUCCESS; |
| 6864 | } |
| 6865 | |
| 6866 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6867 | ospf_max_metric_router_lsa_startup_cmd, |
| 6868 | "max-metric router-lsa on-startup <5-86400>", |
| 6869 | "OSPF maximum / infinite-distance metric\n" |
| 6870 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6871 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6872 | "Time (seconds) to advertise self as stub-router\n") |
| 6873 | { |
| 6874 | unsigned int seconds; |
| 6875 | struct ospf *ospf = vty->index; |
| 6876 | |
| 6877 | if (argc != 1) |
| 6878 | { |
| 6879 | vty_out (vty, "%% Must supply stub-router period"); |
| 6880 | return CMD_WARNING; |
| 6881 | } |
| 6882 | |
| 6883 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6884 | |
| 6885 | ospf->stub_router_startup_time = seconds; |
| 6886 | |
| 6887 | return CMD_SUCCESS; |
| 6888 | } |
| 6889 | |
| 6890 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6891 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6892 | "no max-metric router-lsa on-startup", |
| 6893 | NO_STR |
| 6894 | "OSPF maximum / infinite-distance metric\n" |
| 6895 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6896 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6897 | { |
| 6898 | struct listnode *ln; |
| 6899 | struct ospf_area *area; |
| 6900 | struct ospf *ospf = vty->index; |
| 6901 | |
| 6902 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6903 | |
| 6904 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6905 | { |
| 6906 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 6907 | OSPF_TIMER_OFF (area->t_stub_router); |
| 6908 | |
| 6909 | /* Don't trample on admin stub routed */ |
| 6910 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6911 | { |
| 6912 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6913 | ospf_router_lsa_timer_add (area); |
| 6914 | } |
| 6915 | } |
| 6916 | return CMD_SUCCESS; |
| 6917 | } |
| 6918 | |
| 6919 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 6920 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 6921 | "max-metric router-lsa on-shutdown <5-86400>", |
| 6922 | "OSPF maximum / infinite-distance metric\n" |
| 6923 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6924 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 6925 | "Time (seconds) to wait till full shutdown\n") |
| 6926 | { |
| 6927 | unsigned int seconds; |
| 6928 | struct ospf *ospf = vty->index; |
| 6929 | |
| 6930 | if (argc != 1) |
| 6931 | { |
| 6932 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 6933 | return CMD_WARNING; |
| 6934 | } |
| 6935 | |
| 6936 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 6937 | |
| 6938 | ospf->stub_router_shutdown_time = seconds; |
| 6939 | |
| 6940 | return CMD_SUCCESS; |
| 6941 | } |
| 6942 | |
| 6943 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 6944 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 6945 | "no max-metric router-lsa on-shutdown", |
| 6946 | NO_STR |
| 6947 | "OSPF maximum / infinite-distance metric\n" |
| 6948 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6949 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 6950 | { |
| 6951 | struct ospf *ospf = vty->index; |
| 6952 | |
| 6953 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6954 | |
| 6955 | return CMD_SUCCESS; |
| 6956 | } |
| 6957 | |
| 6958 | static void |
| 6959 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 6960 | { |
| 6961 | struct listnode *ln; |
| 6962 | struct ospf_area *area; |
| 6963 | |
| 6964 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6965 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 6966 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 6967 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6968 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 6969 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 6970 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6971 | { |
| 6972 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6973 | { |
| 6974 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 6975 | VTY_NEWLINE); |
| 6976 | break; |
| 6977 | } |
| 6978 | } |
| 6979 | return; |
| 6980 | } |
| 6981 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6982 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6983 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6984 | { |
| 6985 | struct route_node *rn; |
| 6986 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6987 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6988 | struct ospf_path *path; |
| 6989 | |
| 6990 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6991 | VTY_NEWLINE); |
| 6992 | |
| 6993 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6994 | if ((or = rn->info) != NULL) |
| 6995 | { |
| 6996 | char buf1[19]; |
| 6997 | snprintf (buf1, 19, "%s/%d", |
| 6998 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6999 | |
| 7000 | switch (or->path_type) |
| 7001 | { |
| 7002 | case OSPF_PATH_INTER_AREA: |
| 7003 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 7004 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 7005 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 7006 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 7007 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 7008 | break; |
| 7009 | case OSPF_PATH_INTRA_AREA: |
| 7010 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 7011 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 7012 | break; |
| 7013 | default: |
| 7014 | break; |
| 7015 | } |
| 7016 | |
| 7017 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7018 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7019 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7020 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7021 | { |
| 7022 | if (path->nexthop.s_addr == 0) |
| 7023 | vty_out (vty, "%24s directly attached to %s%s", |
| 7024 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7025 | else |
| 7026 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7027 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7028 | VTY_NEWLINE); |
| 7029 | } |
| 7030 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7031 | } |
| 7032 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7033 | } |
| 7034 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7035 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7036 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 7037 | { |
| 7038 | struct route_node *rn; |
| 7039 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7040 | struct listnode *pnode; |
| 7041 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7042 | struct ospf_path *path; |
| 7043 | |
| 7044 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 7045 | VTY_NEWLINE); |
| 7046 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 7047 | if (rn->info) |
| 7048 | { |
| 7049 | int flag = 0; |
| 7050 | |
| 7051 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 7052 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7053 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 7054 | { |
| 7055 | if (flag++) |
| 7056 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7057 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7058 | /* Show path. */ |
| 7059 | vty_out (vty, "%s [%d] area: %s", |
| 7060 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 7061 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 7062 | /* Show flags. */ |
| 7063 | vty_out (vty, "%s%s%s", |
| 7064 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 7065 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 7066 | VTY_NEWLINE); |
| 7067 | |
| 7068 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 7069 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7070 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
| 7071 | { |
| 7072 | if (path->nexthop.s_addr == 0) |
| 7073 | vty_out (vty, "%24s directly attached to %s%s", |
| 7074 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7075 | else |
| 7076 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7077 | inet_ntoa (path->nexthop), |
| 7078 | path->oi->ifp->name, VTY_NEWLINE); |
| 7079 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7080 | } |
| 7081 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7082 | } |
| 7083 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7084 | } |
| 7085 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7086 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7087 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 7088 | { |
| 7089 | struct route_node *rn; |
| 7090 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7091 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7092 | struct ospf_path *path; |
| 7093 | |
| 7094 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 7095 | VTY_NEWLINE); |
| 7096 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 7097 | if ((er = rn->info) != NULL) |
| 7098 | { |
| 7099 | char buf1[19]; |
| 7100 | snprintf (buf1, 19, "%s/%d", |
| 7101 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 7102 | |
| 7103 | switch (er->path_type) |
| 7104 | { |
| 7105 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 7106 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 7107 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 7108 | break; |
| 7109 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 7110 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 7111 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 7112 | break; |
| 7113 | } |
| 7114 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7115 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7116 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7117 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7118 | { |
| 7119 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7120 | vty_out (vty, "%24s directly attached to %s%s", |
| 7121 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7122 | else |
| 7123 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7124 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7125 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7126 | } |
| 7127 | } |
| 7128 | } |
| 7129 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7130 | } |
| 7131 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7132 | DEFUN (show_ip_ospf_border_routers, |
| 7133 | show_ip_ospf_border_routers_cmd, |
| 7134 | "show ip ospf border-routers", |
| 7135 | SHOW_STR |
| 7136 | IP_STR |
| 7137 | "show all the ABR's and ASBR's\n" |
| 7138 | "for this area\n") |
| 7139 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7140 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7141 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7142 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7143 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7144 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7145 | return CMD_SUCCESS; |
| 7146 | } |
| 7147 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7148 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7149 | { |
| 7150 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7151 | return CMD_SUCCESS; |
| 7152 | } |
| 7153 | |
| 7154 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7155 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7156 | |
| 7157 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7158 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7159 | |
| 7160 | return CMD_SUCCESS; |
| 7161 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7162 | |
| 7163 | DEFUN (show_ip_ospf_route, |
| 7164 | show_ip_ospf_route_cmd, |
| 7165 | "show ip ospf route", |
| 7166 | SHOW_STR |
| 7167 | IP_STR |
| 7168 | "OSPF information\n" |
| 7169 | "OSPF routing table\n") |
| 7170 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7171 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7172 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7173 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7174 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7175 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7176 | return CMD_SUCCESS; |
| 7177 | } |
| 7178 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7179 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7180 | { |
| 7181 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7182 | return CMD_SUCCESS; |
| 7183 | } |
| 7184 | |
| 7185 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7186 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7187 | |
| 7188 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7189 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7190 | |
| 7191 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7192 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7193 | |
| 7194 | return CMD_SUCCESS; |
| 7195 | } |
| 7196 | |
| 7197 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7198 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7199 | { |
| 7200 | "unknown", |
| 7201 | "standard", |
| 7202 | "ibm", |
| 7203 | "cisco", |
| 7204 | "shortcut" |
| 7205 | }; |
| 7206 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7207 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7208 | { |
| 7209 | "default", |
| 7210 | "enable", |
| 7211 | "disable" |
| 7212 | }; |
| 7213 | |
| 7214 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7215 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7216 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 7217 | { |
| 7218 | memset (buf, 0, length); |
| 7219 | |
| 7220 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 7221 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 7222 | else |
| 7223 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 7224 | } |
| 7225 | |
| 7226 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7227 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7228 | { |
| 7229 | "unknown", /* should never be used. */ |
| 7230 | "point-to-point", |
| 7231 | "broadcast", |
| 7232 | "non-broadcast", |
| 7233 | "point-to-multipoint", |
| 7234 | "virtual-link", /* should never be used. */ |
| 7235 | "loopback" |
| 7236 | }; |
| 7237 | |
| 7238 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7239 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7240 | config_write_interface (struct vty *vty) |
| 7241 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7242 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7243 | struct interface *ifp; |
| 7244 | struct crypt_key *ck; |
| 7245 | int write = 0; |
| 7246 | struct route_node *rn = NULL; |
| 7247 | struct ospf_if_params *params; |
| 7248 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7249 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7250 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7251 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 7252 | continue; |
| 7253 | |
| 7254 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 7255 | vty_out (vty, "interface %s%s", ifp->name, |
| 7256 | VTY_NEWLINE); |
| 7257 | if (ifp->desc) |
| 7258 | vty_out (vty, " description %s%s", ifp->desc, |
| 7259 | VTY_NEWLINE); |
| 7260 | |
| 7261 | write++; |
| 7262 | |
| 7263 | params = IF_DEF_PARAMS (ifp); |
| 7264 | |
| 7265 | do { |
| 7266 | /* Interface Network print. */ |
| 7267 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7268 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 7269 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 7270 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 7271 | { |
| 7272 | vty_out (vty, " ip ospf network %s", |
| 7273 | ospf_int_type_str[params->type]); |
| 7274 | if (params != IF_DEF_PARAMS (ifp)) |
| 7275 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7276 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7277 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7278 | } |
| 7279 | |
| 7280 | /* OSPF interface authentication print */ |
| 7281 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 7282 | params->auth_type != OSPF_AUTH_NOTSET) |
| 7283 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7284 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7285 | |
| 7286 | /* Translation tables are not that much help here due to syntax |
| 7287 | of the simple option */ |
| 7288 | switch (params->auth_type) |
| 7289 | { |
| 7290 | |
| 7291 | case OSPF_AUTH_NULL: |
| 7292 | auth_str = " null"; |
| 7293 | break; |
| 7294 | |
| 7295 | case OSPF_AUTH_SIMPLE: |
| 7296 | auth_str = ""; |
| 7297 | break; |
| 7298 | |
| 7299 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 7300 | auth_str = " message-digest"; |
| 7301 | break; |
| 7302 | |
| 7303 | default: |
| 7304 | auth_str = ""; |
| 7305 | break; |
| 7306 | } |
| 7307 | |
| 7308 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 7309 | if (params != IF_DEF_PARAMS (ifp)) |
| 7310 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7311 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7312 | } |
| 7313 | |
| 7314 | /* Simple Authentication Password print. */ |
| 7315 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 7316 | params->auth_simple[0] != '\0') |
| 7317 | { |
| 7318 | vty_out (vty, " ip ospf authentication-key %s", |
| 7319 | params->auth_simple); |
| 7320 | if (params != IF_DEF_PARAMS (ifp)) |
| 7321 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7322 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7323 | } |
| 7324 | |
| 7325 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7326 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7327 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7328 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 7329 | ck->key_id, ck->auth_key); |
| 7330 | if (params != IF_DEF_PARAMS (ifp)) |
| 7331 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7332 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7333 | } |
| 7334 | |
| 7335 | /* Interface Output Cost print. */ |
| 7336 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 7337 | { |
| 7338 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 7339 | if (params != IF_DEF_PARAMS (ifp)) |
| 7340 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7341 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7342 | } |
| 7343 | |
| 7344 | /* Hello Interval print. */ |
| 7345 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 7346 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 7347 | { |
| 7348 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 7349 | if (params != IF_DEF_PARAMS (ifp)) |
| 7350 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7351 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7352 | } |
| 7353 | |
| 7354 | |
| 7355 | /* Router Dead Interval print. */ |
| 7356 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 7357 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 7358 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7359 | vty_out (vty, " ip ospf dead-interval "); |
| 7360 | |
| 7361 | /* fast hello ? */ |
| 7362 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 7363 | vty_out (vty, "minimal hello-multiplier %d", |
| 7364 | params->fast_hello); |
| 7365 | else |
| 7366 | vty_out (vty, "%u", params->v_wait); |
| 7367 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7368 | if (params != IF_DEF_PARAMS (ifp)) |
| 7369 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7370 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7371 | } |
| 7372 | |
| 7373 | /* Router Priority print. */ |
| 7374 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 7375 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 7376 | { |
| 7377 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 7378 | if (params != IF_DEF_PARAMS (ifp)) |
| 7379 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7380 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7381 | } |
| 7382 | |
| 7383 | /* Retransmit Interval print. */ |
| 7384 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 7385 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 7386 | { |
| 7387 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 7388 | params->retransmit_interval); |
| 7389 | if (params != IF_DEF_PARAMS (ifp)) |
| 7390 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7391 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7392 | } |
| 7393 | |
| 7394 | /* Transmit Delay print. */ |
| 7395 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 7396 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7397 | { |
| 7398 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 7399 | if (params != IF_DEF_PARAMS (ifp)) |
| 7400 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7401 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7402 | } |
| 7403 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7404 | /* MTU ignore print. */ |
| 7405 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 7406 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 7407 | { |
| 7408 | if (params->mtu_ignore == 0) |
| 7409 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 7410 | else |
| 7411 | vty_out (vty, " ip ospf mtu-ignore"); |
| 7412 | if (params != IF_DEF_PARAMS (ifp)) |
| 7413 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7414 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7415 | } |
| 7416 | |
| 7417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7418 | while (1) |
| 7419 | { |
| 7420 | if (rn == NULL) |
| 7421 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 7422 | else |
| 7423 | rn = route_next (rn); |
| 7424 | |
| 7425 | if (rn == NULL) |
| 7426 | break; |
| 7427 | params = rn->info; |
| 7428 | if (params != NULL) |
| 7429 | break; |
| 7430 | } |
| 7431 | } while (rn); |
| 7432 | |
| 7433 | #ifdef HAVE_OPAQUE_LSA |
| 7434 | ospf_opaque_config_write_if (vty, ifp); |
| 7435 | #endif /* HAVE_OPAQUE_LSA */ |
| 7436 | } |
| 7437 | |
| 7438 | return write; |
| 7439 | } |
| 7440 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7441 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7442 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7443 | { |
| 7444 | struct route_node *rn; |
| 7445 | u_char buf[INET_ADDRSTRLEN]; |
| 7446 | |
| 7447 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7448 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7449 | if (rn->info) |
| 7450 | { |
| 7451 | struct ospf_network *n = rn->info; |
| 7452 | |
| 7453 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7454 | |
| 7455 | /* Create Area ID string by specified Area ID format. */ |
| 7456 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7457 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7458 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7459 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7460 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7461 | |
| 7462 | /* Network print. */ |
| 7463 | vty_out (vty, " network %s/%d area %s%s", |
| 7464 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7465 | buf, VTY_NEWLINE); |
| 7466 | } |
| 7467 | |
| 7468 | return 0; |
| 7469 | } |
| 7470 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7471 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7472 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7473 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7474 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7475 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7476 | u_char buf[INET_ADDRSTRLEN]; |
| 7477 | |
| 7478 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7479 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7480 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7481 | struct route_node *rn1; |
| 7482 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7483 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7484 | |
| 7485 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7486 | { |
| 7487 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7488 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7489 | else |
| 7490 | vty_out (vty, " area %s authentication message-digest%s", |
| 7491 | buf, VTY_NEWLINE); |
| 7492 | } |
| 7493 | |
| 7494 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7495 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7496 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7497 | VTY_NEWLINE); |
| 7498 | |
| 7499 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7500 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7501 | ) |
| 7502 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7503 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7504 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7505 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7506 | { |
| 7507 | vty_out (vty, " area %s nssa", buf); |
| 7508 | switch (area->NSSATranslatorRole) |
| 7509 | { |
| 7510 | case OSPF_NSSA_ROLE_NEVER: |
| 7511 | vty_out (vty, " translate-never"); |
| 7512 | break; |
| 7513 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7514 | vty_out (vty, " translate-always"); |
| 7515 | break; |
| 7516 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7517 | default: |
| 7518 | vty_out (vty, " translate-candidate"); |
| 7519 | } |
| 7520 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7521 | |
| 7522 | if (area->no_summary) |
| 7523 | vty_out (vty, " no-summary"); |
| 7524 | |
| 7525 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7526 | |
| 7527 | if (area->default_cost != 1) |
| 7528 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7529 | area->default_cost, VTY_NEWLINE); |
| 7530 | } |
| 7531 | |
| 7532 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7533 | if (rn1->info) |
| 7534 | { |
| 7535 | struct ospf_area_range *range = rn1->info; |
| 7536 | |
| 7537 | vty_out (vty, " area %s range %s/%d", buf, |
| 7538 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7539 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7540 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7541 | vty_out (vty, " cost %d", range->cost_config); |
| 7542 | |
| 7543 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7544 | vty_out (vty, " not-advertise"); |
| 7545 | |
| 7546 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7547 | vty_out (vty, " substitute %s/%d", |
| 7548 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7549 | |
| 7550 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7551 | } |
| 7552 | |
| 7553 | if (EXPORT_NAME (area)) |
| 7554 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7555 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7556 | |
| 7557 | if (IMPORT_NAME (area)) |
| 7558 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7559 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7560 | |
| 7561 | if (PREFIX_NAME_IN (area)) |
| 7562 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7563 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7564 | |
| 7565 | if (PREFIX_NAME_OUT (area)) |
| 7566 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7567 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7568 | } |
| 7569 | |
| 7570 | return 0; |
| 7571 | } |
| 7572 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7573 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7574 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7575 | { |
| 7576 | struct ospf_nbr_nbma *nbr_nbma; |
| 7577 | struct route_node *rn; |
| 7578 | |
| 7579 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7580 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7581 | if ((nbr_nbma = rn->info)) |
| 7582 | { |
| 7583 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7584 | |
| 7585 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7586 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7587 | |
| 7588 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7589 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7590 | |
| 7591 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7592 | } |
| 7593 | |
| 7594 | return 0; |
| 7595 | } |
| 7596 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7597 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7598 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7599 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7600 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7601 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7602 | u_char buf[INET_ADDRSTRLEN]; |
| 7603 | |
| 7604 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7605 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7606 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7607 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7608 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7609 | struct ospf_interface *oi; |
| 7610 | |
| 7611 | if (vl_data != NULL) |
| 7612 | { |
| 7613 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7614 | |
| 7615 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7616 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7617 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7618 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7619 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7620 | oi = vl_data->vl_oi; |
| 7621 | |
| 7622 | /* timers */ |
| 7623 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7624 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7625 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7626 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7627 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7628 | buf, |
| 7629 | inet_ntoa (vl_data->vl_peer), |
| 7630 | OSPF_IF_PARAM (oi, v_hello), |
| 7631 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7632 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7633 | OSPF_IF_PARAM (oi, v_wait), |
| 7634 | VTY_NEWLINE); |
| 7635 | else |
| 7636 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7637 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7638 | /* Auth key */ |
| 7639 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7640 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7641 | buf, |
| 7642 | inet_ntoa (vl_data->vl_peer), |
| 7643 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7644 | VTY_NEWLINE); |
| 7645 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7646 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7647 | n2, ck)) |
| 7648 | vty_out (vty, " area %s virtual-link %s" |
| 7649 | " message-digest-key %d md5 %s%s", |
| 7650 | buf, |
| 7651 | inet_ntoa (vl_data->vl_peer), |
| 7652 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7653 | |
| 7654 | } |
| 7655 | } |
| 7656 | |
| 7657 | return 0; |
| 7658 | } |
| 7659 | |
| 7660 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7661 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7662 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7663 | { |
| 7664 | int type; |
| 7665 | |
| 7666 | /* redistribute print. */ |
| 7667 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7668 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7669 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7670 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7671 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7672 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7673 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7674 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7675 | vty_out (vty, " metric-type 1"); |
| 7676 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7677 | if (ROUTEMAP_NAME (ospf, type)) |
| 7678 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7679 | |
| 7680 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7681 | } |
| 7682 | |
| 7683 | return 0; |
| 7684 | } |
| 7685 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7686 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7687 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7688 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7689 | if (ospf->default_metric != -1) |
| 7690 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7691 | VTY_NEWLINE); |
| 7692 | return 0; |
| 7693 | } |
| 7694 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7695 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7696 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7697 | { |
| 7698 | int type; |
| 7699 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7700 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7701 | { |
| 7702 | /* distribute-list print. */ |
| 7703 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7704 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7705 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7706 | ospf->dlist[type].name, |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7707 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7708 | |
| 7709 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7710 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7711 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7712 | vty_out (vty, " default-information originate"); |
| 7713 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7714 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7715 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7716 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7717 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7718 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7719 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7720 | vty_out (vty, " metric-type 1"); |
| 7721 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7722 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7723 | vty_out (vty, " route-map %s", |
| 7724 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7725 | |
| 7726 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7727 | } |
| 7728 | |
| 7729 | } |
| 7730 | |
| 7731 | return 0; |
| 7732 | } |
| 7733 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7734 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7735 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7736 | { |
| 7737 | struct route_node *rn; |
| 7738 | struct ospf_distance *odistance; |
| 7739 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7740 | if (ospf->distance_all) |
| 7741 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7742 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7743 | if (ospf->distance_intra |
| 7744 | || ospf->distance_inter |
| 7745 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7746 | { |
| 7747 | vty_out (vty, " distance ospf"); |
| 7748 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7749 | if (ospf->distance_intra) |
| 7750 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7751 | if (ospf->distance_inter) |
| 7752 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7753 | if (ospf->distance_external) |
| 7754 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7755 | |
| 7756 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7757 | } |
| 7758 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7759 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7760 | if ((odistance = rn->info) != NULL) |
| 7761 | { |
| 7762 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7763 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7764 | odistance->access_list ? odistance->access_list : "", |
| 7765 | VTY_NEWLINE); |
| 7766 | } |
| 7767 | return 0; |
| 7768 | } |
| 7769 | |
| 7770 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7771 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7772 | ospf_config_write (struct vty *vty) |
| 7773 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7774 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7775 | struct interface *ifp; |
| 7776 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7777 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7778 | int write = 0; |
| 7779 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7780 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7781 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7782 | { |
| 7783 | /* `router ospf' print. */ |
| 7784 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7785 | |
| 7786 | write++; |
| 7787 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7788 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7789 | return write; |
| 7790 | |
| 7791 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7792 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7793 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7794 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7795 | |
| 7796 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7797 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7798 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7799 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7800 | |
| 7801 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7802 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7803 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7804 | |
| 7805 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7806 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7807 | { |
| 7808 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7809 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7810 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7811 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7812 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7813 | |
| 7814 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7815 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7816 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7817 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7818 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7819 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7820 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7821 | |
| 7822 | /* Max-metric router-lsa print */ |
| 7823 | config_write_stub_router (vty, ospf); |
| 7824 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7825 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7826 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7827 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7828 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7829 | |
| 7830 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7831 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7832 | |
| 7833 | /* passive-interface print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7834 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 7835 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7836 | vty_out (vty, " passive-interface %s%s", |
| 7837 | ifp->name, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7838 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7839 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 7840 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7841 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
| 7842 | vty_out (vty, " passive-interface %s %s%s", |
| 7843 | oi->ifp->name, |
| 7844 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7845 | |
| 7846 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7847 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7848 | |
| 7849 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7850 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7851 | |
| 7852 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7853 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7854 | |
| 7855 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7856 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7857 | |
| 7858 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7859 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | |
| 7861 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7862 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7863 | |
| 7864 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7865 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7866 | |
| 7867 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7868 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7869 | #endif /* HAVE_OPAQUE_LSA */ |
| 7870 | } |
| 7871 | |
| 7872 | return write; |
| 7873 | } |
| 7874 | |
| 7875 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7876 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7877 | { |
| 7878 | /* "show ip ospf" commands. */ |
| 7879 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7880 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7881 | |
| 7882 | /* "show ip ospf database" commands. */ |
| 7883 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7884 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7885 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7886 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7887 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7888 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7889 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7890 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7891 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7892 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7893 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7894 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7895 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7896 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7897 | |
| 7898 | /* "show ip ospf interface" commands. */ |
| 7899 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7900 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7901 | |
| 7902 | /* "show ip ospf neighbor" commands. */ |
| 7903 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7904 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7905 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7906 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7907 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7908 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7909 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7910 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7911 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7912 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7913 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7914 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7915 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7916 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7917 | |
| 7918 | /* "show ip ospf route" commands. */ |
| 7919 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7920 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7921 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7922 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7923 | } |
| 7924 | |
| 7925 | |
| 7926 | /* ospfd's interface node. */ |
| 7927 | struct cmd_node interface_node = |
| 7928 | { |
| 7929 | INTERFACE_NODE, |
| 7930 | "%s(config-if)# ", |
| 7931 | 1 |
| 7932 | }; |
| 7933 | |
| 7934 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7935 | static void |
| 7936 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7937 | { |
| 7938 | /* Install interface node. */ |
| 7939 | install_node (&interface_node, config_write_interface); |
| 7940 | |
| 7941 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7942 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7943 | install_default (INTERFACE_NODE); |
| 7944 | |
| 7945 | /* "description" commands. */ |
| 7946 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7947 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7948 | |
| 7949 | /* "ip ospf authentication" commands. */ |
| 7950 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7951 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7952 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7953 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7954 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7955 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7956 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7957 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7958 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7959 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7960 | |
| 7961 | /* "ip ospf message-digest-key" commands. */ |
| 7962 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7963 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7964 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7965 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7966 | |
| 7967 | /* "ip ospf cost" commands. */ |
| 7968 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7969 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7970 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7971 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7972 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7973 | /* "ip ospf mtu-ignore" commands. */ |
| 7974 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7975 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7976 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7977 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7978 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7979 | /* "ip ospf dead-interval" commands. */ |
| 7980 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7981 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7982 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 7983 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7984 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7985 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7986 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7987 | /* "ip ospf hello-interval" commands. */ |
| 7988 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7989 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7990 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7991 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7992 | |
| 7993 | /* "ip ospf network" commands. */ |
| 7994 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7995 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7996 | |
| 7997 | /* "ip ospf priority" commands. */ |
| 7998 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7999 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 8000 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 8001 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 8002 | |
| 8003 | /* "ip ospf retransmit-interval" commands. */ |
| 8004 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 8005 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 8006 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 8007 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 8008 | |
| 8009 | /* "ip ospf transmit-delay" commands. */ |
| 8010 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 8011 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 8012 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 8013 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 8014 | |
| 8015 | /* These commands are compatibitliy for previous version. */ |
| 8016 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 8017 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 8018 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 8019 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 8020 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 8021 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 8022 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 8023 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 8024 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 8025 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 8026 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 8027 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 8028 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 8029 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 8030 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 8031 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 8032 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 8033 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 8034 | } |
| 8035 | |
| 8036 | /* Zebra node structure. */ |
| 8037 | struct cmd_node zebra_node = |
| 8038 | { |
| 8039 | ZEBRA_NODE, |
| 8040 | "%s(config-router)#", |
| 8041 | }; |
| 8042 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8043 | static void |
| 8044 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8045 | { |
| 8046 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 8047 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 8048 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 8049 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 8050 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 8051 | install_element (OSPF_NODE, |
| 8052 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 8053 | install_element (OSPF_NODE, |
| 8054 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 8055 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 8056 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 8057 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 8058 | |
| 8059 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 8060 | |
| 8061 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 8062 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 8063 | |
| 8064 | install_element (OSPF_NODE, |
| 8065 | &ospf_default_information_originate_metric_type_cmd); |
| 8066 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 8067 | install_element (OSPF_NODE, |
| 8068 | &ospf_default_information_originate_type_metric_cmd); |
| 8069 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 8070 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 8071 | install_element (OSPF_NODE, |
| 8072 | &ospf_default_information_originate_always_metric_type_cmd); |
| 8073 | install_element (OSPF_NODE, |
| 8074 | &ospf_default_information_originate_always_metric_cmd); |
| 8075 | install_element (OSPF_NODE, |
| 8076 | &ospf_default_information_originate_always_cmd); |
| 8077 | install_element (OSPF_NODE, |
| 8078 | &ospf_default_information_originate_always_type_metric_cmd); |
| 8079 | install_element (OSPF_NODE, |
| 8080 | &ospf_default_information_originate_always_type_cmd); |
| 8081 | |
| 8082 | install_element (OSPF_NODE, |
| 8083 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 8084 | install_element (OSPF_NODE, |
| 8085 | &ospf_default_information_originate_metric_routemap_cmd); |
| 8086 | install_element (OSPF_NODE, |
| 8087 | &ospf_default_information_originate_routemap_cmd); |
| 8088 | install_element (OSPF_NODE, |
| 8089 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 8090 | install_element (OSPF_NODE, |
| 8091 | &ospf_default_information_originate_type_routemap_cmd); |
| 8092 | install_element (OSPF_NODE, |
| 8093 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 8094 | install_element (OSPF_NODE, |
| 8095 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 8096 | install_element (OSPF_NODE, |
| 8097 | &ospf_default_information_originate_always_routemap_cmd); |
| 8098 | install_element (OSPF_NODE, |
| 8099 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 8100 | install_element (OSPF_NODE, |
| 8101 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 8102 | |
| 8103 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 8104 | |
| 8105 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 8106 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 8107 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 8108 | |
| 8109 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 8110 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 8111 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 8112 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 8113 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 8114 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 8115 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 8116 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 8117 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 8118 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 8119 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 8120 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 8121 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 8122 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 8123 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 8124 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 8125 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 8126 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 8127 | #if 0 |
| 8128 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 8129 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 8130 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 8131 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 8132 | #endif /* 0 */ |
| 8133 | } |
| 8134 | |
| 8135 | struct cmd_node ospf_node = |
| 8136 | { |
| 8137 | OSPF_NODE, |
| 8138 | "%s(config-router)# ", |
| 8139 | 1 |
| 8140 | }; |
| 8141 | |
| 8142 | |
| 8143 | /* Install OSPF related vty commands. */ |
| 8144 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8145 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8146 | { |
| 8147 | /* Install ospf top node. */ |
| 8148 | install_node (&ospf_node, ospf_config_write); |
| 8149 | |
| 8150 | /* "router ospf" commands. */ |
| 8151 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 8152 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 8153 | |
| 8154 | install_default (OSPF_NODE); |
| 8155 | |
| 8156 | /* "ospf router-id" commands. */ |
| 8157 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 8158 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8159 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 8160 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8161 | |
| 8162 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8163 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 8164 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 8165 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 8166 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8167 | |
| 8168 | /* "ospf abr-type" commands. */ |
| 8169 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 8170 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 8171 | |
| 8172 | /* "ospf rfc1583-compatible" commands. */ |
| 8173 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 8174 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 8175 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 8176 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 8177 | |
| 8178 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8179 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 8180 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8181 | |
| 8182 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8183 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 8184 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 8185 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8186 | |
| 8187 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8188 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 8189 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 8190 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 8191 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 8192 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 8193 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 8194 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 8195 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 8196 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 8197 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 8198 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8199 | |
| 8200 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8201 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 8202 | install_element (OSPF_NODE, &no_ospf_area_vlink_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_param1_cmd); |
| 8205 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_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_param2_cmd); |
| 8208 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_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_param3_cmd); |
| 8211 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8212 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8213 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 8214 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8215 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8216 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 8217 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 8218 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8219 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8220 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 8221 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8222 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8223 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 8224 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8225 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8226 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 8227 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 8228 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8229 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8230 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 8231 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 8232 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8233 | |
| 8234 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8235 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 8236 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 8237 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 8238 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8239 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8240 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8241 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 8242 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 8243 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 8244 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 8245 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 8246 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8247 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8248 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 8249 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8250 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8251 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 8252 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8253 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8254 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 8255 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8256 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8257 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 8258 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8259 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8260 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 8261 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8262 | |
| 8263 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8264 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 8265 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 8266 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 8267 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 8268 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8269 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8270 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 8271 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 8272 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8273 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8274 | /* max-metric commands */ |
| 8275 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 8276 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 8277 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 8278 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 8279 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 8280 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 8281 | |
| 8282 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8283 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 8284 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8285 | |
| 8286 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8287 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 8288 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 8289 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 8290 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 8291 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 8292 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 8293 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 8294 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8295 | |
| 8296 | /* Init interface related vty commands. */ |
| 8297 | ospf_vty_if_init (); |
| 8298 | |
| 8299 | /* Init zebra related vty commands. */ |
| 8300 | ospf_vty_zebra_init (); |
| 8301 | } |