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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 219 | if (ospf->t_router_id_update == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 220 | OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer, |
| 221 | OSPF_ROUTER_ID_UPDATE_DELAY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 222 | |
| 223 | return CMD_SUCCESS; |
| 224 | } |
| 225 | |
| 226 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 227 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 228 | "router-id A.B.C.D", |
| 229 | "router-id for the OSPF process\n" |
| 230 | "OSPF router-id in IP address format\n") |
| 231 | |
| 232 | DEFUN (no_ospf_router_id, |
| 233 | no_ospf_router_id_cmd, |
| 234 | "no ospf router-id", |
| 235 | NO_STR |
| 236 | "OSPF specific commands\n" |
| 237 | "router-id for the OSPF process\n") |
| 238 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 239 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 240 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 241 | ospf->router_id_static.s_addr = 0; |
| 242 | |
| 243 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 244 | |
| 245 | return CMD_SUCCESS; |
| 246 | } |
| 247 | |
| 248 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 249 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 250 | "no router-id", |
| 251 | NO_STR |
| 252 | "router-id for the OSPF process\n") |
| 253 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 254 | DEFUN (ospf_passive_interface, |
| 255 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 256 | "passive-interface IFNAME A.B.C.D", |
| 257 | "Suppress routing updates on an interface\n" |
| 258 | "Interface's name\n") |
| 259 | { |
| 260 | struct interface *ifp; |
| 261 | struct in_addr addr; |
| 262 | int ret; |
| 263 | struct ospf_if_params *params; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 264 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 265 | |
| 266 | ifp = if_lookup_by_name (argv[0]); |
| 267 | |
| 268 | if (ifp == NULL) |
| 269 | { |
| 270 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 271 | return CMD_WARNING; |
| 272 | } |
| 273 | |
| 274 | params = IF_DEF_PARAMS (ifp); |
| 275 | |
| 276 | if (argc == 2) |
| 277 | { |
| 278 | ret = inet_aton(argv[1], &addr); |
| 279 | if (!ret) |
| 280 | { |
| 281 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 282 | VTY_NEWLINE); |
| 283 | return CMD_WARNING; |
| 284 | } |
| 285 | |
| 286 | params = ospf_get_if_params (ifp, addr); |
| 287 | ospf_if_update_params (ifp, addr); |
| 288 | } |
| 289 | |
| 290 | SET_IF_PARAM (params, passive_interface); |
| 291 | params->passive_interface = OSPF_IF_PASSIVE; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 292 | |
| 293 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 294 | * interfaces for which the passive property changed. It is too much |
| 295 | * work to determine this set, so we do this for every interface. |
| 296 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 297 | * record of joined groups to avoid systems calls if the desired |
| 298 | * memberships match the current memership. |
| 299 | */ |
| 300 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 301 | { |
| 302 | struct ospf_interface *oi = rn->info; |
| 303 | |
| 304 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
| 305 | ospf_if_set_multicast(oi); |
| 306 | } |
| 307 | /* |
| 308 | * XXX It is not clear what state transitions the interface needs to |
| 309 | * undergo when going from active to passive. Fixing this will |
| 310 | * require precise identification of interfaces having such a |
| 311 | * transition. |
| 312 | */ |
| 313 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 314 | return CMD_SUCCESS; |
| 315 | } |
| 316 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 317 | ALIAS (ospf_passive_interface, |
| 318 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 319 | "passive-interface IFNAME", |
| 320 | "Suppress routing updates on an interface\n" |
| 321 | "Interface's name\n") |
| 322 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 323 | DEFUN (no_ospf_passive_interface, |
| 324 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 325 | "no passive-interface IFNAME A.B.C.D", |
| 326 | NO_STR |
| 327 | "Allow routing updates on an interface\n" |
| 328 | "Interface's name\n") |
| 329 | { |
| 330 | struct interface *ifp; |
| 331 | struct in_addr addr; |
| 332 | struct ospf_if_params *params; |
| 333 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 334 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 335 | |
| 336 | ifp = if_lookup_by_name (argv[0]); |
| 337 | |
| 338 | if (ifp == NULL) |
| 339 | { |
| 340 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 341 | return CMD_WARNING; |
| 342 | } |
| 343 | |
| 344 | params = IF_DEF_PARAMS (ifp); |
| 345 | |
| 346 | if (argc == 2) |
| 347 | { |
| 348 | ret = inet_aton(argv[1], &addr); |
| 349 | if (!ret) |
| 350 | { |
| 351 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 352 | VTY_NEWLINE); |
| 353 | return CMD_WARNING; |
| 354 | } |
| 355 | |
| 356 | params = ospf_lookup_if_params (ifp, addr); |
| 357 | if (params == NULL) |
| 358 | return CMD_SUCCESS; |
| 359 | } |
| 360 | |
| 361 | UNSET_IF_PARAM (params, passive_interface); |
| 362 | params->passive_interface = OSPF_IF_ACTIVE; |
| 363 | |
| 364 | if (params != IF_DEF_PARAMS (ifp)) |
| 365 | { |
| 366 | ospf_free_if_params (ifp, addr); |
| 367 | ospf_if_update_params (ifp, addr); |
| 368 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 369 | |
| 370 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 371 | * interfaces for which the passive property changed. It is too much |
| 372 | * work to determine this set, so we do this for every interface. |
| 373 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 374 | * record of joined groups to avoid systems calls if the desired |
| 375 | * memberships match the current memership. |
| 376 | */ |
| 377 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 378 | { |
| 379 | struct ospf_interface *oi = rn->info; |
| 380 | |
| 381 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 382 | ospf_if_set_multicast(oi); |
| 383 | } |
| 384 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 385 | return CMD_SUCCESS; |
| 386 | } |
| 387 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 388 | ALIAS (no_ospf_passive_interface, |
| 389 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 390 | "no passive-interface IFNAME", |
| 391 | NO_STR |
| 392 | "Allow routing updates on an interface\n" |
| 393 | "Interface's name\n") |
| 394 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 395 | DEFUN (ospf_network_area, |
| 396 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 397 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 398 | "Enable routing on an IP network\n" |
| 399 | "OSPF network prefix\n" |
| 400 | "Set the OSPF area ID\n" |
| 401 | "OSPF area ID in IP address format\n" |
| 402 | "OSPF area ID as a decimal value\n") |
| 403 | { |
| 404 | struct ospf *ospf= vty->index; |
| 405 | struct prefix_ipv4 p; |
| 406 | struct in_addr area_id; |
| 407 | int ret, format; |
| 408 | |
| 409 | /* Get network prefix and Area ID. */ |
| 410 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 411 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 412 | |
| 413 | ret = ospf_network_set (ospf, &p, area_id); |
| 414 | if (ret == 0) |
| 415 | { |
| 416 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 417 | return CMD_WARNING; |
| 418 | } |
| 419 | |
| 420 | return CMD_SUCCESS; |
| 421 | } |
| 422 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 423 | DEFUN (no_ospf_network_area, |
| 424 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 425 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 426 | NO_STR |
| 427 | "Enable routing on an IP network\n" |
| 428 | "OSPF network prefix\n" |
| 429 | "Set the OSPF area ID\n" |
| 430 | "OSPF area ID in IP address format\n" |
| 431 | "OSPF area ID as a decimal value\n") |
| 432 | { |
| 433 | struct ospf *ospf = (struct ospf *) vty->index; |
| 434 | struct prefix_ipv4 p; |
| 435 | struct in_addr area_id; |
| 436 | int ret, format; |
| 437 | |
| 438 | /* Get network prefix and Area ID. */ |
| 439 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 440 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 441 | |
| 442 | ret = ospf_network_unset (ospf, &p, area_id); |
| 443 | if (ret == 0) |
| 444 | { |
| 445 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 446 | VTY_NEWLINE); |
| 447 | return CMD_WARNING; |
| 448 | } |
| 449 | |
| 450 | return CMD_SUCCESS; |
| 451 | } |
| 452 | |
| 453 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 454 | DEFUN (ospf_area_range, |
| 455 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 456 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 457 | "OSPF area parameters\n" |
| 458 | "OSPF area ID in IP address format\n" |
| 459 | "OSPF area ID as a decimal value\n" |
| 460 | "Summarize routes matching address/mask (border routers only)\n" |
| 461 | "Area range prefix\n") |
| 462 | { |
| 463 | struct ospf *ospf = vty->index; |
| 464 | struct prefix_ipv4 p; |
| 465 | struct in_addr area_id; |
| 466 | int format; |
| 467 | u_int32_t cost; |
| 468 | |
| 469 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 470 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 471 | |
| 472 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 473 | if (argc > 2) |
| 474 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 475 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 476 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 477 | } |
| 478 | |
| 479 | return CMD_SUCCESS; |
| 480 | } |
| 481 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 482 | ALIAS (ospf_area_range, |
| 483 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 484 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 485 | "OSPF area parameters\n" |
| 486 | "OSPF area ID in IP address format\n" |
| 487 | "OSPF area ID as a decimal value\n" |
| 488 | "OSPF area range for route advertise (default)\n" |
| 489 | "Area range prefix\n" |
| 490 | "Advertise this range (default)\n") |
| 491 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 492 | ALIAS (ospf_area_range, |
| 493 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 494 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 495 | "OSPF area parameters\n" |
| 496 | "OSPF area ID in IP address format\n" |
| 497 | "OSPF area ID as a decimal value\n" |
| 498 | "Summarize routes matching address/mask (border routers only)\n" |
| 499 | "Area range prefix\n" |
| 500 | "User specified metric for this range\n" |
| 501 | "Advertised metric for this range\n") |
| 502 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 503 | ALIAS (ospf_area_range, |
| 504 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 505 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 506 | "OSPF area parameters\n" |
| 507 | "OSPF area ID in IP address format\n" |
| 508 | "OSPF area ID as a decimal value\n" |
| 509 | "Summarize routes matching address/mask (border routers only)\n" |
| 510 | "Area range prefix\n" |
| 511 | "Advertise this range (default)\n" |
| 512 | "User specified metric for this range\n" |
| 513 | "Advertised metric for this range\n") |
| 514 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 515 | DEFUN (ospf_area_range_not_advertise, |
| 516 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 517 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 518 | "OSPF area parameters\n" |
| 519 | "OSPF area ID in IP address format\n" |
| 520 | "OSPF area ID as a decimal value\n" |
| 521 | "Summarize routes matching address/mask (border routers only)\n" |
| 522 | "Area range prefix\n" |
| 523 | "DoNotAdvertise this range\n") |
| 524 | { |
| 525 | struct ospf *ospf = vty->index; |
| 526 | struct prefix_ipv4 p; |
| 527 | struct in_addr area_id; |
| 528 | int format; |
| 529 | |
| 530 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 531 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 532 | |
| 533 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 534 | |
| 535 | return CMD_SUCCESS; |
| 536 | } |
| 537 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 538 | DEFUN (no_ospf_area_range, |
| 539 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 540 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 541 | NO_STR |
| 542 | "OSPF area parameters\n" |
| 543 | "OSPF area ID in IP address format\n" |
| 544 | "OSPF area ID as a decimal value\n" |
| 545 | "Summarize routes matching address/mask (border routers only)\n" |
| 546 | "Area range prefix\n") |
| 547 | { |
| 548 | struct ospf *ospf = vty->index; |
| 549 | struct prefix_ipv4 p; |
| 550 | struct in_addr area_id; |
| 551 | int format; |
| 552 | |
| 553 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 554 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 555 | |
| 556 | ospf_area_range_unset (ospf, area_id, &p); |
| 557 | |
| 558 | return CMD_SUCCESS; |
| 559 | } |
| 560 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 561 | ALIAS (no_ospf_area_range, |
| 562 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 564 | NO_STR |
| 565 | "OSPF area parameters\n" |
| 566 | "OSPF area ID in IP address format\n" |
| 567 | "OSPF area ID as a decimal value\n" |
| 568 | "Summarize routes matching address/mask (border routers only)\n" |
| 569 | "Area range prefix\n" |
| 570 | "Advertise this range (default)\n" |
| 571 | "DoNotAdvertise this range\n") |
| 572 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 573 | ALIAS (no_ospf_area_range, |
| 574 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 575 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 576 | NO_STR |
| 577 | "OSPF area parameters\n" |
| 578 | "OSPF area ID in IP address format\n" |
| 579 | "OSPF area ID as a decimal value\n" |
| 580 | "Summarize routes matching address/mask (border routers only)\n" |
| 581 | "Area range prefix\n" |
| 582 | "User specified metric for this range\n" |
| 583 | "Advertised metric for this range\n") |
| 584 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 585 | ALIAS (no_ospf_area_range, |
| 586 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 587 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 588 | NO_STR |
| 589 | "OSPF area parameters\n" |
| 590 | "OSPF area ID in IP address format\n" |
| 591 | "OSPF area ID as a decimal value\n" |
| 592 | "Summarize routes matching address/mask (border routers only)\n" |
| 593 | "Area range prefix\n" |
| 594 | "Advertise this range (default)\n" |
| 595 | "User specified metric for this range\n" |
| 596 | "Advertised metric for this range\n") |
| 597 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 598 | DEFUN (ospf_area_range_substitute, |
| 599 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 601 | "OSPF area parameters\n" |
| 602 | "OSPF area ID in IP address format\n" |
| 603 | "OSPF area ID as a decimal value\n" |
| 604 | "Summarize routes matching address/mask (border routers only)\n" |
| 605 | "Area range prefix\n" |
| 606 | "Announce area range as another prefix\n" |
| 607 | "Network prefix to be announced instead of range\n") |
| 608 | { |
| 609 | struct ospf *ospf = vty->index; |
| 610 | struct prefix_ipv4 p, s; |
| 611 | struct in_addr area_id; |
| 612 | int format; |
| 613 | |
| 614 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 615 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 616 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 617 | |
| 618 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 619 | |
| 620 | return CMD_SUCCESS; |
| 621 | } |
| 622 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 623 | DEFUN (no_ospf_area_range_substitute, |
| 624 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 625 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 626 | NO_STR |
| 627 | "OSPF area parameters\n" |
| 628 | "OSPF area ID in IP address format\n" |
| 629 | "OSPF area ID as a decimal value\n" |
| 630 | "Summarize routes matching address/mask (border routers only)\n" |
| 631 | "Area range prefix\n" |
| 632 | "Announce area range as another prefix\n" |
| 633 | "Network prefix to be announced instead of range\n") |
| 634 | { |
| 635 | struct ospf *ospf = vty->index; |
| 636 | struct prefix_ipv4 p, s; |
| 637 | struct in_addr area_id; |
| 638 | int format; |
| 639 | |
| 640 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 641 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 642 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 643 | |
| 644 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 645 | |
| 646 | return CMD_SUCCESS; |
| 647 | } |
| 648 | |
| 649 | |
| 650 | /* Command Handler Logic in VLink stuff is delicate!! |
| 651 | |
| 652 | ALTER AT YOUR OWN RISK!!!! |
| 653 | |
| 654 | Various dummy values are used to represent 'NoChange' state for |
| 655 | VLink configuration NOT being changed by a VLink command, and |
| 656 | special syntax is used within the command strings so that the |
| 657 | typed in command verbs can be seen in the configuration command |
| 658 | bacckend handler. This is to drastically reduce the verbeage |
| 659 | required to coe up with a reasonably compatible Cisco VLink command |
| 660 | |
| 661 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 662 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 663 | */ |
| 664 | |
| 665 | |
| 666 | /* Configuration data for virtual links |
| 667 | */ |
| 668 | struct ospf_vl_config_data { |
| 669 | struct vty *vty; /* vty stuff */ |
| 670 | struct in_addr area_id; /* area ID from command line */ |
| 671 | int format; /* command line area ID format */ |
| 672 | struct in_addr vl_peer; /* command line vl_peer */ |
| 673 | int auth_type; /* Authehntication type, if given */ |
| 674 | char *auth_key; /* simple password if present */ |
| 675 | int crypto_key_id; /* Cryptographic key ID */ |
| 676 | char *md5_key; /* MD5 authentication key */ |
| 677 | int hello_interval; /* Obvious what these are... */ |
| 678 | int retransmit_interval; |
| 679 | int transmit_delay; |
| 680 | int dead_interval; |
| 681 | }; |
| 682 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 683 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 684 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 685 | struct vty *vty) |
| 686 | { |
| 687 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 688 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 689 | vl_config->vty = vty; |
| 690 | } |
| 691 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 692 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 693 | 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] | 694 | { |
| 695 | struct ospf_area *area; |
| 696 | struct ospf_vl_data *vl_data; |
| 697 | struct vty *vty; |
| 698 | struct in_addr area_id; |
| 699 | |
| 700 | vty = vl_config->vty; |
| 701 | area_id = vl_config->area_id; |
| 702 | |
| 703 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 704 | { |
| 705 | vty_out (vty, |
| 706 | "Configuring VLs over the backbone is not allowed%s", |
| 707 | VTY_NEWLINE); |
| 708 | return NULL; |
| 709 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 710 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 711 | |
| 712 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 713 | { |
| 714 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 715 | vty_out (vty, "Area %s is %s%s", |
| 716 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 717 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 718 | VTY_NEWLINE); |
| 719 | else |
| 720 | vty_out (vty, "Area %ld is %s%s", |
| 721 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 722 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | VTY_NEWLINE); |
| 724 | return NULL; |
| 725 | } |
| 726 | |
| 727 | if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL) |
| 728 | { |
| 729 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 730 | if (vl_data->vl_oi == NULL) |
| 731 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 732 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 733 | ospf_vl_add (ospf, vl_data); |
| 734 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 735 | } |
| 736 | } |
| 737 | return vl_data; |
| 738 | } |
| 739 | |
| 740 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 741 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 742 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 743 | struct ospf_vl_config_data *vl_config) |
| 744 | { |
| 745 | struct crypt_key *ck; |
| 746 | struct vty *vty; |
| 747 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 748 | |
| 749 | vty = vl_config->vty; |
| 750 | |
| 751 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 752 | { |
| 753 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 754 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 755 | } |
| 756 | |
| 757 | if (vl_config->auth_key) |
| 758 | { |
| 759 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 760 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 761 | OSPF_AUTH_SIMPLE_SIZE); |
| 762 | } |
| 763 | else if (vl_config->md5_key) |
| 764 | { |
| 765 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 766 | != NULL) |
| 767 | { |
| 768 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 769 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 770 | return CMD_WARNING; |
| 771 | } |
| 772 | ck = ospf_crypt_key_new (); |
| 773 | ck->key_id = vl_config->crypto_key_id; |
| 774 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 775 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 776 | |
| 777 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 778 | } |
| 779 | else if (vl_config->crypto_key_id != 0) |
| 780 | { |
| 781 | /* Delete a key */ |
| 782 | |
| 783 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 784 | vl_config->crypto_key_id) == NULL) |
| 785 | { |
| 786 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 787 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 788 | return CMD_WARNING; |
| 789 | } |
| 790 | |
| 791 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 792 | |
| 793 | } |
| 794 | |
| 795 | return CMD_SUCCESS; |
| 796 | } |
| 797 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 798 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 799 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 800 | struct ospf_vl_config_data *vl_config) |
| 801 | { |
| 802 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 803 | /* Virtual Link data initialised to defaults, so only set |
| 804 | if a value given */ |
| 805 | if (vl_config->hello_interval) |
| 806 | { |
| 807 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 808 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 809 | } |
| 810 | |
| 811 | if (vl_config->dead_interval) |
| 812 | { |
| 813 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 814 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 815 | } |
| 816 | |
| 817 | if (vl_config->retransmit_interval) |
| 818 | { |
| 819 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 820 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 821 | } |
| 822 | |
| 823 | if (vl_config->transmit_delay) |
| 824 | { |
| 825 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 826 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 827 | } |
| 828 | |
| 829 | return CMD_SUCCESS; |
| 830 | } |
| 831 | |
| 832 | |
| 833 | |
| 834 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 835 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 836 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 837 | { |
| 838 | struct ospf_vl_data *vl_data; |
| 839 | int ret; |
| 840 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 841 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | if (!vl_data) |
| 843 | return CMD_WARNING; |
| 844 | |
| 845 | /* Process this one first as it can have a fatal result, which can |
| 846 | only logically occur if the virtual link exists already |
| 847 | Thus a command error does not result in a change to the |
| 848 | running configuration such as unexpectedly altered timer |
| 849 | values etc.*/ |
| 850 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 851 | if (ret != CMD_SUCCESS) |
| 852 | return ret; |
| 853 | |
| 854 | /* Set any time based parameters, these area already range checked */ |
| 855 | |
| 856 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 857 | if (ret != CMD_SUCCESS) |
| 858 | return ret; |
| 859 | |
| 860 | return CMD_SUCCESS; |
| 861 | |
| 862 | } |
| 863 | |
| 864 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 865 | */ |
| 866 | #define VLINK_HELPSTR_IPADDR \ |
| 867 | "OSPF area parameters\n" \ |
| 868 | "OSPF area ID in IP address format\n" \ |
| 869 | "OSPF area ID as a decimal value\n" \ |
| 870 | "Configure a virtual link\n" \ |
| 871 | "Router ID of the remote ABR\n" |
| 872 | |
| 873 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 874 | "Enable authentication on this virtual link\n" \ |
| 875 | "dummy string \n" |
| 876 | |
| 877 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 878 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 879 | "Use null authentication\n" \ |
| 880 | "Use message-digest authentication\n" |
| 881 | |
| 882 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 883 | "Time between HELLO packets\n" \ |
| 884 | "Time between retransmitting lost link state advertisements\n" \ |
| 885 | "Link state transmit delay\n" \ |
| 886 | "Interval after which a neighbor is declared dead\n" |
| 887 | |
| 888 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 889 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 890 | "Seconds\n" |
| 891 | |
| 892 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 893 | "Authentication password (key)\n" \ |
| 894 | "The OSPF password (key)" |
| 895 | |
| 896 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 897 | "Message digest authentication password (key)\n" \ |
| 898 | "dummy string \n" \ |
| 899 | "Key ID\n" \ |
| 900 | "Use MD5 algorithm\n" \ |
| 901 | "The OSPF password (key)" |
| 902 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 903 | DEFUN (ospf_area_vlink, |
| 904 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 906 | VLINK_HELPSTR_IPADDR) |
| 907 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 908 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 909 | struct ospf_vl_config_data vl_config; |
| 910 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 911 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 912 | int i; |
| 913 | int ret; |
| 914 | |
| 915 | ospf_vl_config_data_init(&vl_config, vty); |
| 916 | |
| 917 | /* Read off first 2 parameters and check them */ |
| 918 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 919 | if (ret < 0) |
| 920 | { |
| 921 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 922 | return CMD_WARNING; |
| 923 | } |
| 924 | |
| 925 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 926 | if (! ret) |
| 927 | { |
| 928 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 929 | VTY_NEWLINE); |
| 930 | return CMD_WARNING; |
| 931 | } |
| 932 | |
| 933 | if (argc <=2) |
| 934 | { |
| 935 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 936 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 937 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | /* Deal with other parameters */ |
| 941 | for (i=2; i < argc; i++) |
| 942 | { |
| 943 | |
| 944 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 945 | |
| 946 | switch (argv[i][0]) |
| 947 | { |
| 948 | |
| 949 | case 'a': |
| 950 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 951 | { |
| 952 | /* authentication-key - this option can occur anywhere on |
| 953 | command line. At start of command line |
| 954 | must check for authentication option. */ |
| 955 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 956 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 957 | vl_config.auth_key = auth_key; |
| 958 | i++; |
| 959 | } |
| 960 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 961 | { |
| 962 | /* authentication - this option can only occur at start |
| 963 | of command line */ |
| 964 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 965 | if ((i+1) < argc) |
| 966 | { |
| 967 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 968 | { |
| 969 | /* "authentication null" */ |
| 970 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 971 | i++; |
| 972 | } |
| 973 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 974 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 975 | { |
| 976 | /* "authentication message-digest" */ |
| 977 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 978 | i++; |
| 979 | } |
| 980 | } |
| 981 | } |
| 982 | break; |
| 983 | |
| 984 | case 'm': |
| 985 | /* message-digest-key */ |
| 986 | i++; |
| 987 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 988 | if (vl_config.crypto_key_id < 0) |
| 989 | return CMD_WARNING; |
| 990 | i++; |
| 991 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 992 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 993 | vl_config.md5_key = md5_key; |
| 994 | break; |
| 995 | |
| 996 | case 'h': |
| 997 | /* Hello interval */ |
| 998 | i++; |
| 999 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 1000 | if (vl_config.hello_interval < 0) |
| 1001 | return CMD_WARNING; |
| 1002 | break; |
| 1003 | |
| 1004 | case 'r': |
| 1005 | /* Retransmit Interval */ |
| 1006 | i++; |
| 1007 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1008 | if (vl_config.retransmit_interval < 0) |
| 1009 | return CMD_WARNING; |
| 1010 | break; |
| 1011 | |
| 1012 | case 't': |
| 1013 | /* Transmit Delay */ |
| 1014 | i++; |
| 1015 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1016 | if (vl_config.transmit_delay < 0) |
| 1017 | return CMD_WARNING; |
| 1018 | break; |
| 1019 | |
| 1020 | case 'd': |
| 1021 | /* Dead Interval */ |
| 1022 | i++; |
| 1023 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1024 | if (vl_config.dead_interval < 0) |
| 1025 | return CMD_WARNING; |
| 1026 | break; |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | |
| 1031 | /* Action configuration */ |
| 1032 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1033 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1034 | |
| 1035 | } |
| 1036 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1037 | DEFUN (no_ospf_area_vlink, |
| 1038 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1039 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1040 | NO_STR |
| 1041 | VLINK_HELPSTR_IPADDR) |
| 1042 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1043 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1044 | struct ospf_area *area; |
| 1045 | struct ospf_vl_config_data vl_config; |
| 1046 | struct ospf_vl_data *vl_data = NULL; |
| 1047 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1048 | int i; |
| 1049 | int ret, format; |
| 1050 | |
| 1051 | ospf_vl_config_data_init(&vl_config, vty); |
| 1052 | |
| 1053 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1054 | if (ret < 0) |
| 1055 | { |
| 1056 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1057 | return CMD_WARNING; |
| 1058 | } |
| 1059 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1060 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1061 | if (!area) |
| 1062 | { |
| 1063 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1064 | return CMD_WARNING; |
| 1065 | } |
| 1066 | |
| 1067 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1068 | if (! ret) |
| 1069 | { |
| 1070 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1071 | VTY_NEWLINE); |
| 1072 | return CMD_WARNING; |
| 1073 | } |
| 1074 | |
| 1075 | if (argc <=2) |
| 1076 | { |
| 1077 | /* Basic VLink no command */ |
| 1078 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 1079 | if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1080 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1081 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1082 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1083 | |
| 1084 | return CMD_SUCCESS; |
| 1085 | } |
| 1086 | |
| 1087 | /* If we are down here, we are reseting parameters */ |
| 1088 | |
| 1089 | /* Deal with other parameters */ |
| 1090 | for (i=2; i < argc; i++) |
| 1091 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1092 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1093 | |
| 1094 | switch (argv[i][0]) |
| 1095 | { |
| 1096 | |
| 1097 | case 'a': |
| 1098 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1099 | { |
| 1100 | /* authentication-key - this option can occur anywhere on |
| 1101 | command line. At start of command line |
| 1102 | must check for authentication option. */ |
| 1103 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1104 | vl_config.auth_key = auth_key; |
| 1105 | } |
| 1106 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1107 | { |
| 1108 | /* authentication - this option can only occur at start |
| 1109 | of command line */ |
| 1110 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1111 | } |
| 1112 | break; |
| 1113 | |
| 1114 | case 'm': |
| 1115 | /* message-digest-key */ |
| 1116 | /* Delete one key */ |
| 1117 | i++; |
| 1118 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1119 | if (vl_config.crypto_key_id < 0) |
| 1120 | return CMD_WARNING; |
| 1121 | vl_config.md5_key = NULL; |
| 1122 | break; |
| 1123 | |
| 1124 | case 'h': |
| 1125 | /* Hello interval */ |
| 1126 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1127 | break; |
| 1128 | |
| 1129 | case 'r': |
| 1130 | /* Retransmit Interval */ |
| 1131 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1132 | break; |
| 1133 | |
| 1134 | case 't': |
| 1135 | /* Transmit Delay */ |
| 1136 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1137 | break; |
| 1138 | |
| 1139 | case 'd': |
| 1140 | /* Dead Interval */ |
| 1141 | i++; |
| 1142 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1143 | break; |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | |
| 1148 | /* Action configuration */ |
| 1149 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1150 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1151 | } |
| 1152 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1153 | ALIAS (ospf_area_vlink, |
| 1154 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1155 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1156 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1157 | VLINK_HELPSTR_IPADDR |
| 1158 | VLINK_HELPSTR_TIME_PARAM) |
| 1159 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1160 | ALIAS (no_ospf_area_vlink, |
| 1161 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1162 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1163 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1164 | NO_STR |
| 1165 | VLINK_HELPSTR_IPADDR |
| 1166 | VLINK_HELPSTR_TIME_PARAM) |
| 1167 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1168 | ALIAS (ospf_area_vlink, |
| 1169 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1170 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1171 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1172 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1173 | VLINK_HELPSTR_IPADDR |
| 1174 | VLINK_HELPSTR_TIME_PARAM |
| 1175 | VLINK_HELPSTR_TIME_PARAM) |
| 1176 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1177 | ALIAS (no_ospf_area_vlink, |
| 1178 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1179 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1180 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1181 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1182 | NO_STR |
| 1183 | VLINK_HELPSTR_IPADDR |
| 1184 | VLINK_HELPSTR_TIME_PARAM |
| 1185 | VLINK_HELPSTR_TIME_PARAM) |
| 1186 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1187 | ALIAS (ospf_area_vlink, |
| 1188 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1189 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1190 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1191 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1192 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1193 | VLINK_HELPSTR_IPADDR |
| 1194 | VLINK_HELPSTR_TIME_PARAM |
| 1195 | VLINK_HELPSTR_TIME_PARAM |
| 1196 | VLINK_HELPSTR_TIME_PARAM) |
| 1197 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1198 | ALIAS (no_ospf_area_vlink, |
| 1199 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1200 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1201 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1202 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1203 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1204 | NO_STR |
| 1205 | VLINK_HELPSTR_IPADDR |
| 1206 | VLINK_HELPSTR_TIME_PARAM |
| 1207 | VLINK_HELPSTR_TIME_PARAM |
| 1208 | VLINK_HELPSTR_TIME_PARAM) |
| 1209 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1210 | ALIAS (ospf_area_vlink, |
| 1211 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1212 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1213 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1214 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1215 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1216 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 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 (no_ospf_area_vlink, |
| 1224 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1225 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1226 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1227 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1228 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1229 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1230 | NO_STR |
| 1231 | VLINK_HELPSTR_IPADDR |
| 1232 | VLINK_HELPSTR_TIME_PARAM |
| 1233 | VLINK_HELPSTR_TIME_PARAM |
| 1234 | VLINK_HELPSTR_TIME_PARAM |
| 1235 | VLINK_HELPSTR_TIME_PARAM) |
| 1236 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1237 | ALIAS (ospf_area_vlink, |
| 1238 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1239 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1240 | "(authentication|) (message-digest|null)", |
| 1241 | VLINK_HELPSTR_IPADDR |
| 1242 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1243 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1244 | ALIAS (ospf_area_vlink, |
| 1245 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1246 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1247 | "(authentication|)", |
| 1248 | VLINK_HELPSTR_IPADDR |
| 1249 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1250 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1251 | ALIAS (no_ospf_area_vlink, |
| 1252 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1253 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1254 | "(authentication|)", |
| 1255 | NO_STR |
| 1256 | VLINK_HELPSTR_IPADDR |
| 1257 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1258 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1259 | ALIAS (ospf_area_vlink, |
| 1260 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1261 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1262 | "(message-digest-key|) <1-255> md5 KEY", |
| 1263 | VLINK_HELPSTR_IPADDR |
| 1264 | VLINK_HELPSTR_AUTH_MD5) |
| 1265 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1266 | ALIAS (no_ospf_area_vlink, |
| 1267 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1268 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1269 | "(message-digest-key|) <1-255>", |
| 1270 | NO_STR |
| 1271 | VLINK_HELPSTR_IPADDR |
| 1272 | VLINK_HELPSTR_AUTH_MD5) |
| 1273 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1274 | ALIAS (ospf_area_vlink, |
| 1275 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1276 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1277 | "(authentication-key|) AUTH_KEY", |
| 1278 | VLINK_HELPSTR_IPADDR |
| 1279 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1280 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1281 | ALIAS (no_ospf_area_vlink, |
| 1282 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1283 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1284 | "(authentication-key|)", |
| 1285 | NO_STR |
| 1286 | VLINK_HELPSTR_IPADDR |
| 1287 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1288 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1289 | ALIAS (ospf_area_vlink, |
| 1290 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1291 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1292 | "(authentication|) (message-digest|null) " |
| 1293 | "(authentication-key|) AUTH_KEY", |
| 1294 | VLINK_HELPSTR_IPADDR |
| 1295 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1296 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1297 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1298 | ALIAS (ospf_area_vlink, |
| 1299 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1300 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1301 | "(authentication|) " |
| 1302 | "(authentication-key|) AUTH_KEY", |
| 1303 | VLINK_HELPSTR_IPADDR |
| 1304 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1305 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1306 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1307 | ALIAS (no_ospf_area_vlink, |
| 1308 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1309 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1310 | "(authentication|) " |
| 1311 | "(authentication-key|)", |
| 1312 | NO_STR |
| 1313 | VLINK_HELPSTR_IPADDR |
| 1314 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1315 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1316 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1317 | ALIAS (ospf_area_vlink, |
| 1318 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1319 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1320 | "(authentication|) (message-digest|null) " |
| 1321 | "(message-digest-key|) <1-255> md5 KEY", |
| 1322 | VLINK_HELPSTR_IPADDR |
| 1323 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1324 | VLINK_HELPSTR_AUTH_MD5) |
| 1325 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1326 | ALIAS (ospf_area_vlink, |
| 1327 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1328 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1329 | "(authentication|) " |
| 1330 | "(message-digest-key|) <1-255> md5 KEY", |
| 1331 | VLINK_HELPSTR_IPADDR |
| 1332 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1333 | VLINK_HELPSTR_AUTH_MD5) |
| 1334 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1335 | ALIAS (no_ospf_area_vlink, |
| 1336 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1337 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1338 | "(authentication|) " |
| 1339 | "(message-digest-key|)", |
| 1340 | NO_STR |
| 1341 | VLINK_HELPSTR_IPADDR |
| 1342 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1343 | VLINK_HELPSTR_AUTH_MD5) |
| 1344 | |
| 1345 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1346 | DEFUN (ospf_area_shortcut, |
| 1347 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1348 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1349 | "OSPF area parameters\n" |
| 1350 | "OSPF area ID in IP address format\n" |
| 1351 | "OSPF area ID as a decimal value\n" |
| 1352 | "Configure the area's shortcutting mode\n" |
| 1353 | "Set default shortcutting behavior\n" |
| 1354 | "Enable shortcutting through the area\n" |
| 1355 | "Disable shortcutting through the area\n") |
| 1356 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1357 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1358 | struct ospf_area *area; |
| 1359 | struct in_addr area_id; |
| 1360 | int mode; |
| 1361 | int format; |
| 1362 | |
| 1363 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1364 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1365 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1366 | |
| 1367 | if (strncmp (argv[1], "de", 2) == 0) |
| 1368 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1369 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1370 | mode = OSPF_SHORTCUT_DISABLE; |
| 1371 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1372 | mode = OSPF_SHORTCUT_ENABLE; |
| 1373 | else |
| 1374 | return CMD_WARNING; |
| 1375 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1376 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1377 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1378 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1379 | vty_out (vty, "Shortcut area setting will take effect " |
| 1380 | "only when the router is configured as Shortcut ABR%s", |
| 1381 | VTY_NEWLINE); |
| 1382 | |
| 1383 | return CMD_SUCCESS; |
| 1384 | } |
| 1385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1386 | DEFUN (no_ospf_area_shortcut, |
| 1387 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1388 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1389 | NO_STR |
| 1390 | "OSPF area parameters\n" |
| 1391 | "OSPF area ID in IP address format\n" |
| 1392 | "OSPF area ID as a decimal value\n" |
| 1393 | "Deconfigure the area's shortcutting mode\n" |
| 1394 | "Deconfigure enabled shortcutting through the area\n" |
| 1395 | "Deconfigure disabled shortcutting through the area\n") |
| 1396 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1397 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1398 | struct ospf_area *area; |
| 1399 | struct in_addr area_id; |
| 1400 | int format; |
| 1401 | |
| 1402 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1403 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1404 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1405 | if (!area) |
| 1406 | return CMD_SUCCESS; |
| 1407 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1408 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1409 | |
| 1410 | return CMD_SUCCESS; |
| 1411 | } |
| 1412 | |
| 1413 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1414 | DEFUN (ospf_area_stub, |
| 1415 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1416 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1417 | "OSPF area parameters\n" |
| 1418 | "OSPF area ID in IP address format\n" |
| 1419 | "OSPF area ID as a decimal value\n" |
| 1420 | "Configure OSPF area as stub\n") |
| 1421 | { |
| 1422 | struct ospf *ospf = vty->index; |
| 1423 | struct in_addr area_id; |
| 1424 | int ret, format; |
| 1425 | |
| 1426 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1427 | |
| 1428 | ret = ospf_area_stub_set (ospf, area_id); |
| 1429 | if (ret == 0) |
| 1430 | { |
| 1431 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1432 | VTY_NEWLINE); |
| 1433 | return CMD_WARNING; |
| 1434 | } |
| 1435 | |
| 1436 | ospf_area_no_summary_unset (ospf, area_id); |
| 1437 | |
| 1438 | return CMD_SUCCESS; |
| 1439 | } |
| 1440 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1441 | DEFUN (ospf_area_stub_no_summary, |
| 1442 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1443 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1444 | "OSPF stub parameters\n" |
| 1445 | "OSPF area ID in IP address format\n" |
| 1446 | "OSPF area ID as a decimal value\n" |
| 1447 | "Configure OSPF area as stub\n" |
| 1448 | "Do not inject inter-area routes into stub\n") |
| 1449 | { |
| 1450 | struct ospf *ospf = vty->index; |
| 1451 | struct in_addr area_id; |
| 1452 | int ret, format; |
| 1453 | |
| 1454 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1455 | |
| 1456 | ret = ospf_area_stub_set (ospf, area_id); |
| 1457 | if (ret == 0) |
| 1458 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1459 | 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] | 1460 | VTY_NEWLINE); |
| 1461 | return CMD_WARNING; |
| 1462 | } |
| 1463 | |
| 1464 | ospf_area_no_summary_set (ospf, area_id); |
| 1465 | |
| 1466 | return CMD_SUCCESS; |
| 1467 | } |
| 1468 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1469 | DEFUN (no_ospf_area_stub, |
| 1470 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1471 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1472 | NO_STR |
| 1473 | "OSPF area parameters\n" |
| 1474 | "OSPF area ID in IP address format\n" |
| 1475 | "OSPF area ID as a decimal value\n" |
| 1476 | "Configure OSPF area as stub\n") |
| 1477 | { |
| 1478 | struct ospf *ospf = vty->index; |
| 1479 | struct in_addr area_id; |
| 1480 | int format; |
| 1481 | |
| 1482 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1483 | |
| 1484 | ospf_area_stub_unset (ospf, area_id); |
| 1485 | ospf_area_no_summary_unset (ospf, area_id); |
| 1486 | |
| 1487 | return CMD_SUCCESS; |
| 1488 | } |
| 1489 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1490 | DEFUN (no_ospf_area_stub_no_summary, |
| 1491 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1492 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1493 | NO_STR |
| 1494 | "OSPF area parameters\n" |
| 1495 | "OSPF area ID in IP address format\n" |
| 1496 | "OSPF area ID as a decimal value\n" |
| 1497 | "Configure OSPF area as stub\n" |
| 1498 | "Do not inject inter-area routes into area\n") |
| 1499 | { |
| 1500 | struct ospf *ospf = vty->index; |
| 1501 | struct in_addr area_id; |
| 1502 | int format; |
| 1503 | |
| 1504 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1505 | ospf_area_no_summary_unset (ospf, area_id); |
| 1506 | |
| 1507 | return CMD_SUCCESS; |
| 1508 | } |
| 1509 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1510 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1511 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1512 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1513 | { |
| 1514 | struct ospf *ospf = vty->index; |
| 1515 | struct in_addr area_id; |
| 1516 | int ret, format; |
| 1517 | |
| 1518 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1519 | |
| 1520 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1521 | if (ret == 0) |
| 1522 | { |
| 1523 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1524 | VTY_NEWLINE); |
| 1525 | return CMD_WARNING; |
| 1526 | } |
| 1527 | |
| 1528 | if (argc > 1) |
| 1529 | { |
| 1530 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1531 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1532 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1533 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1534 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1535 | OSPF_NSSA_ROLE_NEVER); |
| 1536 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1537 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1538 | OSPF_NSSA_ROLE_ALWAYS); |
| 1539 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1540 | else |
| 1541 | { |
| 1542 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1543 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1544 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1545 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1546 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1547 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1548 | else |
| 1549 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1550 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1551 | ospf_schedule_abr_task (ospf); |
| 1552 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1553 | return CMD_SUCCESS; |
| 1554 | } |
| 1555 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1556 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1557 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1558 | "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] | 1559 | "OSPF area parameters\n" |
| 1560 | "OSPF area ID in IP address format\n" |
| 1561 | "OSPF area ID as a decimal value\n" |
| 1562 | "Configure OSPF area as nssa\n" |
| 1563 | "Configure NSSA-ABR for translate election (default)\n" |
| 1564 | "Configure NSSA-ABR to never translate\n" |
| 1565 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1566 | "Do not inject inter-area routes into nssa\n") |
| 1567 | { |
| 1568 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1569 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1570 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1571 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1572 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1573 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 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 | "Configure NSSA-ABR for translate election (default)\n" |
| 1579 | "Configure NSSA-ABR to never translate\n" |
| 1580 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1581 | { |
| 1582 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1583 | } |
| 1584 | |
| 1585 | DEFUN (ospf_area_nssa, |
| 1586 | ospf_area_nssa_cmd, |
| 1587 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1588 | "OSPF area parameters\n" |
| 1589 | "OSPF area ID in IP address format\n" |
| 1590 | "OSPF area ID as a decimal value\n" |
| 1591 | "Configure OSPF area as nssa\n") |
| 1592 | { |
| 1593 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1594 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1595 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1596 | DEFUN (ospf_area_nssa_no_summary, |
| 1597 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1599 | "OSPF area parameters\n" |
| 1600 | "OSPF area ID in IP address format\n" |
| 1601 | "OSPF area ID as a decimal value\n" |
| 1602 | "Configure OSPF area as nssa\n" |
| 1603 | "Do not inject inter-area routes into nssa\n") |
| 1604 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1605 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1606 | } |
| 1607 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1608 | DEFUN (no_ospf_area_nssa, |
| 1609 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1610 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1611 | NO_STR |
| 1612 | "OSPF area parameters\n" |
| 1613 | "OSPF area ID in IP address format\n" |
| 1614 | "OSPF area ID as a decimal value\n" |
| 1615 | "Configure OSPF area as nssa\n") |
| 1616 | { |
| 1617 | struct ospf *ospf = vty->index; |
| 1618 | struct in_addr area_id; |
| 1619 | int format; |
| 1620 | |
| 1621 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1622 | |
| 1623 | ospf_area_nssa_unset (ospf, area_id); |
| 1624 | ospf_area_no_summary_unset (ospf, area_id); |
| 1625 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1626 | ospf_schedule_abr_task (ospf); |
| 1627 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1628 | return CMD_SUCCESS; |
| 1629 | } |
| 1630 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1631 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1632 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1633 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1634 | NO_STR |
| 1635 | "OSPF area parameters\n" |
| 1636 | "OSPF area ID in IP address format\n" |
| 1637 | "OSPF area ID as a decimal value\n" |
| 1638 | "Configure OSPF area as nssa\n" |
| 1639 | "Do not inject inter-area routes into nssa\n") |
| 1640 | { |
| 1641 | struct ospf *ospf = vty->index; |
| 1642 | struct in_addr area_id; |
| 1643 | int format; |
| 1644 | |
| 1645 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1646 | ospf_area_no_summary_unset (ospf, area_id); |
| 1647 | |
| 1648 | return CMD_SUCCESS; |
| 1649 | } |
| 1650 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1651 | DEFUN (ospf_area_default_cost, |
| 1652 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1653 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1654 | "OSPF area parameters\n" |
| 1655 | "OSPF area ID in IP address format\n" |
| 1656 | "OSPF area ID as a decimal value\n" |
| 1657 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1658 | "Stub's advertised default summary cost\n") |
| 1659 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1660 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1661 | struct ospf_area *area; |
| 1662 | struct in_addr area_id; |
| 1663 | u_int32_t cost; |
| 1664 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1665 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1666 | |
| 1667 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1668 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1669 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1670 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1671 | |
| 1672 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1673 | { |
| 1674 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1675 | return CMD_WARNING; |
| 1676 | } |
| 1677 | |
| 1678 | area->default_cost = cost; |
| 1679 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1680 | p.family = AF_INET; |
| 1681 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1682 | p.prefixlen = 0; |
| 1683 | if (IS_DEBUG_OSPF_EVENT) |
| 1684 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1685 | "announcing 0.0.0.0/0 to area %s", |
| 1686 | inet_ntoa (area->area_id)); |
| 1687 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1688 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1689 | return CMD_SUCCESS; |
| 1690 | } |
| 1691 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1692 | DEFUN (no_ospf_area_default_cost, |
| 1693 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1694 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1695 | NO_STR |
| 1696 | "OSPF area parameters\n" |
| 1697 | "OSPF area ID in IP address format\n" |
| 1698 | "OSPF area ID as a decimal value\n" |
| 1699 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1700 | "Stub's advertised default summary cost\n") |
| 1701 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1702 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1703 | struct ospf_area *area; |
| 1704 | struct in_addr area_id; |
| 1705 | u_int32_t cost; |
| 1706 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1707 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1708 | |
| 1709 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1710 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1711 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1712 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1713 | if (area == NULL) |
| 1714 | return CMD_SUCCESS; |
| 1715 | |
| 1716 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1717 | { |
| 1718 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1719 | return CMD_WARNING; |
| 1720 | } |
| 1721 | |
| 1722 | area->default_cost = 1; |
| 1723 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1724 | p.family = AF_INET; |
| 1725 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1726 | p.prefixlen = 0; |
| 1727 | if (IS_DEBUG_OSPF_EVENT) |
| 1728 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1729 | "announcing 0.0.0.0/0 to area %s", |
| 1730 | inet_ntoa (area->area_id)); |
| 1731 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1732 | |
| 1733 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1734 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1735 | |
| 1736 | return CMD_SUCCESS; |
| 1737 | } |
| 1738 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1739 | DEFUN (ospf_area_export_list, |
| 1740 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1741 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1742 | "OSPF area parameters\n" |
| 1743 | "OSPF area ID in IP address format\n" |
| 1744 | "OSPF area ID as a decimal value\n" |
| 1745 | "Set the filter for networks announced to other areas\n" |
| 1746 | "Name of the access-list\n") |
| 1747 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1748 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1749 | struct ospf_area *area; |
| 1750 | struct in_addr area_id; |
| 1751 | int format; |
| 1752 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1753 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1754 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1755 | area = ospf_area_get (ospf, area_id, format); |
| 1756 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1757 | |
| 1758 | return CMD_SUCCESS; |
| 1759 | } |
| 1760 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1761 | DEFUN (no_ospf_area_export_list, |
| 1762 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1763 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1764 | NO_STR |
| 1765 | "OSPF area parameters\n" |
| 1766 | "OSPF area ID in IP address format\n" |
| 1767 | "OSPF area ID as a decimal value\n" |
| 1768 | "Unset the filter for networks announced to other areas\n" |
| 1769 | "Name of the access-list\n") |
| 1770 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1771 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1772 | struct ospf_area *area; |
| 1773 | struct in_addr area_id; |
| 1774 | int format; |
| 1775 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1776 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1777 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1778 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1779 | if (area == NULL) |
| 1780 | return CMD_SUCCESS; |
| 1781 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1782 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1783 | |
| 1784 | return CMD_SUCCESS; |
| 1785 | } |
| 1786 | |
| 1787 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1788 | DEFUN (ospf_area_import_list, |
| 1789 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1790 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1791 | "OSPF area parameters\n" |
| 1792 | "OSPF area ID in IP address format\n" |
| 1793 | "OSPF area ID as a decimal value\n" |
| 1794 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1795 | "Name of the access-list\n") |
| 1796 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1797 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1798 | struct ospf_area *area; |
| 1799 | struct in_addr area_id; |
| 1800 | int format; |
| 1801 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1802 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1803 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1804 | area = ospf_area_get (ospf, area_id, format); |
| 1805 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1806 | |
| 1807 | return CMD_SUCCESS; |
| 1808 | } |
| 1809 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1810 | DEFUN (no_ospf_area_import_list, |
| 1811 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1812 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1813 | NO_STR |
| 1814 | "OSPF area parameters\n" |
| 1815 | "OSPF area ID in IP address format\n" |
| 1816 | "OSPF area ID as a decimal value\n" |
| 1817 | "Unset the filter for networks announced to other areas\n" |
| 1818 | "Name of the access-list\n") |
| 1819 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1820 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1821 | struct ospf_area *area; |
| 1822 | struct in_addr area_id; |
| 1823 | int format; |
| 1824 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1825 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1826 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1827 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1828 | if (area == NULL) |
| 1829 | return CMD_SUCCESS; |
| 1830 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1831 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1832 | |
| 1833 | return CMD_SUCCESS; |
| 1834 | } |
| 1835 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1836 | DEFUN (ospf_area_filter_list, |
| 1837 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1838 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1839 | "OSPF area parameters\n" |
| 1840 | "OSPF area ID in IP address format\n" |
| 1841 | "OSPF area ID as a decimal value\n" |
| 1842 | "Filter networks between OSPF areas\n" |
| 1843 | "Filter prefixes between OSPF areas\n" |
| 1844 | "Name of an IP prefix-list\n" |
| 1845 | "Filter networks sent to this area\n" |
| 1846 | "Filter networks sent from this area\n") |
| 1847 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1848 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1849 | struct ospf_area *area; |
| 1850 | struct in_addr area_id; |
| 1851 | struct prefix_list *plist; |
| 1852 | int format; |
| 1853 | |
| 1854 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1855 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1856 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1857 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1858 | if (strncmp (argv[2], "in", 2) == 0) |
| 1859 | { |
| 1860 | PREFIX_LIST_IN (area) = plist; |
| 1861 | if (PREFIX_NAME_IN (area)) |
| 1862 | free (PREFIX_NAME_IN (area)); |
| 1863 | |
| 1864 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1865 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1866 | } |
| 1867 | else |
| 1868 | { |
| 1869 | PREFIX_LIST_OUT (area) = plist; |
| 1870 | if (PREFIX_NAME_OUT (area)) |
| 1871 | free (PREFIX_NAME_OUT (area)); |
| 1872 | |
| 1873 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1874 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1875 | } |
| 1876 | |
| 1877 | return CMD_SUCCESS; |
| 1878 | } |
| 1879 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1880 | DEFUN (no_ospf_area_filter_list, |
| 1881 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1883 | NO_STR |
| 1884 | "OSPF area parameters\n" |
| 1885 | "OSPF area ID in IP address format\n" |
| 1886 | "OSPF area ID as a decimal value\n" |
| 1887 | "Filter networks between OSPF areas\n" |
| 1888 | "Filter prefixes between OSPF areas\n" |
| 1889 | "Name of an IP prefix-list\n" |
| 1890 | "Filter networks sent to this area\n" |
| 1891 | "Filter networks sent from this area\n") |
| 1892 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1893 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1894 | struct ospf_area *area; |
| 1895 | struct in_addr area_id; |
| 1896 | struct prefix_list *plist; |
| 1897 | int format; |
| 1898 | |
| 1899 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1900 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1901 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1902 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1903 | if (strncmp (argv[2], "in", 2) == 0) |
| 1904 | { |
| 1905 | if (PREFIX_NAME_IN (area)) |
| 1906 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1907 | return CMD_SUCCESS; |
| 1908 | |
| 1909 | PREFIX_LIST_IN (area) = NULL; |
| 1910 | if (PREFIX_NAME_IN (area)) |
| 1911 | free (PREFIX_NAME_IN (area)); |
| 1912 | |
| 1913 | PREFIX_NAME_IN (area) = NULL; |
| 1914 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1915 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1916 | } |
| 1917 | else |
| 1918 | { |
| 1919 | if (PREFIX_NAME_OUT (area)) |
| 1920 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1921 | return CMD_SUCCESS; |
| 1922 | |
| 1923 | PREFIX_LIST_OUT (area) = NULL; |
| 1924 | if (PREFIX_NAME_OUT (area)) |
| 1925 | free (PREFIX_NAME_OUT (area)); |
| 1926 | |
| 1927 | PREFIX_NAME_OUT (area) = NULL; |
| 1928 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1929 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1930 | } |
| 1931 | |
| 1932 | return CMD_SUCCESS; |
| 1933 | } |
| 1934 | |
| 1935 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1936 | DEFUN (ospf_area_authentication_message_digest, |
| 1937 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1938 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1939 | "OSPF area parameters\n" |
| 1940 | "Enable authentication\n" |
| 1941 | "Use message-digest authentication\n") |
| 1942 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1943 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1944 | struct ospf_area *area; |
| 1945 | struct in_addr area_id; |
| 1946 | int format; |
| 1947 | |
| 1948 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1949 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1950 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1951 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1952 | |
| 1953 | return CMD_SUCCESS; |
| 1954 | } |
| 1955 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1956 | DEFUN (ospf_area_authentication, |
| 1957 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1958 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1959 | "OSPF area parameters\n" |
| 1960 | "OSPF area ID in IP address format\n" |
| 1961 | "OSPF area ID as a decimal value\n" |
| 1962 | "Enable authentication\n") |
| 1963 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1964 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1965 | struct ospf_area *area; |
| 1966 | struct in_addr area_id; |
| 1967 | int format; |
| 1968 | |
| 1969 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1970 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1971 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1972 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1973 | |
| 1974 | return CMD_SUCCESS; |
| 1975 | } |
| 1976 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1977 | DEFUN (no_ospf_area_authentication, |
| 1978 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1979 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1980 | NO_STR |
| 1981 | "OSPF area parameters\n" |
| 1982 | "OSPF area ID in IP address format\n" |
| 1983 | "OSPF area ID as a decimal value\n" |
| 1984 | "Enable authentication\n") |
| 1985 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1986 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1987 | struct ospf_area *area; |
| 1988 | struct in_addr area_id; |
| 1989 | int format; |
| 1990 | |
| 1991 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1992 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1993 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1994 | if (area == NULL) |
| 1995 | return CMD_SUCCESS; |
| 1996 | |
| 1997 | area->auth_type = OSPF_AUTH_NULL; |
| 1998 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1999 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2000 | |
| 2001 | return CMD_SUCCESS; |
| 2002 | } |
| 2003 | |
| 2004 | |
| 2005 | DEFUN (ospf_abr_type, |
| 2006 | ospf_abr_type_cmd, |
| 2007 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 2008 | "OSPF specific commands\n" |
| 2009 | "Set OSPF ABR type\n" |
| 2010 | "Alternative ABR, cisco implementation\n" |
| 2011 | "Alternative ABR, IBM implementation\n" |
| 2012 | "Shortcut ABR\n" |
| 2013 | "Standard behavior (RFC2328)\n") |
| 2014 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2015 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2016 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2017 | |
| 2018 | if (strncmp (argv[0], "c", 1) == 0) |
| 2019 | abr_type = OSPF_ABR_CISCO; |
| 2020 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2021 | abr_type = OSPF_ABR_IBM; |
| 2022 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2023 | abr_type = OSPF_ABR_SHORTCUT; |
| 2024 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2025 | abr_type = OSPF_ABR_STAND; |
| 2026 | else |
| 2027 | return CMD_WARNING; |
| 2028 | |
| 2029 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2030 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2031 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2032 | ospf->abr_type = abr_type; |
| 2033 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2034 | } |
| 2035 | |
| 2036 | return CMD_SUCCESS; |
| 2037 | } |
| 2038 | |
| 2039 | DEFUN (no_ospf_abr_type, |
| 2040 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2041 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2042 | NO_STR |
| 2043 | "OSPF specific commands\n" |
| 2044 | "Set OSPF ABR type\n" |
| 2045 | "Alternative ABR, cisco implementation\n" |
| 2046 | "Alternative ABR, IBM implementation\n" |
| 2047 | "Shortcut ABR\n") |
| 2048 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2049 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2050 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2051 | |
| 2052 | if (strncmp (argv[0], "c", 1) == 0) |
| 2053 | abr_type = OSPF_ABR_CISCO; |
| 2054 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2055 | abr_type = OSPF_ABR_IBM; |
| 2056 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2057 | abr_type = OSPF_ABR_SHORTCUT; |
| 2058 | else |
| 2059 | return CMD_WARNING; |
| 2060 | |
| 2061 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2062 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2064 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2065 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | return CMD_SUCCESS; |
| 2069 | } |
| 2070 | |
| 2071 | DEFUN (ospf_compatible_rfc1583, |
| 2072 | ospf_compatible_rfc1583_cmd, |
| 2073 | "compatible rfc1583", |
| 2074 | "OSPF compatibility list\n" |
| 2075 | "compatible with RFC 1583\n") |
| 2076 | { |
| 2077 | struct ospf *ospf = vty->index; |
| 2078 | |
| 2079 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2080 | { |
| 2081 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2082 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2083 | } |
| 2084 | return CMD_SUCCESS; |
| 2085 | } |
| 2086 | |
| 2087 | DEFUN (no_ospf_compatible_rfc1583, |
| 2088 | no_ospf_compatible_rfc1583_cmd, |
| 2089 | "no compatible rfc1583", |
| 2090 | NO_STR |
| 2091 | "OSPF compatibility list\n" |
| 2092 | "compatible with RFC 1583\n") |
| 2093 | { |
| 2094 | struct ospf *ospf = vty->index; |
| 2095 | |
| 2096 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2097 | { |
| 2098 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2099 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2100 | } |
| 2101 | return CMD_SUCCESS; |
| 2102 | } |
| 2103 | |
| 2104 | ALIAS (ospf_compatible_rfc1583, |
| 2105 | ospf_rfc1583_flag_cmd, |
| 2106 | "ospf rfc1583compatibility", |
| 2107 | "OSPF specific commands\n" |
| 2108 | "Enable the RFC1583Compatibility flag\n") |
| 2109 | |
| 2110 | ALIAS (no_ospf_compatible_rfc1583, |
| 2111 | no_ospf_rfc1583_flag_cmd, |
| 2112 | "no ospf rfc1583compatibility", |
| 2113 | NO_STR |
| 2114 | "OSPF specific commands\n" |
| 2115 | "Disable the RFC1583Compatibility flag\n") |
| 2116 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2117 | DEFUN (ospf_timers_spf, |
| 2118 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2119 | "timers spf <0-4294967295> <0-4294967295>", |
| 2120 | "Adjust routing timers\n" |
| 2121 | "OSPF SPF timers\n" |
| 2122 | "Delay between receiving a change to SPF calculation\n" |
| 2123 | "Hold time between consecutive SPF calculations\n") |
| 2124 | { |
| 2125 | struct ospf *ospf = vty->index; |
| 2126 | u_int32_t delay, hold; |
| 2127 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2128 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2129 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2130 | |
| 2131 | ospf_timers_spf_set (ospf, delay, hold); |
| 2132 | |
| 2133 | return CMD_SUCCESS; |
| 2134 | } |
| 2135 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2136 | DEFUN (no_ospf_timers_spf, |
| 2137 | no_ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2138 | "no timers spf", |
| 2139 | NO_STR |
| 2140 | "Adjust routing timers\n" |
| 2141 | "OSPF SPF timers\n") |
| 2142 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2143 | struct ospf *ospf = vty->index; |
| 2144 | |
| 2145 | ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT; |
| 2146 | ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2147 | |
| 2148 | return CMD_SUCCESS; |
| 2149 | } |
| 2150 | |
| 2151 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2152 | DEFUN (ospf_neighbor, |
| 2153 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2154 | "neighbor A.B.C.D", |
| 2155 | NEIGHBOR_STR |
| 2156 | "Neighbor IP address\n") |
| 2157 | { |
| 2158 | struct ospf *ospf = vty->index; |
| 2159 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2160 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2161 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2162 | |
| 2163 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2164 | |
| 2165 | if (argc > 1) |
| 2166 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2167 | |
| 2168 | if (argc > 2) |
| 2169 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2170 | |
| 2171 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2172 | if (argc > 1) |
| 2173 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2174 | if (argc > 2) |
| 2175 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2176 | |
| 2177 | return CMD_SUCCESS; |
| 2178 | } |
| 2179 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2180 | ALIAS (ospf_neighbor, |
| 2181 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2182 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2183 | NEIGHBOR_STR |
| 2184 | "Neighbor IP address\n" |
| 2185 | "Neighbor Priority\n" |
| 2186 | "Priority\n" |
| 2187 | "Dead Neighbor Polling interval\n" |
| 2188 | "Seconds\n") |
| 2189 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2190 | ALIAS (ospf_neighbor, |
| 2191 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | "neighbor A.B.C.D priority <0-255>", |
| 2193 | NEIGHBOR_STR |
| 2194 | "Neighbor IP address\n" |
| 2195 | "Neighbor Priority\n" |
| 2196 | "Seconds\n") |
| 2197 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2198 | DEFUN (ospf_neighbor_poll_interval, |
| 2199 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2200 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2201 | NEIGHBOR_STR |
| 2202 | "Neighbor IP address\n" |
| 2203 | "Dead Neighbor Polling interval\n" |
| 2204 | "Seconds\n") |
| 2205 | { |
| 2206 | struct ospf *ospf = vty->index; |
| 2207 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2208 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2209 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | |
| 2211 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2212 | |
| 2213 | if (argc > 1) |
| 2214 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2215 | |
| 2216 | if (argc > 2) |
| 2217 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2218 | |
| 2219 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2220 | if (argc > 1) |
| 2221 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2222 | if (argc > 2) |
| 2223 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2224 | |
| 2225 | return CMD_SUCCESS; |
| 2226 | } |
| 2227 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2228 | ALIAS (ospf_neighbor_poll_interval, |
| 2229 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2230 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2231 | NEIGHBOR_STR |
| 2232 | "Neighbor address\n" |
| 2233 | "OSPF dead-router polling interval\n" |
| 2234 | "Seconds\n" |
| 2235 | "OSPF priority of non-broadcast neighbor\n" |
| 2236 | "Priority\n") |
| 2237 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2238 | DEFUN (no_ospf_neighbor, |
| 2239 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | "no neighbor A.B.C.D", |
| 2241 | NO_STR |
| 2242 | NEIGHBOR_STR |
| 2243 | "Neighbor IP address\n") |
| 2244 | { |
| 2245 | struct ospf *ospf = vty->index; |
| 2246 | struct in_addr nbr_addr; |
| 2247 | int ret; |
| 2248 | |
| 2249 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2250 | |
| 2251 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2252 | |
| 2253 | return CMD_SUCCESS; |
| 2254 | } |
| 2255 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2256 | ALIAS (no_ospf_neighbor, |
| 2257 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2258 | "no neighbor A.B.C.D priority <0-255>", |
| 2259 | NO_STR |
| 2260 | NEIGHBOR_STR |
| 2261 | "Neighbor IP address\n" |
| 2262 | "Neighbor Priority\n" |
| 2263 | "Priority\n") |
| 2264 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2265 | ALIAS (no_ospf_neighbor, |
| 2266 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2267 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2268 | NO_STR |
| 2269 | NEIGHBOR_STR |
| 2270 | "Neighbor IP address\n" |
| 2271 | "Dead Neighbor Polling interval\n" |
| 2272 | "Seconds\n") |
| 2273 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2274 | ALIAS (no_ospf_neighbor, |
| 2275 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2276 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2277 | NO_STR |
| 2278 | NEIGHBOR_STR |
| 2279 | "Neighbor IP address\n" |
| 2280 | "Neighbor Priority\n" |
| 2281 | "Priority\n" |
| 2282 | "Dead Neighbor Polling interval\n" |
| 2283 | "Seconds\n") |
| 2284 | |
| 2285 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2286 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2287 | "refresh timer <10-1800>", |
| 2288 | "Adjust refresh parameters\n" |
| 2289 | "Set refresh timer\n" |
| 2290 | "Timer value in seconds\n") |
| 2291 | { |
| 2292 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2293 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2294 | |
| 2295 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2296 | interval = (interval / 10) * 10; |
| 2297 | |
| 2298 | ospf_timers_refresh_set (ospf, interval); |
| 2299 | |
| 2300 | return CMD_SUCCESS; |
| 2301 | } |
| 2302 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2303 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2304 | "no refresh timer <10-1800>", |
| 2305 | "Adjust refresh parameters\n" |
| 2306 | "Unset refresh timer\n" |
| 2307 | "Timer value in seconds\n") |
| 2308 | { |
| 2309 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2310 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | |
| 2312 | if (argc == 1) |
| 2313 | { |
| 2314 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2315 | |
| 2316 | if (ospf->lsa_refresh_interval != interval || |
| 2317 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2318 | return CMD_SUCCESS; |
| 2319 | } |
| 2320 | |
| 2321 | ospf_timers_refresh_unset (ospf); |
| 2322 | |
| 2323 | return CMD_SUCCESS; |
| 2324 | } |
| 2325 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2326 | ALIAS (no_ospf_refresh_timer, |
| 2327 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2328 | "no refresh timer", |
| 2329 | "Adjust refresh parameters\n" |
| 2330 | "Unset refresh timer\n") |
| 2331 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2332 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2333 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2334 | "auto-cost reference-bandwidth <1-4294967>", |
| 2335 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2336 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2337 | "The reference bandwidth in terms of Mbits per second\n") |
| 2338 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2339 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2340 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2341 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2342 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2343 | |
| 2344 | refbw = strtol (argv[0], NULL, 10); |
| 2345 | if (refbw < 1 || refbw > 4294967) |
| 2346 | { |
| 2347 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2348 | return CMD_WARNING; |
| 2349 | } |
| 2350 | |
| 2351 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2352 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2353 | return CMD_SUCCESS; |
| 2354 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2355 | ospf->ref_bandwidth = refbw * 1000; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2356 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2357 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2358 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2359 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2360 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2361 | |
| 2362 | return CMD_SUCCESS; |
| 2363 | } |
| 2364 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2365 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2366 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | "no auto-cost reference-bandwidth", |
| 2368 | NO_STR |
| 2369 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2370 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2371 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2372 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2373 | struct listnode *node, *nnode; |
| 2374 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2376 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2377 | return CMD_SUCCESS; |
| 2378 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2379 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2380 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2381 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2382 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2383 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2384 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2385 | |
| 2386 | return CMD_SUCCESS; |
| 2387 | } |
| 2388 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2389 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2390 | { |
| 2391 | "Unknown", |
| 2392 | "Standard (RFC2328)", |
| 2393 | "Alternative IBM", |
| 2394 | "Alternative Cisco", |
| 2395 | "Alternative Shortcut" |
| 2396 | }; |
| 2397 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2398 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2399 | { |
| 2400 | "Default", |
| 2401 | "Enabled", |
| 2402 | "Disabled" |
| 2403 | }; |
| 2404 | |
| 2405 | |
| 2406 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2407 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2409 | { |
| 2410 | /* Show Area ID. */ |
| 2411 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2412 | |
| 2413 | /* Show Area type/mode. */ |
| 2414 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2415 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2416 | else |
| 2417 | { |
| 2418 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2419 | vty_out (vty, " (Stub%s%s)", |
| 2420 | area->no_summary ? ", no summary" : "", |
| 2421 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2422 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2423 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2424 | vty_out (vty, " (NSSA%s%s)", |
| 2425 | area->no_summary ? ", no summary" : "", |
| 2426 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2427 | |
| 2428 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2429 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2430 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2431 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2432 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2433 | } |
| 2434 | |
| 2435 | /* Show number of interfaces. */ |
| 2436 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2437 | "Active: %d%s", listcount (area->oiflist), |
| 2438 | area->act_ints, VTY_NEWLINE); |
| 2439 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2440 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2441 | { |
| 2442 | 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] | 2443 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2444 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2445 | VTY_NEWLINE); |
| 2446 | else if (area->NSSATranslatorState) |
| 2447 | { |
| 2448 | vty_out (vty, " We are an ABR and "); |
| 2449 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2450 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2451 | VTY_NEWLINE); |
| 2452 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2453 | vty_out (vty, "always an NSSA Translator. %s", |
| 2454 | VTY_NEWLINE); |
| 2455 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2456 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2457 | { |
| 2458 | vty_out (vty, " We are an ABR, but "); |
| 2459 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2460 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2461 | VTY_NEWLINE); |
| 2462 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2463 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2464 | VTY_NEWLINE); |
| 2465 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2466 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2467 | |
| 2468 | /* Show number of fully adjacent neighbors. */ |
| 2469 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2470 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2471 | |
| 2472 | /* Show authentication type. */ |
| 2473 | vty_out (vty, " Area has "); |
| 2474 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2475 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2476 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2477 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2478 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2479 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2480 | |
| 2481 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2482 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2483 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2484 | |
| 2485 | /* Show SPF calculation times. */ |
| 2486 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2487 | area->spf_calculation, VTY_NEWLINE); |
| 2488 | |
| 2489 | /* Show number of LSA. */ |
| 2490 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2491 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2492 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2493 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2494 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2495 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2496 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2497 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2498 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2499 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2500 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2501 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2502 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2503 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2504 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2505 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2506 | #ifdef HAVE_OPAQUE_LSA |
| 2507 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2508 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2509 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2510 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2511 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2512 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2513 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2514 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2515 | } |
| 2516 | |
| 2517 | DEFUN (show_ip_ospf, |
| 2518 | show_ip_ospf_cmd, |
| 2519 | "show ip ospf", |
| 2520 | SHOW_STR |
| 2521 | IP_STR |
| 2522 | "OSPF information\n") |
| 2523 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2524 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2525 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2526 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2527 | |
| 2528 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2529 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2530 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2531 | { |
| 2532 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2533 | return CMD_SUCCESS; |
| 2534 | } |
| 2535 | |
| 2536 | /* Show Router ID. */ |
| 2537 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2538 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2539 | VTY_NEWLINE); |
| 2540 | |
| 2541 | /* Show capability. */ |
| 2542 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2543 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2544 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2545 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | "enabled" : "disabled", VTY_NEWLINE); |
| 2547 | #ifdef HAVE_OPAQUE_LSA |
| 2548 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2549 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2550 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2551 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2552 | " (origination blocked)" : "", |
| 2553 | VTY_NEWLINE); |
| 2554 | #endif /* HAVE_OPAQUE_LSA */ |
| 2555 | |
| 2556 | /* Show SPF timers. */ |
| 2557 | vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2558 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2559 | |
| 2560 | /* Show refresh parameters. */ |
| 2561 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2562 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | |
| 2564 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2565 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2567 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2568 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2569 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2570 | vty_out (vty, " This router is an ASBR " |
| 2571 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2572 | |
| 2573 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2574 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2575 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2576 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2577 | #ifdef HAVE_OPAQUE_LSA |
| 2578 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2579 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2580 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2581 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2582 | /* Show number of areas attached. */ |
| 2583 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2584 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | |
| 2586 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2587 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2588 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2589 | |
| 2590 | return CMD_SUCCESS; |
| 2591 | } |
| 2592 | |
| 2593 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2594 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2595 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2596 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2597 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2598 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2599 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2600 | struct route_node *rn; |
| 2601 | char buf[9]; |
| 2602 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2603 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2604 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2605 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2606 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2607 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2608 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2609 | |
| 2610 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2611 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2612 | { |
| 2613 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2614 | return; |
| 2615 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2616 | else if (!is_up) |
| 2617 | { |
| 2618 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2619 | VTY_NEWLINE); |
| 2620 | return; |
| 2621 | } |
| 2622 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2623 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2624 | { |
| 2625 | struct ospf_interface *oi = rn->info; |
| 2626 | |
| 2627 | if (oi == NULL) |
| 2628 | continue; |
| 2629 | |
| 2630 | /* Show OSPF interface information. */ |
| 2631 | vty_out (vty, " Internet Address %s/%d,", |
| 2632 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2633 | |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2634 | if (oi->connected->destination) |
| 2635 | vty_out (vty, " %s %s,", |
| 2636 | ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"), |
| 2637 | inet_ntoa (oi->connected->destination->u.prefix4)); |
| 2638 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2639 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2640 | VTY_NEWLINE); |
| 2641 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2642 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2643 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2644 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2645 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2646 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2647 | oi->output_cost, VTY_NEWLINE); |
| 2648 | |
| 2649 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2650 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2651 | PRIORITY (oi), VTY_NEWLINE); |
| 2652 | |
| 2653 | /* Show DR information. */ |
| 2654 | if (DR (oi).s_addr == 0) |
| 2655 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2656 | else |
| 2657 | { |
| 2658 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2659 | if (nbr == NULL) |
| 2660 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2661 | else |
| 2662 | { |
| 2663 | vty_out (vty, " Designated Router (ID) %s,", |
| 2664 | inet_ntoa (nbr->router_id)); |
| 2665 | vty_out (vty, " Interface Address %s%s", |
| 2666 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2667 | } |
| 2668 | } |
| 2669 | |
| 2670 | /* Show BDR information. */ |
| 2671 | if (BDR (oi).s_addr == 0) |
| 2672 | vty_out (vty, " No backup designated router on this network%s", |
| 2673 | VTY_NEWLINE); |
| 2674 | else |
| 2675 | { |
| 2676 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2677 | if (nbr == NULL) |
| 2678 | vty_out (vty, " No backup designated router on this network%s", |
| 2679 | VTY_NEWLINE); |
| 2680 | else |
| 2681 | { |
| 2682 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2683 | inet_ntoa (nbr->router_id)); |
| 2684 | vty_out (vty, " Interface Address %s%s", |
| 2685 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2686 | } |
| 2687 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2688 | |
| 2689 | vty_out (vty, " Multicast group memberships:"); |
| 2690 | if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS)) |
| 2691 | vty_out (vty, " OSPFAllRouters"); |
| 2692 | if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS)) |
| 2693 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2694 | if (!CHECK_FLAG(oi->multicast_memberships, |
| 2695 | MEMBER_ALLROUTERS|MEMBER_DROUTERS)) |
| 2696 | vty_out (vty, " <None>"); |
| 2697 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2698 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2699 | vty_out (vty, " Timer intervals configured,"); |
| 2700 | vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s", |
| 2701 | OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait), |
| 2702 | OSPF_IF_PARAM (oi, v_wait), |
| 2703 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2704 | VTY_NEWLINE); |
| 2705 | |
| 2706 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
| 2707 | vty_out (vty, " Hello due in %s%s", |
| 2708 | ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE); |
| 2709 | else /* OSPF_IF_PASSIVE is set */ |
| 2710 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2711 | |
| 2712 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2713 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2714 | VTY_NEWLINE); |
| 2715 | } |
| 2716 | } |
| 2717 | |
| 2718 | DEFUN (show_ip_ospf_interface, |
| 2719 | show_ip_ospf_interface_cmd, |
| 2720 | "show ip ospf interface [INTERFACE]", |
| 2721 | SHOW_STR |
| 2722 | IP_STR |
| 2723 | "OSPF information\n" |
| 2724 | "Interface information\n" |
| 2725 | "Interface name\n") |
| 2726 | { |
| 2727 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2728 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2729 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2730 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2731 | ospf = ospf_lookup (); |
| 2732 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2733 | /* Show All Interfaces. */ |
| 2734 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2735 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 2736 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2737 | /* Interface name is specified. */ |
| 2738 | else |
| 2739 | { |
| 2740 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2741 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2742 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2743 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2744 | } |
| 2745 | |
| 2746 | return CMD_SUCCESS; |
| 2747 | } |
| 2748 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2749 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2750 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2751 | { |
| 2752 | struct route_node *rn; |
| 2753 | struct ospf_neighbor *nbr; |
| 2754 | char msgbuf[16]; |
| 2755 | char timebuf[9]; |
| 2756 | |
| 2757 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2758 | if ((nbr = rn->info)) |
| 2759 | /* Do not show myself. */ |
| 2760 | if (nbr != oi->nbr_self) |
| 2761 | /* Down state is not shown. */ |
| 2762 | if (nbr->state != NSM_Down) |
| 2763 | { |
| 2764 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2765 | |
| 2766 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2767 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2768 | "-", nbr->priority, |
| 2769 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2770 | else |
| 2771 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2772 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2773 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2774 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
| 2775 | vty_out (vty, "%-15s %5ld %5ld %5d%s", |
| 2776 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2777 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2778 | VTY_NEWLINE); |
| 2779 | } |
| 2780 | } |
| 2781 | |
| 2782 | DEFUN (show_ip_ospf_neighbor, |
| 2783 | show_ip_ospf_neighbor_cmd, |
| 2784 | "show ip ospf neighbor", |
| 2785 | SHOW_STR |
| 2786 | IP_STR |
| 2787 | "OSPF information\n" |
| 2788 | "Neighbor list\n") |
| 2789 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2790 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2791 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2792 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2793 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2794 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2795 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2796 | { |
| 2797 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2798 | return CMD_SUCCESS; |
| 2799 | } |
| 2800 | |
| 2801 | /* Show All neighbors. */ |
| 2802 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2803 | "Time Address Interface RXmtL " |
| 2804 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2805 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2806 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 2807 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2808 | |
| 2809 | return CMD_SUCCESS; |
| 2810 | } |
| 2811 | |
| 2812 | DEFUN (show_ip_ospf_neighbor_all, |
| 2813 | show_ip_ospf_neighbor_all_cmd, |
| 2814 | "show ip ospf neighbor all", |
| 2815 | SHOW_STR |
| 2816 | IP_STR |
| 2817 | "OSPF information\n" |
| 2818 | "Neighbor list\n" |
| 2819 | "include down status neighbor\n") |
| 2820 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2821 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2822 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2823 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2824 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2825 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2826 | { |
| 2827 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2828 | return CMD_SUCCESS; |
| 2829 | } |
| 2830 | |
| 2831 | /* Show All neighbors. */ |
| 2832 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2833 | "Time Address Interface RXmtL " |
| 2834 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2835 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2836 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2837 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2838 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2839 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2840 | |
| 2841 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2842 | |
| 2843 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2844 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2845 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2846 | if (nbr_nbma->nbr == NULL |
| 2847 | || nbr_nbma->nbr->state == NSM_Down) |
| 2848 | { |
| 2849 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2850 | "-", nbr_nbma->priority, "Down", "-"); |
| 2851 | vty_out (vty, "%-15s %-15s %5d %5d %5d%s", |
| 2852 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 2853 | 0, 0, 0, VTY_NEWLINE); |
| 2854 | } |
| 2855 | } |
| 2856 | } |
| 2857 | |
| 2858 | return CMD_SUCCESS; |
| 2859 | } |
| 2860 | |
| 2861 | DEFUN (show_ip_ospf_neighbor_int, |
| 2862 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2863 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2864 | SHOW_STR |
| 2865 | IP_STR |
| 2866 | "OSPF information\n" |
| 2867 | "Neighbor list\n" |
| 2868 | "Interface name\n") |
| 2869 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2870 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2871 | struct interface *ifp; |
| 2872 | struct route_node *rn; |
| 2873 | |
| 2874 | ifp = if_lookup_by_name (argv[0]); |
| 2875 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2876 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2877 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2878 | return CMD_WARNING; |
| 2879 | } |
| 2880 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2881 | ospf = ospf_lookup (); |
| 2882 | if (ospf == NULL) |
| 2883 | { |
| 2884 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2885 | return CMD_SUCCESS; |
| 2886 | } |
| 2887 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2888 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2889 | "Time Address Interface RXmtL " |
| 2890 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2891 | |
| 2892 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2893 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 2894 | struct ospf_interface *oi = rn->info; |
| 2895 | |
| 2896 | if (oi == NULL) |
| 2897 | continue; |
| 2898 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2899 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2900 | } |
| 2901 | |
| 2902 | return CMD_SUCCESS; |
| 2903 | } |
| 2904 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2905 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2906 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2907 | struct ospf_nbr_nbma *nbr_nbma) |
| 2908 | { |
| 2909 | char timebuf[9]; |
| 2910 | |
| 2911 | /* Show neighbor ID. */ |
| 2912 | vty_out (vty, " Neighbor %s,", "-"); |
| 2913 | |
| 2914 | /* Show interface address. */ |
| 2915 | vty_out (vty, " interface address %s%s", |
| 2916 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 2917 | /* Show Area ID. */ |
| 2918 | vty_out (vty, " In the area %s via interface %s%s", |
| 2919 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 2920 | /* Show neighbor priority and state. */ |
| 2921 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2922 | nbr_nbma->priority, "Down"); |
| 2923 | /* Show state changes. */ |
| 2924 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 2925 | |
| 2926 | /* Show PollInterval */ |
| 2927 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 2928 | |
| 2929 | /* Show poll-interval timer. */ |
| 2930 | vty_out (vty, " Poll timer due in %s%s", |
| 2931 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE); |
| 2932 | |
| 2933 | /* Show poll-interval timer thread. */ |
| 2934 | vty_out (vty, " Thread Poll Timer %s%s", |
| 2935 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 2936 | } |
| 2937 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2938 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2939 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2940 | struct ospf_neighbor *nbr) |
| 2941 | { |
| 2942 | char timebuf[9]; |
| 2943 | |
| 2944 | /* Show neighbor ID. */ |
| 2945 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2946 | vty_out (vty, " Neighbor %s,", "-"); |
| 2947 | else |
| 2948 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 2949 | |
| 2950 | /* Show interface address. */ |
| 2951 | vty_out (vty, " interface address %s%s", |
| 2952 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2953 | /* Show Area ID. */ |
| 2954 | vty_out (vty, " In the area %s via interface %s%s", |
| 2955 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 2956 | /* Show neighbor priority and state. */ |
| 2957 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2958 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 2959 | /* Show state changes. */ |
| 2960 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 2961 | |
| 2962 | /* Show Designated Rotuer ID. */ |
| 2963 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 2964 | /* Show Backup Designated Rotuer ID. */ |
| 2965 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 2966 | /* Show options. */ |
| 2967 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 2968 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 2969 | /* Show Router Dead interval timer. */ |
| 2970 | vty_out (vty, " Dead timer due in %s%s", |
| 2971 | ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE); |
| 2972 | /* Show Database Summary list. */ |
| 2973 | vty_out (vty, " Database Summary List %d%s", |
| 2974 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 2975 | /* Show Link State Request list. */ |
| 2976 | vty_out (vty, " Link State Request List %ld%s", |
| 2977 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 2978 | /* Show Link State Retransmission list. */ |
| 2979 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 2980 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 2981 | /* Show inactivity timer thread. */ |
| 2982 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 2983 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 2984 | /* Show Database Description retransmission thread. */ |
| 2985 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 2986 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 2987 | /* Show Link State Request Retransmission thread. */ |
| 2988 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 2989 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 2990 | /* Show Link State Update Retransmission thread. */ |
| 2991 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 2992 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 2993 | } |
| 2994 | |
| 2995 | DEFUN (show_ip_ospf_neighbor_id, |
| 2996 | show_ip_ospf_neighbor_id_cmd, |
| 2997 | "show ip ospf neighbor A.B.C.D", |
| 2998 | SHOW_STR |
| 2999 | IP_STR |
| 3000 | "OSPF information\n" |
| 3001 | "Neighbor list\n" |
| 3002 | "Neighbor ID\n") |
| 3003 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3004 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3005 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3006 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3007 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3008 | struct in_addr router_id; |
| 3009 | int ret; |
| 3010 | |
| 3011 | ret = inet_aton (argv[0], &router_id); |
| 3012 | if (!ret) |
| 3013 | { |
| 3014 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3015 | return CMD_WARNING; |
| 3016 | } |
| 3017 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3018 | ospf = ospf_lookup (); |
| 3019 | if (ospf == NULL) |
| 3020 | { |
| 3021 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3022 | return CMD_SUCCESS; |
| 3023 | } |
| 3024 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3025 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3026 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 3027 | { |
| 3028 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3029 | return CMD_SUCCESS; |
| 3030 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3031 | |
| 3032 | /* Nothing to show. */ |
| 3033 | return CMD_SUCCESS; |
| 3034 | } |
| 3035 | |
| 3036 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3037 | show_ip_ospf_neighbor_detail_cmd, |
| 3038 | "show ip ospf neighbor detail", |
| 3039 | SHOW_STR |
| 3040 | IP_STR |
| 3041 | "OSPF information\n" |
| 3042 | "Neighbor list\n" |
| 3043 | "detail of all neighbors\n") |
| 3044 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3045 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3046 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3047 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3049 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3050 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3051 | { |
| 3052 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3053 | return CMD_SUCCESS; |
| 3054 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3055 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3056 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3057 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3058 | struct route_node *rn; |
| 3059 | struct ospf_neighbor *nbr; |
| 3060 | |
| 3061 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3062 | if ((nbr = rn->info)) |
| 3063 | if (nbr != oi->nbr_self) |
| 3064 | if (nbr->state != NSM_Down) |
| 3065 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3066 | } |
| 3067 | |
| 3068 | return CMD_SUCCESS; |
| 3069 | } |
| 3070 | |
| 3071 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3072 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3073 | "show ip ospf neighbor detail all", |
| 3074 | SHOW_STR |
| 3075 | IP_STR |
| 3076 | "OSPF information\n" |
| 3077 | "Neighbor list\n" |
| 3078 | "detail of all neighbors\n" |
| 3079 | "include down status neighbor\n") |
| 3080 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3081 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3082 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3083 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3084 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3085 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3086 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3087 | { |
| 3088 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3089 | return CMD_SUCCESS; |
| 3090 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3091 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3092 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3093 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3094 | struct route_node *rn; |
| 3095 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3096 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3097 | |
| 3098 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3099 | if ((nbr = rn->info)) |
| 3100 | if (nbr != oi->nbr_self) |
| 3101 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3102 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3103 | |
| 3104 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3105 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3106 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3107 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3108 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3109 | if (nbr_nbma->nbr == NULL |
| 3110 | || nbr_nbma->nbr->state == NSM_Down) |
| 3111 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3112 | } |
| 3113 | } |
| 3114 | |
| 3115 | return CMD_SUCCESS; |
| 3116 | } |
| 3117 | |
| 3118 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3119 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3120 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3121 | SHOW_STR |
| 3122 | IP_STR |
| 3123 | "OSPF information\n" |
| 3124 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3125 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3126 | "detail of all neighbors") |
| 3127 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3128 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3129 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3130 | struct interface *ifp; |
| 3131 | struct route_node *rn, *nrn; |
| 3132 | struct ospf_neighbor *nbr; |
| 3133 | |
| 3134 | ifp = if_lookup_by_name (argv[0]); |
| 3135 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3136 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3137 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3138 | return CMD_WARNING; |
| 3139 | } |
| 3140 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3141 | ospf = ospf_lookup (); |
| 3142 | if (ospf == NULL) |
| 3143 | { |
| 3144 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3145 | return CMD_SUCCESS; |
| 3146 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3148 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3149 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3150 | if ((oi = rn->info)) |
| 3151 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3152 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3153 | if (nbr != oi->nbr_self) |
| 3154 | if (nbr->state != NSM_Down) |
| 3155 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3156 | |
| 3157 | return CMD_SUCCESS; |
| 3158 | } |
| 3159 | |
| 3160 | |
| 3161 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3162 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3163 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3164 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3165 | struct router_lsa *rl; |
| 3166 | struct summary_lsa *sl; |
| 3167 | struct as_external_lsa *asel; |
| 3168 | struct prefix_ipv4 p; |
| 3169 | |
| 3170 | if (lsa != NULL) |
| 3171 | /* If self option is set, check LSA self flag. */ |
| 3172 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3173 | { |
| 3174 | /* LSA common part show. */ |
| 3175 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3176 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3177 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3178 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3179 | /* LSA specific part show. */ |
| 3180 | switch (lsa->data->type) |
| 3181 | { |
| 3182 | case OSPF_ROUTER_LSA: |
| 3183 | rl = (struct router_lsa *) lsa->data; |
| 3184 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3185 | break; |
| 3186 | case OSPF_SUMMARY_LSA: |
| 3187 | sl = (struct summary_lsa *) lsa->data; |
| 3188 | |
| 3189 | p.family = AF_INET; |
| 3190 | p.prefix = sl->header.id; |
| 3191 | p.prefixlen = ip_masklen (sl->mask); |
| 3192 | apply_mask_ipv4 (&p); |
| 3193 | |
| 3194 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3195 | break; |
| 3196 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3197 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3198 | asel = (struct as_external_lsa *) lsa->data; |
| 3199 | |
| 3200 | p.family = AF_INET; |
| 3201 | p.prefix = asel->header.id; |
| 3202 | p.prefixlen = ip_masklen (asel->mask); |
| 3203 | apply_mask_ipv4 (&p); |
| 3204 | |
| 3205 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3206 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3207 | inet_ntoa (p.prefix), p.prefixlen, |
| 3208 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3209 | break; |
| 3210 | case OSPF_NETWORK_LSA: |
| 3211 | case OSPF_ASBR_SUMMARY_LSA: |
| 3212 | #ifdef HAVE_OPAQUE_LSA |
| 3213 | case OSPF_OPAQUE_LINK_LSA: |
| 3214 | case OSPF_OPAQUE_AREA_LSA: |
| 3215 | case OSPF_OPAQUE_AS_LSA: |
| 3216 | #endif /* HAVE_OPAQUE_LSA */ |
| 3217 | default: |
| 3218 | break; |
| 3219 | } |
| 3220 | vty_out (vty, VTY_NEWLINE); |
| 3221 | } |
| 3222 | |
| 3223 | return 0; |
| 3224 | } |
| 3225 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3226 | const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3227 | { |
| 3228 | "unknown", |
| 3229 | "Router Link States", |
| 3230 | "Net Link States", |
| 3231 | "Summary Link States", |
| 3232 | "ASBR-Summary Link States", |
| 3233 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | "Group Membership LSA", |
| 3235 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3236 | #ifdef HAVE_OPAQUE_LSA |
| 3237 | "Type-8 LSA", |
| 3238 | "Link-Local Opaque-LSA", |
| 3239 | "Area-Local Opaque-LSA", |
| 3240 | "AS-external Opaque-LSA", |
| 3241 | #endif /* HAVE_OPAQUE_LSA */ |
| 3242 | }; |
| 3243 | |
| 3244 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3245 | "Link ID ADV Router Age Seq# CkSum" |
| 3246 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3247 | const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3248 | { |
| 3249 | "", |
| 3250 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3251 | "Link ID ADV Router Age Seq# CkSum", |
| 3252 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3253 | "Link ID ADV Router Age Seq# CkSum", |
| 3254 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3255 | " --- header for Group Member ----", |
| 3256 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3257 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3258 | " --- type-8 ---", |
| 3259 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3260 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3261 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3262 | #endif /* HAVE_OPAQUE_LSA */ |
| 3263 | }; |
| 3264 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3265 | const char *show_lsa_flags[] = |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3266 | { |
| 3267 | "Self-originated", |
| 3268 | "Checked", |
| 3269 | "Received", |
| 3270 | "Approved", |
| 3271 | "Discard", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3272 | "Translated", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3273 | }; |
| 3274 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3275 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3276 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3277 | { |
| 3278 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3279 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3280 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3281 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3282 | lsa->data->options, |
| 3283 | ospf_options_dump(lsa->data->options), |
| 3284 | VTY_NEWLINE); |
| 3285 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3286 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3287 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3288 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3289 | |
| 3290 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3291 | { |
| 3292 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3293 | |
| 3294 | if (rlsa->flags) |
| 3295 | vty_out (vty, " :%s%s%s%s", |
| 3296 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3297 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3298 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3299 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3300 | |
| 3301 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3302 | } |
| 3303 | vty_out (vty, " LS Type: %s%s", |
| 3304 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3305 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3306 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3307 | vty_out (vty, " Advertising Router: %s%s", |
| 3308 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3309 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3310 | VTY_NEWLINE); |
| 3311 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3312 | VTY_NEWLINE); |
| 3313 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3314 | } |
| 3315 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3316 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3317 | { |
| 3318 | "(null)", |
| 3319 | "another Router (point-to-point)", |
| 3320 | "a Transit Network", |
| 3321 | "Stub Network", |
| 3322 | "a Virtual Link", |
| 3323 | }; |
| 3324 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3325 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3326 | { |
| 3327 | "(null)", |
| 3328 | "Neighboring Router ID", |
| 3329 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3330 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3331 | "Neighboring Router ID", |
| 3332 | }; |
| 3333 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3334 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3335 | { |
| 3336 | "(null)", |
| 3337 | "Router Interface address", |
| 3338 | "Router Interface address", |
| 3339 | "Network Mask", |
| 3340 | "Router Interface address", |
| 3341 | }; |
| 3342 | |
| 3343 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3344 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3345 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3346 | struct router_lsa *rl) |
| 3347 | { |
| 3348 | int len, i, type; |
| 3349 | |
| 3350 | len = ntohs (rl->header.length) - 4; |
| 3351 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3352 | { |
| 3353 | type = rl->link[i].type; |
| 3354 | |
| 3355 | vty_out (vty, " Link connected to: %s%s", |
| 3356 | link_type_desc[type], VTY_NEWLINE); |
| 3357 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3358 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3359 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3360 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3361 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3362 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3363 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3364 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3365 | } |
| 3366 | } |
| 3367 | |
| 3368 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3369 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3370 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3371 | { |
| 3372 | if (lsa != NULL) |
| 3373 | { |
| 3374 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3375 | |
| 3376 | show_ip_ospf_database_header (vty, lsa); |
| 3377 | |
| 3378 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3379 | VTY_NEWLINE, VTY_NEWLINE); |
| 3380 | |
| 3381 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3382 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3383 | } |
| 3384 | |
| 3385 | return 0; |
| 3386 | } |
| 3387 | |
| 3388 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3389 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3390 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3391 | { |
| 3392 | int length, i; |
| 3393 | |
| 3394 | if (lsa != NULL) |
| 3395 | { |
| 3396 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3397 | |
| 3398 | show_ip_ospf_database_header (vty, lsa); |
| 3399 | |
| 3400 | vty_out (vty, " Network Mask: /%d%s", |
| 3401 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3402 | |
| 3403 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3404 | |
| 3405 | for (i = 0; length > 0; i++, length -= 4) |
| 3406 | vty_out (vty, " Attached Router: %s%s", |
| 3407 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3408 | |
| 3409 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3410 | } |
| 3411 | |
| 3412 | return 0; |
| 3413 | } |
| 3414 | |
| 3415 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3416 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3417 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3418 | { |
| 3419 | if (lsa != NULL) |
| 3420 | { |
| 3421 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3422 | |
| 3423 | show_ip_ospf_database_header (vty, lsa); |
| 3424 | |
| 3425 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3426 | VTY_NEWLINE); |
| 3427 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3428 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3429 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3430 | } |
| 3431 | |
| 3432 | return 0; |
| 3433 | } |
| 3434 | |
| 3435 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3436 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3437 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3438 | { |
| 3439 | if (lsa != NULL) |
| 3440 | { |
| 3441 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3442 | |
| 3443 | show_ip_ospf_database_header (vty, lsa); |
| 3444 | |
| 3445 | vty_out (vty, " Network Mask: /%d%s", |
| 3446 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3447 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3448 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3449 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3450 | } |
| 3451 | |
| 3452 | return 0; |
| 3453 | } |
| 3454 | |
| 3455 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3456 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3457 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3458 | { |
| 3459 | if (lsa != NULL) |
| 3460 | { |
| 3461 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3462 | |
| 3463 | show_ip_ospf_database_header (vty, lsa); |
| 3464 | |
| 3465 | vty_out (vty, " Network Mask: /%d%s", |
| 3466 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3467 | vty_out (vty, " Metric Type: %s%s", |
| 3468 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3469 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3470 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3471 | vty_out (vty, " Metric: %d%s", |
| 3472 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3473 | vty_out (vty, " Forward Address: %s%s", |
| 3474 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3475 | |
| 3476 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3477 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3478 | } |
| 3479 | |
| 3480 | return 0; |
| 3481 | } |
| 3482 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3483 | /* N.B. This function currently seems to be unused. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3484 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3485 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3486 | { |
| 3487 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3488 | |
| 3489 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3490 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3491 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3492 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3493 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3494 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3495 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3496 | zlog_debug( " TOS: 0%s", "\n"); |
| 3497 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3499 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3500 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3501 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3502 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3503 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3504 | |
| 3505 | return 0; |
| 3506 | } |
| 3507 | |
| 3508 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3509 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3510 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3511 | { |
| 3512 | if (lsa != NULL) |
| 3513 | { |
| 3514 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3515 | |
| 3516 | show_ip_ospf_database_header (vty, lsa); |
| 3517 | |
| 3518 | vty_out (vty, " Network Mask: /%d%s", |
| 3519 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3520 | vty_out (vty, " Metric Type: %s%s", |
| 3521 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3522 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3523 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3524 | vty_out (vty, " Metric: %d%s", |
| 3525 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3526 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3527 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3528 | |
| 3529 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3530 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3531 | } |
| 3532 | |
| 3533 | return 0; |
| 3534 | } |
| 3535 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3536 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3537 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3538 | { |
| 3539 | return 0; |
| 3540 | } |
| 3541 | |
| 3542 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3543 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3544 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3545 | { |
| 3546 | if (lsa != NULL) |
| 3547 | { |
| 3548 | show_ip_ospf_database_header (vty, lsa); |
| 3549 | show_opaque_info_detail (vty, lsa); |
| 3550 | |
| 3551 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3552 | } |
| 3553 | return 0; |
| 3554 | } |
| 3555 | #endif /* HAVE_OPAQUE_LSA */ |
| 3556 | |
| 3557 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3558 | { |
| 3559 | NULL, |
| 3560 | show_router_lsa_detail, |
| 3561 | show_network_lsa_detail, |
| 3562 | show_summary_lsa_detail, |
| 3563 | show_summary_asbr_lsa_detail, |
| 3564 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3565 | show_func_dummy, |
| 3566 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3567 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3568 | NULL, /* type-8 */ |
| 3569 | show_opaque_lsa_detail, |
| 3570 | show_opaque_lsa_detail, |
| 3571 | show_opaque_lsa_detail, |
| 3572 | #endif /* HAVE_OPAQUE_LSA */ |
| 3573 | }; |
| 3574 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3575 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3576 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3577 | struct in_addr *adv_router) |
| 3578 | { |
| 3579 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3580 | lp->family = 0; |
| 3581 | if (id == NULL) |
| 3582 | lp->prefixlen = 0; |
| 3583 | else if (adv_router == NULL) |
| 3584 | { |
| 3585 | lp->prefixlen = 32; |
| 3586 | lp->id = *id; |
| 3587 | } |
| 3588 | else |
| 3589 | { |
| 3590 | lp->prefixlen = 64; |
| 3591 | lp->id = *id; |
| 3592 | lp->adv_router = *adv_router; |
| 3593 | } |
| 3594 | } |
| 3595 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3596 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3597 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3598 | struct in_addr *id, struct in_addr *adv_router) |
| 3599 | { |
| 3600 | struct prefix_ls lp; |
| 3601 | struct route_node *rn, *start; |
| 3602 | struct ospf_lsa *lsa; |
| 3603 | |
| 3604 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3605 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3606 | if (start) |
| 3607 | { |
| 3608 | route_lock_node (start); |
| 3609 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3610 | if ((lsa = rn->info)) |
| 3611 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3612 | if (show_function[lsa->data->type] != NULL) |
| 3613 | show_function[lsa->data->type] (vty, lsa); |
| 3614 | } |
| 3615 | route_unlock_node (start); |
| 3616 | } |
| 3617 | } |
| 3618 | |
| 3619 | /* Show detail LSA information |
| 3620 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3621 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3622 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3623 | struct in_addr *id, struct in_addr *adv_router) |
| 3624 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3625 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3626 | struct ospf_area *area; |
| 3627 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3628 | switch (type) |
| 3629 | { |
| 3630 | case OSPF_AS_EXTERNAL_LSA: |
| 3631 | #ifdef HAVE_OPAQUE_LSA |
| 3632 | case OSPF_OPAQUE_AS_LSA: |
| 3633 | #endif /* HAVE_OPAQUE_LSA */ |
| 3634 | vty_out (vty, " %s %s%s", |
| 3635 | show_database_desc[type], |
| 3636 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3637 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3638 | break; |
| 3639 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3640 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3641 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3643 | VTY_NEWLINE, show_database_desc[type], |
| 3644 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3645 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3646 | } |
| 3647 | break; |
| 3648 | } |
| 3649 | } |
| 3650 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3651 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3652 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3653 | struct in_addr *adv_router) |
| 3654 | { |
| 3655 | struct route_node *rn; |
| 3656 | struct ospf_lsa *lsa; |
| 3657 | |
| 3658 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3659 | if ((lsa = rn->info)) |
| 3660 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3661 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3662 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3663 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3664 | if (show_function[lsa->data->type] != NULL) |
| 3665 | show_function[lsa->data->type] (vty, lsa); |
| 3666 | } |
| 3667 | } |
| 3668 | |
| 3669 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3670 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3671 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3672 | struct in_addr *adv_router) |
| 3673 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3674 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3675 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3676 | |
| 3677 | switch (type) |
| 3678 | { |
| 3679 | case OSPF_AS_EXTERNAL_LSA: |
| 3680 | #ifdef HAVE_OPAQUE_LSA |
| 3681 | case OSPF_OPAQUE_AS_LSA: |
| 3682 | #endif /* HAVE_OPAQUE_LSA */ |
| 3683 | vty_out (vty, " %s %s%s", |
| 3684 | show_database_desc[type], |
| 3685 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3686 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3687 | adv_router); |
| 3688 | break; |
| 3689 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3690 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3691 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3692 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3693 | VTY_NEWLINE, show_database_desc[type], |
| 3694 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3695 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3696 | adv_router); |
| 3697 | } |
| 3698 | break; |
| 3699 | } |
| 3700 | } |
| 3701 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3702 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3703 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3704 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3705 | struct ospf_lsa *lsa; |
| 3706 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3707 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3708 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3709 | int type; |
| 3710 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3711 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3712 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3713 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3714 | { |
| 3715 | switch (type) |
| 3716 | { |
| 3717 | case OSPF_AS_EXTERNAL_LSA: |
| 3718 | #ifdef HAVE_OPAQUE_LSA |
| 3719 | case OSPF_OPAQUE_AS_LSA: |
| 3720 | #endif /* HAVE_OPAQUE_LSA */ |
| 3721 | continue; |
| 3722 | default: |
| 3723 | break; |
| 3724 | } |
| 3725 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3726 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3727 | { |
| 3728 | vty_out (vty, " %s (Area %s)%s%s", |
| 3729 | show_database_desc[type], |
| 3730 | ospf_area_desc_string (area), |
| 3731 | VTY_NEWLINE, VTY_NEWLINE); |
| 3732 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3733 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3734 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3735 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3736 | |
| 3737 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3738 | } |
| 3739 | } |
| 3740 | } |
| 3741 | |
| 3742 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3743 | { |
| 3744 | switch (type) |
| 3745 | { |
| 3746 | case OSPF_AS_EXTERNAL_LSA: |
| 3747 | #ifdef HAVE_OPAQUE_LSA |
| 3748 | case OSPF_OPAQUE_AS_LSA: |
| 3749 | #endif /* HAVE_OPAQUE_LSA */ |
| 3750 | break;; |
| 3751 | default: |
| 3752 | continue; |
| 3753 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3754 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3755 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3756 | { |
| 3757 | vty_out (vty, " %s%s%s", |
| 3758 | show_database_desc[type], |
| 3759 | VTY_NEWLINE, VTY_NEWLINE); |
| 3760 | vty_out (vty, "%s%s", show_database_header[type], |
| 3761 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3762 | |
| 3763 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3764 | show_lsa_summary (vty, lsa, self); |
| 3765 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3766 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3767 | } |
| 3768 | } |
| 3769 | |
| 3770 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3771 | } |
| 3772 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3773 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3774 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3775 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3776 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3777 | struct ospf_lsa *lsa; |
| 3778 | |
| 3779 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3780 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3781 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3782 | for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa)) |
| 3783 | { |
| 3784 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3785 | vty_out (vty, "Link State ID: %s%s", |
| 3786 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3787 | vty_out (vty, "Advertising Router: %s%s", |
| 3788 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3789 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3790 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3791 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3792 | } |
| 3793 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3794 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3795 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3796 | |
| 3797 | #ifdef HAVE_OPAQUE_LSA |
| 3798 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3799 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3800 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3801 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3802 | #else /* HAVE_OPAQUE_LSA */ |
| 3803 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3804 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3805 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3806 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3807 | #endif /* HAVE_OPAQUE_LSA */ |
| 3808 | |
| 3809 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3810 | "asbr-summary|external|network|router|summary" \ |
| 3811 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3812 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3813 | |
| 3814 | #define OSPF_LSA_TYPES_DESC \ |
| 3815 | "ASBR summary link states\n" \ |
| 3816 | "External link states\n" \ |
| 3817 | "Network link states\n" \ |
| 3818 | "Router link states\n" \ |
| 3819 | "Network summary link states\n" \ |
| 3820 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3821 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3822 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3823 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3824 | |
| 3825 | DEFUN (show_ip_ospf_database, |
| 3826 | show_ip_ospf_database_cmd, |
| 3827 | "show ip ospf database", |
| 3828 | SHOW_STR |
| 3829 | IP_STR |
| 3830 | "OSPF information\n" |
| 3831 | "Database summary\n") |
| 3832 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3833 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3834 | int type, ret; |
| 3835 | struct in_addr id, adv_router; |
| 3836 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3837 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3838 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3839 | return CMD_SUCCESS; |
| 3840 | |
| 3841 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3842 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3843 | |
| 3844 | /* Show all LSA. */ |
| 3845 | if (argc == 0) |
| 3846 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3847 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3848 | return CMD_SUCCESS; |
| 3849 | } |
| 3850 | |
| 3851 | /* Set database type to show. */ |
| 3852 | if (strncmp (argv[0], "r", 1) == 0) |
| 3853 | type = OSPF_ROUTER_LSA; |
| 3854 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3855 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3856 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3857 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3858 | else if (strncmp (argv[0], "su", 2) == 0) |
| 3859 | type = OSPF_SUMMARY_LSA; |
| 3860 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3861 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3862 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3863 | type = OSPF_AS_EXTERNAL_LSA; |
| 3864 | else if (strncmp (argv[0], "se", 2) == 0) |
| 3865 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3866 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3867 | return CMD_SUCCESS; |
| 3868 | } |
| 3869 | else if (strncmp (argv[0], "m", 1) == 0) |
| 3870 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3871 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3872 | return CMD_SUCCESS; |
| 3873 | } |
| 3874 | #ifdef HAVE_OPAQUE_LSA |
| 3875 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3876 | type = OSPF_OPAQUE_LINK_LSA; |
| 3877 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3878 | type = OSPF_OPAQUE_AREA_LSA; |
| 3879 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3880 | type = OSPF_OPAQUE_AS_LSA; |
| 3881 | #endif /* HAVE_OPAQUE_LSA */ |
| 3882 | else |
| 3883 | return CMD_WARNING; |
| 3884 | |
| 3885 | /* `show ip ospf database LSA'. */ |
| 3886 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3887 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3888 | else if (argc >= 2) |
| 3889 | { |
| 3890 | ret = inet_aton (argv[1], &id); |
| 3891 | if (!ret) |
| 3892 | return CMD_WARNING; |
| 3893 | |
| 3894 | /* `show ip ospf database LSA ID'. */ |
| 3895 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3896 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3897 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 3898 | else if (argc == 3) |
| 3899 | { |
| 3900 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3901 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3902 | else |
| 3903 | { |
| 3904 | ret = inet_aton (argv[2], &adv_router); |
| 3905 | if (!ret) |
| 3906 | return CMD_WARNING; |
| 3907 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3908 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3909 | } |
| 3910 | } |
| 3911 | |
| 3912 | return CMD_SUCCESS; |
| 3913 | } |
| 3914 | |
| 3915 | ALIAS (show_ip_ospf_database, |
| 3916 | show_ip_ospf_database_type_cmd, |
| 3917 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 3918 | SHOW_STR |
| 3919 | IP_STR |
| 3920 | "OSPF information\n" |
| 3921 | "Database summary\n" |
| 3922 | OSPF_LSA_TYPES_DESC |
| 3923 | "LSAs in MaxAge list\n" |
| 3924 | "Self-originated link states\n") |
| 3925 | |
| 3926 | ALIAS (show_ip_ospf_database, |
| 3927 | show_ip_ospf_database_type_id_cmd, |
| 3928 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 3929 | SHOW_STR |
| 3930 | IP_STR |
| 3931 | "OSPF information\n" |
| 3932 | "Database summary\n" |
| 3933 | OSPF_LSA_TYPES_DESC |
| 3934 | "Link State ID (as an IP address)\n") |
| 3935 | |
| 3936 | ALIAS (show_ip_ospf_database, |
| 3937 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 3938 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 3939 | SHOW_STR |
| 3940 | IP_STR |
| 3941 | "OSPF information\n" |
| 3942 | "Database summary\n" |
| 3943 | OSPF_LSA_TYPES_DESC |
| 3944 | "Link State ID (as an IP address)\n" |
| 3945 | "Advertising Router link states\n" |
| 3946 | "Advertising Router (as an IP address)\n") |
| 3947 | |
| 3948 | ALIAS (show_ip_ospf_database, |
| 3949 | show_ip_ospf_database_type_id_self_cmd, |
| 3950 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 3951 | SHOW_STR |
| 3952 | IP_STR |
| 3953 | "OSPF information\n" |
| 3954 | "Database summary\n" |
| 3955 | OSPF_LSA_TYPES_DESC |
| 3956 | "Link State ID (as an IP address)\n" |
| 3957 | "Self-originated link states\n" |
| 3958 | "\n") |
| 3959 | |
| 3960 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 3961 | show_ip_ospf_database_type_adv_router_cmd, |
| 3962 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 3963 | SHOW_STR |
| 3964 | IP_STR |
| 3965 | "OSPF information\n" |
| 3966 | "Database summary\n" |
| 3967 | OSPF_LSA_TYPES_DESC |
| 3968 | "Advertising Router link states\n" |
| 3969 | "Advertising Router (as an IP address)\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 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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3977 | return CMD_SUCCESS; |
| 3978 | |
| 3979 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3980 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3981 | |
| 3982 | if (argc != 2) |
| 3983 | return CMD_WARNING; |
| 3984 | |
| 3985 | /* Set database type to show. */ |
| 3986 | if (strncmp (argv[0], "r", 1) == 0) |
| 3987 | type = OSPF_ROUTER_LSA; |
| 3988 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3989 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3990 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3991 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3992 | else if (strncmp (argv[0], "s", 1) == 0) |
| 3993 | type = OSPF_SUMMARY_LSA; |
| 3994 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3995 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3996 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3997 | type = OSPF_AS_EXTERNAL_LSA; |
| 3998 | #ifdef HAVE_OPAQUE_LSA |
| 3999 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4000 | type = OSPF_OPAQUE_LINK_LSA; |
| 4001 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4002 | type = OSPF_OPAQUE_AREA_LSA; |
| 4003 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4004 | type = OSPF_OPAQUE_AS_LSA; |
| 4005 | #endif /* HAVE_OPAQUE_LSA */ |
| 4006 | else |
| 4007 | return CMD_WARNING; |
| 4008 | |
| 4009 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4010 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4011 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4012 | else |
| 4013 | { |
| 4014 | ret = inet_aton (argv[1], &adv_router); |
| 4015 | if (!ret) |
| 4016 | return CMD_WARNING; |
| 4017 | } |
| 4018 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4019 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4020 | |
| 4021 | return CMD_SUCCESS; |
| 4022 | } |
| 4023 | |
| 4024 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4025 | show_ip_ospf_database_type_self_cmd, |
| 4026 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4027 | SHOW_STR |
| 4028 | IP_STR |
| 4029 | "OSPF information\n" |
| 4030 | "Database summary\n" |
| 4031 | OSPF_LSA_TYPES_DESC |
| 4032 | "Self-originated link states\n") |
| 4033 | |
| 4034 | |
| 4035 | DEFUN (ip_ospf_authentication_args, |
| 4036 | ip_ospf_authentication_args_addr_cmd, |
| 4037 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4038 | "IP Information\n" |
| 4039 | "OSPF interface commands\n" |
| 4040 | "Enable authentication on this interface\n" |
| 4041 | "Use null authentication\n" |
| 4042 | "Use message-digest authentication\n" |
| 4043 | "Address of interface") |
| 4044 | { |
| 4045 | struct interface *ifp; |
| 4046 | struct in_addr addr; |
| 4047 | int ret; |
| 4048 | struct ospf_if_params *params; |
| 4049 | |
| 4050 | ifp = vty->index; |
| 4051 | params = IF_DEF_PARAMS (ifp); |
| 4052 | |
| 4053 | if (argc == 2) |
| 4054 | { |
| 4055 | ret = inet_aton(argv[1], &addr); |
| 4056 | if (!ret) |
| 4057 | { |
| 4058 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4059 | VTY_NEWLINE); |
| 4060 | return CMD_WARNING; |
| 4061 | } |
| 4062 | |
| 4063 | params = ospf_get_if_params (ifp, addr); |
| 4064 | ospf_if_update_params (ifp, addr); |
| 4065 | } |
| 4066 | |
| 4067 | /* Handle null authentication */ |
| 4068 | if ( argv[0][0] == 'n' ) |
| 4069 | { |
| 4070 | SET_IF_PARAM (params, auth_type); |
| 4071 | params->auth_type = OSPF_AUTH_NULL; |
| 4072 | return CMD_SUCCESS; |
| 4073 | } |
| 4074 | |
| 4075 | /* Handle message-digest authentication */ |
| 4076 | if ( argv[0][0] == 'm' ) |
| 4077 | { |
| 4078 | SET_IF_PARAM (params, auth_type); |
| 4079 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4080 | return CMD_SUCCESS; |
| 4081 | } |
| 4082 | |
| 4083 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4084 | return CMD_WARNING; |
| 4085 | } |
| 4086 | |
| 4087 | ALIAS (ip_ospf_authentication_args, |
| 4088 | ip_ospf_authentication_args_cmd, |
| 4089 | "ip ospf authentication (null|message-digest)", |
| 4090 | "IP Information\n" |
| 4091 | "OSPF interface commands\n" |
| 4092 | "Enable authentication on this interface\n" |
| 4093 | "Use null authentication\n" |
| 4094 | "Use message-digest authentication\n") |
| 4095 | |
| 4096 | DEFUN (ip_ospf_authentication, |
| 4097 | ip_ospf_authentication_addr_cmd, |
| 4098 | "ip ospf authentication A.B.C.D", |
| 4099 | "IP Information\n" |
| 4100 | "OSPF interface commands\n" |
| 4101 | "Enable authentication on this interface\n" |
| 4102 | "Address of interface") |
| 4103 | { |
| 4104 | struct interface *ifp; |
| 4105 | struct in_addr addr; |
| 4106 | int ret; |
| 4107 | struct ospf_if_params *params; |
| 4108 | |
| 4109 | ifp = vty->index; |
| 4110 | params = IF_DEF_PARAMS (ifp); |
| 4111 | |
| 4112 | if (argc == 1) |
| 4113 | { |
| 4114 | ret = inet_aton(argv[1], &addr); |
| 4115 | if (!ret) |
| 4116 | { |
| 4117 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4118 | VTY_NEWLINE); |
| 4119 | return CMD_WARNING; |
| 4120 | } |
| 4121 | |
| 4122 | params = ospf_get_if_params (ifp, addr); |
| 4123 | ospf_if_update_params (ifp, addr); |
| 4124 | } |
| 4125 | |
| 4126 | SET_IF_PARAM (params, auth_type); |
| 4127 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4128 | |
| 4129 | return CMD_SUCCESS; |
| 4130 | } |
| 4131 | |
| 4132 | ALIAS (ip_ospf_authentication, |
| 4133 | ip_ospf_authentication_cmd, |
| 4134 | "ip ospf authentication", |
| 4135 | "IP Information\n" |
| 4136 | "OSPF interface commands\n" |
| 4137 | "Enable authentication on this interface\n") |
| 4138 | |
| 4139 | DEFUN (no_ip_ospf_authentication, |
| 4140 | no_ip_ospf_authentication_addr_cmd, |
| 4141 | "no ip ospf authentication A.B.C.D", |
| 4142 | NO_STR |
| 4143 | "IP Information\n" |
| 4144 | "OSPF interface commands\n" |
| 4145 | "Enable authentication on this interface\n" |
| 4146 | "Address of interface") |
| 4147 | { |
| 4148 | struct interface *ifp; |
| 4149 | struct in_addr addr; |
| 4150 | int ret; |
| 4151 | struct ospf_if_params *params; |
| 4152 | |
| 4153 | ifp = vty->index; |
| 4154 | params = IF_DEF_PARAMS (ifp); |
| 4155 | |
| 4156 | if (argc == 1) |
| 4157 | { |
| 4158 | ret = inet_aton(argv[1], &addr); |
| 4159 | if (!ret) |
| 4160 | { |
| 4161 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4162 | VTY_NEWLINE); |
| 4163 | return CMD_WARNING; |
| 4164 | } |
| 4165 | |
| 4166 | params = ospf_lookup_if_params (ifp, addr); |
| 4167 | if (params == NULL) |
| 4168 | return CMD_SUCCESS; |
| 4169 | } |
| 4170 | |
| 4171 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4172 | UNSET_IF_PARAM (params, auth_type); |
| 4173 | |
| 4174 | if (params != IF_DEF_PARAMS (ifp)) |
| 4175 | { |
| 4176 | ospf_free_if_params (ifp, addr); |
| 4177 | ospf_if_update_params (ifp, addr); |
| 4178 | } |
| 4179 | |
| 4180 | return CMD_SUCCESS; |
| 4181 | } |
| 4182 | |
| 4183 | ALIAS (no_ip_ospf_authentication, |
| 4184 | no_ip_ospf_authentication_cmd, |
| 4185 | "no ip ospf authentication", |
| 4186 | NO_STR |
| 4187 | "IP Information\n" |
| 4188 | "OSPF interface commands\n" |
| 4189 | "Enable authentication on this interface\n") |
| 4190 | |
| 4191 | DEFUN (ip_ospf_authentication_key, |
| 4192 | ip_ospf_authentication_key_addr_cmd, |
| 4193 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4194 | "IP Information\n" |
| 4195 | "OSPF interface commands\n" |
| 4196 | "Authentication password (key)\n" |
| 4197 | "The OSPF password (key)\n" |
| 4198 | "Address of interface") |
| 4199 | { |
| 4200 | struct interface *ifp; |
| 4201 | struct in_addr addr; |
| 4202 | int ret; |
| 4203 | struct ospf_if_params *params; |
| 4204 | |
| 4205 | ifp = vty->index; |
| 4206 | params = IF_DEF_PARAMS (ifp); |
| 4207 | |
| 4208 | if (argc == 2) |
| 4209 | { |
| 4210 | ret = inet_aton(argv[1], &addr); |
| 4211 | if (!ret) |
| 4212 | { |
| 4213 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4214 | VTY_NEWLINE); |
| 4215 | return CMD_WARNING; |
| 4216 | } |
| 4217 | |
| 4218 | params = ospf_get_if_params (ifp, addr); |
| 4219 | ospf_if_update_params (ifp, addr); |
| 4220 | } |
| 4221 | |
| 4222 | |
| 4223 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4224 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4225 | SET_IF_PARAM (params, auth_simple); |
| 4226 | |
| 4227 | return CMD_SUCCESS; |
| 4228 | } |
| 4229 | |
| 4230 | ALIAS (ip_ospf_authentication_key, |
| 4231 | ip_ospf_authentication_key_cmd, |
| 4232 | "ip ospf authentication-key AUTH_KEY", |
| 4233 | "IP Information\n" |
| 4234 | "OSPF interface commands\n" |
| 4235 | "Authentication password (key)\n" |
| 4236 | "The OSPF password (key)") |
| 4237 | |
| 4238 | ALIAS (ip_ospf_authentication_key, |
| 4239 | ospf_authentication_key_cmd, |
| 4240 | "ospf authentication-key AUTH_KEY", |
| 4241 | "OSPF interface commands\n" |
| 4242 | "Authentication password (key)\n" |
| 4243 | "The OSPF password (key)") |
| 4244 | |
| 4245 | DEFUN (no_ip_ospf_authentication_key, |
| 4246 | no_ip_ospf_authentication_key_addr_cmd, |
| 4247 | "no ip ospf authentication-key A.B.C.D", |
| 4248 | NO_STR |
| 4249 | "IP Information\n" |
| 4250 | "OSPF interface commands\n" |
| 4251 | "Authentication password (key)\n" |
| 4252 | "Address of interface") |
| 4253 | { |
| 4254 | struct interface *ifp; |
| 4255 | struct in_addr addr; |
| 4256 | int ret; |
| 4257 | struct ospf_if_params *params; |
| 4258 | |
| 4259 | ifp = vty->index; |
| 4260 | params = IF_DEF_PARAMS (ifp); |
| 4261 | |
| 4262 | if (argc == 2) |
| 4263 | { |
| 4264 | ret = inet_aton(argv[1], &addr); |
| 4265 | if (!ret) |
| 4266 | { |
| 4267 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4268 | VTY_NEWLINE); |
| 4269 | return CMD_WARNING; |
| 4270 | } |
| 4271 | |
| 4272 | params = ospf_lookup_if_params (ifp, addr); |
| 4273 | if (params == NULL) |
| 4274 | return CMD_SUCCESS; |
| 4275 | } |
| 4276 | |
| 4277 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4278 | UNSET_IF_PARAM (params, auth_simple); |
| 4279 | |
| 4280 | if (params != IF_DEF_PARAMS (ifp)) |
| 4281 | { |
| 4282 | ospf_free_if_params (ifp, addr); |
| 4283 | ospf_if_update_params (ifp, addr); |
| 4284 | } |
| 4285 | |
| 4286 | return CMD_SUCCESS; |
| 4287 | } |
| 4288 | |
| 4289 | ALIAS (no_ip_ospf_authentication_key, |
| 4290 | no_ip_ospf_authentication_key_cmd, |
| 4291 | "no ip ospf authentication-key", |
| 4292 | NO_STR |
| 4293 | "IP Information\n" |
| 4294 | "OSPF interface commands\n" |
| 4295 | "Authentication password (key)\n") |
| 4296 | |
| 4297 | ALIAS (no_ip_ospf_authentication_key, |
| 4298 | no_ospf_authentication_key_cmd, |
| 4299 | "no ospf authentication-key", |
| 4300 | NO_STR |
| 4301 | "OSPF interface commands\n" |
| 4302 | "Authentication password (key)\n") |
| 4303 | |
| 4304 | DEFUN (ip_ospf_message_digest_key, |
| 4305 | ip_ospf_message_digest_key_addr_cmd, |
| 4306 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4307 | "IP Information\n" |
| 4308 | "OSPF interface commands\n" |
| 4309 | "Message digest authentication password (key)\n" |
| 4310 | "Key ID\n" |
| 4311 | "Use MD5 algorithm\n" |
| 4312 | "The OSPF password (key)" |
| 4313 | "Address of interface") |
| 4314 | { |
| 4315 | struct interface *ifp; |
| 4316 | struct crypt_key *ck; |
| 4317 | u_char key_id; |
| 4318 | struct in_addr addr; |
| 4319 | int ret; |
| 4320 | struct ospf_if_params *params; |
| 4321 | |
| 4322 | ifp = vty->index; |
| 4323 | params = IF_DEF_PARAMS (ifp); |
| 4324 | |
| 4325 | if (argc == 3) |
| 4326 | { |
| 4327 | ret = inet_aton(argv[2], &addr); |
| 4328 | if (!ret) |
| 4329 | { |
| 4330 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4331 | VTY_NEWLINE); |
| 4332 | return CMD_WARNING; |
| 4333 | } |
| 4334 | |
| 4335 | params = ospf_get_if_params (ifp, addr); |
| 4336 | ospf_if_update_params (ifp, addr); |
| 4337 | } |
| 4338 | |
| 4339 | key_id = strtol (argv[0], NULL, 10); |
| 4340 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4341 | { |
| 4342 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4343 | return CMD_WARNING; |
| 4344 | } |
| 4345 | |
| 4346 | ck = ospf_crypt_key_new (); |
| 4347 | ck->key_id = (u_char) key_id; |
| 4348 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4349 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4350 | |
| 4351 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4352 | SET_IF_PARAM (params, auth_crypt); |
| 4353 | |
| 4354 | return CMD_SUCCESS; |
| 4355 | } |
| 4356 | |
| 4357 | ALIAS (ip_ospf_message_digest_key, |
| 4358 | ip_ospf_message_digest_key_cmd, |
| 4359 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4360 | "IP Information\n" |
| 4361 | "OSPF interface commands\n" |
| 4362 | "Message digest authentication password (key)\n" |
| 4363 | "Key ID\n" |
| 4364 | "Use MD5 algorithm\n" |
| 4365 | "The OSPF password (key)") |
| 4366 | |
| 4367 | ALIAS (ip_ospf_message_digest_key, |
| 4368 | ospf_message_digest_key_cmd, |
| 4369 | "ospf message-digest-key <1-255> md5 KEY", |
| 4370 | "OSPF interface commands\n" |
| 4371 | "Message digest authentication password (key)\n" |
| 4372 | "Key ID\n" |
| 4373 | "Use MD5 algorithm\n" |
| 4374 | "The OSPF password (key)") |
| 4375 | |
| 4376 | DEFUN (no_ip_ospf_message_digest_key, |
| 4377 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4378 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4379 | NO_STR |
| 4380 | "IP Information\n" |
| 4381 | "OSPF interface commands\n" |
| 4382 | "Message digest authentication password (key)\n" |
| 4383 | "Key ID\n" |
| 4384 | "Address of interface") |
| 4385 | { |
| 4386 | struct interface *ifp; |
| 4387 | struct crypt_key *ck; |
| 4388 | int key_id; |
| 4389 | struct in_addr addr; |
| 4390 | int ret; |
| 4391 | struct ospf_if_params *params; |
| 4392 | |
| 4393 | ifp = vty->index; |
| 4394 | params = IF_DEF_PARAMS (ifp); |
| 4395 | |
| 4396 | if (argc == 2) |
| 4397 | { |
| 4398 | ret = inet_aton(argv[1], &addr); |
| 4399 | if (!ret) |
| 4400 | { |
| 4401 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4402 | VTY_NEWLINE); |
| 4403 | return CMD_WARNING; |
| 4404 | } |
| 4405 | |
| 4406 | params = ospf_lookup_if_params (ifp, addr); |
| 4407 | if (params == NULL) |
| 4408 | return CMD_SUCCESS; |
| 4409 | } |
| 4410 | |
| 4411 | key_id = strtol (argv[0], NULL, 10); |
| 4412 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4413 | if (ck == NULL) |
| 4414 | { |
| 4415 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4416 | return CMD_WARNING; |
| 4417 | } |
| 4418 | |
| 4419 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4420 | |
| 4421 | if (params != IF_DEF_PARAMS (ifp)) |
| 4422 | { |
| 4423 | ospf_free_if_params (ifp, addr); |
| 4424 | ospf_if_update_params (ifp, addr); |
| 4425 | } |
| 4426 | |
| 4427 | return CMD_SUCCESS; |
| 4428 | } |
| 4429 | |
| 4430 | ALIAS (no_ip_ospf_message_digest_key, |
| 4431 | no_ip_ospf_message_digest_key_cmd, |
| 4432 | "no ip ospf message-digest-key <1-255>", |
| 4433 | NO_STR |
| 4434 | "IP Information\n" |
| 4435 | "OSPF interface commands\n" |
| 4436 | "Message digest authentication password (key)\n" |
| 4437 | "Key ID\n") |
| 4438 | |
| 4439 | ALIAS (no_ip_ospf_message_digest_key, |
| 4440 | no_ospf_message_digest_key_cmd, |
| 4441 | "no ospf message-digest-key <1-255>", |
| 4442 | NO_STR |
| 4443 | "OSPF interface commands\n" |
| 4444 | "Message digest authentication password (key)\n" |
| 4445 | "Key ID\n") |
| 4446 | |
| 4447 | DEFUN (ip_ospf_cost, |
| 4448 | ip_ospf_cost_addr_cmd, |
| 4449 | "ip ospf cost <1-65535> A.B.C.D", |
| 4450 | "IP Information\n" |
| 4451 | "OSPF interface commands\n" |
| 4452 | "Interface cost\n" |
| 4453 | "Cost\n" |
| 4454 | "Address of interface") |
| 4455 | { |
| 4456 | struct interface *ifp = vty->index; |
| 4457 | u_int32_t cost; |
| 4458 | struct in_addr addr; |
| 4459 | int ret; |
| 4460 | struct ospf_if_params *params; |
| 4461 | |
| 4462 | params = IF_DEF_PARAMS (ifp); |
| 4463 | |
| 4464 | cost = strtol (argv[0], NULL, 10); |
| 4465 | |
| 4466 | /* cost range is <1-65535>. */ |
| 4467 | if (cost < 1 || cost > 65535) |
| 4468 | { |
| 4469 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4470 | return CMD_WARNING; |
| 4471 | } |
| 4472 | |
| 4473 | if (argc == 2) |
| 4474 | { |
| 4475 | ret = inet_aton(argv[1], &addr); |
| 4476 | if (!ret) |
| 4477 | { |
| 4478 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4479 | VTY_NEWLINE); |
| 4480 | return CMD_WARNING; |
| 4481 | } |
| 4482 | |
| 4483 | params = ospf_get_if_params (ifp, addr); |
| 4484 | ospf_if_update_params (ifp, addr); |
| 4485 | } |
| 4486 | |
| 4487 | SET_IF_PARAM (params, output_cost_cmd); |
| 4488 | params->output_cost_cmd = cost; |
| 4489 | |
| 4490 | ospf_if_recalculate_output_cost (ifp); |
| 4491 | |
| 4492 | return CMD_SUCCESS; |
| 4493 | } |
| 4494 | |
| 4495 | ALIAS (ip_ospf_cost, |
| 4496 | ip_ospf_cost_cmd, |
| 4497 | "ip ospf cost <1-65535>", |
| 4498 | "IP Information\n" |
| 4499 | "OSPF interface commands\n" |
| 4500 | "Interface cost\n" |
| 4501 | "Cost") |
| 4502 | |
| 4503 | ALIAS (ip_ospf_cost, |
| 4504 | ospf_cost_cmd, |
| 4505 | "ospf cost <1-65535>", |
| 4506 | "OSPF interface commands\n" |
| 4507 | "Interface cost\n" |
| 4508 | "Cost") |
| 4509 | |
| 4510 | DEFUN (no_ip_ospf_cost, |
| 4511 | no_ip_ospf_cost_addr_cmd, |
| 4512 | "no ip ospf cost A.B.C.D", |
| 4513 | NO_STR |
| 4514 | "IP Information\n" |
| 4515 | "OSPF interface commands\n" |
| 4516 | "Interface cost\n" |
| 4517 | "Address of interface") |
| 4518 | { |
| 4519 | struct interface *ifp = vty->index; |
| 4520 | struct in_addr addr; |
| 4521 | int ret; |
| 4522 | struct ospf_if_params *params; |
| 4523 | |
| 4524 | ifp = vty->index; |
| 4525 | params = IF_DEF_PARAMS (ifp); |
| 4526 | |
| 4527 | if (argc == 1) |
| 4528 | { |
| 4529 | ret = inet_aton(argv[0], &addr); |
| 4530 | if (!ret) |
| 4531 | { |
| 4532 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4533 | VTY_NEWLINE); |
| 4534 | return CMD_WARNING; |
| 4535 | } |
| 4536 | |
| 4537 | params = ospf_lookup_if_params (ifp, addr); |
| 4538 | if (params == NULL) |
| 4539 | return CMD_SUCCESS; |
| 4540 | } |
| 4541 | |
| 4542 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4543 | |
| 4544 | if (params != IF_DEF_PARAMS (ifp)) |
| 4545 | { |
| 4546 | ospf_free_if_params (ifp, addr); |
| 4547 | ospf_if_update_params (ifp, addr); |
| 4548 | } |
| 4549 | |
| 4550 | ospf_if_recalculate_output_cost (ifp); |
| 4551 | |
| 4552 | return CMD_SUCCESS; |
| 4553 | } |
| 4554 | |
| 4555 | ALIAS (no_ip_ospf_cost, |
| 4556 | no_ip_ospf_cost_cmd, |
| 4557 | "no ip ospf cost", |
| 4558 | NO_STR |
| 4559 | "IP Information\n" |
| 4560 | "OSPF interface commands\n" |
| 4561 | "Interface cost\n") |
| 4562 | |
| 4563 | ALIAS (no_ip_ospf_cost, |
| 4564 | no_ospf_cost_cmd, |
| 4565 | "no ospf cost", |
| 4566 | NO_STR |
| 4567 | "OSPF interface commands\n" |
| 4568 | "Interface cost\n") |
| 4569 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4570 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4571 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4572 | { |
| 4573 | struct route_node *rn; |
| 4574 | struct ospf_neighbor *nbr; |
| 4575 | |
| 4576 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4577 | if ((nbr = rn->info)) |
| 4578 | { |
| 4579 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4580 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4581 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4582 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4583 | } |
| 4584 | } |
| 4585 | |
| 4586 | DEFUN (ip_ospf_dead_interval, |
| 4587 | ip_ospf_dead_interval_addr_cmd, |
| 4588 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4589 | "IP Information\n" |
| 4590 | "OSPF interface commands\n" |
| 4591 | "Interval after which a neighbor is declared dead\n" |
| 4592 | "Seconds\n" |
| 4593 | "Address of interface") |
| 4594 | { |
| 4595 | struct interface *ifp = vty->index; |
| 4596 | u_int32_t seconds; |
| 4597 | struct in_addr addr; |
| 4598 | int ret; |
| 4599 | struct ospf_if_params *params; |
| 4600 | struct ospf_interface *oi; |
| 4601 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4602 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4603 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4604 | ospf = ospf_lookup (); |
| 4605 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4606 | params = IF_DEF_PARAMS (ifp); |
| 4607 | |
| 4608 | seconds = strtol (argv[0], NULL, 10); |
| 4609 | |
| 4610 | /* dead_interval range is <1-65535>. */ |
| 4611 | if (seconds < 1 || seconds > 65535) |
| 4612 | { |
| 4613 | vty_out (vty, "Router Dead Interval 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, v_wait); |
| 4632 | params->v_wait = seconds; |
| 4633 | |
| 4634 | /* Update timer values in neighbor structure. */ |
| 4635 | if (argc == 2) |
| 4636 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4637 | if (ospf) |
| 4638 | { |
| 4639 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4640 | if (oi) |
| 4641 | ospf_nbr_timer_update (oi); |
| 4642 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4643 | } |
| 4644 | else |
| 4645 | { |
| 4646 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4647 | if ((oi = rn->info)) |
| 4648 | ospf_nbr_timer_update (oi); |
| 4649 | } |
| 4650 | |
| 4651 | return CMD_SUCCESS; |
| 4652 | } |
| 4653 | |
| 4654 | ALIAS (ip_ospf_dead_interval, |
| 4655 | ip_ospf_dead_interval_cmd, |
| 4656 | "ip ospf dead-interval <1-65535>", |
| 4657 | "IP Information\n" |
| 4658 | "OSPF interface commands\n" |
| 4659 | "Interval after which a neighbor is declared dead\n" |
| 4660 | "Seconds\n") |
| 4661 | |
| 4662 | ALIAS (ip_ospf_dead_interval, |
| 4663 | ospf_dead_interval_cmd, |
| 4664 | "ospf dead-interval <1-65535>", |
| 4665 | "OSPF interface commands\n" |
| 4666 | "Interval after which a neighbor is declared dead\n" |
| 4667 | "Seconds\n") |
| 4668 | |
| 4669 | DEFUN (no_ip_ospf_dead_interval, |
| 4670 | no_ip_ospf_dead_interval_addr_cmd, |
| 4671 | "no ip ospf dead-interval A.B.C.D", |
| 4672 | NO_STR |
| 4673 | "IP Information\n" |
| 4674 | "OSPF interface commands\n" |
| 4675 | "Interval after which a neighbor is declared dead\n" |
| 4676 | "Address of interface") |
| 4677 | { |
| 4678 | struct interface *ifp = vty->index; |
| 4679 | struct in_addr addr; |
| 4680 | int ret; |
| 4681 | struct ospf_if_params *params; |
| 4682 | struct ospf_interface *oi; |
| 4683 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4684 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4685 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4686 | ospf = ospf_lookup (); |
| 4687 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4688 | ifp = vty->index; |
| 4689 | params = IF_DEF_PARAMS (ifp); |
| 4690 | |
| 4691 | if (argc == 1) |
| 4692 | { |
| 4693 | ret = inet_aton(argv[0], &addr); |
| 4694 | if (!ret) |
| 4695 | { |
| 4696 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4697 | VTY_NEWLINE); |
| 4698 | return CMD_WARNING; |
| 4699 | } |
| 4700 | |
| 4701 | params = ospf_lookup_if_params (ifp, addr); |
| 4702 | if (params == NULL) |
| 4703 | return CMD_SUCCESS; |
| 4704 | } |
| 4705 | |
| 4706 | UNSET_IF_PARAM (params, v_wait); |
| 4707 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4708 | |
| 4709 | if (params != IF_DEF_PARAMS (ifp)) |
| 4710 | { |
| 4711 | ospf_free_if_params (ifp, addr); |
| 4712 | ospf_if_update_params (ifp, addr); |
| 4713 | } |
| 4714 | |
| 4715 | /* Update timer values in neighbor structure. */ |
| 4716 | if (argc == 1) |
| 4717 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4718 | if (ospf) |
| 4719 | { |
| 4720 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4721 | if (oi) |
| 4722 | ospf_nbr_timer_update (oi); |
| 4723 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4724 | } |
| 4725 | else |
| 4726 | { |
| 4727 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4728 | if ((oi = rn->info)) |
| 4729 | ospf_nbr_timer_update (oi); |
| 4730 | } |
| 4731 | |
| 4732 | return CMD_SUCCESS; |
| 4733 | } |
| 4734 | |
| 4735 | ALIAS (no_ip_ospf_dead_interval, |
| 4736 | no_ip_ospf_dead_interval_cmd, |
| 4737 | "no ip ospf dead-interval", |
| 4738 | NO_STR |
| 4739 | "IP Information\n" |
| 4740 | "OSPF interface commands\n" |
| 4741 | "Interval after which a neighbor is declared dead\n") |
| 4742 | |
| 4743 | ALIAS (no_ip_ospf_dead_interval, |
| 4744 | no_ospf_dead_interval_cmd, |
| 4745 | "no ospf dead-interval", |
| 4746 | NO_STR |
| 4747 | "OSPF interface commands\n" |
| 4748 | "Interval after which a neighbor is declared dead\n") |
| 4749 | |
| 4750 | DEFUN (ip_ospf_hello_interval, |
| 4751 | ip_ospf_hello_interval_addr_cmd, |
| 4752 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4753 | "IP Information\n" |
| 4754 | "OSPF interface commands\n" |
| 4755 | "Time between HELLO packets\n" |
| 4756 | "Seconds\n" |
| 4757 | "Address of interface") |
| 4758 | { |
| 4759 | struct interface *ifp = vty->index; |
| 4760 | u_int32_t seconds; |
| 4761 | struct in_addr addr; |
| 4762 | int ret; |
| 4763 | struct ospf_if_params *params; |
| 4764 | |
| 4765 | params = IF_DEF_PARAMS (ifp); |
| 4766 | |
| 4767 | seconds = strtol (argv[0], NULL, 10); |
| 4768 | |
| 4769 | /* HelloInterval range is <1-65535>. */ |
| 4770 | if (seconds < 1 || seconds > 65535) |
| 4771 | { |
| 4772 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4773 | return CMD_WARNING; |
| 4774 | } |
| 4775 | |
| 4776 | if (argc == 2) |
| 4777 | { |
| 4778 | ret = inet_aton(argv[1], &addr); |
| 4779 | if (!ret) |
| 4780 | { |
| 4781 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4782 | VTY_NEWLINE); |
| 4783 | return CMD_WARNING; |
| 4784 | } |
| 4785 | |
| 4786 | params = ospf_get_if_params (ifp, addr); |
| 4787 | ospf_if_update_params (ifp, addr); |
| 4788 | } |
| 4789 | |
| 4790 | SET_IF_PARAM (params, v_hello); |
| 4791 | params->v_hello = seconds; |
| 4792 | |
| 4793 | return CMD_SUCCESS; |
| 4794 | } |
| 4795 | |
| 4796 | ALIAS (ip_ospf_hello_interval, |
| 4797 | ip_ospf_hello_interval_cmd, |
| 4798 | "ip ospf hello-interval <1-65535>", |
| 4799 | "IP Information\n" |
| 4800 | "OSPF interface commands\n" |
| 4801 | "Time between HELLO packets\n" |
| 4802 | "Seconds\n") |
| 4803 | |
| 4804 | ALIAS (ip_ospf_hello_interval, |
| 4805 | ospf_hello_interval_cmd, |
| 4806 | "ospf hello-interval <1-65535>", |
| 4807 | "OSPF interface commands\n" |
| 4808 | "Time between HELLO packets\n" |
| 4809 | "Seconds\n") |
| 4810 | |
| 4811 | DEFUN (no_ip_ospf_hello_interval, |
| 4812 | no_ip_ospf_hello_interval_addr_cmd, |
| 4813 | "no ip ospf hello-interval A.B.C.D", |
| 4814 | NO_STR |
| 4815 | "IP Information\n" |
| 4816 | "OSPF interface commands\n" |
| 4817 | "Time between HELLO packets\n" |
| 4818 | "Address of interface") |
| 4819 | { |
| 4820 | struct interface *ifp = vty->index; |
| 4821 | struct in_addr addr; |
| 4822 | int ret; |
| 4823 | struct ospf_if_params *params; |
| 4824 | |
| 4825 | ifp = vty->index; |
| 4826 | params = IF_DEF_PARAMS (ifp); |
| 4827 | |
| 4828 | if (argc == 1) |
| 4829 | { |
| 4830 | ret = inet_aton(argv[0], &addr); |
| 4831 | if (!ret) |
| 4832 | { |
| 4833 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4834 | VTY_NEWLINE); |
| 4835 | return CMD_WARNING; |
| 4836 | } |
| 4837 | |
| 4838 | params = ospf_lookup_if_params (ifp, addr); |
| 4839 | if (params == NULL) |
| 4840 | return CMD_SUCCESS; |
| 4841 | } |
| 4842 | |
| 4843 | UNSET_IF_PARAM (params, v_hello); |
| 4844 | params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4845 | |
| 4846 | if (params != IF_DEF_PARAMS (ifp)) |
| 4847 | { |
| 4848 | ospf_free_if_params (ifp, addr); |
| 4849 | ospf_if_update_params (ifp, addr); |
| 4850 | } |
| 4851 | |
| 4852 | return CMD_SUCCESS; |
| 4853 | } |
| 4854 | |
| 4855 | ALIAS (no_ip_ospf_hello_interval, |
| 4856 | no_ip_ospf_hello_interval_cmd, |
| 4857 | "no ip ospf hello-interval", |
| 4858 | NO_STR |
| 4859 | "IP Information\n" |
| 4860 | "OSPF interface commands\n" |
| 4861 | "Time between HELLO packets\n") |
| 4862 | |
| 4863 | ALIAS (no_ip_ospf_hello_interval, |
| 4864 | no_ospf_hello_interval_cmd, |
| 4865 | "no ospf hello-interval", |
| 4866 | NO_STR |
| 4867 | "OSPF interface commands\n" |
| 4868 | "Time between HELLO packets\n") |
| 4869 | |
| 4870 | DEFUN (ip_ospf_network, |
| 4871 | ip_ospf_network_cmd, |
| 4872 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4873 | "IP Information\n" |
| 4874 | "OSPF interface commands\n" |
| 4875 | "Network type\n" |
| 4876 | "Specify OSPF broadcast multi-access network\n" |
| 4877 | "Specify OSPF NBMA network\n" |
| 4878 | "Specify OSPF point-to-multipoint network\n" |
| 4879 | "Specify OSPF point-to-point network\n") |
| 4880 | { |
| 4881 | struct interface *ifp = vty->index; |
| 4882 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4883 | struct route_node *rn; |
| 4884 | |
| 4885 | if (strncmp (argv[0], "b", 1) == 0) |
| 4886 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 4887 | else if (strncmp (argv[0], "n", 1) == 0) |
| 4888 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 4889 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 4890 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 4891 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 4892 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 4893 | |
| 4894 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4895 | return CMD_SUCCESS; |
| 4896 | |
| 4897 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 4898 | |
| 4899 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4900 | { |
| 4901 | struct ospf_interface *oi = rn->info; |
| 4902 | |
| 4903 | if (!oi) |
| 4904 | continue; |
| 4905 | |
| 4906 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4907 | |
| 4908 | if (oi->state > ISM_Down) |
| 4909 | { |
| 4910 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4911 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4912 | } |
| 4913 | } |
| 4914 | |
| 4915 | return CMD_SUCCESS; |
| 4916 | } |
| 4917 | |
| 4918 | ALIAS (ip_ospf_network, |
| 4919 | ospf_network_cmd, |
| 4920 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4921 | "OSPF interface commands\n" |
| 4922 | "Network type\n" |
| 4923 | "Specify OSPF broadcast multi-access network\n" |
| 4924 | "Specify OSPF NBMA network\n" |
| 4925 | "Specify OSPF point-to-multipoint network\n" |
| 4926 | "Specify OSPF point-to-point network\n") |
| 4927 | |
| 4928 | DEFUN (no_ip_ospf_network, |
| 4929 | no_ip_ospf_network_cmd, |
| 4930 | "no ip ospf network", |
| 4931 | NO_STR |
| 4932 | "IP Information\n" |
| 4933 | "OSPF interface commands\n" |
| 4934 | "Network type\n") |
| 4935 | { |
| 4936 | struct interface *ifp = vty->index; |
| 4937 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4938 | struct route_node *rn; |
| 4939 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 4940 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4941 | |
| 4942 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4943 | return CMD_SUCCESS; |
| 4944 | |
| 4945 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4946 | { |
| 4947 | struct ospf_interface *oi = rn->info; |
| 4948 | |
| 4949 | if (!oi) |
| 4950 | continue; |
| 4951 | |
| 4952 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4953 | |
| 4954 | if (oi->state > ISM_Down) |
| 4955 | { |
| 4956 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4957 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4958 | } |
| 4959 | } |
| 4960 | |
| 4961 | return CMD_SUCCESS; |
| 4962 | } |
| 4963 | |
| 4964 | ALIAS (no_ip_ospf_network, |
| 4965 | no_ospf_network_cmd, |
| 4966 | "no ospf network", |
| 4967 | NO_STR |
| 4968 | "OSPF interface commands\n" |
| 4969 | "Network type\n") |
| 4970 | |
| 4971 | DEFUN (ip_ospf_priority, |
| 4972 | ip_ospf_priority_addr_cmd, |
| 4973 | "ip ospf priority <0-255> A.B.C.D", |
| 4974 | "IP Information\n" |
| 4975 | "OSPF interface commands\n" |
| 4976 | "Router priority\n" |
| 4977 | "Priority\n" |
| 4978 | "Address of interface") |
| 4979 | { |
| 4980 | struct interface *ifp = vty->index; |
| 4981 | u_int32_t priority; |
| 4982 | struct route_node *rn; |
| 4983 | struct in_addr addr; |
| 4984 | int ret; |
| 4985 | struct ospf_if_params *params; |
| 4986 | |
| 4987 | params = IF_DEF_PARAMS (ifp); |
| 4988 | |
| 4989 | priority = strtol (argv[0], NULL, 10); |
| 4990 | |
| 4991 | /* Router Priority range is <0-255>. */ |
| 4992 | if (priority < 0 || priority > 255) |
| 4993 | { |
| 4994 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 4995 | return CMD_WARNING; |
| 4996 | } |
| 4997 | |
| 4998 | if (argc == 2) |
| 4999 | { |
| 5000 | ret = inet_aton(argv[1], &addr); |
| 5001 | if (!ret) |
| 5002 | { |
| 5003 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5004 | VTY_NEWLINE); |
| 5005 | return CMD_WARNING; |
| 5006 | } |
| 5007 | |
| 5008 | params = ospf_get_if_params (ifp, addr); |
| 5009 | ospf_if_update_params (ifp, addr); |
| 5010 | } |
| 5011 | |
| 5012 | SET_IF_PARAM (params, priority); |
| 5013 | params->priority = priority; |
| 5014 | |
| 5015 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5016 | { |
| 5017 | struct ospf_interface *oi = rn->info; |
| 5018 | |
| 5019 | if (!oi) |
| 5020 | continue; |
| 5021 | |
| 5022 | |
| 5023 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5024 | { |
| 5025 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5026 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5027 | } |
| 5028 | } |
| 5029 | |
| 5030 | return CMD_SUCCESS; |
| 5031 | } |
| 5032 | |
| 5033 | ALIAS (ip_ospf_priority, |
| 5034 | ip_ospf_priority_cmd, |
| 5035 | "ip ospf priority <0-255>", |
| 5036 | "IP Information\n" |
| 5037 | "OSPF interface commands\n" |
| 5038 | "Router priority\n" |
| 5039 | "Priority\n") |
| 5040 | |
| 5041 | ALIAS (ip_ospf_priority, |
| 5042 | ospf_priority_cmd, |
| 5043 | "ospf priority <0-255>", |
| 5044 | "OSPF interface commands\n" |
| 5045 | "Router priority\n" |
| 5046 | "Priority\n") |
| 5047 | |
| 5048 | DEFUN (no_ip_ospf_priority, |
| 5049 | no_ip_ospf_priority_addr_cmd, |
| 5050 | "no ip ospf priority A.B.C.D", |
| 5051 | NO_STR |
| 5052 | "IP Information\n" |
| 5053 | "OSPF interface commands\n" |
| 5054 | "Router priority\n" |
| 5055 | "Address of interface") |
| 5056 | { |
| 5057 | struct interface *ifp = vty->index; |
| 5058 | struct route_node *rn; |
| 5059 | struct in_addr addr; |
| 5060 | int ret; |
| 5061 | struct ospf_if_params *params; |
| 5062 | |
| 5063 | ifp = vty->index; |
| 5064 | params = IF_DEF_PARAMS (ifp); |
| 5065 | |
| 5066 | if (argc == 1) |
| 5067 | { |
| 5068 | ret = inet_aton(argv[0], &addr); |
| 5069 | if (!ret) |
| 5070 | { |
| 5071 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5072 | VTY_NEWLINE); |
| 5073 | return CMD_WARNING; |
| 5074 | } |
| 5075 | |
| 5076 | params = ospf_lookup_if_params (ifp, addr); |
| 5077 | if (params == NULL) |
| 5078 | return CMD_SUCCESS; |
| 5079 | } |
| 5080 | |
| 5081 | UNSET_IF_PARAM (params, priority); |
| 5082 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5083 | |
| 5084 | if (params != IF_DEF_PARAMS (ifp)) |
| 5085 | { |
| 5086 | ospf_free_if_params (ifp, addr); |
| 5087 | ospf_if_update_params (ifp, addr); |
| 5088 | } |
| 5089 | |
| 5090 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5091 | { |
| 5092 | struct ospf_interface *oi = rn->info; |
| 5093 | |
| 5094 | if (!oi) |
| 5095 | continue; |
| 5096 | |
| 5097 | |
| 5098 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5099 | { |
| 5100 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5101 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5102 | } |
| 5103 | } |
| 5104 | |
| 5105 | return CMD_SUCCESS; |
| 5106 | } |
| 5107 | |
| 5108 | ALIAS (no_ip_ospf_priority, |
| 5109 | no_ip_ospf_priority_cmd, |
| 5110 | "no ip ospf priority", |
| 5111 | NO_STR |
| 5112 | "IP Information\n" |
| 5113 | "OSPF interface commands\n" |
| 5114 | "Router priority\n") |
| 5115 | |
| 5116 | ALIAS (no_ip_ospf_priority, |
| 5117 | no_ospf_priority_cmd, |
| 5118 | "no ospf priority", |
| 5119 | NO_STR |
| 5120 | "OSPF interface commands\n" |
| 5121 | "Router priority\n") |
| 5122 | |
| 5123 | DEFUN (ip_ospf_retransmit_interval, |
| 5124 | ip_ospf_retransmit_interval_addr_cmd, |
| 5125 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5126 | "IP Information\n" |
| 5127 | "OSPF interface commands\n" |
| 5128 | "Time between retransmitting lost link state advertisements\n" |
| 5129 | "Seconds\n" |
| 5130 | "Address of interface") |
| 5131 | { |
| 5132 | struct interface *ifp = vty->index; |
| 5133 | u_int32_t seconds; |
| 5134 | struct in_addr addr; |
| 5135 | int ret; |
| 5136 | struct ospf_if_params *params; |
| 5137 | |
| 5138 | params = IF_DEF_PARAMS (ifp); |
| 5139 | seconds = strtol (argv[0], NULL, 10); |
| 5140 | |
| 5141 | /* Retransmit Interval range is <3-65535>. */ |
| 5142 | if (seconds < 3 || seconds > 65535) |
| 5143 | { |
| 5144 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5145 | return CMD_WARNING; |
| 5146 | } |
| 5147 | |
| 5148 | |
| 5149 | if (argc == 2) |
| 5150 | { |
| 5151 | ret = inet_aton(argv[1], &addr); |
| 5152 | if (!ret) |
| 5153 | { |
| 5154 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5155 | VTY_NEWLINE); |
| 5156 | return CMD_WARNING; |
| 5157 | } |
| 5158 | |
| 5159 | params = ospf_get_if_params (ifp, addr); |
| 5160 | ospf_if_update_params (ifp, addr); |
| 5161 | } |
| 5162 | |
| 5163 | SET_IF_PARAM (params, retransmit_interval); |
| 5164 | params->retransmit_interval = seconds; |
| 5165 | |
| 5166 | return CMD_SUCCESS; |
| 5167 | } |
| 5168 | |
| 5169 | ALIAS (ip_ospf_retransmit_interval, |
| 5170 | ip_ospf_retransmit_interval_cmd, |
| 5171 | "ip ospf retransmit-interval <3-65535>", |
| 5172 | "IP Information\n" |
| 5173 | "OSPF interface commands\n" |
| 5174 | "Time between retransmitting lost link state advertisements\n" |
| 5175 | "Seconds\n") |
| 5176 | |
| 5177 | ALIAS (ip_ospf_retransmit_interval, |
| 5178 | ospf_retransmit_interval_cmd, |
| 5179 | "ospf retransmit-interval <3-65535>", |
| 5180 | "OSPF interface commands\n" |
| 5181 | "Time between retransmitting lost link state advertisements\n" |
| 5182 | "Seconds\n") |
| 5183 | |
| 5184 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5185 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5186 | "no ip ospf retransmit-interval A.B.C.D", |
| 5187 | NO_STR |
| 5188 | "IP Information\n" |
| 5189 | "OSPF interface commands\n" |
| 5190 | "Time between retransmitting lost link state advertisements\n" |
| 5191 | "Address of interface") |
| 5192 | { |
| 5193 | struct interface *ifp = vty->index; |
| 5194 | struct in_addr addr; |
| 5195 | int ret; |
| 5196 | struct ospf_if_params *params; |
| 5197 | |
| 5198 | ifp = vty->index; |
| 5199 | params = IF_DEF_PARAMS (ifp); |
| 5200 | |
| 5201 | if (argc == 1) |
| 5202 | { |
| 5203 | ret = inet_aton(argv[0], &addr); |
| 5204 | if (!ret) |
| 5205 | { |
| 5206 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5207 | VTY_NEWLINE); |
| 5208 | return CMD_WARNING; |
| 5209 | } |
| 5210 | |
| 5211 | params = ospf_lookup_if_params (ifp, addr); |
| 5212 | if (params == NULL) |
| 5213 | return CMD_SUCCESS; |
| 5214 | } |
| 5215 | |
| 5216 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5217 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5218 | |
| 5219 | if (params != IF_DEF_PARAMS (ifp)) |
| 5220 | { |
| 5221 | ospf_free_if_params (ifp, addr); |
| 5222 | ospf_if_update_params (ifp, addr); |
| 5223 | } |
| 5224 | |
| 5225 | return CMD_SUCCESS; |
| 5226 | } |
| 5227 | |
| 5228 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5229 | no_ip_ospf_retransmit_interval_cmd, |
| 5230 | "no ip ospf retransmit-interval", |
| 5231 | NO_STR |
| 5232 | "IP Information\n" |
| 5233 | "OSPF interface commands\n" |
| 5234 | "Time between retransmitting lost link state advertisements\n") |
| 5235 | |
| 5236 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5237 | no_ospf_retransmit_interval_cmd, |
| 5238 | "no ospf retransmit-interval", |
| 5239 | NO_STR |
| 5240 | "OSPF interface commands\n" |
| 5241 | "Time between retransmitting lost link state advertisements\n") |
| 5242 | |
| 5243 | DEFUN (ip_ospf_transmit_delay, |
| 5244 | ip_ospf_transmit_delay_addr_cmd, |
| 5245 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5246 | "IP Information\n" |
| 5247 | "OSPF interface commands\n" |
| 5248 | "Link state transmit delay\n" |
| 5249 | "Seconds\n" |
| 5250 | "Address of interface") |
| 5251 | { |
| 5252 | struct interface *ifp = vty->index; |
| 5253 | u_int32_t seconds; |
| 5254 | struct in_addr addr; |
| 5255 | int ret; |
| 5256 | struct ospf_if_params *params; |
| 5257 | |
| 5258 | params = IF_DEF_PARAMS (ifp); |
| 5259 | seconds = strtol (argv[0], NULL, 10); |
| 5260 | |
| 5261 | /* Transmit Delay range is <1-65535>. */ |
| 5262 | if (seconds < 1 || seconds > 65535) |
| 5263 | { |
| 5264 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5265 | return CMD_WARNING; |
| 5266 | } |
| 5267 | |
| 5268 | if (argc == 2) |
| 5269 | { |
| 5270 | ret = inet_aton(argv[1], &addr); |
| 5271 | if (!ret) |
| 5272 | { |
| 5273 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5274 | VTY_NEWLINE); |
| 5275 | return CMD_WARNING; |
| 5276 | } |
| 5277 | |
| 5278 | params = ospf_get_if_params (ifp, addr); |
| 5279 | ospf_if_update_params (ifp, addr); |
| 5280 | } |
| 5281 | |
| 5282 | SET_IF_PARAM (params, transmit_delay); |
| 5283 | params->transmit_delay = seconds; |
| 5284 | |
| 5285 | return CMD_SUCCESS; |
| 5286 | } |
| 5287 | |
| 5288 | ALIAS (ip_ospf_transmit_delay, |
| 5289 | ip_ospf_transmit_delay_cmd, |
| 5290 | "ip ospf transmit-delay <1-65535>", |
| 5291 | "IP Information\n" |
| 5292 | "OSPF interface commands\n" |
| 5293 | "Link state transmit delay\n" |
| 5294 | "Seconds\n") |
| 5295 | |
| 5296 | ALIAS (ip_ospf_transmit_delay, |
| 5297 | ospf_transmit_delay_cmd, |
| 5298 | "ospf transmit-delay <1-65535>", |
| 5299 | "OSPF interface commands\n" |
| 5300 | "Link state transmit delay\n" |
| 5301 | "Seconds\n") |
| 5302 | |
| 5303 | DEFUN (no_ip_ospf_transmit_delay, |
| 5304 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5305 | "no ip ospf transmit-delay A.B.C.D", |
| 5306 | NO_STR |
| 5307 | "IP Information\n" |
| 5308 | "OSPF interface commands\n" |
| 5309 | "Link state transmit delay\n" |
| 5310 | "Address of interface") |
| 5311 | { |
| 5312 | struct interface *ifp = vty->index; |
| 5313 | struct in_addr addr; |
| 5314 | int ret; |
| 5315 | struct ospf_if_params *params; |
| 5316 | |
| 5317 | ifp = vty->index; |
| 5318 | params = IF_DEF_PARAMS (ifp); |
| 5319 | |
| 5320 | if (argc == 1) |
| 5321 | { |
| 5322 | ret = inet_aton(argv[0], &addr); |
| 5323 | if (!ret) |
| 5324 | { |
| 5325 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5326 | VTY_NEWLINE); |
| 5327 | return CMD_WARNING; |
| 5328 | } |
| 5329 | |
| 5330 | params = ospf_lookup_if_params (ifp, addr); |
| 5331 | if (params == NULL) |
| 5332 | return CMD_SUCCESS; |
| 5333 | } |
| 5334 | |
| 5335 | UNSET_IF_PARAM (params, transmit_delay); |
| 5336 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5337 | |
| 5338 | if (params != IF_DEF_PARAMS (ifp)) |
| 5339 | { |
| 5340 | ospf_free_if_params (ifp, addr); |
| 5341 | ospf_if_update_params (ifp, addr); |
| 5342 | } |
| 5343 | |
| 5344 | return CMD_SUCCESS; |
| 5345 | } |
| 5346 | |
| 5347 | ALIAS (no_ip_ospf_transmit_delay, |
| 5348 | no_ip_ospf_transmit_delay_cmd, |
| 5349 | "no ip ospf transmit-delay", |
| 5350 | NO_STR |
| 5351 | "IP Information\n" |
| 5352 | "OSPF interface commands\n" |
| 5353 | "Link state transmit delay\n") |
| 5354 | |
| 5355 | ALIAS (no_ip_ospf_transmit_delay, |
| 5356 | no_ospf_transmit_delay_cmd, |
| 5357 | "no ospf transmit-delay", |
| 5358 | NO_STR |
| 5359 | "OSPF interface commands\n" |
| 5360 | "Link state transmit delay\n") |
| 5361 | |
| 5362 | |
| 5363 | DEFUN (ospf_redistribute_source_metric_type, |
| 5364 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5365 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5366 | "Redistribute information from another routing protocol\n" |
| 5367 | "Kernel routes\n" |
| 5368 | "Connected\n" |
| 5369 | "Static routes\n" |
| 5370 | "Routing Information Protocol (RIP)\n" |
| 5371 | "Border Gateway Protocol (BGP)\n" |
| 5372 | "Metric for redistributed routes\n" |
| 5373 | "OSPF default metric\n" |
| 5374 | "OSPF exterior metric type for redistributed routes\n" |
| 5375 | "Set OSPF External Type 1 metrics\n" |
| 5376 | "Set OSPF External Type 2 metrics\n" |
| 5377 | "Route map reference\n" |
| 5378 | "Pointer to route-map entries\n") |
| 5379 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5380 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5381 | int source; |
| 5382 | int type = -1; |
| 5383 | int metric = -1; |
| 5384 | |
| 5385 | /* Get distribute source. */ |
| 5386 | if (!str2distribute_source (argv[0], &source)) |
| 5387 | return CMD_WARNING; |
| 5388 | |
| 5389 | /* Get metric value. */ |
| 5390 | if (argc >= 2) |
| 5391 | if (!str2metric (argv[1], &metric)) |
| 5392 | return CMD_WARNING; |
| 5393 | |
| 5394 | /* Get metric type. */ |
| 5395 | if (argc >= 3) |
| 5396 | if (!str2metric_type (argv[2], &type)) |
| 5397 | return CMD_WARNING; |
| 5398 | |
| 5399 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5400 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5401 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5402 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5403 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5404 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5405 | } |
| 5406 | |
| 5407 | ALIAS (ospf_redistribute_source_metric_type, |
| 5408 | ospf_redistribute_source_metric_type_cmd, |
| 5409 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5410 | "Redistribute information from another routing protocol\n" |
| 5411 | "Kernel routes\n" |
| 5412 | "Connected\n" |
| 5413 | "Static routes\n" |
| 5414 | "Routing Information Protocol (RIP)\n" |
| 5415 | "Border Gateway Protocol (BGP)\n" |
| 5416 | "Metric for redistributed routes\n" |
| 5417 | "OSPF default metric\n" |
| 5418 | "OSPF exterior metric type for redistributed routes\n" |
| 5419 | "Set OSPF External Type 1 metrics\n" |
| 5420 | "Set OSPF External Type 2 metrics\n") |
| 5421 | |
| 5422 | ALIAS (ospf_redistribute_source_metric_type, |
| 5423 | ospf_redistribute_source_metric_cmd, |
| 5424 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5425 | "Redistribute information from another routing protocol\n" |
| 5426 | "Kernel routes\n" |
| 5427 | "Connected\n" |
| 5428 | "Static routes\n" |
| 5429 | "Routing Information Protocol (RIP)\n" |
| 5430 | "Border Gateway Protocol (BGP)\n" |
| 5431 | "Metric for redistributed routes\n" |
| 5432 | "OSPF default metric\n") |
| 5433 | |
| 5434 | DEFUN (ospf_redistribute_source_type_metric, |
| 5435 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5436 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5437 | "Redistribute information from another routing protocol\n" |
| 5438 | "Kernel routes\n" |
| 5439 | "Connected\n" |
| 5440 | "Static routes\n" |
| 5441 | "Routing Information Protocol (RIP)\n" |
| 5442 | "Border Gateway Protocol (BGP)\n" |
| 5443 | "OSPF exterior metric type for redistributed routes\n" |
| 5444 | "Set OSPF External Type 1 metrics\n" |
| 5445 | "Set OSPF External Type 2 metrics\n" |
| 5446 | "Metric for redistributed routes\n" |
| 5447 | "OSPF default metric\n" |
| 5448 | "Route map reference\n" |
| 5449 | "Pointer to route-map entries\n") |
| 5450 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5451 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5452 | int source; |
| 5453 | int type = -1; |
| 5454 | int metric = -1; |
| 5455 | |
| 5456 | /* Get distribute source. */ |
| 5457 | if (!str2distribute_source (argv[0], &source)) |
| 5458 | return CMD_WARNING; |
| 5459 | |
| 5460 | /* Get metric value. */ |
| 5461 | if (argc >= 2) |
| 5462 | if (!str2metric_type (argv[1], &type)) |
| 5463 | return CMD_WARNING; |
| 5464 | |
| 5465 | /* Get metric type. */ |
| 5466 | if (argc >= 3) |
| 5467 | if (!str2metric (argv[2], &metric)) |
| 5468 | return CMD_WARNING; |
| 5469 | |
| 5470 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5471 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5472 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5473 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5474 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5475 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5476 | } |
| 5477 | |
| 5478 | ALIAS (ospf_redistribute_source_type_metric, |
| 5479 | ospf_redistribute_source_type_metric_cmd, |
| 5480 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5481 | "Redistribute information from another routing protocol\n" |
| 5482 | "Kernel routes\n" |
| 5483 | "Connected\n" |
| 5484 | "Static routes\n" |
| 5485 | "Routing Information Protocol (RIP)\n" |
| 5486 | "Border Gateway Protocol (BGP)\n" |
| 5487 | "OSPF exterior metric type for redistributed routes\n" |
| 5488 | "Set OSPF External Type 1 metrics\n" |
| 5489 | "Set OSPF External Type 2 metrics\n" |
| 5490 | "Metric for redistributed routes\n" |
| 5491 | "OSPF default metric\n") |
| 5492 | |
| 5493 | ALIAS (ospf_redistribute_source_type_metric, |
| 5494 | ospf_redistribute_source_type_cmd, |
| 5495 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5496 | "Redistribute information from another routing protocol\n" |
| 5497 | "Kernel routes\n" |
| 5498 | "Connected\n" |
| 5499 | "Static routes\n" |
| 5500 | "Routing Information Protocol (RIP)\n" |
| 5501 | "Border Gateway Protocol (BGP)\n" |
| 5502 | "OSPF exterior metric type for redistributed routes\n" |
| 5503 | "Set OSPF External Type 1 metrics\n" |
| 5504 | "Set OSPF External Type 2 metrics\n") |
| 5505 | |
| 5506 | ALIAS (ospf_redistribute_source_type_metric, |
| 5507 | ospf_redistribute_source_cmd, |
| 5508 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5509 | "Redistribute information from another routing protocol\n" |
| 5510 | "Kernel routes\n" |
| 5511 | "Connected\n" |
| 5512 | "Static routes\n" |
| 5513 | "Routing Information Protocol (RIP)\n" |
| 5514 | "Border Gateway Protocol (BGP)\n") |
| 5515 | |
| 5516 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5517 | ospf_redistribute_source_metric_routemap_cmd, |
| 5518 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5519 | "Redistribute information from another routing protocol\n" |
| 5520 | "Kernel routes\n" |
| 5521 | "Connected\n" |
| 5522 | "Static routes\n" |
| 5523 | "Routing Information Protocol (RIP)\n" |
| 5524 | "Border Gateway Protocol (BGP)\n" |
| 5525 | "Metric for redistributed routes\n" |
| 5526 | "OSPF default metric\n" |
| 5527 | "Route map reference\n" |
| 5528 | "Pointer to route-map entries\n") |
| 5529 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5530 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5531 | int source; |
| 5532 | int metric = -1; |
| 5533 | |
| 5534 | /* Get distribute source. */ |
| 5535 | if (!str2distribute_source (argv[0], &source)) |
| 5536 | return CMD_WARNING; |
| 5537 | |
| 5538 | /* Get metric value. */ |
| 5539 | if (argc >= 2) |
| 5540 | if (!str2metric (argv[1], &metric)) |
| 5541 | return CMD_WARNING; |
| 5542 | |
| 5543 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5544 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5545 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5546 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5547 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5548 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5549 | } |
| 5550 | |
| 5551 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5552 | ospf_redistribute_source_type_routemap_cmd, |
| 5553 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5554 | "Redistribute information from another routing protocol\n" |
| 5555 | "Kernel routes\n" |
| 5556 | "Connected\n" |
| 5557 | "Static routes\n" |
| 5558 | "Routing Information Protocol (RIP)\n" |
| 5559 | "Border Gateway Protocol (BGP)\n" |
| 5560 | "OSPF exterior metric type for redistributed routes\n" |
| 5561 | "Set OSPF External Type 1 metrics\n" |
| 5562 | "Set OSPF External Type 2 metrics\n" |
| 5563 | "Route map reference\n" |
| 5564 | "Pointer to route-map entries\n") |
| 5565 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5566 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5567 | int source; |
| 5568 | int type = -1; |
| 5569 | |
| 5570 | /* Get distribute source. */ |
| 5571 | if (!str2distribute_source (argv[0], &source)) |
| 5572 | return CMD_WARNING; |
| 5573 | |
| 5574 | /* Get metric value. */ |
| 5575 | if (argc >= 2) |
| 5576 | if (!str2metric_type (argv[1], &type)) |
| 5577 | return CMD_WARNING; |
| 5578 | |
| 5579 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5580 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5581 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5582 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5583 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5584 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5585 | } |
| 5586 | |
| 5587 | DEFUN (ospf_redistribute_source_routemap, |
| 5588 | ospf_redistribute_source_routemap_cmd, |
| 5589 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5590 | "Redistribute information from another routing protocol\n" |
| 5591 | "Kernel routes\n" |
| 5592 | "Connected\n" |
| 5593 | "Static routes\n" |
| 5594 | "Routing Information Protocol (RIP)\n" |
| 5595 | "Border Gateway Protocol (BGP)\n" |
| 5596 | "Route map reference\n" |
| 5597 | "Pointer to route-map entries\n") |
| 5598 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5599 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5600 | int source; |
| 5601 | |
| 5602 | /* Get distribute source. */ |
| 5603 | if (!str2distribute_source (argv[0], &source)) |
| 5604 | return CMD_WARNING; |
| 5605 | |
| 5606 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5607 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5608 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5609 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5610 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5611 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | } |
| 5613 | |
| 5614 | DEFUN (no_ospf_redistribute_source, |
| 5615 | no_ospf_redistribute_source_cmd, |
| 5616 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5617 | NO_STR |
| 5618 | "Redistribute information from another routing protocol\n" |
| 5619 | "Kernel routes\n" |
| 5620 | "Connected\n" |
| 5621 | "Static routes\n" |
| 5622 | "Routing Information Protocol (RIP)\n" |
| 5623 | "Border Gateway Protocol (BGP)\n") |
| 5624 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5625 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5626 | int source; |
| 5627 | |
| 5628 | if (!str2distribute_source (argv[0], &source)) |
| 5629 | return CMD_WARNING; |
| 5630 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5631 | ospf_routemap_unset (ospf, source); |
| 5632 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5633 | } |
| 5634 | |
| 5635 | DEFUN (ospf_distribute_list_out, |
| 5636 | ospf_distribute_list_out_cmd, |
| 5637 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5638 | "Filter networks in routing updates\n" |
| 5639 | "Access-list name\n" |
| 5640 | OUT_STR |
| 5641 | "Kernel routes\n" |
| 5642 | "Connected\n" |
| 5643 | "Static routes\n" |
| 5644 | "Routing Information Protocol (RIP)\n" |
| 5645 | "Border Gateway Protocol (BGP)\n") |
| 5646 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5647 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5648 | int source; |
| 5649 | |
| 5650 | /* Get distribute source. */ |
| 5651 | if (!str2distribute_source (argv[1], &source)) |
| 5652 | return CMD_WARNING; |
| 5653 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5654 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5655 | } |
| 5656 | |
| 5657 | DEFUN (no_ospf_distribute_list_out, |
| 5658 | no_ospf_distribute_list_out_cmd, |
| 5659 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5660 | NO_STR |
| 5661 | "Filter networks in routing updates\n" |
| 5662 | "Access-list name\n" |
| 5663 | OUT_STR |
| 5664 | "Kernel routes\n" |
| 5665 | "Connected\n" |
| 5666 | "Static routes\n" |
| 5667 | "Routing Information Protocol (RIP)\n" |
| 5668 | "Border Gateway Protocol (BGP)\n") |
| 5669 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5670 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5671 | int source; |
| 5672 | |
| 5673 | if (!str2distribute_source (argv[1], &source)) |
| 5674 | return CMD_WARNING; |
| 5675 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5676 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5677 | } |
| 5678 | |
| 5679 | /* Default information originate. */ |
| 5680 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5681 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5682 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5683 | "Control distribution of default information\n" |
| 5684 | "Distribute a default route\n" |
| 5685 | "OSPF default metric\n" |
| 5686 | "OSPF metric\n" |
| 5687 | "OSPF metric type for default routes\n" |
| 5688 | "Set OSPF External Type 1 metrics\n" |
| 5689 | "Set OSPF External Type 2 metrics\n" |
| 5690 | "Route map reference\n" |
| 5691 | "Pointer to route-map entries\n") |
| 5692 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5693 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5694 | int type = -1; |
| 5695 | int metric = -1; |
| 5696 | |
| 5697 | /* Get metric value. */ |
| 5698 | if (argc >= 1) |
| 5699 | if (!str2metric (argv[0], &metric)) |
| 5700 | return CMD_WARNING; |
| 5701 | |
| 5702 | /* Get metric type. */ |
| 5703 | if (argc >= 2) |
| 5704 | if (!str2metric_type (argv[1], &type)) |
| 5705 | return CMD_WARNING; |
| 5706 | |
| 5707 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5708 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5709 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5710 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5711 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5712 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5713 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5714 | } |
| 5715 | |
| 5716 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5717 | ospf_default_information_originate_metric_type_cmd, |
| 5718 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5719 | "Control distribution of default information\n" |
| 5720 | "Distribute a default route\n" |
| 5721 | "OSPF default metric\n" |
| 5722 | "OSPF metric\n" |
| 5723 | "OSPF metric type for default routes\n" |
| 5724 | "Set OSPF External Type 1 metrics\n" |
| 5725 | "Set OSPF External Type 2 metrics\n") |
| 5726 | |
| 5727 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5728 | ospf_default_information_originate_metric_cmd, |
| 5729 | "default-information originate metric <0-16777214>", |
| 5730 | "Control distribution of default information\n" |
| 5731 | "Distribute a default route\n" |
| 5732 | "OSPF default metric\n" |
| 5733 | "OSPF metric\n") |
| 5734 | |
| 5735 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5736 | ospf_default_information_originate_cmd, |
| 5737 | "default-information originate", |
| 5738 | "Control distribution of default information\n" |
| 5739 | "Distribute a default route\n") |
| 5740 | |
| 5741 | /* Default information originate. */ |
| 5742 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5743 | ospf_default_information_originate_metric_routemap_cmd, |
| 5744 | "default-information originate metric <0-16777214> route-map WORD", |
| 5745 | "Control distribution of default information\n" |
| 5746 | "Distribute a default route\n" |
| 5747 | "OSPF default metric\n" |
| 5748 | "OSPF metric\n" |
| 5749 | "Route map reference\n" |
| 5750 | "Pointer to route-map entries\n") |
| 5751 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5752 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5753 | int metric = -1; |
| 5754 | |
| 5755 | /* Get metric value. */ |
| 5756 | if (argc >= 1) |
| 5757 | if (!str2metric (argv[0], &metric)) |
| 5758 | return CMD_WARNING; |
| 5759 | |
| 5760 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5761 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5762 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5763 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5764 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5765 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5766 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5767 | } |
| 5768 | |
| 5769 | /* Default information originate. */ |
| 5770 | DEFUN (ospf_default_information_originate_routemap, |
| 5771 | ospf_default_information_originate_routemap_cmd, |
| 5772 | "default-information originate route-map WORD", |
| 5773 | "Control distribution of default information\n" |
| 5774 | "Distribute a default route\n" |
| 5775 | "Route map reference\n" |
| 5776 | "Pointer to route-map entries\n") |
| 5777 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5778 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5779 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5780 | if (argc == 1) |
| 5781 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5782 | else |
| 5783 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5784 | |
| 5785 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5786 | } |
| 5787 | |
| 5788 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 5789 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 5790 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5791 | "Control distribution of default information\n" |
| 5792 | "Distribute a default route\n" |
| 5793 | "OSPF metric type for default routes\n" |
| 5794 | "Set OSPF External Type 1 metrics\n" |
| 5795 | "Set OSPF External Type 2 metrics\n" |
| 5796 | "OSPF default metric\n" |
| 5797 | "OSPF metric\n" |
| 5798 | "Route map reference\n" |
| 5799 | "Pointer to route-map entries\n") |
| 5800 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5801 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5802 | int type = -1; |
| 5803 | int metric = -1; |
| 5804 | |
| 5805 | /* Get metric type. */ |
| 5806 | if (argc >= 1) |
| 5807 | if (!str2metric_type (argv[0], &type)) |
| 5808 | return CMD_WARNING; |
| 5809 | |
| 5810 | /* Get metric value. */ |
| 5811 | if (argc >= 2) |
| 5812 | if (!str2metric (argv[1], &metric)) |
| 5813 | return CMD_WARNING; |
| 5814 | |
| 5815 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5816 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5817 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5818 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5819 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5820 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5821 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5822 | } |
| 5823 | |
| 5824 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5825 | ospf_default_information_originate_type_metric_cmd, |
| 5826 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 5827 | "Control distribution of default information\n" |
| 5828 | "Distribute a default route\n" |
| 5829 | "OSPF metric type for default routes\n" |
| 5830 | "Set OSPF External Type 1 metrics\n" |
| 5831 | "Set OSPF External Type 2 metrics\n" |
| 5832 | "OSPF default metric\n" |
| 5833 | "OSPF metric\n") |
| 5834 | |
| 5835 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5836 | ospf_default_information_originate_type_cmd, |
| 5837 | "default-information originate metric-type (1|2)", |
| 5838 | "Control distribution of default information\n" |
| 5839 | "Distribute a default route\n" |
| 5840 | "OSPF metric type for default routes\n" |
| 5841 | "Set OSPF External Type 1 metrics\n" |
| 5842 | "Set OSPF External Type 2 metrics\n") |
| 5843 | |
| 5844 | DEFUN (ospf_default_information_originate_type_routemap, |
| 5845 | ospf_default_information_originate_type_routemap_cmd, |
| 5846 | "default-information originate metric-type (1|2) route-map WORD", |
| 5847 | "Control distribution of default information\n" |
| 5848 | "Distribute a default route\n" |
| 5849 | "OSPF metric type for default routes\n" |
| 5850 | "Set OSPF External Type 1 metrics\n" |
| 5851 | "Set OSPF External Type 2 metrics\n" |
| 5852 | "Route map reference\n" |
| 5853 | "Pointer to route-map entries\n") |
| 5854 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5855 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5856 | int type = -1; |
| 5857 | |
| 5858 | /* Get metric type. */ |
| 5859 | if (argc >= 1) |
| 5860 | if (!str2metric_type (argv[0], &type)) |
| 5861 | return CMD_WARNING; |
| 5862 | |
| 5863 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5864 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5865 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5866 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5867 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5868 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5869 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5870 | } |
| 5871 | |
| 5872 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 5873 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 5874 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5875 | "Control distribution of default information\n" |
| 5876 | "Distribute a default route\n" |
| 5877 | "Always advertise default route\n" |
| 5878 | "OSPF default metric\n" |
| 5879 | "OSPF metric\n" |
| 5880 | "OSPF metric type for default routes\n" |
| 5881 | "Set OSPF External Type 1 metrics\n" |
| 5882 | "Set OSPF External Type 2 metrics\n" |
| 5883 | "Route map reference\n" |
| 5884 | "Pointer to route-map entries\n") |
| 5885 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5886 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5887 | int type = -1; |
| 5888 | int metric = -1; |
| 5889 | |
| 5890 | /* Get metric value. */ |
| 5891 | if (argc >= 1) |
| 5892 | if (!str2metric (argv[0], &metric)) |
| 5893 | return CMD_WARNING; |
| 5894 | |
| 5895 | /* Get metric type. */ |
| 5896 | if (argc >= 2) |
| 5897 | if (!str2metric_type (argv[1], &type)) |
| 5898 | return CMD_WARNING; |
| 5899 | |
| 5900 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5901 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5902 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5903 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5904 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5905 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5906 | type, metric); |
| 5907 | } |
| 5908 | |
| 5909 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5910 | ospf_default_information_originate_always_metric_type_cmd, |
| 5911 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 5912 | "Control distribution of default information\n" |
| 5913 | "Distribute a default route\n" |
| 5914 | "Always advertise default route\n" |
| 5915 | "OSPF default metric\n" |
| 5916 | "OSPF metric\n" |
| 5917 | "OSPF metric type for default routes\n" |
| 5918 | "Set OSPF External Type 1 metrics\n" |
| 5919 | "Set OSPF External Type 2 metrics\n") |
| 5920 | |
| 5921 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5922 | ospf_default_information_originate_always_metric_cmd, |
| 5923 | "default-information originate always metric <0-16777214>", |
| 5924 | "Control distribution of default information\n" |
| 5925 | "Distribute a default route\n" |
| 5926 | "Always advertise default route\n" |
| 5927 | "OSPF default metric\n" |
| 5928 | "OSPF metric\n" |
| 5929 | "OSPF metric type for default routes\n") |
| 5930 | |
| 5931 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5932 | ospf_default_information_originate_always_cmd, |
| 5933 | "default-information originate always", |
| 5934 | "Control distribution of default information\n" |
| 5935 | "Distribute a default route\n" |
| 5936 | "Always advertise default route\n") |
| 5937 | |
| 5938 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 5939 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 5940 | "default-information originate always metric <0-16777214> route-map WORD", |
| 5941 | "Control distribution of default information\n" |
| 5942 | "Distribute a default route\n" |
| 5943 | "Always advertise default route\n" |
| 5944 | "OSPF default metric\n" |
| 5945 | "OSPF metric\n" |
| 5946 | "Route map reference\n" |
| 5947 | "Pointer to route-map entries\n") |
| 5948 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5949 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5950 | int metric = -1; |
| 5951 | |
| 5952 | /* Get metric value. */ |
| 5953 | if (argc >= 1) |
| 5954 | if (!str2metric (argv[0], &metric)) |
| 5955 | return CMD_WARNING; |
| 5956 | |
| 5957 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5958 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5959 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5960 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5962 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 5963 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5964 | } |
| 5965 | |
| 5966 | DEFUN (ospf_default_information_originate_always_routemap, |
| 5967 | ospf_default_information_originate_always_routemap_cmd, |
| 5968 | "default-information originate always route-map WORD", |
| 5969 | "Control distribution of default information\n" |
| 5970 | "Distribute a default route\n" |
| 5971 | "Always advertise default route\n" |
| 5972 | "Route map reference\n" |
| 5973 | "Pointer to route-map entries\n") |
| 5974 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5975 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5977 | if (argc == 1) |
| 5978 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5979 | else |
| 5980 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5981 | |
| 5982 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5983 | } |
| 5984 | |
| 5985 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 5986 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 5987 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5988 | "Control distribution of default information\n" |
| 5989 | "Distribute a default route\n" |
| 5990 | "Always advertise default route\n" |
| 5991 | "OSPF metric type for default routes\n" |
| 5992 | "Set OSPF External Type 1 metrics\n" |
| 5993 | "Set OSPF External Type 2 metrics\n" |
| 5994 | "OSPF default metric\n" |
| 5995 | "OSPF metric\n" |
| 5996 | "Route map reference\n" |
| 5997 | "Pointer to route-map entries\n") |
| 5998 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5999 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6000 | int type = -1; |
| 6001 | int metric = -1; |
| 6002 | |
| 6003 | /* Get metric type. */ |
| 6004 | if (argc >= 1) |
| 6005 | if (!str2metric_type (argv[0], &type)) |
| 6006 | return CMD_WARNING; |
| 6007 | |
| 6008 | /* Get metric value. */ |
| 6009 | if (argc >= 2) |
| 6010 | if (!str2metric (argv[1], &metric)) |
| 6011 | return CMD_WARNING; |
| 6012 | |
| 6013 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6014 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6015 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6016 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6018 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6019 | type, metric); |
| 6020 | } |
| 6021 | |
| 6022 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6023 | ospf_default_information_originate_always_type_metric_cmd, |
| 6024 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 6025 | "Control distribution of default information\n" |
| 6026 | "Distribute a default route\n" |
| 6027 | "Always advertise default route\n" |
| 6028 | "OSPF metric type for default routes\n" |
| 6029 | "Set OSPF External Type 1 metrics\n" |
| 6030 | "Set OSPF External Type 2 metrics\n" |
| 6031 | "OSPF default metric\n" |
| 6032 | "OSPF metric\n") |
| 6033 | |
| 6034 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6035 | ospf_default_information_originate_always_type_cmd, |
| 6036 | "default-information originate always metric-type (1|2)", |
| 6037 | "Control distribution of default information\n" |
| 6038 | "Distribute a default route\n" |
| 6039 | "Always advertise 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_always_type_routemap, |
| 6045 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6046 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6047 | "Control distribution of default information\n" |
| 6048 | "Distribute a default route\n" |
| 6049 | "Always advertise default route\n" |
| 6050 | "OSPF metric type for default routes\n" |
| 6051 | "Set OSPF External Type 1 metrics\n" |
| 6052 | "Set OSPF External Type 2 metrics\n" |
| 6053 | "Route map reference\n" |
| 6054 | "Pointer to route-map entries\n") |
| 6055 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6056 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | int type = -1; |
| 6058 | |
| 6059 | /* Get metric type. */ |
| 6060 | if (argc >= 1) |
| 6061 | if (!str2metric_type (argv[0], &type)) |
| 6062 | return CMD_WARNING; |
| 6063 | |
| 6064 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6065 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6066 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6067 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6068 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6069 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6070 | type, -1); |
| 6071 | } |
| 6072 | |
| 6073 | DEFUN (no_ospf_default_information_originate, |
| 6074 | no_ospf_default_information_originate_cmd, |
| 6075 | "no default-information originate", |
| 6076 | NO_STR |
| 6077 | "Control distribution of default information\n" |
| 6078 | "Distribute a default route\n") |
| 6079 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6080 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6081 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6082 | |
| 6083 | p.family = AF_INET; |
| 6084 | p.prefix.s_addr = 0; |
| 6085 | p.prefixlen = 0; |
| 6086 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6087 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6088 | |
| 6089 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6090 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6091 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6092 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6093 | } |
| 6094 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6095 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6096 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6097 | } |
| 6098 | |
| 6099 | DEFUN (ospf_default_metric, |
| 6100 | ospf_default_metric_cmd, |
| 6101 | "default-metric <0-16777214>", |
| 6102 | "Set metric of redistributed routes\n" |
| 6103 | "Default metric\n") |
| 6104 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6105 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6106 | int metric = -1; |
| 6107 | |
| 6108 | if (!str2metric (argv[0], &metric)) |
| 6109 | return CMD_WARNING; |
| 6110 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6111 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6112 | |
| 6113 | return CMD_SUCCESS; |
| 6114 | } |
| 6115 | |
| 6116 | DEFUN (no_ospf_default_metric, |
| 6117 | no_ospf_default_metric_cmd, |
| 6118 | "no default-metric", |
| 6119 | NO_STR |
| 6120 | "Set metric of redistributed routes\n") |
| 6121 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6122 | struct ospf *ospf = vty->index; |
| 6123 | |
| 6124 | ospf->default_metric = -1; |
| 6125 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | return CMD_SUCCESS; |
| 6127 | } |
| 6128 | |
| 6129 | ALIAS (no_ospf_default_metric, |
| 6130 | no_ospf_default_metric_val_cmd, |
| 6131 | "no default-metric <0-16777214>", |
| 6132 | NO_STR |
| 6133 | "Set metric of redistributed routes\n" |
| 6134 | "Default metric\n") |
| 6135 | |
| 6136 | DEFUN (ospf_distance, |
| 6137 | ospf_distance_cmd, |
| 6138 | "distance <1-255>", |
| 6139 | "Define an administrative distance\n" |
| 6140 | "OSPF Administrative distance\n") |
| 6141 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6142 | struct ospf *ospf = vty->index; |
| 6143 | |
| 6144 | ospf->distance_all = atoi (argv[0]); |
| 6145 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6146 | return CMD_SUCCESS; |
| 6147 | } |
| 6148 | |
| 6149 | DEFUN (no_ospf_distance, |
| 6150 | no_ospf_distance_cmd, |
| 6151 | "no distance <1-255>", |
| 6152 | NO_STR |
| 6153 | "Define an administrative distance\n" |
| 6154 | "OSPF Administrative distance\n") |
| 6155 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6156 | struct ospf *ospf = vty->index; |
| 6157 | |
| 6158 | ospf->distance_all = 0; |
| 6159 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6160 | return CMD_SUCCESS; |
| 6161 | } |
| 6162 | |
| 6163 | DEFUN (no_ospf_distance_ospf, |
| 6164 | no_ospf_distance_ospf_cmd, |
| 6165 | "no distance ospf", |
| 6166 | NO_STR |
| 6167 | "Define an administrative distance\n" |
| 6168 | "OSPF Administrative distance\n" |
| 6169 | "OSPF Distance\n") |
| 6170 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6171 | struct ospf *ospf = vty->index; |
| 6172 | |
| 6173 | ospf->distance_intra = 0; |
| 6174 | ospf->distance_inter = 0; |
| 6175 | ospf->distance_external = 0; |
| 6176 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6177 | return CMD_SUCCESS; |
| 6178 | } |
| 6179 | |
| 6180 | DEFUN (ospf_distance_ospf_intra, |
| 6181 | ospf_distance_ospf_intra_cmd, |
| 6182 | "distance ospf intra-area <1-255>", |
| 6183 | "Define an administrative distance\n" |
| 6184 | "OSPF Administrative distance\n" |
| 6185 | "Intra-area routes\n" |
| 6186 | "Distance for intra-area routes\n") |
| 6187 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6188 | struct ospf *ospf = vty->index; |
| 6189 | |
| 6190 | ospf->distance_intra = atoi (argv[0]); |
| 6191 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6192 | return CMD_SUCCESS; |
| 6193 | } |
| 6194 | |
| 6195 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6196 | ospf_distance_ospf_intra_inter_cmd, |
| 6197 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6198 | "Define an administrative distance\n" |
| 6199 | "OSPF Administrative distance\n" |
| 6200 | "Intra-area routes\n" |
| 6201 | "Distance for intra-area routes\n" |
| 6202 | "Inter-area routes\n" |
| 6203 | "Distance for inter-area routes\n") |
| 6204 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6205 | struct ospf *ospf = vty->index; |
| 6206 | |
| 6207 | ospf->distance_intra = atoi (argv[0]); |
| 6208 | ospf->distance_inter = atoi (argv[1]); |
| 6209 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6210 | return CMD_SUCCESS; |
| 6211 | } |
| 6212 | |
| 6213 | DEFUN (ospf_distance_ospf_intra_external, |
| 6214 | ospf_distance_ospf_intra_external_cmd, |
| 6215 | "distance ospf intra-area <1-255> external <1-255>", |
| 6216 | "Define an administrative distance\n" |
| 6217 | "OSPF Administrative distance\n" |
| 6218 | "Intra-area routes\n" |
| 6219 | "Distance for intra-area routes\n" |
| 6220 | "External routes\n" |
| 6221 | "Distance for external routes\n") |
| 6222 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6223 | struct ospf *ospf = vty->index; |
| 6224 | |
| 6225 | ospf->distance_intra = atoi (argv[0]); |
| 6226 | ospf->distance_external = atoi (argv[1]); |
| 6227 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6228 | return CMD_SUCCESS; |
| 6229 | } |
| 6230 | |
| 6231 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6232 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6233 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6234 | "Define an administrative distance\n" |
| 6235 | "OSPF Administrative distance\n" |
| 6236 | "Intra-area routes\n" |
| 6237 | "Distance for intra-area routes\n" |
| 6238 | "Inter-area routes\n" |
| 6239 | "Distance for inter-area routes\n" |
| 6240 | "External routes\n" |
| 6241 | "Distance for external routes\n") |
| 6242 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6243 | struct ospf *ospf = vty->index; |
| 6244 | |
| 6245 | ospf->distance_intra = atoi (argv[0]); |
| 6246 | ospf->distance_inter = atoi (argv[1]); |
| 6247 | ospf->distance_external = atoi (argv[2]); |
| 6248 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6249 | return CMD_SUCCESS; |
| 6250 | } |
| 6251 | |
| 6252 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6253 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6254 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6255 | "Define an administrative distance\n" |
| 6256 | "OSPF Administrative distance\n" |
| 6257 | "Intra-area routes\n" |
| 6258 | "Distance for intra-area routes\n" |
| 6259 | "External routes\n" |
| 6260 | "Distance for external routes\n" |
| 6261 | "Inter-area routes\n" |
| 6262 | "Distance for inter-area routes\n") |
| 6263 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6264 | struct ospf *ospf = vty->index; |
| 6265 | |
| 6266 | ospf->distance_intra = atoi (argv[0]); |
| 6267 | ospf->distance_external = atoi (argv[1]); |
| 6268 | ospf->distance_inter = atoi (argv[2]); |
| 6269 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6270 | return CMD_SUCCESS; |
| 6271 | } |
| 6272 | |
| 6273 | DEFUN (ospf_distance_ospf_inter, |
| 6274 | ospf_distance_ospf_inter_cmd, |
| 6275 | "distance ospf inter-area <1-255>", |
| 6276 | "Define an administrative distance\n" |
| 6277 | "OSPF Administrative distance\n" |
| 6278 | "Inter-area routes\n" |
| 6279 | "Distance for inter-area routes\n") |
| 6280 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6281 | struct ospf *ospf = vty->index; |
| 6282 | |
| 6283 | ospf->distance_inter = atoi (argv[0]); |
| 6284 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6285 | return CMD_SUCCESS; |
| 6286 | } |
| 6287 | |
| 6288 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6289 | ospf_distance_ospf_inter_intra_cmd, |
| 6290 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6291 | "Define an administrative distance\n" |
| 6292 | "OSPF Administrative distance\n" |
| 6293 | "Inter-area routes\n" |
| 6294 | "Distance for inter-area routes\n" |
| 6295 | "Intra-area routes\n" |
| 6296 | "Distance for intra-area routes\n") |
| 6297 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6298 | struct ospf *ospf = vty->index; |
| 6299 | |
| 6300 | ospf->distance_inter = atoi (argv[0]); |
| 6301 | ospf->distance_intra = atoi (argv[1]); |
| 6302 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6303 | return CMD_SUCCESS; |
| 6304 | } |
| 6305 | |
| 6306 | DEFUN (ospf_distance_ospf_inter_external, |
| 6307 | ospf_distance_ospf_inter_external_cmd, |
| 6308 | "distance ospf inter-area <1-255> external <1-255>", |
| 6309 | "Define an administrative distance\n" |
| 6310 | "OSPF Administrative distance\n" |
| 6311 | "Inter-area routes\n" |
| 6312 | "Distance for inter-area routes\n" |
| 6313 | "External routes\n" |
| 6314 | "Distance for external routes\n") |
| 6315 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6316 | struct ospf *ospf = vty->index; |
| 6317 | |
| 6318 | ospf->distance_inter = atoi (argv[0]); |
| 6319 | ospf->distance_external = atoi (argv[1]); |
| 6320 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6321 | return CMD_SUCCESS; |
| 6322 | } |
| 6323 | |
| 6324 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6325 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6326 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6327 | "Define an administrative distance\n" |
| 6328 | "OSPF Administrative distance\n" |
| 6329 | "Inter-area routes\n" |
| 6330 | "Distance for inter-area routes\n" |
| 6331 | "Intra-area routes\n" |
| 6332 | "Distance for intra-area routes\n" |
| 6333 | "External routes\n" |
| 6334 | "Distance for external routes\n") |
| 6335 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6336 | struct ospf *ospf = vty->index; |
| 6337 | |
| 6338 | ospf->distance_inter = atoi (argv[0]); |
| 6339 | ospf->distance_intra = atoi (argv[1]); |
| 6340 | ospf->distance_external = atoi (argv[2]); |
| 6341 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6342 | return CMD_SUCCESS; |
| 6343 | } |
| 6344 | |
| 6345 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6346 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6347 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6348 | "Define an administrative distance\n" |
| 6349 | "OSPF Administrative distance\n" |
| 6350 | "Inter-area routes\n" |
| 6351 | "Distance for inter-area routes\n" |
| 6352 | "External routes\n" |
| 6353 | "Distance for external routes\n" |
| 6354 | "Intra-area routes\n" |
| 6355 | "Distance for intra-area routes\n") |
| 6356 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6357 | struct ospf *ospf = vty->index; |
| 6358 | |
| 6359 | ospf->distance_inter = atoi (argv[0]); |
| 6360 | ospf->distance_external = atoi (argv[1]); |
| 6361 | ospf->distance_intra = atoi (argv[2]); |
| 6362 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6363 | return CMD_SUCCESS; |
| 6364 | } |
| 6365 | |
| 6366 | DEFUN (ospf_distance_ospf_external, |
| 6367 | ospf_distance_ospf_external_cmd, |
| 6368 | "distance ospf external <1-255>", |
| 6369 | "Define an administrative distance\n" |
| 6370 | "OSPF Administrative distance\n" |
| 6371 | "External routes\n" |
| 6372 | "Distance for external routes\n") |
| 6373 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6374 | struct ospf *ospf = vty->index; |
| 6375 | |
| 6376 | ospf->distance_external = atoi (argv[0]); |
| 6377 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6378 | return CMD_SUCCESS; |
| 6379 | } |
| 6380 | |
| 6381 | DEFUN (ospf_distance_ospf_external_intra, |
| 6382 | ospf_distance_ospf_external_intra_cmd, |
| 6383 | "distance ospf external <1-255> intra-area <1-255>", |
| 6384 | "Define an administrative distance\n" |
| 6385 | "OSPF Administrative distance\n" |
| 6386 | "External routes\n" |
| 6387 | "Distance for external routes\n" |
| 6388 | "Intra-area routes\n" |
| 6389 | "Distance for intra-area routes\n") |
| 6390 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6391 | struct ospf *ospf = vty->index; |
| 6392 | |
| 6393 | ospf->distance_external = atoi (argv[0]); |
| 6394 | ospf->distance_intra = atoi (argv[1]); |
| 6395 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6396 | return CMD_SUCCESS; |
| 6397 | } |
| 6398 | |
| 6399 | DEFUN (ospf_distance_ospf_external_inter, |
| 6400 | ospf_distance_ospf_external_inter_cmd, |
| 6401 | "distance ospf external <1-255> inter-area <1-255>", |
| 6402 | "Define an administrative distance\n" |
| 6403 | "OSPF Administrative distance\n" |
| 6404 | "External routes\n" |
| 6405 | "Distance for external routes\n" |
| 6406 | "Inter-area routes\n" |
| 6407 | "Distance for inter-area routes\n") |
| 6408 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6409 | struct ospf *ospf = vty->index; |
| 6410 | |
| 6411 | ospf->distance_external = atoi (argv[0]); |
| 6412 | ospf->distance_inter = atoi (argv[1]); |
| 6413 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6414 | return CMD_SUCCESS; |
| 6415 | } |
| 6416 | |
| 6417 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6418 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6419 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6420 | "Define an administrative distance\n" |
| 6421 | "OSPF Administrative distance\n" |
| 6422 | "External routes\n" |
| 6423 | "Distance for external routes\n" |
| 6424 | "Intra-area routes\n" |
| 6425 | "Distance for intra-area routes\n" |
| 6426 | "Inter-area routes\n" |
| 6427 | "Distance for inter-area routes\n") |
| 6428 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6429 | struct ospf *ospf = vty->index; |
| 6430 | |
| 6431 | ospf->distance_external = atoi (argv[0]); |
| 6432 | ospf->distance_intra = atoi (argv[1]); |
| 6433 | ospf->distance_inter = atoi (argv[2]); |
| 6434 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6435 | return CMD_SUCCESS; |
| 6436 | } |
| 6437 | |
| 6438 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6439 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6440 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6441 | "Define an administrative distance\n" |
| 6442 | "OSPF Administrative distance\n" |
| 6443 | "External routes\n" |
| 6444 | "Distance for external routes\n" |
| 6445 | "Inter-area routes\n" |
| 6446 | "Distance for inter-area routes\n" |
| 6447 | "Intra-area routes\n" |
| 6448 | "Distance for intra-area routes\n") |
| 6449 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6450 | struct ospf *ospf = vty->index; |
| 6451 | |
| 6452 | ospf->distance_external = atoi (argv[0]); |
| 6453 | ospf->distance_inter = atoi (argv[1]); |
| 6454 | ospf->distance_intra = atoi (argv[2]); |
| 6455 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6456 | return CMD_SUCCESS; |
| 6457 | } |
| 6458 | |
| 6459 | DEFUN (ospf_distance_source, |
| 6460 | ospf_distance_source_cmd, |
| 6461 | "distance <1-255> A.B.C.D/M", |
| 6462 | "Administrative distance\n" |
| 6463 | "Distance value\n" |
| 6464 | "IP source prefix\n") |
| 6465 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6466 | struct ospf *ospf = vty->index; |
| 6467 | |
| 6468 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6470 | return CMD_SUCCESS; |
| 6471 | } |
| 6472 | |
| 6473 | DEFUN (no_ospf_distance_source, |
| 6474 | no_ospf_distance_source_cmd, |
| 6475 | "no distance <1-255> A.B.C.D/M", |
| 6476 | NO_STR |
| 6477 | "Administrative distance\n" |
| 6478 | "Distance value\n" |
| 6479 | "IP source prefix\n") |
| 6480 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6481 | struct ospf *ospf = vty->index; |
| 6482 | |
| 6483 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6484 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6485 | return CMD_SUCCESS; |
| 6486 | } |
| 6487 | |
| 6488 | DEFUN (ospf_distance_source_access_list, |
| 6489 | ospf_distance_source_access_list_cmd, |
| 6490 | "distance <1-255> A.B.C.D/M WORD", |
| 6491 | "Administrative distance\n" |
| 6492 | "Distance value\n" |
| 6493 | "IP source prefix\n" |
| 6494 | "Access list name\n") |
| 6495 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6496 | struct ospf *ospf = vty->index; |
| 6497 | |
| 6498 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6499 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6500 | return CMD_SUCCESS; |
| 6501 | } |
| 6502 | |
| 6503 | DEFUN (no_ospf_distance_source_access_list, |
| 6504 | no_ospf_distance_source_access_list_cmd, |
| 6505 | "no distance <1-255> A.B.C.D/M WORD", |
| 6506 | NO_STR |
| 6507 | "Administrative distance\n" |
| 6508 | "Distance value\n" |
| 6509 | "IP source prefix\n" |
| 6510 | "Access list name\n") |
| 6511 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6512 | struct ospf *ospf = vty->index; |
| 6513 | |
| 6514 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6515 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6516 | return CMD_SUCCESS; |
| 6517 | } |
| 6518 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6519 | DEFUN (ip_ospf_mtu_ignore, |
| 6520 | ip_ospf_mtu_ignore_addr_cmd, |
| 6521 | "ip ospf mtu-ignore A.B.C.D", |
| 6522 | "IP Information\n" |
| 6523 | "OSPF interface commands\n" |
| 6524 | "Disable mtu mismatch detection\n" |
| 6525 | "Address of interface") |
| 6526 | { |
| 6527 | struct interface *ifp = vty->index; |
| 6528 | struct in_addr addr; |
| 6529 | int ret; |
| 6530 | |
| 6531 | struct ospf_if_params *params; |
| 6532 | params = IF_DEF_PARAMS (ifp); |
| 6533 | |
| 6534 | if (argc == 1) |
| 6535 | { |
| 6536 | ret = inet_aton(argv[0], &addr); |
| 6537 | if (!ret) |
| 6538 | { |
| 6539 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6540 | VTY_NEWLINE); |
| 6541 | return CMD_WARNING; |
| 6542 | } |
| 6543 | params = ospf_get_if_params (ifp, addr); |
| 6544 | ospf_if_update_params (ifp, addr); |
| 6545 | } |
| 6546 | params->mtu_ignore = 1; |
| 6547 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6548 | SET_IF_PARAM (params, mtu_ignore); |
| 6549 | else |
| 6550 | { |
| 6551 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6552 | if (params != IF_DEF_PARAMS (ifp)) |
| 6553 | { |
| 6554 | ospf_free_if_params (ifp, addr); |
| 6555 | ospf_if_update_params (ifp, addr); |
| 6556 | } |
| 6557 | } |
| 6558 | return CMD_SUCCESS; |
| 6559 | } |
| 6560 | |
| 6561 | ALIAS (ip_ospf_mtu_ignore, |
| 6562 | ip_ospf_mtu_ignore_cmd, |
| 6563 | "ip ospf mtu-ignore", |
| 6564 | "IP Information\n" |
| 6565 | "OSPF interface commands\n" |
| 6566 | "Disable mtu mismatch detection\n") |
| 6567 | |
| 6568 | |
| 6569 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6570 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6571 | "no ip ospf mtu-ignore A.B.C.D", |
| 6572 | "IP Information\n" |
| 6573 | "OSPF interface commands\n" |
| 6574 | "Disable mtu mismatch detection\n" |
| 6575 | "Address of interface") |
| 6576 | { |
| 6577 | struct interface *ifp = vty->index; |
| 6578 | struct in_addr addr; |
| 6579 | int ret; |
| 6580 | |
| 6581 | struct ospf_if_params *params; |
| 6582 | params = IF_DEF_PARAMS (ifp); |
| 6583 | |
| 6584 | if (argc == 1) |
| 6585 | { |
| 6586 | ret = inet_aton(argv[0], &addr); |
| 6587 | if (!ret) |
| 6588 | { |
| 6589 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6590 | VTY_NEWLINE); |
| 6591 | return CMD_WARNING; |
| 6592 | } |
| 6593 | params = ospf_get_if_params (ifp, addr); |
| 6594 | ospf_if_update_params (ifp, addr); |
| 6595 | } |
| 6596 | params->mtu_ignore = 0; |
| 6597 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6598 | SET_IF_PARAM (params, mtu_ignore); |
| 6599 | else |
| 6600 | { |
| 6601 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6602 | if (params != IF_DEF_PARAMS (ifp)) |
| 6603 | { |
| 6604 | ospf_free_if_params (ifp, addr); |
| 6605 | ospf_if_update_params (ifp, addr); |
| 6606 | } |
| 6607 | } |
| 6608 | return CMD_SUCCESS; |
| 6609 | } |
| 6610 | |
| 6611 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6612 | no_ip_ospf_mtu_ignore_cmd, |
| 6613 | "no ip ospf mtu-ignore", |
| 6614 | "IP Information\n" |
| 6615 | "OSPF interface commands\n" |
| 6616 | "Disable mtu mismatch detection\n") |
| 6617 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6618 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6619 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6620 | { |
| 6621 | struct route_node *rn; |
| 6622 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6623 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6624 | struct ospf_path *path; |
| 6625 | |
| 6626 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6627 | VTY_NEWLINE); |
| 6628 | |
| 6629 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6630 | if ((or = rn->info) != NULL) |
| 6631 | { |
| 6632 | char buf1[19]; |
| 6633 | snprintf (buf1, 19, "%s/%d", |
| 6634 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6635 | |
| 6636 | switch (or->path_type) |
| 6637 | { |
| 6638 | case OSPF_PATH_INTER_AREA: |
| 6639 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6640 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6641 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6642 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6643 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6644 | break; |
| 6645 | case OSPF_PATH_INTRA_AREA: |
| 6646 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6647 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6648 | break; |
| 6649 | default: |
| 6650 | break; |
| 6651 | } |
| 6652 | |
| 6653 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6654 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6655 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6656 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6657 | { |
| 6658 | if (path->nexthop.s_addr == 0) |
| 6659 | vty_out (vty, "%24s directly attached to %s%s", |
| 6660 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6661 | else |
| 6662 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6663 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6664 | VTY_NEWLINE); |
| 6665 | } |
| 6666 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6667 | } |
| 6668 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6669 | } |
| 6670 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6671 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6672 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6673 | { |
| 6674 | struct route_node *rn; |
| 6675 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6676 | struct listnode *pnode; |
| 6677 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6678 | struct ospf_path *path; |
| 6679 | |
| 6680 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6681 | VTY_NEWLINE); |
| 6682 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6683 | if (rn->info) |
| 6684 | { |
| 6685 | int flag = 0; |
| 6686 | |
| 6687 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6688 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6689 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 6690 | { |
| 6691 | if (flag++) |
| 6692 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6693 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6694 | /* Show path. */ |
| 6695 | vty_out (vty, "%s [%d] area: %s", |
| 6696 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6697 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6698 | /* Show flags. */ |
| 6699 | vty_out (vty, "%s%s%s", |
| 6700 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6701 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6702 | VTY_NEWLINE); |
| 6703 | |
| 6704 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 6705 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6706 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
| 6707 | { |
| 6708 | if (path->nexthop.s_addr == 0) |
| 6709 | vty_out (vty, "%24s directly attached to %s%s", |
| 6710 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6711 | else |
| 6712 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6713 | inet_ntoa (path->nexthop), |
| 6714 | path->oi->ifp->name, VTY_NEWLINE); |
| 6715 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6716 | } |
| 6717 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6718 | } |
| 6719 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6720 | } |
| 6721 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6722 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6723 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6724 | { |
| 6725 | struct route_node *rn; |
| 6726 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6727 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6728 | struct ospf_path *path; |
| 6729 | |
| 6730 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6731 | VTY_NEWLINE); |
| 6732 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6733 | if ((er = rn->info) != NULL) |
| 6734 | { |
| 6735 | char buf1[19]; |
| 6736 | snprintf (buf1, 19, "%s/%d", |
| 6737 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6738 | |
| 6739 | switch (er->path_type) |
| 6740 | { |
| 6741 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6742 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6743 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6744 | break; |
| 6745 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6746 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6747 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6748 | break; |
| 6749 | } |
| 6750 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6751 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6752 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6753 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6754 | { |
| 6755 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6756 | vty_out (vty, "%24s directly attached to %s%s", |
| 6757 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6758 | else |
| 6759 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6760 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6761 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6762 | } |
| 6763 | } |
| 6764 | } |
| 6765 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6766 | } |
| 6767 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6768 | DEFUN (show_ip_ospf_border_routers, |
| 6769 | show_ip_ospf_border_routers_cmd, |
| 6770 | "show ip ospf border-routers", |
| 6771 | SHOW_STR |
| 6772 | IP_STR |
| 6773 | "show all the ABR's and ASBR's\n" |
| 6774 | "for this area\n") |
| 6775 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6776 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6777 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6778 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6779 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6780 | { |
| 6781 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6782 | return CMD_SUCCESS; |
| 6783 | } |
| 6784 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6785 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6786 | { |
| 6787 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6788 | return CMD_SUCCESS; |
| 6789 | } |
| 6790 | |
| 6791 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6792 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6793 | |
| 6794 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6795 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6796 | |
| 6797 | return CMD_SUCCESS; |
| 6798 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6799 | |
| 6800 | DEFUN (show_ip_ospf_route, |
| 6801 | show_ip_ospf_route_cmd, |
| 6802 | "show ip ospf route", |
| 6803 | SHOW_STR |
| 6804 | IP_STR |
| 6805 | "OSPF information\n" |
| 6806 | "OSPF routing table\n") |
| 6807 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6808 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6809 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6810 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6811 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6812 | { |
| 6813 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6814 | return CMD_SUCCESS; |
| 6815 | } |
| 6816 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6817 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6818 | { |
| 6819 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6820 | return CMD_SUCCESS; |
| 6821 | } |
| 6822 | |
| 6823 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6824 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6825 | |
| 6826 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6827 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6828 | |
| 6829 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6830 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6831 | |
| 6832 | return CMD_SUCCESS; |
| 6833 | } |
| 6834 | |
| 6835 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6836 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6837 | { |
| 6838 | "unknown", |
| 6839 | "standard", |
| 6840 | "ibm", |
| 6841 | "cisco", |
| 6842 | "shortcut" |
| 6843 | }; |
| 6844 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6845 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6846 | { |
| 6847 | "default", |
| 6848 | "enable", |
| 6849 | "disable" |
| 6850 | }; |
| 6851 | |
| 6852 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6853 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6854 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6855 | { |
| 6856 | memset (buf, 0, length); |
| 6857 | |
| 6858 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6859 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6860 | else |
| 6861 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6862 | } |
| 6863 | |
| 6864 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6865 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6866 | { |
| 6867 | "unknown", /* should never be used. */ |
| 6868 | "point-to-point", |
| 6869 | "broadcast", |
| 6870 | "non-broadcast", |
| 6871 | "point-to-multipoint", |
| 6872 | "virtual-link", /* should never be used. */ |
| 6873 | "loopback" |
| 6874 | }; |
| 6875 | |
| 6876 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6877 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6878 | config_write_interface (struct vty *vty) |
| 6879 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6880 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6881 | struct interface *ifp; |
| 6882 | struct crypt_key *ck; |
| 6883 | int write = 0; |
| 6884 | struct route_node *rn = NULL; |
| 6885 | struct ospf_if_params *params; |
| 6886 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6887 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6888 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6889 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6890 | continue; |
| 6891 | |
| 6892 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6893 | vty_out (vty, "interface %s%s", ifp->name, |
| 6894 | VTY_NEWLINE); |
| 6895 | if (ifp->desc) |
| 6896 | vty_out (vty, " description %s%s", ifp->desc, |
| 6897 | VTY_NEWLINE); |
| 6898 | |
| 6899 | write++; |
| 6900 | |
| 6901 | params = IF_DEF_PARAMS (ifp); |
| 6902 | |
| 6903 | do { |
| 6904 | /* Interface Network print. */ |
| 6905 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6906 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6907 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 6908 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 6909 | { |
| 6910 | vty_out (vty, " ip ospf network %s", |
| 6911 | ospf_int_type_str[params->type]); |
| 6912 | if (params != IF_DEF_PARAMS (ifp)) |
| 6913 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6914 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6915 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6916 | } |
| 6917 | |
| 6918 | /* OSPF interface authentication print */ |
| 6919 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6920 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6921 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6922 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6923 | |
| 6924 | /* Translation tables are not that much help here due to syntax |
| 6925 | of the simple option */ |
| 6926 | switch (params->auth_type) |
| 6927 | { |
| 6928 | |
| 6929 | case OSPF_AUTH_NULL: |
| 6930 | auth_str = " null"; |
| 6931 | break; |
| 6932 | |
| 6933 | case OSPF_AUTH_SIMPLE: |
| 6934 | auth_str = ""; |
| 6935 | break; |
| 6936 | |
| 6937 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6938 | auth_str = " message-digest"; |
| 6939 | break; |
| 6940 | |
| 6941 | default: |
| 6942 | auth_str = ""; |
| 6943 | break; |
| 6944 | } |
| 6945 | |
| 6946 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6947 | if (params != IF_DEF_PARAMS (ifp)) |
| 6948 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6949 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6950 | } |
| 6951 | |
| 6952 | /* Simple Authentication Password print. */ |
| 6953 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6954 | params->auth_simple[0] != '\0') |
| 6955 | { |
| 6956 | vty_out (vty, " ip ospf authentication-key %s", |
| 6957 | params->auth_simple); |
| 6958 | if (params != IF_DEF_PARAMS (ifp)) |
| 6959 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6960 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6961 | } |
| 6962 | |
| 6963 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6964 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6965 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6966 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6967 | ck->key_id, ck->auth_key); |
| 6968 | if (params != IF_DEF_PARAMS (ifp)) |
| 6969 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6970 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6971 | } |
| 6972 | |
| 6973 | /* Interface Output Cost print. */ |
| 6974 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6975 | { |
| 6976 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6977 | if (params != IF_DEF_PARAMS (ifp)) |
| 6978 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6979 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6980 | } |
| 6981 | |
| 6982 | /* Hello Interval print. */ |
| 6983 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6984 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6985 | { |
| 6986 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6987 | if (params != IF_DEF_PARAMS (ifp)) |
| 6988 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6989 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6990 | } |
| 6991 | |
| 6992 | |
| 6993 | /* Router Dead Interval print. */ |
| 6994 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6995 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6996 | { |
| 6997 | vty_out (vty, " ip ospf dead-interval %u", params->v_wait); |
| 6998 | if (params != IF_DEF_PARAMS (ifp)) |
| 6999 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7000 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7001 | } |
| 7002 | |
| 7003 | /* Router Priority print. */ |
| 7004 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 7005 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 7006 | { |
| 7007 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 7008 | if (params != IF_DEF_PARAMS (ifp)) |
| 7009 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7010 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7011 | } |
| 7012 | |
| 7013 | /* Retransmit Interval print. */ |
| 7014 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 7015 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 7016 | { |
| 7017 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 7018 | params->retransmit_interval); |
| 7019 | if (params != IF_DEF_PARAMS (ifp)) |
| 7020 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7021 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7022 | } |
| 7023 | |
| 7024 | /* Transmit Delay print. */ |
| 7025 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 7026 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7027 | { |
| 7028 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 7029 | if (params != IF_DEF_PARAMS (ifp)) |
| 7030 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7031 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7032 | } |
| 7033 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7034 | /* MTU ignore print. */ |
| 7035 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 7036 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 7037 | { |
| 7038 | if (params->mtu_ignore == 0) |
| 7039 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 7040 | else |
| 7041 | vty_out (vty, " ip ospf mtu-ignore"); |
| 7042 | if (params != IF_DEF_PARAMS (ifp)) |
| 7043 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7044 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7045 | } |
| 7046 | |
| 7047 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7048 | while (1) |
| 7049 | { |
| 7050 | if (rn == NULL) |
| 7051 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 7052 | else |
| 7053 | rn = route_next (rn); |
| 7054 | |
| 7055 | if (rn == NULL) |
| 7056 | break; |
| 7057 | params = rn->info; |
| 7058 | if (params != NULL) |
| 7059 | break; |
| 7060 | } |
| 7061 | } while (rn); |
| 7062 | |
| 7063 | #ifdef HAVE_OPAQUE_LSA |
| 7064 | ospf_opaque_config_write_if (vty, ifp); |
| 7065 | #endif /* HAVE_OPAQUE_LSA */ |
| 7066 | } |
| 7067 | |
| 7068 | return write; |
| 7069 | } |
| 7070 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7071 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7072 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7073 | { |
| 7074 | struct route_node *rn; |
| 7075 | u_char buf[INET_ADDRSTRLEN]; |
| 7076 | |
| 7077 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7078 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7079 | if (rn->info) |
| 7080 | { |
| 7081 | struct ospf_network *n = rn->info; |
| 7082 | |
| 7083 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7084 | |
| 7085 | /* Create Area ID string by specified Area ID format. */ |
| 7086 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7087 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7088 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7089 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7090 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7091 | |
| 7092 | /* Network print. */ |
| 7093 | vty_out (vty, " network %s/%d area %s%s", |
| 7094 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7095 | buf, VTY_NEWLINE); |
| 7096 | } |
| 7097 | |
| 7098 | return 0; |
| 7099 | } |
| 7100 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7101 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7102 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7103 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7104 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7105 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7106 | u_char buf[INET_ADDRSTRLEN]; |
| 7107 | |
| 7108 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7109 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7110 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7111 | struct route_node *rn1; |
| 7112 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7113 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7114 | |
| 7115 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7116 | { |
| 7117 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7118 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7119 | else |
| 7120 | vty_out (vty, " area %s authentication message-digest%s", |
| 7121 | buf, VTY_NEWLINE); |
| 7122 | } |
| 7123 | |
| 7124 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7125 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7126 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7127 | VTY_NEWLINE); |
| 7128 | |
| 7129 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7130 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7131 | ) |
| 7132 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7133 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7134 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7135 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7136 | { |
| 7137 | vty_out (vty, " area %s nssa", buf); |
| 7138 | switch (area->NSSATranslatorRole) |
| 7139 | { |
| 7140 | case OSPF_NSSA_ROLE_NEVER: |
| 7141 | vty_out (vty, " translate-never"); |
| 7142 | break; |
| 7143 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7144 | vty_out (vty, " translate-always"); |
| 7145 | break; |
| 7146 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7147 | default: |
| 7148 | vty_out (vty, " translate-candidate"); |
| 7149 | } |
| 7150 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7151 | |
| 7152 | if (area->no_summary) |
| 7153 | vty_out (vty, " no-summary"); |
| 7154 | |
| 7155 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7156 | |
| 7157 | if (area->default_cost != 1) |
| 7158 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7159 | area->default_cost, VTY_NEWLINE); |
| 7160 | } |
| 7161 | |
| 7162 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7163 | if (rn1->info) |
| 7164 | { |
| 7165 | struct ospf_area_range *range = rn1->info; |
| 7166 | |
| 7167 | vty_out (vty, " area %s range %s/%d", buf, |
| 7168 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7169 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7170 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7171 | vty_out (vty, " cost %d", range->cost_config); |
| 7172 | |
| 7173 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7174 | vty_out (vty, " not-advertise"); |
| 7175 | |
| 7176 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7177 | vty_out (vty, " substitute %s/%d", |
| 7178 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7179 | |
| 7180 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7181 | } |
| 7182 | |
| 7183 | if (EXPORT_NAME (area)) |
| 7184 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7185 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7186 | |
| 7187 | if (IMPORT_NAME (area)) |
| 7188 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7189 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7190 | |
| 7191 | if (PREFIX_NAME_IN (area)) |
| 7192 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7193 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7194 | |
| 7195 | if (PREFIX_NAME_OUT (area)) |
| 7196 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7197 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7198 | } |
| 7199 | |
| 7200 | return 0; |
| 7201 | } |
| 7202 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7203 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7204 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7205 | { |
| 7206 | struct ospf_nbr_nbma *nbr_nbma; |
| 7207 | struct route_node *rn; |
| 7208 | |
| 7209 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7210 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7211 | if ((nbr_nbma = rn->info)) |
| 7212 | { |
| 7213 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7214 | |
| 7215 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7216 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7217 | |
| 7218 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7219 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7220 | |
| 7221 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7222 | } |
| 7223 | |
| 7224 | return 0; |
| 7225 | } |
| 7226 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7227 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7228 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7229 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7230 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7231 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7232 | u_char buf[INET_ADDRSTRLEN]; |
| 7233 | |
| 7234 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7235 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7236 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7237 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7238 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7239 | struct ospf_interface *oi; |
| 7240 | |
| 7241 | if (vl_data != NULL) |
| 7242 | { |
| 7243 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7244 | |
| 7245 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7246 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7247 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7248 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7249 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7250 | oi = vl_data->vl_oi; |
| 7251 | |
| 7252 | /* timers */ |
| 7253 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7254 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7255 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7256 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7257 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7258 | buf, |
| 7259 | inet_ntoa (vl_data->vl_peer), |
| 7260 | OSPF_IF_PARAM (oi, v_hello), |
| 7261 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7262 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7263 | OSPF_IF_PARAM (oi, v_wait), |
| 7264 | VTY_NEWLINE); |
| 7265 | else |
| 7266 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7267 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7268 | /* Auth key */ |
| 7269 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7270 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7271 | buf, |
| 7272 | inet_ntoa (vl_data->vl_peer), |
| 7273 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7274 | VTY_NEWLINE); |
| 7275 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7276 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7277 | n2, ck)) |
| 7278 | vty_out (vty, " area %s virtual-link %s" |
| 7279 | " message-digest-key %d md5 %s%s", |
| 7280 | buf, |
| 7281 | inet_ntoa (vl_data->vl_peer), |
| 7282 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7283 | |
| 7284 | } |
| 7285 | } |
| 7286 | |
| 7287 | return 0; |
| 7288 | } |
| 7289 | |
| 7290 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7291 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7292 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7293 | { |
| 7294 | int type; |
| 7295 | |
| 7296 | /* redistribute print. */ |
| 7297 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7298 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7299 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame^] | 7300 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7301 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7302 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7303 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7304 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7305 | vty_out (vty, " metric-type 1"); |
| 7306 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7307 | if (ROUTEMAP_NAME (ospf, type)) |
| 7308 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7309 | |
| 7310 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7311 | } |
| 7312 | |
| 7313 | return 0; |
| 7314 | } |
| 7315 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7316 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7317 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7318 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7319 | if (ospf->default_metric != -1) |
| 7320 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7321 | VTY_NEWLINE); |
| 7322 | return 0; |
| 7323 | } |
| 7324 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7325 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7326 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7327 | { |
| 7328 | int type; |
| 7329 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7330 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7331 | { |
| 7332 | /* distribute-list print. */ |
| 7333 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7334 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7335 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7336 | ospf->dlist[type].name, |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame^] | 7337 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7338 | |
| 7339 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7340 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7341 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7342 | if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7343 | vty_out (vty, " default-information originate"); |
| 7344 | else |
| 7345 | vty_out (vty, " default-information originate always"); |
| 7346 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7347 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7348 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7349 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7350 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7351 | vty_out (vty, " metric-type 1"); |
| 7352 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7353 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7354 | vty_out (vty, " route-map %s", |
| 7355 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7356 | |
| 7357 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7358 | } |
| 7359 | |
| 7360 | } |
| 7361 | |
| 7362 | return 0; |
| 7363 | } |
| 7364 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7365 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7366 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7367 | { |
| 7368 | struct route_node *rn; |
| 7369 | struct ospf_distance *odistance; |
| 7370 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7371 | if (ospf->distance_all) |
| 7372 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7373 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7374 | if (ospf->distance_intra |
| 7375 | || ospf->distance_inter |
| 7376 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7377 | { |
| 7378 | vty_out (vty, " distance ospf"); |
| 7379 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7380 | if (ospf->distance_intra) |
| 7381 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7382 | if (ospf->distance_inter) |
| 7383 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7384 | if (ospf->distance_external) |
| 7385 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7386 | |
| 7387 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7388 | } |
| 7389 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7390 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7391 | if ((odistance = rn->info) != NULL) |
| 7392 | { |
| 7393 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7394 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7395 | odistance->access_list ? odistance->access_list : "", |
| 7396 | VTY_NEWLINE); |
| 7397 | } |
| 7398 | return 0; |
| 7399 | } |
| 7400 | |
| 7401 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7402 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7403 | ospf_config_write (struct vty *vty) |
| 7404 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7405 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7406 | struct interface *ifp; |
| 7407 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7408 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7409 | int write = 0; |
| 7410 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7411 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7412 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7413 | { |
| 7414 | /* `router ospf' print. */ |
| 7415 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7416 | |
| 7417 | write++; |
| 7418 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7419 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7420 | return write; |
| 7421 | |
| 7422 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7423 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7424 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7425 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7426 | |
| 7427 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7428 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7429 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7430 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7431 | |
| 7432 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7433 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7434 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7435 | |
| 7436 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7437 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7438 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7439 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7440 | |
| 7441 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7442 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
| 7443 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7444 | vty_out (vty, " timers spf %d %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7445 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7446 | |
| 7447 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7448 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7449 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7450 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7451 | |
| 7452 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7453 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7454 | |
| 7455 | /* passive-interface print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7456 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 7457 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7458 | vty_out (vty, " passive-interface %s%s", |
| 7459 | ifp->name, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7460 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7461 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 7462 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7463 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
| 7464 | vty_out (vty, " passive-interface %s %s%s", |
| 7465 | oi->ifp->name, |
| 7466 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7467 | |
| 7468 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7469 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7470 | |
| 7471 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7472 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7473 | |
| 7474 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7475 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7476 | |
| 7477 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7478 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7479 | |
| 7480 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7481 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7482 | |
| 7483 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7484 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7485 | |
| 7486 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7487 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7488 | |
| 7489 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7490 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7491 | #endif /* HAVE_OPAQUE_LSA */ |
| 7492 | } |
| 7493 | |
| 7494 | return write; |
| 7495 | } |
| 7496 | |
| 7497 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7498 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7499 | { |
| 7500 | /* "show ip ospf" commands. */ |
| 7501 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7502 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7503 | |
| 7504 | /* "show ip ospf database" commands. */ |
| 7505 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7506 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7507 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7508 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7509 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7510 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7511 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7512 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7513 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7514 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7515 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7516 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7517 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7518 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7519 | |
| 7520 | /* "show ip ospf interface" commands. */ |
| 7521 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7522 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7523 | |
| 7524 | /* "show ip ospf neighbor" commands. */ |
| 7525 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7526 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7527 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7528 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7529 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7530 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7531 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7532 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7533 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7534 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7535 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7536 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7537 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7538 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7539 | |
| 7540 | /* "show ip ospf route" commands. */ |
| 7541 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7542 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7543 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7544 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7545 | } |
| 7546 | |
| 7547 | |
| 7548 | /* ospfd's interface node. */ |
| 7549 | struct cmd_node interface_node = |
| 7550 | { |
| 7551 | INTERFACE_NODE, |
| 7552 | "%s(config-if)# ", |
| 7553 | 1 |
| 7554 | }; |
| 7555 | |
| 7556 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7557 | static void |
| 7558 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7559 | { |
| 7560 | /* Install interface node. */ |
| 7561 | install_node (&interface_node, config_write_interface); |
| 7562 | |
| 7563 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7564 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7565 | install_default (INTERFACE_NODE); |
| 7566 | |
| 7567 | /* "description" commands. */ |
| 7568 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7569 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7570 | |
| 7571 | /* "ip ospf authentication" commands. */ |
| 7572 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7573 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7574 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7575 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7576 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7577 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7578 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7579 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7580 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7581 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7582 | |
| 7583 | /* "ip ospf message-digest-key" commands. */ |
| 7584 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7585 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7586 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7587 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7588 | |
| 7589 | /* "ip ospf cost" commands. */ |
| 7590 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7591 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7592 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7593 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7594 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7595 | /* "ip ospf mtu-ignore" commands. */ |
| 7596 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7597 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7598 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7599 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7600 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7601 | /* "ip ospf dead-interval" commands. */ |
| 7602 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7603 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
| 7604 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7605 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
| 7606 | |
| 7607 | /* "ip ospf hello-interval" commands. */ |
| 7608 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7609 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7610 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7611 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7612 | |
| 7613 | /* "ip ospf network" commands. */ |
| 7614 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7615 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7616 | |
| 7617 | /* "ip ospf priority" commands. */ |
| 7618 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7619 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7620 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7621 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7622 | |
| 7623 | /* "ip ospf retransmit-interval" commands. */ |
| 7624 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7625 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7626 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7627 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7628 | |
| 7629 | /* "ip ospf transmit-delay" commands. */ |
| 7630 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7631 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7632 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7633 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7634 | |
| 7635 | /* These commands are compatibitliy for previous version. */ |
| 7636 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7637 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7638 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7639 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 7640 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 7641 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 7642 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7643 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7644 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7645 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7646 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7647 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7648 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7649 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7650 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7651 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7652 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7653 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7654 | } |
| 7655 | |
| 7656 | /* Zebra node structure. */ |
| 7657 | struct cmd_node zebra_node = |
| 7658 | { |
| 7659 | ZEBRA_NODE, |
| 7660 | "%s(config-router)#", |
| 7661 | }; |
| 7662 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7663 | static void |
| 7664 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7665 | { |
| 7666 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 7667 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 7668 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 7669 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 7670 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 7671 | install_element (OSPF_NODE, |
| 7672 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 7673 | install_element (OSPF_NODE, |
| 7674 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 7675 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 7676 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 7677 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 7678 | |
| 7679 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7680 | |
| 7681 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7682 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7683 | |
| 7684 | install_element (OSPF_NODE, |
| 7685 | &ospf_default_information_originate_metric_type_cmd); |
| 7686 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 7687 | install_element (OSPF_NODE, |
| 7688 | &ospf_default_information_originate_type_metric_cmd); |
| 7689 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 7690 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 7691 | install_element (OSPF_NODE, |
| 7692 | &ospf_default_information_originate_always_metric_type_cmd); |
| 7693 | install_element (OSPF_NODE, |
| 7694 | &ospf_default_information_originate_always_metric_cmd); |
| 7695 | install_element (OSPF_NODE, |
| 7696 | &ospf_default_information_originate_always_cmd); |
| 7697 | install_element (OSPF_NODE, |
| 7698 | &ospf_default_information_originate_always_type_metric_cmd); |
| 7699 | install_element (OSPF_NODE, |
| 7700 | &ospf_default_information_originate_always_type_cmd); |
| 7701 | |
| 7702 | install_element (OSPF_NODE, |
| 7703 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 7704 | install_element (OSPF_NODE, |
| 7705 | &ospf_default_information_originate_metric_routemap_cmd); |
| 7706 | install_element (OSPF_NODE, |
| 7707 | &ospf_default_information_originate_routemap_cmd); |
| 7708 | install_element (OSPF_NODE, |
| 7709 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 7710 | install_element (OSPF_NODE, |
| 7711 | &ospf_default_information_originate_type_routemap_cmd); |
| 7712 | install_element (OSPF_NODE, |
| 7713 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 7714 | install_element (OSPF_NODE, |
| 7715 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 7716 | install_element (OSPF_NODE, |
| 7717 | &ospf_default_information_originate_always_routemap_cmd); |
| 7718 | install_element (OSPF_NODE, |
| 7719 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 7720 | install_element (OSPF_NODE, |
| 7721 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 7722 | |
| 7723 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7724 | |
| 7725 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7726 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7727 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7728 | |
| 7729 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7730 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7731 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 7732 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 7733 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 7734 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 7735 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 7736 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 7737 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 7738 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 7739 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 7740 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 7741 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 7742 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 7743 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 7744 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 7745 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 7746 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 7747 | #if 0 |
| 7748 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7749 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7750 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7751 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7752 | #endif /* 0 */ |
| 7753 | } |
| 7754 | |
| 7755 | struct cmd_node ospf_node = |
| 7756 | { |
| 7757 | OSPF_NODE, |
| 7758 | "%s(config-router)# ", |
| 7759 | 1 |
| 7760 | }; |
| 7761 | |
| 7762 | |
| 7763 | /* Install OSPF related vty commands. */ |
| 7764 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7765 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7766 | { |
| 7767 | /* Install ospf top node. */ |
| 7768 | install_node (&ospf_node, ospf_config_write); |
| 7769 | |
| 7770 | /* "router ospf" commands. */ |
| 7771 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7772 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7773 | |
| 7774 | install_default (OSPF_NODE); |
| 7775 | |
| 7776 | /* "ospf router-id" commands. */ |
| 7777 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7778 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7779 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7780 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7781 | |
| 7782 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7783 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7784 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 7785 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7786 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7787 | |
| 7788 | /* "ospf abr-type" commands. */ |
| 7789 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7790 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7791 | |
| 7792 | /* "ospf rfc1583-compatible" commands. */ |
| 7793 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7794 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7795 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7796 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7797 | |
| 7798 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7799 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7800 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7801 | |
| 7802 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7803 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7804 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7805 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7806 | |
| 7807 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7808 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7809 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7810 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7811 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7812 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7813 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7814 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7815 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7816 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7817 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7818 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7819 | |
| 7820 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7821 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7822 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7823 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7824 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7825 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7826 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7827 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7828 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7829 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7830 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7831 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7832 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7833 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7834 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7835 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7836 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7837 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7838 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7839 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7840 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7841 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7842 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7843 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7844 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7845 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7846 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7847 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7848 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7849 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7850 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7851 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7852 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7853 | |
| 7854 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7855 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7856 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7857 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7858 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7859 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7861 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7862 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7863 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7864 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7865 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7866 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7867 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7868 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7869 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7870 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7871 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7872 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7873 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7874 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 7875 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7876 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7877 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 7878 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7879 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7880 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 7881 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7882 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7883 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 7884 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7885 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7886 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 7887 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7888 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7889 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7890 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 7891 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7892 | |
| 7893 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7894 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7895 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7896 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7897 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7898 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7899 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7900 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7901 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7902 | |
| 7903 | /* Init interface related vty commands. */ |
| 7904 | ospf_vty_if_init (); |
| 7905 | |
| 7906 | /* Init zebra related vty commands. */ |
| 7907 | ospf_vty_zebra_init (); |
| 7908 | } |